mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
PlayerMoveEvent optimization.
This commit is contained in:
parent
e23db244a5
commit
ad5a236bc2
@ -222,6 +222,20 @@ public class TFM_PlayerListener implements Listener
|
|||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerMove(PlayerMoveEvent event)
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
|
final Location from = event.getFrom();
|
||||||
|
final Location to = event.getTo();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (from.getWorld() == to.getWorld() && from.distanceSquared(to) < (0.0001 * 0.0001))
|
||||||
|
{
|
||||||
|
// If player just rotated, but didn't move, don't process this event.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
if (!TFM_AdminWorld.getInstance().validateMovement(event))
|
if (!TFM_AdminWorld.getInstance().validateMovement(event))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -279,14 +293,13 @@ public class TFM_PlayerListener implements Listener
|
|||||||
|
|
||||||
if (do_freeze)
|
if (do_freeze)
|
||||||
{
|
{
|
||||||
Location from = event.getFrom();
|
Location freezeTo = to.clone();
|
||||||
Location to = event.getTo().clone();
|
|
||||||
|
|
||||||
to.setX(from.getX());
|
freezeTo.setX(from.getX());
|
||||||
to.setY(from.getY());
|
freezeTo.setY(from.getY());
|
||||||
to.setZ(from.getZ());
|
freezeTo.setZ(from.getZ());
|
||||||
|
|
||||||
event.setTo(to);
|
event.setTo(freezeTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerdata.isCaged())
|
if (playerdata.isCaged())
|
||||||
|
Loading…
Reference in New Issue
Block a user