geforkt von Mirrors/Paper
Fixed the PLAYER_TELEPORT event so event.getTo().getWorld() is correct. (#451)
Dieser Commit ist enthalten in:
Ursprung
d08ee17352
Commit
376ac51cea
@ -258,30 +258,47 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(double d0, double d1, double d2, float f, float f1) {
|
// CraftBukkit start -- Delegate for a(double, double, double, float, float)
|
||||||
// CraftBukkit start
|
public boolean teleport(Location dest) {
|
||||||
|
// Note: the world in location is used only for the event
|
||||||
|
// Inter-world teleportation is handled in CraftPlayer.teleport()
|
||||||
|
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
Location from = player.getLocation();
|
Location from = player.getLocation();
|
||||||
Location to = new Location(player.getWorld(), d0, d1, d2, f, f1);
|
Location to = dest.clone();
|
||||||
PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_TELEPORT, player, from, to);
|
PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_TELEPORT, player, from, to);
|
||||||
server.getPluginManager().callEvent(event);
|
server.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
from = event.getFrom();
|
from = event.getFrom();
|
||||||
to = event.isCancelled() ? from : event.getTo();
|
to = event.isCancelled() ? from : event.getTo();
|
||||||
|
|
||||||
|
double d0, d1, d2;
|
||||||
|
float f, f1;
|
||||||
|
|
||||||
d0 = to.getX();
|
d0 = to.getX();
|
||||||
d1 = to.getY();
|
d1 = to.getY();
|
||||||
d2 = to.getZ();
|
d2 = to.getZ();
|
||||||
f = to.getYaw();
|
f = to.getYaw();
|
||||||
f1 = to.getPitch();
|
f1 = to.getPitch();
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
|
// net.minecraft.server start
|
||||||
this.l = false;
|
this.l = false;
|
||||||
this.i = d0;
|
this.i = d0;
|
||||||
this.j = d1;
|
this.j = d1;
|
||||||
this.k = d2;
|
this.k = d2;
|
||||||
this.e.b(d0, d1, d2, f, f1);
|
this.e.b(d0, d1, d2, f, f1);
|
||||||
this.e.a.b((Packet) (new Packet13PlayerLookMove(d0, d1 + 1.6200000047683716D, d1, d2, f, f1, false)));
|
this.e.a.b((Packet) (new Packet13PlayerLookMove(d0, d1 + 1.6200000047683716D, d1, d2, f, f1, false)));
|
||||||
|
// net.minecraft.server end
|
||||||
|
|
||||||
|
// Returns TRUE if the teleport was successful
|
||||||
|
return !event.isCancelled();
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
public void a(double d0, double d1, double d2, float f, float f1) {
|
||||||
|
// CraftBukkit start -- Delegate to teleport(Location)
|
||||||
|
teleport(new Location(getPlayer().getWorld(), d0, d1, d2, f, f1));
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(Packet14BlockDig packet14blockdig) {
|
public void a(Packet14BlockDig packet14blockdig) {
|
||||||
|
@ -107,13 +107,23 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||||||
return ((WorldServer)entity.world).getWorld();
|
return ((WorldServer)entity.world).getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teleportTo(Location location) {
|
public boolean teleport(Location location) {
|
||||||
entity.world = ((CraftWorld)location.getWorld()).getHandle();
|
entity.world = ((CraftWorld)location.getWorld()).getHandle();
|
||||||
entity.b(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
entity.b(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||||
|
// entity.b() throws no event, and so cannot be cancelled
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean teleport(org.bukkit.entity.Entity destination) {
|
||||||
|
return teleport(destination.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void teleportTo(Location location) {
|
||||||
|
teleport(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teleportTo(org.bukkit.entity.Entity destination) {
|
public void teleportTo(org.bukkit.entity.Entity destination) {
|
||||||
teleportTo(destination.getLocation());
|
teleport(destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEntityId() {
|
public int getEntityId() {
|
||||||
|
@ -137,18 +137,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleportTo(Location location) {
|
public boolean teleport(Location location) {
|
||||||
WorldServer oldWorld = ((CraftWorld)getWorld()).getHandle();
|
WorldServer oldWorld = ((CraftWorld)getWorld()).getHandle();
|
||||||
WorldServer newWorld = ((CraftWorld)location.getWorld()).getHandle();
|
WorldServer newWorld = ((CraftWorld)location.getWorld()).getHandle();
|
||||||
ServerConfigurationManager manager = server.getHandle();
|
ServerConfigurationManager manager = server.getHandle();
|
||||||
EntityPlayer entity = getHandle();
|
EntityPlayer entity = getHandle();
|
||||||
|
boolean teleportSuccess;
|
||||||
|
|
||||||
if (oldWorld != newWorld) {
|
if (oldWorld != newWorld) {
|
||||||
manager.c.k.a(entity);
|
|
||||||
manager.c.k.b(entity);
|
|
||||||
oldWorld.manager.b(entity);
|
|
||||||
manager.b.remove(entity);
|
|
||||||
oldWorld.e(entity);
|
|
||||||
|
|
||||||
EntityPlayer newEntity = new EntityPlayer(manager.c, newWorld, entity.name, new ItemInWorldManager(newWorld));
|
EntityPlayer newEntity = new EntityPlayer(manager.c, newWorld, entity.name, new ItemInWorldManager(newWorld));
|
||||||
|
|
||||||
@ -160,17 +156,31 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
newEntity.inventory.e = newEntity;
|
newEntity.inventory.e = newEntity;
|
||||||
newEntity.activeContainer = entity.activeContainer;
|
newEntity.activeContainer = entity.activeContainer;
|
||||||
newEntity.defaultContainer = entity.defaultContainer;
|
newEntity.defaultContainer = entity.defaultContainer;
|
||||||
|
newEntity.locX = location.getX();
|
||||||
|
newEntity.locY = location.getY();
|
||||||
|
newEntity.locZ = location.getZ();
|
||||||
newWorld.u.d((int) location.getBlockX() >> 4, (int) location.getBlockZ() >> 4);
|
newWorld.u.d((int) location.getBlockX() >> 4, (int) location.getBlockZ() >> 4);
|
||||||
|
|
||||||
newEntity.a.a(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
teleportSuccess = newEntity.a.teleport(location);
|
||||||
newWorld.manager.a(newEntity);
|
|
||||||
newWorld.a(newEntity);
|
|
||||||
manager.b.add(newEntity);
|
|
||||||
|
|
||||||
entity.a.e = newEntity;
|
if (teleportSuccess) {
|
||||||
this.entity = newEntity;
|
manager.c.k.a(entity);
|
||||||
|
manager.c.k.b(entity);
|
||||||
|
oldWorld.manager.b(entity);
|
||||||
|
manager.b.remove(entity);
|
||||||
|
oldWorld.e(entity);
|
||||||
|
|
||||||
|
newWorld.manager.a(newEntity);
|
||||||
|
newWorld.a(newEntity);
|
||||||
|
manager.b.add(newEntity);
|
||||||
|
|
||||||
|
entity.a.e = newEntity;
|
||||||
|
this.entity = newEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return teleportSuccess;
|
||||||
} else {
|
} else {
|
||||||
entity.a.a(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
return entity.a.teleport(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren