@Override
  public void run() {
    while (AutoBackup.isBackingUp) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        break;
      }
    }

    for (int i : DimensionManager.getIDs()) {
      WorldSaver.addWorldNeedsSave(i);
    }
  }
 @Override
 public List<?> addTabCompletionOptions(ICommandSender sender, String[] args) {
   // Zone selection
   if (args.length == 1) {
     ArrayList<String> list = new ArrayList<String>();
     if (sender instanceof EntityPlayer) {
       list.add("world");
       list.add("here");
     }
     for (int i : DimensionManager.getIDs()) {
       list.add("" + i);
     }
     return getListOfStringsFromIterableMatchingLastWord(args, list);
   }
   if (args.length == 2)
     return getListOfStringsMatchingLastWord(args, "start", "stop", "reset", "speed");
   return null;
 }
示例#3
0
	public World getWorld(int dimID) {
		if (worlds.containsKey(dimID))
			return worlds.get(dimID);
		else if (!worlds.containsKey(dimID) && Arrays.asList(DimensionManager.getIDs()).contains(dimID)) {
			// dim there but not registered with us.
			WorldServer internal = DimensionManager.getWorld(dimID);
			int dim = internal.getWorldInfo().getDimension();
				System.out.println("Registering dimension with BukkitForge: " + dim + "..." );
				WorldProvider w = internal.provider;
				
				Environment env = w.isHellWorld ? Environment.NETHER : Environment.NORMAL;
				ChunkGenerator cg = new NormalChunkGenerator(internal);//(((WorldServer)ev.world).theChunkProviderServer);
				BukkitWorld bukkit = new BukkitWorld(internal, cg, env);
				BukkitServer.instance().worlds.put(dim, bukkit);
				return bukkit;
			
		}
		return null;
	}
