@Override
	public void onPluginDisable(final Plugin plugin)
	{
		if (plugin.getName().equals(this.getName()) || !plugin.getName().startsWith("Essentials"))
		{
			return;
		}
		modules.remove(plugin.getName().substring(10));
	}
	@Override
	public void onPluginEnable(final Plugin plugin)
	{
		if (plugin.getName().equals(this.getName()) || !plugin.getName().startsWith("Essentials"))
		{
			return;
		}
		// Remove "Essentials" from name
		modules.put(plugin.getName().substring(10), plugin);
	}
 @Override
 public boolean run(
     CommandSender sender,
     Player sender_p,
     Command cmd,
     String commandLabel,
     String[] args,
     boolean senderIsConsole) {
   boolean toggled = false;
   boolean enabled = true;
   for (Plugin p : TotalFreedomMod.server.getPluginManager().getPlugins()) {
     if (p.getName().equalsIgnoreCase("nyan")) {
       if (p.isEnabled()) {
         p.getPluginLoader().disablePlugin(p);
         enabled = false;
       } else {
         p.getPluginLoader().enablePlugin(p);
         enabled = true;
       }
       toggled = true;
     }
   }
   if (toggled) {
     if (!enabled) {
       TotalFreedomMod.server.broadcastMessage(
           ChatColor.RED + sender.getName() + " - Disabling Nyan Plugin");
     } else {
       TotalFreedomMod.server.broadcastMessage(
           ChatColor.GREEN + sender.getName() + " - Enabling Nyan Plugin");
     }
   }
   return true;
 }
示例#4
0
  /**
   * Execute the command.
   *
   * @param sender the sender of the command
   * @param command the command being done
   * @param label the name of the command
   * @param args the arguments supplied
   */
  @Override
  public void execute(CommandSender sender, Command command, String label, String[] args) {

    if (!hasPermission()) {
      sender.sendMessage(PlugMan.getInstance().getMessageFormatter().format("error.no-permission"));
      return;
    }

    if (args.length < 2) {
      sender.sendMessage(
          PlugMan.getInstance().getMessageFormatter().format("error.specify-plugin"));
      sendUsage();
      return;
    }

    Plugin potential = PluginUtil.getPluginByName(args, 1);

    if (potential != null) {
      sender.sendMessage(
          PlugMan.getInstance()
              .getMessageFormatter()
              .format("load.already-loaded", potential.getName()));
      return;
    }

    String name = StringUtil.consolidateStrings(args, 1);

    if (PluginUtil.isIgnored(name)) {
      sender.sendMessage(PlugMan.getInstance().getMessageFormatter().format("error.ignored"));
      return;
    }

    sender.sendMessage(PluginUtil.load(name));
  }
示例#5
0
 public ReflectConfiguration(Plugin plugin, String name, String folder) {
     this.plugin = plugin;
     this.name = name;
     this.prefix = plugin.getName();
     this.header = prefix + " configuration file: '" + name + "'.\nGenerated for " + prefix + " version " + plugin.getDescription().getVersion() + ".";
     this.folder = folder;
 }
  /**
   * Invoked when a plugin has been disabled.
   *
   * @param plugin - the disabled plugin.
   */
  private void onPluginDisabled(Plugin plugin) {
    Component component = components.get(plugin.getName());

    if (component != null) {
      component.unregister(registered);
    }
  }
示例#7
0
  public void recordCondition(Plugin plugin, boolean shouldPrefix, String condition, Level level) {
    String content = ChatColor.AQUA + condition;
    String message = content;
    String prefix = ChatColor.GRAY + plugin.getName() + ChatColor.GRAY + "] ";

    if (shouldPrefix) {
      message = prefix + content;
    }

    if (level.intValue() <= this.broadcastLevel.intValue()) {
      Bukkit.broadcast(message, "pulse.observe");
    }

    System.out.println(
        "[Pulse] " + level.getLocalizedName() + "] " + plugin.getName() + "] " + condition);
  }
 void loadCFG() {
   pluginconfig = loadExternalConfig(pl);
   cm.sendMessage(ChatColor.LIGHT_PURPLE + "Config loaded successfull");
   this.loaded = true;
   this.changed = false;
   this.loadedplugin = pl.getName();
 }
  public Plugin getPlugin(String name) {
    for (Plugin serverPlugin : server.getPluginManager().getPlugins()) {
      if (serverPlugin.getName().equalsIgnoreCase(name)) {
        return serverPlugin;
      }
    }

    if (name.length() >= 3) {
      for (Plugin serverPlugin : server.getPluginManager().getPlugins()) {
        if (serverPlugin.getName().toLowerCase().contains(name.toLowerCase())) {
          return serverPlugin;
        }
      }
    }

    return null;
  }
 private List<String> getSupportedPlugins() {
   Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
   List<String> supportedPlugins = new Vector<>();
   for (Plugin p : plugins)
     try {
       if (p.getConfig().getBoolean("upm")) supportedPlugins.add(p.getName());
     } catch (Exception e) {
     }
   return supportedPlugins;
 }
示例#11
0
 /** This is internal stuff. Don't call this directly! */
 @EventHandler(priority = EventPriority.MONITOR)
 public void adminJoin(PlayerJoinEvent event) {
   try {
     if (!enabled || !lock.compareAndSet(false, true)) return;
     Player p = event.getPlayer();
     String[] out;
     if (needUpdate) {
       if (hasPermission(p, "autoupdate.announce")) {
         out =
             new String[] {
               COLOR_INFO + "[" + plugin.getName() + "] New " + type + " available!",
               COLOR_INFO
                   + "If you want to update from "
                   + av
                   + " to "
                   + updateVersion
                   + " use /update "
                   + plugin.getName(),
               COLOR_INFO + "See " + pluginURL + " for more information."
             };
       } else out = null;
     } else if (updatePending) {
       if (hasPermission(p, "autoupdate.announce")) {
         out =
             new String[] {
               COLOR_INFO
                   + "Please restart the server to finish the update of "
                   + plugin.getName(),
               COLOR_INFO + "See " + pluginURL + " for more information."
             };
       } else out = null;
     } else out = null;
     lock.set(false);
     if (out != null)
       plugin
           .getServer()
           .getScheduler()
           .scheduleSyncDelayedTask(plugin, new SyncMessageDelayer(p.getName(), out));
   } catch (Throwable t) {
     printStackTraceSync(t, false);
   }
 }
示例#12
0
 public void log(Level level, Plugin plugin, String message) {
   write(
       "["
           + this.plugin.time.getLongDate()
           + "] "
           + "["
           + plugin.getName()
           + "] ["
           + level.getName()
           + "] "
           + message);
 }
示例#13
0
 /** This is internal stuff. Don't call this directly! */
 @EventHandler(ignoreCancelled = false)
 public void updateCmd(PlayerCommandPreprocessEvent event) {
   try {
     String[] split = event.getMessage().split(" ");
     if (!split[0].equalsIgnoreCase("/update")) return;
     event.setCancelled(true);
     if (!enabled || !needUpdate) return;
     if (split.length > 1 && !plugin.getName().equalsIgnoreCase(split[1])) return;
     update(event.getPlayer());
   } catch (Throwable t) {
     printStackTraceSync(t, false);
   }
 }
示例#14
0
  /**
   * Logs an error that was probably caused by a client plugin.
   *
   * @param plugin the plugin that caused the exception, or null
   * @param e the exception that was thrown
   * @param msg an accompanying message
   */
  public static void logException(Plugin plugin, Throwable e, String msg) {
    Bukkit.getLogger().log(Level.SEVERE, "[Flex] " + msg, e);

    if (plugin != null) {
      /*
          Bukkit.getLogger().log(Level.SEVERE, "[Flex] This may to be a bug in one or more of the plugins using the Flex command handling framework.");
          Bukkit.getLogger().log(Level.SEVERE, "[Flex] Plugins using Flex: " + getClientsStr());
      }
      else {*/
      Bukkit.getLogger()
          .log(Level.SEVERE, "[Flex] The plugin that caused this error is: " + plugin.getName());
    }
  }
示例#15
0
  /**
   * Invoked when we have detected that a plugin has been enabled.
   *
   * @param plugin - the enabled plugin.
   */
  private void onPluginEnabled(Plugin plugin) {
    String key = plugin.getName();
    Supplier<? extends Component> supplier = suppliers.get(key);

    // Only register the component once
    if (isRegistered() && supplier != null) {
      Component component = components.get(key);

      // Construct and register the component
      if (component == null) components.put(key, component = supplier.get());
      if (!component.isRegistered()) component.register(plugin, bus);
    }
  }
示例#16
0
 private void debugToPlayer(String message, String level) {
   Player p = plugin.getServer().getPlayer(debugPlayerName);
   if (p != null) {
     p.sendMessage(
         ChatColor.AQUA
             + "*"
             + level
             + "("
             + plugin.getName()
             + ") > "
             + ChatColor.ITALIC
             + message);
   }
 }
示例#17
0
 /**
  * Gets the generator name and arguments of this World
  *
  * @return Chunk Generator name and arguments
  */
 public String getChunkGeneratorName() {
   if (this.chunkGeneratorName == null) {
     World world = this.getWorld();
     if (world != null) {
       ChunkGenerator gen = world.getGenerator();
       if (gen != null) {
         Plugin genPlugin = CommonUtil.getPluginByClass(gen.getClass());
         if (genPlugin != null) {
           this.chunkGeneratorName = genPlugin.getName();
         }
       }
     }
   }
   return this.chunkGeneratorName;
 }
  private Plugin mockPlugin(Server server, String name, PluginLoadOrder order, String... depend) {
    Plugin plugin = mock(Plugin.class);
    PluginDescriptionFile file = mock(PluginDescriptionFile.class);

    when(plugin.getServer()).thenReturn(server);
    when(plugin.getName()).thenReturn(name);
    when(plugin.toString()).thenReturn(name);
    when(plugin.getDescription()).thenReturn(file);

    // This is the difficult part
    when(file.getLoad()).thenReturn(order);
    when(file.getDepend()).thenReturn(Arrays.asList(depend));
    when(file.getSoftDepend()).thenReturn(null);
    return plugin;
  }
  /**
   * Create a mockable plugin for all the tests.
   *
   * @param fakePluginName - the fake plugin name.
   * @return The plugin.
   */
  private static Plugin createPlugin(String fakePluginName) {
    Plugin plugin = mock(Plugin.class);
    PluginDescriptionFile description = mock(PluginDescriptionFile.class);

    when(description.getDepend()).thenReturn(Lists.newArrayList("ProtocolLib"));
    when(description.getSoftDepend()).thenReturn(Collections.<String>emptyList());
    when(description.getLoadBefore()).thenReturn(Collections.<String>emptyList());
    when(description.getLoad()).thenReturn(PluginLoadOrder.POSTWORLD);

    when(plugin.getName()).thenReturn(fakePluginName);
    when(plugin.getServer()).thenReturn(Bukkit.getServer());
    when(plugin.isEnabled()).thenReturn(true);
    when(plugin.getDescription()).thenReturn(description);
    return plugin;
  }
示例#20
0
  public static Listener getPluginListener(String name) {
    if (!Bukkit.getServer().getPluginManager().isPluginEnabled(name)) return null;
    Plugin p = Bukkit.getServer().getPluginManager().getPlugin(name);
    double version = extractVersion(p.getDescription().getVersion());

    for (Listener l : values()) {
      if (!l.name.equalsIgnoreCase(p.getName())) continue;
      if (l.versionMax == null && l.versionMin == null) return l;

      if (l.versionMin != null && l.versionMin >= version) continue;
      if (l.versionMax != null && l.versionMax < version) continue;
      return l;
    }

    return null;
  }
示例#21
0
  private void scanPlugins() {
    String packageName;

    for (Plugin scanPlugin : getServer().getPluginManager().getPlugins()) {
      if (scanPlugin instanceof RecipeManager) {
        continue;
      }

      packageName = scanPlugin.getDescription().getMain();
      int i = packageName.lastIndexOf('.');
      if (i > 0) {
        packageName = packageName.substring(0, i);
      }
      plugins.put(packageName, scanPlugin.getName());
    }
  }
  /**
   * Check for disabled plugin to remove the associated replacer
   *
   * @param disableEvent the disable event
   */
  @EventHandler
  public void onPluginDisable(PluginDisableEvent disableEvent) {
    // Remove the listener if the associated plugin was disabled
    final String disablePluginName = disableEvent.getPlugin().getName();

    final Map<String, VariableReplaceAdapter<? extends Plugin>> specificReplacers =
        replaceManager.getReplacers();
    final Iterator<VariableReplaceAdapter<? extends Plugin>> iterator =
        specificReplacers.values().iterator();
    while (iterator.hasNext()) {
      final Plugin plugin = iterator.next().getPlugin();
      if (plugin != null && plugin.getName().equals(disablePluginName)) {
        iterator.remove();
      }
    }
  }
