Fixes an ender pearl exploit allowing players to clip through blocks who occupy less than 1 block in width or length

This commit is contained in:
Ammar Askar 2012-06-10 14:22:50 +05:00
parent 5988e8e5af
commit 0b2e9e340d

View File

@ -7,6 +7,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
@ -38,5 +39,28 @@ public class FactionsExploitListener implements Listener
target.setX(target.getBlockX() + 0.5); target.setX(target.getBlockX() + 0.5);
target.setZ(target.getBlockZ() + 0.5); target.setZ(target.getBlockZ() + 0.5);
event.setTo(target); 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;
}
}
} }
} }