コード例 #1
0
  private void removeDuplicateCommands(MinecraftServer server) {
    if (server.getCommandManager() instanceof CommandHandler) {
      try {
        Set<String> commandNames = new HashSet<String>();
        Set<String> toRemoveNames = new HashSet<String>();
        CommandHandler cmdMng = (CommandHandler) server.getCommandManager();

        for (Object cmdObj : cmdMng.commandSet) {
          ICommand cmd = (ICommand) cmdObj;
          if (!commandNames.add(cmd.getCommandName())) {
            OutputHandler.debug("Duplicate command found! Name:" + cmd.getCommandName());
            toRemoveNames.add(cmd.getCommandName());
          }
        }
        Set toRemove = new HashSet();
        for (Object cmdObj : cmdMng.commandSet) {
          ICommand cmd = (ICommand) cmdObj;
          if (toRemoveNames.contains(cmd.getCommandName())) {
            Class<?> cmdClass = cmd.getClass();
            if (!cmdClass.getPackage().getName().contains("ForgeEssentials")) {
              OutputHandler.debug(
                  "Removing command '"
                      + cmd.getCommandName()
                      + "' from class: "
                      + cmdClass.getName());
              toRemove.add(cmd.getCommandName());
            }
          }
        }
        cmdMng.commandSet.removeAll(toRemove);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
コード例 #2
0
ファイル: UPermissions.java プロジェクト: Nauthul/uMods
 @ServerStarting
 public void serverStarting(FMLServerStartingEvent event) {
   MinecraftServer server = ModLoader.getMinecraftServerInstance();
   ICommandManager commandManager = server.getCommandManager();
   ServerCommandManager serverCommandManager = (ServerCommandManager) commandManager;
   serverCommandManager.registerCommand(new CommanduPerm());
 }
コード例 #3
0
 @EventHandler
 public void onServerStart(FMLServerStartingEvent evt) {
   MinecraftServer server = MinecraftServer.getServer();
   ICommandManager command = server.getCommandManager();
   ServerCommandManager manager = (ServerCommandManager) command;
   manager.registerCommand(new ServerCommandsVC());
 }
コード例 #4
0
ファイル: JaffasTrees.java プロジェクト: mnn/jaffas
 @Mod.EventHandler
 public void serverStarting(FMLServerStartingEvent event) {
   server = event.getServer();
   ICommandManager commandManager = server.getCommandManager();
   ServerCommandManager serverCommandManager = ((ServerCommandManager) commandManager);
   addCommands(serverCommandManager);
 }
コード例 #5
0
ファイル: NewDawn.java プロジェクト: twothe/newdawn
 @Mod.EventHandler
 public void serverStart(FMLServerStartingEvent event) {
   final MinecraftServer server = event.getServer();
   final ICommandManager commandManager = server.getCommandManager();
   if (commandManager instanceof ServerCommandManager) {
     final ServerCommandManager serverCommandManager = (ServerCommandManager) commandManager;
     serverCommandManager.registerCommand(new CommandGenerateWorld());
   } else {
     FMLLog.warning("Unable to get server command manager. No slash-commands will be available.");
   }
 }
コード例 #6
0
ファイル: CraftServer.java プロジェクト: wmchris/BukkitForge
  @Override
  public boolean dispatchCommand(CommandSender sender, String commandLine) throws CommandException {
    if (sender instanceof CraftConsoleCommandSender) {
      theServer.executeCommand(commandLine);
    } else {
      ICommandSender ics = ((CraftPlayer) sender).getHandle();
      theServer.getCommandManager().executeCommand(ics, commandLine);
    }

    return true;
  }
コード例 #7
0
 private void func_72566_d(String par1Str) {
   if (mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username)
       || "/seed".equals(par1Str)) {
     logger.info(
         (new StringBuilder())
             .append(playerEntity.username)
             .append(" issued server command: ")
             .append(par1Str)
             .toString());
     mcServer.getCommandManager().executeCommand(playerEntity, par1Str);
   }
 }
コード例 #8
0
  /** Execute the command, called when the command block is powered. */
  public int executeCommandOnPowered(World par1World) {
    if (par1World.isRemote) {
      return 0;
    } else {
      MinecraftServer var2 = MinecraftServer.getServer();

      if (var2 != null && var2.isCommandBlockEnabled()) {
        ICommandManager var3 = var2.getCommandManager();
        return var3.executeCommand(this, this.command);
      } else {
        return 0;
      }
    }
  }
コード例 #9
0
ファイル: BukkitServer.java プロジェクト: sct/BukkitForge
	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);
			}

		}

	}
コード例 #10
0
ファイル: CraftServer.java プロジェクト: wmchris/BukkitForge
  @Override
  public void reload() {
    configuration = YamlConfiguration.loadConfiguration(new File("bukkit.yml"));
    //

    if (theServer instanceof DedicatedServer) {
      PropertyManager config = new PropertyManager(theServer.getFile("server.properties"));
      ((DedicatedServer) theServer).settings = config;
    }

    //

    boolean animals = theServer.getCanSpawnAnimals();
    boolean monsters = theServer.worldServerForDimension(0).difficultySetting > 0;
    int difficulty = theServer.worldServerForDimension(0).difficultySetting;

    // theServer.pro
    /*theServer.setOnlineMode(theServer.isServerInOnlineMode());
    theServer.setCanSpawnAnimals(config.getBooleanProperty("spawn-animals", theServer.getCanSpawnAnimals()));
    theServer.setAllowPvp(config.getBooleanProperty("pvp", theServer.isPVPEnabled()));
    theServer.setAllowFlight(config.getBooleanProperty("allow-flight", theServer.isFlightAllowed()));
    theServer.setMOTD(config.getProperty("motd", theServer.getMOTD()));*/
    monsterSpawn = configuration.getInt("spawn-limits.monsters");
    animalSpawn = configuration.getInt("spawn-limits.animals");
    waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
    warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
    // = bukkitConfig.getInt("ticks-per.autosave");

    for (WorldServer world : theServer.worldServers) {
      world.difficultySetting = difficulty;
      world.spawnHostileMobs = monsters;
      world.spawnPeacefulMobs = animals;
      /*if (this.getTicksPerAnimalSpawns() < 0) {
          world.ticksPerAnimalSpawns = 400;
      } else {
          world.ticksPerAnimalSpawns = this.getTicksPerAnimalSpawns();
      }

      if (this.getTicksPerMonsterSpawns() < 0) {
          world.ticksPerMonsterSpawns = 1;
      } else {
          world.ticksPerMonsterSpawns = this.getTicksPerMonsterSpawns();
      }*/
    }

    pluginManager.clearPlugins();
    commandMap.clearCommands();
    resetRecipes();

    int pollCount = 0;

    // Wait for at most 2.5 seconds for plugins to close their threads
    while (pollCount < 50 && getScheduler().getActiveWorkers().size() > 0) {
      try {
        Thread.sleep(50);
      } catch (InterruptedException e) {
      }
      pollCount++;
    }

    List<BukkitWorker> overdueWorkers = getScheduler().getActiveWorkers();
    for (BukkitWorker worker : overdueWorkers) {
      Plugin plugin = worker.getOwner();
      String author = "<NoAuthorGiven>";
      if (plugin.getDescription().getAuthors().size() > 0) {
        author = plugin.getDescription().getAuthors().get(0);
      }
      getLogger()
          .log(
              Level.SEVERE,
              String.format(
                  "Nag author: '%s' of '%s' about the following: %s",
                  author,
                  plugin.getDescription().getName(),
                  "This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin"));
    }
    loadPlugins();
    enablePlugins(PluginLoadOrder.STARTUP);
    enablePlugins(PluginLoadOrder.POSTWORLD);
    // reload commands
    commandMap.doneLoadingPlugins((ServerCommandManager) theServer.getCommandManager());
  }
コード例 #11
0
ファイル: CraftServer.java プロジェクト: wmchris/BukkitForge
  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);
      }
    }
  }