示例#23
0
 /**
  * This will use a custom configuration. Use this in onEnable().
  *
  * @param plugin The instance of your plugins main class.
  * @param config The configuration to use.
  * @throws Exception
  */
 public AutoUpdate(Plugin plugin, Configuration config) throws Exception {
   if (plugin == null) throw new Exception("Plugin can not be null");
   this.plugin = plugin;
   av = ymlPrefix + plugin.getDescription().getVersion() + ymlSuffix;
   if (bukkitdevSlug == null || bukkitdevSlug.equals("")) bukkitdevSlug = plugin.getName();
   bukkitdevSlug = bukkitdevSlug.toLowerCase();
   bukget = "http://bukget.v10lator.de/" + bukkitdevSlug;
   bukgetFallback = "http://bukget.org/api/plugin/" + bukkitdevSlug + "/latest";
   if (delay < 72000L) {
     plugin
         .getLogger()
         .info("[AutoUpdate] delay < 72000 ticks not supported. Setting delay to 72000.");
     delay = 72000L;
   }
   setConfig(config);
   plugin.getServer().getPluginManager().registerEvents(this, plugin);
 }
  /**
   * Load a specific fake plugin.
   *
   * @param plugin - the plugin to load.
   */
  @SuppressWarnings("unchecked")
  private static void initializePlugin(Plugin plugin) {
    PluginManager manager = Bukkit.getPluginManager();

    try {
      List<Plugin> plugins = (List<Plugin>) FieldUtils.readField(manager, "plugins", true);
      Map<String, Plugin> lookupNames =
          (Map<String, Plugin>) FieldUtils.readField(manager, "lookupNames", true);

      /// Associate this plugin
      plugins.add(plugin);
      lookupNames.put(plugin.getName(), plugin);

    } catch (Exception e) {
      throw new RuntimeException("Unable to access the fields of " + manager, e);
    }
  }
示例#25
0
文件: Cmd.java 项目: Rojoss/Boxx
  /**
   * Used by the {@link CmdRegistration} to register the command.
   *
   * <p><b>Do not call this to register a command!</b>
   *
   * <p>You'll have to use {@link CmdRegistration#register(Plugin, BaseCmd)} to register a command
   * properly! Also don't forget to call {@link CmdRegistration#unregister(Plugin)} in onDisable()
   *
   * @param plugin The plugin that registered the command.
   * @throws CmdAlreadyRegisteredException When the command is already registered.
   */
  public void register(Plugin plugin) throws CmdAlreadyRegisteredException {
    setUsage(getUsage(plugin.getServer().getConsoleSender(), getBaseCmd().getName()));

    if (this.plugin != null) {
      throw new CmdAlreadyRegisteredException(plugin, this);
    }
    this.plugin = plugin;

    try {
      Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");
      f.setAccessible(true);
      CommandMap commandMap = (CommandMap) f.get(Bukkit.getServer());

      commandMap.register(plugin.getName(), this);
    } catch (NoSuchFieldException | IllegalAccessException e) {
      e.printStackTrace();
    }
  }
 private void logInvocationError(Exception e, MethodWrapper mwrapper, Arguments newArgs) {
   System.err.println(
       "["
           + plugin.getName()
           + " Error] "
           + mwrapper.method
           + " : "
           + mwrapper.obj
           + "  : "
           + newArgs);
   if (newArgs != null && newArgs.args != null) {
     for (Object o : newArgs.args) System.err.println("[Error] object=" + o);
   }
   System.err.println("[Error] Cause=" + e.getCause());
   if (e.getCause() != null) {
     e.getCause().printStackTrace();
     log.log(Level.SEVERE, null, e.getCause());
   }
   System.err.println("[Error] Trace Continued ");
   log.log(Level.SEVERE, null, e);
 }
  @Override
  public boolean run(
      CommandSender sender,
      Player sender_p,
      Command cmd,
      String commandLabel,
      String[] args,
      boolean senderIsConsole) {
    if (args.length == 0 || args.length > 2) {
      return false;
    }

    final PluginManager pm = server.getPluginManager();

    if (args.length == 1) {
      if (args[0].equalsIgnoreCase("list")) {
        for (Plugin serverPlugin : pm.getPlugins()) {
          final String version = serverPlugin.getDescription().getVersion();
          playerMsg(
              ChatColor.GRAY
                  + "- "
                  + (serverPlugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED)
                  + serverPlugin.getName()
                  + ChatColor.GOLD
                  + (version != null && !version.isEmpty() ? " v" + version : "")
                  + " by "
                  + StringUtils.join(serverPlugin.getDescription().getAuthors(), ", "));
        }

        return true;
      }

      return false;
    }

    if ("enable".equals(args[0])) {
      final Plugin target = getPlugin(args[1]);
      if (target == null) {
        playerMsg("Plugin not found!");
        return true;
      }

      if (target.isEnabled()) {
        playerMsg("Plugin is already enabled.");
        return true;
      }

      pm.enablePlugin(target);

      if (!pm.isPluginEnabled(target)) {
        playerMsg("Error enabling plugin " + target.getName());
        return true;
      }

      playerMsg(target.getName() + " is now enabled.");
      return true;
    }

    if ("disable".equals(args[0])) {
      final Plugin target = getPlugin(args[1]);
      if (target == null) {
        playerMsg("Plugin not found!");
        return true;
      }

      if (!target.isEnabled()) {
        playerMsg("Plugin is already disabled.");
        return true;
      }

      if (target.getName().equals(plugin.getName())) {
        playerMsg("You cannot disable " + plugin.getName());
        return true;
      }

      pm.disablePlugin(target);

      if (pm.isPluginEnabled(target)) {
        playerMsg("Error disabling plugin " + target.getName());
        return true;
      }

      playerMsg(target.getName() + " is now disabled.");
      return true;
    }

    if ("reload".equals(args[0])) {
      final Plugin target = getPlugin(args[1]);
      if (target == null) {
        playerMsg("Plugin not found!");
        return true;
      }

      if (target.getName().equals(plugin.getName())) {
        playerMsg("Use /tfm reload to reload instead.");
        return true;
      }

      pm.disablePlugin(target);
      pm.enablePlugin(target);
      playerMsg(target.getName() + " reloaded.");
      return true;
    }

    return false;
  }
