From 0b2e9e340d683080d521a4bfacd696c7f3df561c Mon Sep 17 00:00:00 2001 From: Ammar Askar Date: Sun, 10 Jun 2012 14:22:50 +0500 Subject: [PATCH] Fixes an ender pearl exploit allowing players to clip through blocks who occupy less than 1 block in width or length --- .../listeners/FactionsExploitListener.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/com/massivecraft/factions/listeners/FactionsExploitListener.java b/src/com/massivecraft/factions/listeners/FactionsExploitListener.java index 133b6800..10e39e5c 100644 --- a/src/com/massivecraft/factions/listeners/FactionsExploitListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsExploitListener.java @@ -7,6 +7,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.Location; +import org.bukkit.Material; import com.massivecraft.factions.Conf; @@ -38,5 +39,28 @@ public class FactionsExploitListener implements Listener target.setX(target.getBlockX() + 0.5); target.setZ(target.getBlockZ() + 0.5); event.setTo(target); + + // this exploit allows players to clip through blocks who occupy less than 1 block width or length wise + Location from = event.getFrom(); + if(event.getTo().getBlock().getType() == Material.THIN_GLASS || event.getTo().getBlock().getType() == Material.IRON_FENCE){ + if((from.getX() > target.getX() && (from.getX() - target.getX()) < 0.65) || (target.getX() > from.getX() && (target.getX() - from.getX() < 0.65))){ + event.setTo(from); + return; + } + if((from.getZ() > target.getZ() && (from.getZ() - target.getZ()) < 0.65) || (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < 0.65))){ + event.setTo(from); + return; + } + } + if(event.getTo().getBlock().getType() == Material.FENCE || event.getTo().getBlock().getType() == Material.NETHER_FENCE){ + if((from.getX() > target.getX() && (from.getX() - target.getX()) < 0.45) || (target.getX() > from.getX() && (target.getX() - from.getX() < 0.45))){ + event.setTo(from); + return; + } + if((from.getZ() > target.getZ() && (from.getZ() - target.getZ()) < 0.45) || (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < 0.45))){ + event.setTo(from); + return; + } + } } }