From 7bdc190637081a8f46c404b556bafc5eccf4903f Mon Sep 17 00:00:00 2001 From: Dinnerbone Date: Sun, 6 Feb 2011 22:53:48 +0000 Subject: [PATCH] Possibly fixed block/chunk leaking --- .../net/minecraft/server/PlayerManager.java | 6 ++++- .../server/ServerConfigurationManager.java | 26 +++++++++++-------- .../net/minecraft/server/WorldServer.java | 2 ++ .../craftbukkit/entity/CraftPlayer.java | 4 +-- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/minecraft/server/PlayerManager.java b/src/main/java/net/minecraft/server/PlayerManager.java index 3837635b1e..51dca1b4a6 100644 --- a/src/main/java/net/minecraft/server/PlayerManager.java +++ b/src/main/java/net/minecraft/server/PlayerManager.java @@ -9,9 +9,13 @@ public class PlayerManager { private PlayerList b = new PlayerList(); private List c = new ArrayList(); private MinecraftServer d; + private WorldServer world; // Craftbukkit - public PlayerManager(MinecraftServer minecraftserver) { + // Craftbukkit - change of method signature + public PlayerManager(MinecraftServer minecraftserver, WorldServer world) { this.d = minecraftserver; + + this.world = world; // Craftbukkit } public void a() { diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java index 1532f97cf2..dfb86e489a 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java @@ -28,7 +28,7 @@ public class ServerConfigurationManager { public static Logger a = Logger.getLogger("Minecraft"); public List b = new ArrayList(); public MinecraftServer c; // Craftbukkit - public - public PlayerManager d; // Craftbukkit - public + // public PlayerManager d; // Craftbukkit - removed! private int e; private Set f = new HashSet(); private Set g = new HashSet(); @@ -54,7 +54,7 @@ public class ServerConfigurationManager { this.i = minecraftserver.a("banned-players.txt"); this.j = minecraftserver.a("banned-ips.txt"); this.k = minecraftserver.a("ops.txt"); - this.d = new PlayerManager(minecraftserver); + // this.d = new PlayerManager(minecraftserver); // Craftbukkit - removed! this.e = minecraftserver.d.a("max-players", 20); this.e(); this.g(); @@ -69,7 +69,7 @@ public class ServerConfigurationManager { } public int a() { - return this.d.b(); + return 144; // Craftbukkit - magic number from PlayerManager.b() (??) } public void a(EntityPlayer entityplayer) { @@ -86,22 +86,22 @@ public class ServerConfigurationManager { entityplayer.world.a(entityplayer); server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_JOIN, server.getPlayer(entityplayer))); + + ((WorldServer)entityplayer.world).manager.a(entityplayer); // Craftbukkit end - - this.d.a(entityplayer); } public void b(EntityPlayer entityplayer) { - this.d.c(entityplayer); + ((WorldServer)entityplayer.world).c(entityplayer); // Craftbukkit } public void c(EntityPlayer entityplayer) { this.l.a(entityplayer); entityplayer.world.d(entityplayer); // Craftbukkit this.b.remove(entityplayer); - this.d.b(entityplayer); // CraftBukkit start + ((WorldServer)entityplayer.world).manager.b(entityplayer); server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_QUIT, server.getPlayer(entityplayer))); // CraftBukkit // CraftBukkit end } @@ -150,7 +150,7 @@ public class ServerConfigurationManager { // Craftbukkit start - every reference to this.c.e should be entityplayer.world this.c.k.a(entityplayer); this.c.k.b(entityplayer); - this.d.b(entityplayer); + ((WorldServer)entityplayer.world).manager.b(entityplayer); this.b.remove(entityplayer); entityplayer.world.e(entityplayer); EntityPlayer entityplayer1 = new EntityPlayer(this.c, entityplayer.world, entityplayer.name, new ItemInWorldManager(entityplayer.world)); @@ -177,7 +177,7 @@ public class ServerConfigurationManager { entityplayer1.a.b((Packet) (new Packet9Respawn())); entityplayer1.a.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch); - this.d.a(entityplayer1); + ((WorldServer)entityplayer1.world).manager.a(entityplayer1); entityplayer.world.a(entityplayer1); this.b.add(entityplayer1); entityplayer1.l(); @@ -186,12 +186,16 @@ public class ServerConfigurationManager { } public void b() { - this.d.a(); + // Craftbukkit start + for (WorldServer world : c.worlds) { + world.manager.a(); + } + // Craftbukkit end } // Craftbukkit - changed signature public void a(int i, int j, int k, WorldServer world) { - this.d.a(i, j, k, world); // Craftbukkit + world.manager.a(i, j, k, world); // Craftbukkit } public void a(Packet packet) { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index 0e43967a80..8a18621d43 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -22,6 +22,7 @@ public class WorldServer extends World implements BlockChangeDelegate { public boolean C; private MinecraftServer D; private EntityList E = new EntityList(); + public PlayerManager manager; // Craftbukkit public WorldServer(MinecraftServer minecraftserver, File file1, String s, int i) { super(file1, s, (new Random()).nextLong(), WorldProvider.a(i)); @@ -30,6 +31,7 @@ public class WorldServer extends World implements BlockChangeDelegate { // CraftBukkit start world = new CraftWorld(this); server = minecraftserver.server; + manager = new PlayerManager(minecraftserver, this); } private final CraftWorld world; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 4b42c04fb1..920244d239 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -123,7 +123,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (oldWorld != newWorld) { manager.c.k.a(entity); manager.c.k.b(entity); - manager.d.b(entity); + oldWorld.manager.b(entity); manager.b.remove(entity); oldWorld.e(entity); @@ -136,7 +136,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { newWorld.A.d((int) location.getBlockX() >> 4, (int) location.getBlockZ() >> 4); newEntity.a.a(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); - manager.d.a(newEntity); + newWorld.manager.a(newEntity); newWorld.a(newEntity); manager.b.add(newEntity); newEntity.l();