/** Unload chunks with no locks on them. */ public void unloadOldChunks() { for (Map.Entry<GlowChunk.Key, GlowChunk> entry : chunks.entrySet()) { Set<ChunkLock> lockSet = locks.get(entry.getKey()); if (lockSet == null || lockSet.size() == 0) { if (!entry.getValue().unload(true, true)) { GlowServer.logger.warning( "Failed to unload chunk " + world.getName() + ":" + entry.getKey()); } } // cannot remove old chunks from cache - GlowBlock and GlowBlockState keep references. // they must either be changed to look up the chunk again all the time, or this code left out. /*if (!entry.getValue().isLoaded()) { //GlowServer.logger.info("Removing from cache " + entry.getKey()); chunks.entrySet().remove(entry); locks.remove(entry.getKey()); }*/ } }
/** * Gets the world by the given name. * * @param name The name of the world to look up. * @return The {@link GlowWorld} this server manages. */ public GlowWorld getWorld(String name) { for (GlowWorld world : worlds) { if (world.getName().equalsIgnoreCase(name)) return world; } return null; }