Added GLIDE and SWIM MoveTypes, and made Horses use RIDE

This commit is contained in:
Matthew Miller 2019-01-02 17:24:49 +10:00
parent 9804c69044
commit 3ea7c9fc08
2 changed files with 12 additions and 1 deletions

View File

@ -29,6 +29,8 @@ public enum MoveType {
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),

View File

@ -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);