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(); } } }
@Override public void run() { OutputHandler.debug("Started running the logger"); while (run) { try { Thread.sleep(1000 * ModulePlayerLogger.interval); } catch (final InterruptedException e) { } if (buffer.isEmpty()) { OutputHandler.SOP("No logs to make"); } else { OutputHandler.SOP("Making logs"); makeLogs(); OutputHandler.SOP("Done making logs"); } } }