예제 #1
0
  /** Saves all necessary data as preparation for stopping the server. */
  public void stopServer() {
    if (!this.worldIsBeingDeleted) {
      this.func_98033_al().func_98233_a("Stopping server");

      if (this.getNetworkThread() != null) {
        this.getNetworkThread().stopListening();
      }

      if (this.serverConfigManager != null) {
        this.func_98033_al().func_98233_a("Saving players");
        this.serverConfigManager.saveAllPlayerData();
        this.serverConfigManager.removeAllPlayers();
      }

      this.func_98033_al().func_98233_a("Saving worlds");
      this.saveAllWorlds(false);

      for (int i = 0; i < this.worldServers.length; ++i) {
        WorldServer worldserver = this.worldServers[i];
        MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(worldserver));
        worldserver.flush();
      }

      WorldServer[] tmp = worldServers;
      for (WorldServer world : tmp) {
        DimensionManager.setWorld(world.provider.dimensionId, null);
      }

      if (this.usageSnooper != null && this.usageSnooper.isSnooperRunning()) {
        this.usageSnooper.stopSnooper();
      }
    }
  }
예제 #2
0
 /*
  * To be called by the server at the appropriate time, do not call from mod code.
  */
 public static void unloadWorlds(Hashtable<Integer, long[]> worldTickTimes) {
   for (int id : unloadQueue) {
     WorldServer w = worlds.get(id);
     try {
       if (w != null) {
         w.saveAllChunks(true, null);
       } else {
         FMLLog.warning("Unexpected world unload - world %d is already unloaded", id);
       }
     } catch (MinecraftException e) {
       e.printStackTrace();
     } finally {
       if (w != null) {
         MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(w));
         w.flush();
         setWorld(id, null);
       }
     }
   }
   unloadQueue.clear();
 }
예제 #3
0
	@Override
	public World createWorld(WorldCreator creator) {
		if (creator == null) {
			throw new IllegalArgumentException("Creator may not be null");
		}

		String name = creator.name();
		ChunkGenerator generator = creator.generator();
		File folder = new File(getWorldContainer().getParentFile(), name);
		int dimension = DimensionManager.getNextFreeDimId();
		World world = getWorld(dimension);
		WorldType type = WorldType.parseWorldType(creator.type().getName());
		boolean generateStructures = creator.generateStructures();

		if (world != null) {
			return world;
		}

		if ((folder.exists()) && (!folder.isDirectory())) {
			throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
		}

		if (generator == null) {
			generator = getGenerator(dimension);
		}

		AnvilSaveConverter converter = new AnvilSaveConverter(getWorldContainer());
		if (converter.isOldMapFormat(name)) {
			getLogger().info("Converting world '" + name + "'");
			converter.convertMapFormat(name, new ConvertingProgressUpdate(theServer));
		}


		boolean hardcore = false;

		WorldServer internal = new WorldServer(theServer, new AnvilSaveHandler(getWorldContainer().getParentFile(), name, true), name, dimension, new WorldSettings(creator.seed(), EnumGameType.getByID(getDefaultGameMode().getValue()), generateStructures, hardcore, type), theServer.theProfiler);

		if (!(worlds.containsKey(dimension))) {
			return null;
		}

		//internal.getWorldInfo().get = console.worldServerForDimension(0).worldMaps;

		//internal. = new EntityTracker(internal); // CraftBukkit
		internal.addWorldAccess((IWorldAccess) new WorldManager(theServer, internal));
		internal.difficultySetting = 1;
		//internal.(true, true);
		//theServer.worldServers[theServer.worldServers.length] = internal;
		DimensionManager.setWorld(dimension, internal);
		this.worlds.put(dimension, new BukkitWorld(internal, creator.generator(), creator.environment()));
		if (generator != null) {
			(worlds.get(dimension)).getPopulators().addAll(generator.getDefaultPopulators(worlds.get(dimension)));
		}

		pluginManager.callEvent(new WorldInitEvent((worlds.get(dimension))));
		System.out.print("Preparing start region for level " + (theServer.worldServers.length - 1) + " (Seed: " + internal.getSeed() + ")");

		if (DimensionManager.shouldLoadSpawn(dimension)) {
			short short1 = 196;
			long i = System.currentTimeMillis();
			for (int j = -short1; j <= short1; j += 16) {
				for (int k = -short1; k <= short1; k += 16) {
					long l = System.currentTimeMillis();

					if (l < i) {
						i = l;
					}

					if (l > i + 1000L) {
						int i1 = (short1 * 2 + 1) * (short1 * 2 + 1);
						int j1 = (j + short1) * (short1 * 2 + 1) + k + 1;

						System.out.println("Preparing spawn area for " + name + ", " + (j1 * 100 / i1) + "%");
								i = l;
					}

					ChunkCoordinates chunkcoordinates = internal.getSpawnPoint();
					internal.theChunkProviderServer.provideChunk(chunkcoordinates.posX + j >> 4, chunkcoordinates.posZ + k >> 4);

					//while (internal.updateLights()) {
					//  ;
				}//
			}
		}
		pluginManager.callEvent( new WorldLoadEvent(worlds.get(dimension)));
		return worlds.get(dimension);
	}