Updated PLAYER_MOVE hook to deal correctly with a cancelled event.
Dieser Commit ist enthalten in:
Ursprung
5402eb5c86
Commit
5faa476554
@ -62,23 +62,24 @@ public class EntityPlayerMP extends EntityPlayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Craftbukkit: Overloaded version of b(double,double,double,float)
|
* Craftbukkit: Overloaded version of b(double,double,double,float, float)
|
||||||
*
|
*
|
||||||
* Enables monitoring of PLAYER_MOVE events.
|
* Enables monitoring of PLAYER_MOVE events.
|
||||||
*/
|
*/
|
||||||
public void b(double x, double y, double z, float rotation, float pitch) {
|
public void b(double x, double y, double z, float rotation, float pitch) {
|
||||||
super.b(x,y,z,pitch,rotation);
|
Location newLocation = new Location(server.getWorld(b.e),x,y,z);
|
||||||
|
|
||||||
// Only send an event if player position has changed.
|
// Only send an event if player position has changed.
|
||||||
if (x == oldLocation.getX() && y == oldLocation.getY() && z == oldLocation.getZ())
|
if (x != oldLocation.getX() || y != oldLocation.getY() || z != oldLocation.getZ()) {
|
||||||
return;
|
PlayerMoveEvent pm = new PlayerMoveEvent(Event.Type.PLAYER_MOVE, server.getPlayer(this),
|
||||||
|
oldLocation, newLocation);
|
||||||
|
|
||||||
Location newLocation = new Location(server.getWorld(b.e),x,y,z);
|
server.getPluginManager().callEvent(pm);
|
||||||
PlayerMoveEvent pm = new PlayerMoveEvent(Event.Type.PLAYER_MOVE, server.getPlayer(this),
|
if (pm.isCancelled())
|
||||||
oldLocation, newLocation);
|
newLocation = pm.getFrom();
|
||||||
|
}
|
||||||
server.getPluginManager().callEvent(pm);
|
|
||||||
oldLocation = newLocation;
|
oldLocation = newLocation;
|
||||||
|
super.b(newLocation.getX(),newLocation.getY(),newLocation.getZ(),rotation, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void k() {
|
public void k() {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren