clean up code from last commit a bit
This commit is contained in:
parent
98f20a4ec6
commit
8e64c7c137
@ -34,33 +34,35 @@ public class FactionsExploitListener implements Listener
|
|||||||
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) return;
|
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) return;
|
||||||
|
|
||||||
// this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar...
|
// this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar...
|
||||||
// simple fix: ender pearl target locations are standardized to be in the center (X/Z) of the target block, not at the edges
|
|
||||||
Location target = event.getTo();
|
Location target = event.getTo();
|
||||||
|
Location from = event.getFrom();
|
||||||
|
|
||||||
|
// blocks who occupy less than 1 block width or length wise need to be handled differently
|
||||||
|
Material mat = event.getTo().getBlock().getType();
|
||||||
|
if (
|
||||||
|
((mat == Material.THIN_GLASS || mat == Material.IRON_FENCE) && clippingThrough(target, from, 0.65))
|
||||||
|
|| ((mat == Material.FENCE || mat == Material.NETHER_FENCE) && clippingThrough(target, from, 0.45))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
event.setTo(from);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// simple fix otherwise: ender pearl target locations are standardized to be in the center (X/Z) of the target block, not at the edges
|
||||||
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){
|
public boolean clippingThrough(Location target, Location from, double thickness)
|
||||||
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
|
||||||
return;
|
(
|
||||||
}
|
(from.getX() > target.getX() && (from.getX() - target.getX() < thickness))
|
||||||
if((from.getZ() > target.getZ() && (from.getZ() - target.getZ()) < 0.65) || (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < 0.65))){
|
|| (target.getX() > from.getX() && (target.getX() - from.getX() < thickness))
|
||||||
event.setTo(from);
|
|| (from.getZ() > target.getZ() && (from.getZ() - target.getZ() < thickness))
|
||||||
return;
|
|| (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < thickness))
|
||||||
}
|
);
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user