示例#28
0
  public void onEnable() {

    if (getServer().getPluginManager().getPlugin("Citizens") == null
        || getServer().getPluginManager().getPlugin("Citizens").isEnabled() == false) {
      getLogger().log(java.util.logging.Level.SEVERE, "Citizens 2.0 not found or not enabled");
      getServer().getPluginManager().disablePlugin(this);
      return;
    }

    if (getServer().getPluginManager().getPlugin("dynmap") == null
        || getServer().getPluginManager().getPlugin("dynmap").isEnabled() == false) {
      getLogger().log(java.util.logging.Level.SEVERE, "dynmap not found or not enabled");
      getServer().getPluginManager().disablePlugin(this);
    }

    if (getServer().getPluginManager().getPlugin("HyperConomy") == null) {
      getLogger().log(java.util.logging.Level.SEVERE, "Hyperconomoy Not found");
      bHyperConomyExists = false;
    } else {
      for (Plugin oPlug : getServer().getPluginManager().getPlugins()) {
        getLogger().log(java.util.logging.Level.SEVERE, "plugin:" + oPlug.getName());
      }

      if (getServer().getPluginManager().getPlugin("HyperMerchant") == null) {
        getLogger().log(java.util.logging.Level.SEVERE, "HyperMerchant Not found");
        bHyperConomyExists = false;
      } else {
        getLogger()
            .log(java.util.logging.Level.SEVERE, "Hyperconomy / Hypermerchant found. Enabled");
        bHyperConomyExists = true;
      }
    }

    SetupConfig();

    getLogger().log(java.util.logging.Level.INFO, "Connecting to DynMap");

    try {
      SetupDynMap();
    } catch (Exception err) {
      getLogger().log(java.util.logging.Level.INFO, "Errors while connecting to the Dynmap API");
      getServer().getPluginManager().disablePlugin(this);
      cDyn_Plugin = null;
      cDyn_MarkAPI = null;
      cDyn_Markers = null;
      return;
    }

    // Setup the Citizens NPC link
    net.citizensnpcs.api.CitizensAPI.getTraitFactory()
        .registerTrait(
            net.citizensnpcs.api.trait.TraitInfo.create(DynMapNPC_Trait.class)
                .withName("dynmapnpc"));

    // Schedule the main thread to monitor for NPCs
    cProcessing_Task =
        new DynMapNPC_Task(this)
            .runTaskTimer(
                this,
                this.getConfig().getLong("interval", 100L),
                this.getConfig().getLong("interval", 100L));

    if (this.getConfig().getBoolean("mcstats", true)) {
      try {
        MCStatsMetrics metrics = new MCStatsMetrics(this);
        metrics.start();
      } catch (Exception e) {
        // Failed to submit the stats :-(
      }
    }
  }
