From a4bb515ee0db9f39364f7dd0a19cbddf0ccda789 Mon Sep 17 00:00:00 2001 From: Evenprime Date: Thu, 30 Jun 2011 13:30:00 +0200 Subject: [PATCH] Potential fix(es) for flying after respawning --- plugin.yml | 2 +- .../bukkit/nocheat/checks/MovingCheck.java | 14 +++++++++----- .../bukkit/nocheat/data/MovingData.java | 17 ++++++++--------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/plugin.yml b/plugin.yml index 27c03e49..4b33475b 100644 --- a/plugin.yml +++ b/plugin.yml @@ -3,7 +3,7 @@ name: NoCheat author: Evenprime main: cc.co.evenprime.bukkit.nocheat.NoCheat -version: 1.06 +version: 1.06a softdepend: [ Permissions, CraftIRC ] diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java index 77e64399..bcb00fb6 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java @@ -392,7 +392,7 @@ public class MovingCheck extends Check { final Location l = data.lastLocation; // Player is currently changing worlds - if(l.getWorld() != from.getWorld()) { + if(!l.getWorld().equals(from.getWorld())) { return true; } @@ -462,7 +462,7 @@ public class MovingCheck extends Check { if(!event.isCancelled()) { data.lastLocation = event.getTo(); data.jumpPhase = 0; - data.setBackPoint = event.getTo(); + data.setBackPoint = event.getTo().clone(); } } @@ -472,7 +472,8 @@ public class MovingCheck extends Check { */ public void respawned(PlayerRespawnEvent event) { MovingData data = MovingData.get(event.getPlayer()); - data.lastLocation = event.getRespawnLocation(); // We expect the player to be there next + data.lastLocation = event.getRespawnLocation(); + data.setBackPoint = event.getRespawnLocation().clone(); } /** @@ -525,12 +526,15 @@ public class MovingCheck extends Check { double y = data.setBackPoint.getY(); // search for the first solid block up to 5 blocks below the setbackpoint and teleport the player there - for(int i = 0; i < 20; i++) { + int i = 0; + for(; i < 20; i++) { if(playerIsOnGround(data.setBackPoint, -0.5*i) != MovingData.NONSOLID) { - y -= 0.5*i; break; } } + y -= 0.5*i; + + data.setBackPoint.setY(y); // Remember the location we send the player to, to identify teleports that were started by us data.teleportTo = new Location(data.setBackPoint.getWorld(), data.setBackPoint.getX(), y, data.setBackPoint.getZ(), event.getTo().getYaw(), event.getTo().getPitch()); diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java b/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java index 9362dae7..c01ebc16 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java @@ -16,11 +16,11 @@ public class MovingData { public double horizFreedom = 0.0D; public double vertFreedom = 0.0D; public int vertFreedomCounter = 0; - + // setbackpoint is a recommendation - try to teleport to first solid block below it // for better effect public Location setBackPoint = null; - + public int summaryTask = -1; public Level highestLogLevel = null; public double maxYVelocity = 0.0D; @@ -46,18 +46,18 @@ public class MovingData { public static final int LADDER = 4; // 0x00000100 public static final int FENCE = 8; // 0x00001000 - + // Until I can think of a better way to determine if a block is solid or not, this is what I'll do public static final int types[] = new int[256]; - + static { // Find and define properties of all blocks for(int i = 0; i < types.length; i++) { - + // Everything is considered nonsolid at first types[i] = NONSOLID; - + if(Block.byId[i] != null) { if(Block.byId[i].material.isSolid()) { // solid blocks like STONE, CAKE, TRAPDOORS @@ -69,12 +69,12 @@ public class MovingData { } } } - + // Special types just for me types[Material.LADDER.getId()]= LADDER | SOLID; types[Material.FENCE.getId()]= FENCE | SOLID; } - + public static MovingData get(final Player p) { final NoCheatData data = NoCheatData.getPlayerData(p); @@ -86,5 +86,4 @@ public class MovingData { return data.moving; } - }