示例#4
0
	public BukkitServer(MinecraftServer server) {
		instance = this;
		cbBuild = BukkitContainer.CRAFT_VERSION;
		configMan = server.getConfigurationManager();
		theServer = server;
		List<Integer> ids = Arrays.asList(DimensionManager.getIDs());
		Iterator<Integer> _ = ids.iterator();

		System.out.println("IS THE INSTANCE NULL? " + (instance == null ? "YES" : "NO"));
		this.pluginManager = new SimplePluginManager(this, commandMap);
		
		//pluginManager = new SimplePluginManager(this, commandMap);
		bukkitConfig = new YamlConfiguration();
		YamlConfiguration yml = new YamlConfiguration();
		try {
			yml.load(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"));
			if (!new File("bukkit.yml").exists()) {
				new File("bukkit.yml").createNewFile();
				yml.save("bukkit.yml");
			}
			bukkitConfig.load("bukkit.yml");
			bukkitConfig.addDefaults(yml);
			bukkitConfig.save("bukkit.yml");

		}
		catch (Exception e) {
			e.printStackTrace();
		}

		String vanillaName = theServer.worldServerForDimension(0).getWorldInfo().getWorldName();
		
		while(_.hasNext()) {
			int i = _.next();
			WorldServer x = theServer.worldServerForDimension(i);
			BukkitWorld world = new BukkitWorld(x, this.getGenerator(x.getWorldInfo().getDimension()), this.wtToEnv(x));
			worlds.put(i, world);
			//if (!x.getWorldInfo().getWorldName().equals(vanillaName))
				pluginWorldMapping.put(x.getWorldInfo().getWorldName(), world);
		}
		this.theLogger = BukkitContainer.bukkitLogger;
		theLogger.info("Bukkit API for Vanilla, version " + apiVer + " starting up...");
		thePluginLoader = new BukkitClassLoader(getClass().getClassLoader());
		
		// I MAINTAIN THAT THIS WILL WORK EVENTUALLY
		/*try {
			System.out.println("This is a test of the SPM Loader!");
			// this *should* load simplepluginamanger via BukkitClassLoader
			Class<?> pluginMan = thePluginLoader.loadClass("org.bukkit.plugin.SimplePluginManager");
			System.out.println("Loaded class: " + pluginMan.getCanonicalName() + " via " + pluginMan.getClassLoader().getClass().getCanonicalName());
			Method insn = pluginMan.getMethod("newInstance", new Class[] { BukkitServer.class, SimpleCommandMap.class });
			insn.setAccessible(true);
			this.pluginManager = (PluginManager) insn.invoke(null, this, this.commandMap);


		} catch (Exception e1) {
			throw new RuntimeException("BukkitForge encountered an error (most likely it  was installed incorrectly!)", e1);
		}*/
		Bukkit.setServer(this);
		this.theHelpMap = new SimpleHelpMap(this);
		this.theMessenger = new StandardMessenger();
		//theLogger.info("Testing the bukkit Logger!");
		this.entityMetadata = new EntityMetadataStore();
		this.playerMetadata = new PlayerMetadataStore();
		this.worldMetadata = new WorldMetadataStore();
		this.warningState = Warning.WarningState.DEFAULT;
		this.console = (BukkitConsoleCommandSender) BukkitConsoleCommandSender.getInstance();
		// wait until server start

		/*try {
			Thread.currentThread().wait();
		} catch (InterruptedException e) {
			theLogger.log(Level.FINE, "The server was interrupted, it might explode!", e);
		}*/
		theLogger.info("Completing load...");
		// fix for the 'mod recipes disappear' bug
		BukkitModRecipeHelper.saveCraftingManagerRecipes();
		//configMan = theServer.getConfigurationManager();
		//theServer = (DedicatedServer) server;
		HelpTopic myHelp = new CommandHelpTopic("bexec", "Run a command forcibly bukkit aliases", "", "");
		Bukkit.getServer().getHelpMap().addTopic(myHelp);
		
		loadPlugins();
		enablePlugins(PluginLoadOrder.STARTUP);

		theLogger.info("Loading PostWorld plugins...");
		enablePlugins(PluginLoadOrder.POSTWORLD);
		theLogger.info("Loaded plugins: ");
		for (Plugin i : pluginManager.getPlugins()) {
			theLogger.info(i.getName() + "- Enabled: " +  i.isEnabled());
		}
		ForgeEventHandler.ready = true;
		commandMap.doneLoadingPlugins((ServerCommandManager) theServer.getCommandManager());
		if (!theServer.isDedicatedServer()) {
			EntityPlayer par0 = theServer.getConfigurationManager().getPlayerForUsername(theServer.getServerOwner());
			if (par0 != null) {
				par0.sendChatToPlayer(ChatColor.GREEN + "BukkitForge has finished loading! You may now enjoy a (relatively) lag-free game!");
				theServer.getCommandManager().executeCommand(par0, "/plugins");
				(new PlayerTracker()).onPlayerLogin(par0);
			}

		}

	}
示例#5
0
  public void updateTimeLightAndEntities() {
    this.theProfiler.startSection("levels");
    int i;

    Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0);
    for (int x = 0; x < ids.length; x++) {
      int id = ids[x];
      long j = System.nanoTime();

      if (id == 0 || this.getAllowNether()) {
        WorldServer worldserver = DimensionManager.getWorld(id);
        this.theProfiler.startSection(worldserver.getWorldInfo().getWorldName());
        this.theProfiler.startSection("pools");
        worldserver.getWorldVec3Pool().clear();
        this.theProfiler.endSection();

        if (this.tickCounter % 20 == 0) {
          this.theProfiler.startSection("timeSync");
          this.serverConfigManager.sendPacketToAllPlayersInDimension(
              new Packet4UpdateTime(worldserver.getTotalWorldTime(), worldserver.getWorldTime()),
              worldserver.provider.dimensionId);
          this.theProfiler.endSection();
        }

        this.theProfiler.startSection("tick");
        FMLCommonHandler.instance().onPreWorldTick(worldserver);
        CrashReport crashreport;

        try {
          worldserver.tick();
        } catch (Throwable throwable) {
          crashreport = CrashReport.makeCrashReport(throwable, "Exception ticking world");
          worldserver.addWorldInfoToCrashReport(crashreport);
          throw new ReportedException(crashreport);
        }

        try {
          worldserver.updateEntities();
        } catch (Throwable throwable1) {
          crashreport = CrashReport.makeCrashReport(throwable1, "Exception ticking world entities");
          worldserver.addWorldInfoToCrashReport(crashreport);
          throw new ReportedException(crashreport);
        }

        FMLCommonHandler.instance().onPostWorldTick(worldserver);
        this.theProfiler.endSection();
        this.theProfiler.startSection("tracker");
        worldserver.getEntityTracker().updateTrackedEntities();
        this.theProfiler.endSection();
        this.theProfiler.endSection();
      }

      worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j;
    }

    this.theProfiler.endStartSection("dim_unloading");
    DimensionManager.unloadWorlds(worldTickTimes);
    this.theProfiler.endStartSection("connection");
    this.getNetworkThread().networkTick();
    this.theProfiler.endStartSection("players");
    this.serverConfigManager.sendPlayerInfoToAllPlayers();
    this.theProfiler.endStartSection("tickables");

    for (i = 0; i < this.tickables.size(); ++i) {
      ((IUpdatePlayerListBox) this.tickables.get(i)).update();
    }

    this.theProfiler.endSection();
  }
