From 416964ef5a9241984ffa0201b070f15133750904 Mon Sep 17 00:00:00 2001 From: Dinnerbone Date: Thu, 30 Dec 2010 04:37:32 +0000 Subject: [PATCH] No lookup for worlds, store on object --- src/net/minecraft/server/WorldServer.java | 6 +++++- src/org/bukkit/craftbukkit/CraftEntity.java | 2 +- src/org/bukkit/craftbukkit/CraftServer.java | 14 +------------- src/org/bukkit/craftbukkit/CraftWorld.java | 2 +- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/net/minecraft/server/WorldServer.java b/src/net/minecraft/server/WorldServer.java index d4046c435d..aa33b46d50 100644 --- a/src/net/minecraft/server/WorldServer.java +++ b/src/net/minecraft/server/WorldServer.java @@ -20,7 +20,7 @@ public class WorldServer extends World { B = false; E = new MCHashTable(); D = minecraftserver; - world = (CraftWorld)D.server.getWorld(this); // CraftBukkit + world = new CraftWorld(this); // CraftBukkit } // CraftBukkit start @@ -37,6 +37,10 @@ public class WorldServer extends World { world.updateBlock(i1, j1, k1); return result; } + + public CraftWorld getWorld() { + return world; + } // CraftBukkit stop public void f() { diff --git a/src/org/bukkit/craftbukkit/CraftEntity.java b/src/org/bukkit/craftbukkit/CraftEntity.java index 71aa013c1b..2a2f2392e7 100644 --- a/src/org/bukkit/craftbukkit/CraftEntity.java +++ b/src/org/bukkit/craftbukkit/CraftEntity.java @@ -20,7 +20,7 @@ public class CraftEntity implements org.bukkit.Entity { } public World getWorld() { - return server.getWorld((WorldServer)entity.l); + return ((WorldServer)entity.l).getWorld(); } public void teleportTo(Location location) { diff --git a/src/org/bukkit/craftbukkit/CraftServer.java b/src/org/bukkit/craftbukkit/CraftServer.java index 34aca81e79..9060d062ad 100644 --- a/src/org/bukkit/craftbukkit/CraftServer.java +++ b/src/org/bukkit/craftbukkit/CraftServer.java @@ -19,7 +19,6 @@ public final class CraftServer implements Server { private final String serverName = "Craftbukkit"; private final String serverVersion; private final HashMap playerCache = new HashMap(); - private final HashMap worldCache = new HashMap(); private final PluginManager pluginManager = new SimplePluginManager(this); protected final MinecraftServer console; @@ -87,18 +86,7 @@ public final class CraftServer implements Server { } public World[] getWorlds() { - return new World[] { getWorld(console.e) }; - } - - public World getWorld(WorldServer world) { - World result = worldCache.get(world); - - if (result == null) { - result = new CraftWorld(world); - worldCache.put(world, result); - } - - return result; + return new World[] { console.e.getWorld() }; } public ServerConfigurationManager getHandle() { diff --git a/src/org/bukkit/craftbukkit/CraftWorld.java b/src/org/bukkit/craftbukkit/CraftWorld.java index f8f5a40e09..e3d691f846 100644 --- a/src/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/org/bukkit/craftbukkit/CraftWorld.java @@ -13,7 +13,7 @@ public class CraftWorld implements World { private final Map blockCache = new HashMap(); private final WorldServer world; - protected CraftWorld(WorldServer world) { + public CraftWorld(WorldServer world) { this.world = world; }