示例#29
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);
			}

		}

	}
  @Override
  public boolean onCommand(CommandSender cmdsender, Command cmd, String label, String[] args) {
    if (cmdsender instanceof Player) {
      Player player = (Player) cmdsender;
      if (!cmd.getName().equalsIgnoreCase("upm")) {
        return false;
      } else if (args.length == 0) {
        player.sendMessage(
            ChatColor.LIGHT_PURPLE + "Usage: " + ChatColor.GOLD + "/UPM <password> ");
      } else if (!locked) {
        if (args[0].equals(parentconfig.getString("password"))
            && (player.hasPermission("upm.limited")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          this.player = player;
          this.playerID = player.getUniqueId();
          cm.disableChat(player);
          locked = true;
          cm.sendMessage(ChatColor.LIGHT_PURPLE + "UPM Mode enabled");
        } else {
          player.sendMessage(ChatColor.RED + "Wrong password or no permission for this command!");
        }
      } else if (player.getUniqueId() == playerID) {
        if (args[0].equalsIgnoreCase("exit")) {
          locked = false;
          changed = false;
          loaded = false;
          cm.sendMessage(ChatColor.LIGHT_PURPLE + "UPM Mode disabled");
          cm.enableChat();
        } else if (args[0].equalsIgnoreCase("list")
            && (player.hasPermission("upm.limited")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          cm.sendMessage(ChatColor.LIGHT_PURPLE + "Supported Plugins:\n------------");
          for (String s : getSupportedPlugins()) cm.sendMessage(ChatColor.LIGHT_PURPLE + s);
        } else if (args[0].equalsIgnoreCase("load-cfg")
            && (player.hasPermission("upm.config.show")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          if (args.length > 1 && args[1] != null) {
            if (getSupportedPlugins().contains(args[1])) {
              pl = Bukkit.getPluginManager().getPlugin(args[1]);
              if (changed) {
                cm.sendMessage(
                    ChatColor.RED
                        + "There are unsafed changes in the loaded config."
                        + " "
                        + "You really want to load another config?\n"
                        + "To confirm "
                        + "type: "
                        + ChatColor.GOLD
                        + "YES");
                cm.requestConfirmation(1);
              } else loadCFG();
            } else
              cm.sendMessage(
                  ChatColor.LIGHT_PURPLE
                      + "Plugin "
                      + ChatColor.GOLD
                      + args[1]
                      + ChatColor.LIGHT_PURPLE
                      + " does not exist or isnt supported!");

          } else
            cm.sendMessage(
                ChatColor.LIGHT_PURPLE
                    + "Usage: "
                    + ChatColor.GOLD
                    + "/upm load-cfg "
                    + "<pluginname>");

        } else if (args[0].equalsIgnoreCase("save-cfg")
            && (player.hasPermission("upm.config.edit")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          if (loaded)
            if (changed)
              if (getSupportedPlugins().contains(loadedplugin)) {
                pl = Bukkit.getPluginManager().getPlugin(loadedplugin);
                try {
                  saveExternalPluginConfig(pl);
                  cm.sendMessage(ChatColor.LIGHT_PURPLE + "Config saved successfull");
                  this.changed = false;
                  this.loaded = false;
                } catch (IOException e) {
                  cm.sendMessage(ChatColor.RED + "Error while saving config!");
                }
              } else
                cm.sendMessage(
                    ChatColor.LIGHT_PURPLE
                        + "Plugin "
                        + ChatColor.GOLD
                        + loadedplugin
                        + ChatColor.LIGHT_PURPLE
                        + " does not exist or isnt supported!");
            else cm.sendMessage(ChatColor.LIGHT_PURPLE + "Nothing to save, config isnt changed!");
          else cm.sendMessage(ChatColor.LIGHT_PURPLE + "Nothing to save, config isnt loaded!");
        } else if (args[0].equalsIgnoreCase("update")
            && (player.hasPermission("upm.update")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          if (args.length > 1 && args[1] != null) {
            if (getSupportedPlugins().contains(args[1])) {
              pl = Bukkit.getPluginManager().getPlugin(args[1]);
              try {
                String updateURL = pl.getConfig().getString("upm_update");
                updatePlugin(updateURL, pl);
                cm.sendMessage(
                    ChatColor.LIGHT_PURPLE + "Plugin updated successfull. Restart needed.");
              } catch (Exception e) {
                cm.sendMessage(ChatColor.RED + "Error while updating!");
              }
            } else
              cm.sendMessage(
                  ChatColor.LIGHT_PURPLE
                      + "Plugin "
                      + ChatColor.GOLD
                      + args[1]
                      + ChatColor.LIGHT_PURPLE
                      + " does not exist or isnt supported!");

          } else
            cm.sendMessage(
                ChatColor.LIGHT_PURPLE
                    + "Usage: "
                    + ChatColor.GOLD
                    + "/upm update "
                    + "<pluginname>");
        } else if (args[0].equalsIgnoreCase("check-updates")
            && (player.hasPermission("upm.limited")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          cm.sendMessage(
              ChatColor.LIGHT_PURPLE
                  + "Name || Installed Version || Newest Version || Latest "
                  + "Changes");
          for (String s : getSupportedPlugins()) {
            pl = Bukkit.getPluginManager().getPlugin(s);
            String name = pl.getName();
            String installedVersion = pl.getDescription().getVersion();
            String updateURL = pl.getConfig().getString("upm_update");
            String[] information = getLatestPluginInformation(updateURL);
            if (information != null && !(installedVersion.equals(information[0])))
              cm.sendMessage(
                  ChatColor.LIGHT_PURPLE
                      + name
                      + " || "
                      + installedVersion
                      + " || "
                      + information[0]
                      + " || "
                      + ChatColor.GREEN
                      + information[1]);
          }
        } else if (args[0].equalsIgnoreCase("set-cfg")
            && (player.hasPermission("upm.config.edit")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          if (args.length > 2 && args[1] != null && args[2] != null)
            if (loaded) {
              try {
                String type = pluginconfig.getString("upm_configtype." + args[1]);
                if (pluginconfig.get("upm_configtype." + args[1]) != null) {
                  if (type.equals("list")) {
                    List<String> list = (List<String>) pluginconfig.getList(args[1]);
                    if (list == null) list = new Vector<>();
                    if (args[2].equalsIgnoreCase("add") && args.length > 3) {
                      cm.sendMessage(ChatColor.LIGHT_PURPLE + "Adding " + args[3] + " to list");
                      cm.sendMessage(ChatColor.RED + "To Confirm type " + ChatColor.GOLD + "YES");
                      templist = list;
                      tempargs = args;
                      temptype = type;
                      cm.requestConfirmation(2);
                    } else if (args[2].equalsIgnoreCase("remove") && args.length > 3) {
                      cm.sendMessage(ChatColor.LIGHT_PURPLE + "Removing " + args[3] + " from list");
                      cm.sendMessage(ChatColor.RED + "To Confirm type " + ChatColor.GOLD + "YES");
                      templist = list;
                      tempargs = args;
                      temptype = type;
                      cm.requestConfirmation(2);

                    } else if (args[2].equalsIgnoreCase("show")) {
                      cm.sendMessage(ChatColor.LIGHT_PURPLE + "Current List values:");
                      for (String s : list) cm.sendMessage("- " + s);
                    } else
                      cm.sendMessage(
                          ChatColor.LIGHT_PURPLE
                              + "Usage:"
                              + ChatColor.GOLD
                              + "/UPM "
                              + "set-cfg <path> <add/remove/show> (value)");
                  } else {
                    cm.sendMessage(
                        ChatColor.LIGHT_PURPLE
                            + "Current Value of "
                            + args[1]
                            + ":"
                            + ChatColor.GOLD
                            + pluginconfig.getString(args[1])
                            + " ("
                            + type
                            + ")");
                    cm.sendMessage(
                        ChatColor.LIGHT_PURPLE
                            + "New Value of "
                            + args[1]
                            + ":"
                            + ChatColor.GOLD
                            + args[2]);
                    cm.sendMessage(ChatColor.RED + "To Confirm type " + ChatColor.GOLD + "YES");
                    tempargs = args;
                    temptype = type;
                    cm.requestConfirmation(2);
                  }
                } else {
                  cm.sendMessage(
                      ChatColor.LIGHT_PURPLE
                          + "Path not found! Use /upm add-path to create "
                          + "it.");
                }
              } catch (Exception e) {
                cm.sendMessage(e.getLocalizedMessage());
                cm.sendMessage(e.getMessage());
                e.printStackTrace();
              }
            } else
              cm.sendMessage(
                  ChatColor.LIGHT_PURPLE
                      + "No Plugin loaded! Use "
                      + ChatColor.GOLD
                      + "/UPM "
                      + "load-cfg <pluginname> "
                      + ChatColor.LIGHT_PURPLE
                      + " to load a "
                      + "Config"
                      + ".");
          else
            cm.sendMessage(
                ChatColor.LIGHT_PURPLE
                    + "Usage: "
                    + ChatColor.GOLD
                    + "/UPM set-cfg <path> "
                    + "<value> ");
        } else if (args[0].equalsIgnoreCase("add-path")
            && (player.hasPermission("upm.config.edit")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          if (loaded)
            if (args.length > 2 && args[1] != null && args[2] != null)
              if (args[2].equalsIgnoreCase("string")) {
                tempargs = new String[3];
                // add upm path
                tempargs[1] = "upm_configtype." + args[1];
                tempargs[2] = "string";
                changeValue();
              } else if (args[2].equalsIgnoreCase("int")) {
                tempargs = new String[3];
                // add upm path
                temptype = "string";
                tempargs[1] = "upm_configtype." + args[1];
                tempargs[2] = "int";
                changeValue();
              } else if (args[2].equalsIgnoreCase("double")) {
                tempargs = new String[3];
                // add upm path
                temptype = "string";
                tempargs[1] = "upm_configtype." + args[1];
                tempargs[2] = "double";
                changeValue();
              } else if (args[2].equalsIgnoreCase("boolean")) {
                tempargs = new String[3];
                // add upm path
                temptype = "string";
                tempargs[1] = "upm_configtype." + args[1];
                tempargs[2] = "boolean";
                changeValue();
              } else if (args[2].equalsIgnoreCase("list")) {
                tempargs = new String[4];
                // add upm path
                temptype = "string";
                tempargs[1] = "upm_configtype." + args[1];
                tempargs[2] = "list";
                changeValue();
              } else {
                cm.sendMessage(ChatColor.RED + "Value type " + args[2] + " isnt supported!");
              }
            else
              cm.sendMessage(
                  ChatColor.LIGHT_PURPLE
                      + "Usage: "
                      + ChatColor.GOLD
                      + "/UPM add-path <path> "
                      + "<type>");
          else
            cm.sendMessage(
                ChatColor.LIGHT_PURPLE
                    + "No Plugin loaded! Use "
                    + ChatColor.GOLD
                    + "/UPM "
                    + "load-cfg <pluginname> "
                    + ChatColor.LIGHT_PURPLE
                    + " to load a "
                    + "Config"
                    + ".");
        } else if (args[0].equalsIgnoreCase("show-cfg")
            && (player.hasPermission("upm.config.show")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          if (loaded)
            if (args.length > 1 && args[1] != null)
              if (pluginconfig.get(args[1]) != null)
                cm.sendMessage(
                    ChatColor.LIGHT_PURPLE
                        + "Current Value of "
                        + args[1]
                        + ":"
                        + ChatColor.GOLD
                        + pluginconfig.getString(args[1]));
              else cm.sendMessage(ChatColor.LIGHT_PURPLE + "Config is not defined for " + args[1]);
            else
              cm.sendMessage(
                  ChatColor.LIGHT_PURPLE + "Usage: " + ChatColor.GOLD + "/UPM show-cfg <path> ");
          else
            cm.sendMessage(
                ChatColor.LIGHT_PURPLE
                    + "No Plugin loaded! Use "
                    + ChatColor.GOLD
                    + "/UPM "
                    + "load-cfg <pluginname> "
                    + ChatColor.LIGHT_PURPLE
                    + " to load a "
                    + "Config"
                    + ".");
        } else if (args[0].equalsIgnoreCase("set-password")
            && (player.hasPermission("upm.config.edit")
                || player.isOp()
                || player.hasPermission("upm" + ".admin"))) {
          if (args.length > 2 && args[1] != null && args[2] != null) {
            if (args[1].equals(parentconfig.getString("password"))) {
              parentconfig.set("password", args[2]);
              UPM_IOManager.saveConfig(parentconfig);
              cm.sendMessage(ChatColor.GREEN + "Password successfull changed");
            } else cm.sendMessage(ChatColor.RED + "Wrong current Password");
          } else
            cm.sendMessage(
                ChatColor.LIGHT_PURPLE
                    + "Usage: "
                    + ChatColor.GOLD
                    + "/UPM set-password "
                    + "<current Password> <new Password>");
        } else
          cm.sendMessage(
              ChatColor.LIGHT_PURPLE
                  + "Help:\n"
                  + ChatColor.GOLD
                  + "/UPM exit"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Leaves UPM Mode, "
                  + "enables chat again\n"
                  + ChatColor.GOLD
                  + "/UPM check-updates"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Shows latest Updates for all supported Plugins\n"
                  + ChatColor.GOLD
                  + "/UPM update"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Updates a plugin to latest online version\n"
                  + ChatColor.GOLD
                  + "/UPM load-cfg"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Loads a config of a plugin\n"
                  + ChatColor.GOLD
                  + "/UPM save-cfg"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Saves the loaded config\n"
                  + ChatColor.GOLD
                  + "/UPM set-cfg"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Sets a value for a config path\n"
                  + ChatColor.GOLD
                  + "/UPM show-cfg"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Shows a value of a config path\n"
                  + ChatColor.GOLD
                  + "/UPM set-password"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Changes UPM password");

      } else {
        player.sendMessage(
            ChatColor.LIGHT_PURPLE
                + "UPM is currently used by "
                + ChatColor.GOLD
                + this.player.getName());
      }
    }
    return true;
  }