示例#6
0
  public CraftServer(MinecraftServer server) {
    instance = this;
    configMan = server.getConfigurationManager();
    theServer = server;
    List<Integer> ids = Arrays.asList(DimensionManager.getIDs());
    Iterator<Integer> worldIter = ids.iterator();

    System.out.println("IS THE INSTANCE NULL? " + (instance == null ? "YES" : "NO"));
    this.pluginManager = new SimplePluginManager(this, commandMap);

    // pluginManager = new SimplePluginManager(this, commandMap);
    configuration = new YamlConfiguration();
    YamlConfiguration yml = new YamlConfiguration();
    try {
      yml.load(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"));
      if (!new File("bukkit.yml").exists()) {
        new File("bukkit.yml").createNewFile();
        yml.save("bukkit.yml");
      }
      configuration.load("bukkit.yml");
      configuration.addDefaults(yml);
      configuration.save("bukkit.yml");

    } catch (Exception e) {
      e.printStackTrace();
    }

    for (int id : ids) {
      worlds.get(id);
    }

    this.theLogger = BukkitContainer.bukkitLogger;
    // theLogger.info("Bukkit API for Vanilla, version " + apiVer + " starting up...");
    theLogger.info(
        "Starting BukkitForge "
            + BukkitContainer.BF_FULL_VERSION
            + "(CB-Version: "
            + BukkitContainer.CRAFT_VERSION
            + ").");

    Bukkit.setServer(this);
    this.theHelpMap = new SimpleHelpMap(this);
    this.theMessenger = new StandardMessenger();
    this.entityMetadata = new EntityMetadataStore();
    this.playerMetadata = new PlayerMetadataStore();
    this.worldMetadata = new WorldMetadataStore();
    this.warningState = Warning.WarningState.DEFAULT;
    this.console = (CraftConsoleCommandSender) CraftConsoleCommandSender.getInstance();

    CraftModRecipeHelper.saveCraftingManagerRecipes();

    HelpTopic myHelp =
        new CommandHelpTopic("bexec", "Run a command forcibly bukkit aliases", "", "");
    Bukkit.getServer().getHelpMap().addTopic(myHelp);

    loadPlugins();
    enablePlugins(PluginLoadOrder.STARTUP);

    // load plugin worlds - TODO

    theLogger.info("Loading PostWorld plugins...");
    enablePlugins(PluginLoadOrder.POSTWORLD);
    theLogger.info("Loaded plugins: ");
    for (Plugin i : pluginManager.getPlugins()) {
      theLogger.info(i.getName() + "- Enabled: " + i.isEnabled());
    }
    ForgeEventHandler.ready = true;
    commandMap.doneLoadingPlugins((ServerCommandManager) theServer.getCommandManager());
    if (!theServer.isDedicatedServer()) {
      EntityPlayer player =
          theServer.getConfigurationManager().getPlayerForUsername(theServer.getServerOwner());
      if (player != null) {
        player.sendChatToPlayer(
            ChatColor.GREEN
                + "CraftForge has finished loading! You may now enjoy a (relatively) lag-free game!");
        theServer.getCommandManager().executeCommand(player, "/plugins");
        (new PlayerTracker()).onPlayerLogin(player);
      }
    }
  }