Permalink
Browse files

Added GLIDE and SWIM MoveTypes, and made Horses use RIDE

  • Loading branch information...
me4502 committed Jan 2, 2019
1 parent 9804c69 commit 3ea7c9fc0820d154bf83ffccbfced2ab71a3e29d
@@ -29,6 +29,8 @@
RESPAWN(false, true),
EMBARK(true, false),
MOVE(true, false),
GLIDE(true, false),
SWIM(true, false),
TELEPORT(true, true),
RIDE(true, false),
OTHER_NON_CANCELLABLE(false, false),
@@ -28,6 +28,7 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -80,7 +81,15 @@ public void onPlayerMove(PlayerMoveEvent event) {
LocalPlayer localPlayer = plugin.wrapPlayer(player);

Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer);
com.sk89q.worldedit.util.Location weLocation = session.testMoveTo(localPlayer, BukkitAdapter.adapt(event.getTo()), MoveType.MOVE);
MoveType moveType = MoveType.MOVE;
if (event.getPlayer().isGliding()) {
moveType = MoveType.GLIDE;
} else if (event.getPlayer().isSwimming()) {
moveType = MoveType.SWIM;
} else if (event.getPlayer().getVehicle() != null && event.getPlayer().getVehicle() instanceof Horse) {
moveType = MoveType.RIDE;
}
com.sk89q.worldedit.util.Location weLocation = session.testMoveTo(localPlayer, BukkitAdapter.adapt(event.getTo()), moveType);

if (weLocation != null) {
final Location override = BukkitAdapter.adapt(weLocation);

0 comments on commit 3ea7c9f

Please sign in to comment.