@EventHandler public void init(FMLInitializationEvent event) { EnderPacketHandler.init(); for (IConfigHandler c : configs) { c.initHook(); } Handlers.register(event); CompatRegistry.INSTANCE.handle(event); ClientCommandHandler.instance.registerCommand(CommandReloadConfigs.CLIENT); if (event.getSide().isServer()) { ((CommandHandler) MinecraftServer.getServer().getCommandManager()).registerCommand(CommandReloadConfigs.SERVER); } IMCRegistry.INSTANCE.init(); }
private void updateConfig() { message = configuration.getString("message", CATEGORY_GENERAL, "Now is not the time to use that. ~Prof. Oak", "The message you get when using an item that is banned."); log = configuration.getBoolean("log", CATEGORY_GENERAL, false, "Log every instance of any banned item used. (SPAM WARNING!)"); unpack4all = configuration.getBoolean("unpack4all", CATEGORY_GENERAL, true, "Let everyone unpack items by using the 'unpack' command. So items can be used in crafting."); if (configuration.hasChanged()) configuration.save(); if (pastStart) { CommandHandler ch = (CommandHandler) FMLCommonHandler.instance().getMinecraftServerInstance().getCommandManager(); if (unpack4all) ch.registerCommand(CommandUnpack.I); else { ch.getCommands().remove(CommandUnpack.I.getName()); for (String s : CommandUnpack.I.getAliases()) ch.getCommands().remove(s); } } }
@SuppressWarnings("unchecked") @Override public List addTabCompletionOptions(ICommandSender sender, String[] strings) { if (strings.length == 1) { CommandHandler ch = (CommandHandler) MinecraftServer.getServer().getCommandManager(); List<String> ret = new ArrayList<>(ch.getCommands().size()); for (ICommand command : (Collection<ICommand>) ch.getCommands().values()) { ret.add("cmd." + command.getCommandName()); } return getListOfStringsFromIterableMatchingLastWord(strings, ret); } else if (strings.length == 2) { Collection<String> groupKeys = PermissionManager.getGroupNames(); return getListOfStringsMatchingLastWord(strings, groupKeys.toArray(new String[groupKeys.size()])); } else { return null; } }
@SubscribeEvent public void tick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) return; Iterator<DelayedCommand> delayedIterator = delayedCommands.iterator(); while (delayedIterator.hasNext()) { DelayedCommand delayedCommand = delayedIterator.next(); delayedCommand.timer--; if (delayedCommand.timer <= 0) { CommandHandler ch = (CommandHandler) MinecraftServer.getServer().getCommandManager(); LoreCommandSender commandSender = new LoreCommandSender(delayedCommand.getPlayer()); for (String command : delayedCommand.commands) { ch.executeCommand(commandSender, command); } delayedIterator.remove(); } } }
@Mod.EventHandler public void beforeServerStart(FMLServerAboutToStartEvent event) { ICommandManager manager = event.getServer().getCommandManager(); if (manager instanceof CommandHandler) { ((CommandHandler) manager).registerCommand(new DebugDamageCommand()); } }
@Mod.EventHandler public void serverStarting(FMLServerStartingEvent event){ MinecraftServer server = event.getServer(); ICommandManager cmdmng = server.getCommandManager(); if (cmdmng instanceof ServerCommandManager && cmdmng instanceof CommandHandler) { CommandHandler cmdhnd = (CommandHandler) cmdmng; TaleCraftCommands.register(cmdhnd); } // By calling this method, we create the ServerMirror for the given server. ServerHandler.getServerMirror(server); }
public static void registerCommandHandler(ICommand cmd) { if (MeddleUtil.isClientJar()) delayedICommands.add(cmd); else { ((CommandHandler) getServer().getCommandManager()).registerCommand(cmd); } }
public static void onServerRunHook(MinecraftServer server) { if (MeddleUtil.isClientJar()) { CommandHandler cmdHandler = (CommandHandler) server.getCommandManager(); for (ICommand cmd : delayedICommands) { cmdHandler.registerCommand(cmd); } } }
@EventHandler() public void serverStarting(FMLServerStartingEvent event) { CommandHandler cm = (CommandHandler) event.getServer().getCommandManager(); if (DEBUG) { cm.registerCommand(new CmdMineStatistics()); } RegistrationManager.INSTANCE.registerAll(this, "StartServer"); }
@Override protected void registerAliases() { CommandHandler commandHandler = (CommandHandler) FMLCommonHandler.instance().getMinecraftServerInstance().getCommandManager(); String command; for (String alias : this.aliases.keySet()) { command = this.aliases.get(alias).split(" ")[0]; if (!command.equalsIgnoreCase(alias) && !commandHandler.getCommands().containsKey(alias)) { DummyCommand cmd = new DummyCommand(alias, false); commandHandler.getCommands().put(alias, cmd); } } }
/** * @author jamierocks - 15th May 2015 * @reason Add Canary tab-completion results */ @Overwrite public List<String> getTabCompletionOptions(ICommandSender sender, String input, BlockPos pos) { final String[] commandSplit = input.split(" ", -1); final String commandName = commandSplit[0]; if (commandSplit.length == 1) { final List<String> matches = Lists.newArrayList(); // Neptune - Add Canary command matches matches.addAll(Canary.commands().matchCommandNames((MessageReceiver) sender, commandName, false)); // Neptune - end for (final Map.Entry<String, ICommand> alias : this.commandMap.entrySet()) { if (CommandBase.doesStringStartWith(commandName, alias.getKey()) && alias.getValue().canCommandSenderUseCommand(sender)) { matches.add(alias.getKey()); } } return matches; } else { if (commandSplit.length > 1) { // Neptune - Tab complete through Canary if possible final List<String> options = Canary.commands().tabComplete((MessageReceiver) sender, commandName, CommandHandler.dropFirstString(commandSplit)); if (options != null) { return options; } // Neptune - end final ICommand command = this.commandMap.get(commandName); if (command != null && command.canCommandSenderUseCommand(sender)) { return command.addTabCompletionOptions(sender, CommandHandler.dropFirstString(commandSplit), pos); } } return null; } }
@Mod.EventHandler public void serverStarting(FMLServerStartingEvent event) { CommandHandler ch = (CommandHandler) event.getServer().getCommandManager(); for (CommandEntry e : commandsMap.values()) { if (e.isEnabled()) ch.registerCommand(e.getInstance()); } pastStart = true; }
@EventHandler public void serverStarted(FMLServerStartedEvent event) { CommandHandler handler = (CommandHandler) MinecraftServer.getServer().getCommandManager(); if ((Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) { handler.registerCommand(new CommandDebug()); } }
private void overrideHelp(final CommandHandler commandHandler) { if (Loader.isModLoaded("HelpFixer")) { log.trace("HelpFixer detected. Not overriding /help"); } else { log.trace("Overriding /help"); commandHandler.registerCommand(new CommandHelp() { @Override protected List<ICommand> getSortedPossibleCommands(final ICommandSender sender) { final List<ICommand> list = MinecraftServer.getServer().getCommandManager().getPossibleCommands(sender); final Iterator<ICommand> iterator = list.iterator(); while (iterator.hasNext()) { ICommand command = iterator.next(); if (command.getCommandName() == null) { log.warn("Identified command with a null name: {}", command.getClass()); iterator.remove(); } else if (command.getCommandUsage(sender) == null) { log.warn("Identified command with null usage: {}", command.getClass()); iterator.remove(); } } Collections.sort(list, (o1, o2) -> o1.getCommandName().compareTo(o2.getCommandName())); return list; } }); } }
/** * <em>Internal Use Only!</em> * * @param server The server */ public void doRegister(final MinecraftServer server) { log.trace("Registering commands with Minecraft..."); CommandHandler commandHandler = (CommandHandler) server.getCommandManager(); commands.forEach(commandHandler::registerCommand); if (ServerToolsCore.instance().getConfig().getGeneral().isHelpOverrideEnabled()) { overrideHelp(commandHandler); } }
public void serverStarting(MinecraftServer server) { CommandHandler commandManager = (CommandHandler) server.getCommandManager(); for (IPlugin plugin : PluginManager.plugins) if (plugin.isAvailable()) { ICommand[] commands = plugin.getConsoleCommands(); if (commands == null) { continue; } for (ICommand command : commands) { commandManager.registerCommand(command); } } }
public void initCommands(MinecraftServer server) { ICommandManager manager = server.getCommandManager(); if(manager instanceof CommandHandler) { CommandHandler handler = (CommandHandler)manager; handler.registerCommand(new CommandHats()); } }
@EventHandler public void serverStarting(FMLServerStartingEvent event) { CommandHandler commandManager = (CommandHandler)event.getServer().getCommandManager(); commandManager.registerCommand(new CommandCreateGroup()); commandManager.registerCommand(new CommandJoinGroup()); }
public void initCommands(MinecraftServer server) { ICommandManager manager = server.getCommandManager(); if(manager instanceof CommandHandler) { CommandHandler handler = (CommandHandler)manager; handler.registerCommand(new CommandMorph()); } }
public static void registration(FMLServerStartingEvent event) { CommandHandler commandManager = (CommandHandler) event.getServer().getCommandManager(); commandManager.registerCommand(new Command()); commandManager.registerCommand(new CommandLowerCase()); commandManager.registerCommand(new CommandGravestone()); commandManager.registerCommand(new CommandGravestoneLowerCase()); }
@EventHandler public void onServerStart(FMLServerAboutToStartEvent event){ CommandHandler manager = (CommandHandler) event.getServer().getCommandManager(); manager.registerCommand(new VelocityCommand()); manager.registerCommand(new CTabCommand()); manager.registerCommand(new NotifyCommand()); manager.registerCommand(new WipeEntitiesCommand()); }
public void registerServerCommand(ICommand command) { CommandHandler ch = (CommandHandler) getServer().getCommandManager(); ch.registerCommand(command); }
public static void registerCommand(ICommand command) { ((CommandHandler) mc().getCommandManager()).registerCommand(command); }
public void registerServerCommand(ICommand command) { CommandHandler ch = (CommandHandler) getServer().func_71187_D(); ch.func_71560_a(command); }
public static void register(CommandHandler registry) { for(ICommand cmd : commands) { registry.registerCommand(cmd); } }
@Override protected void register( Class<? extends ICommand> theClass, RegCommand anno) throws Exception { CommandHandler ch = (CommandHandler) MinecraftServer.getServer().getCommandManager(); ch.registerCommand(theClass.newInstance()); }
public static void init(MinecraftServer server) { CommandHandler commandHandler = (CommandHandler) server.getCommandManager(); commandHandler.registerCommand(new CommandCreativeBlocks()); }
private void updateConfig() { final String items = "itemcommands"; configuration.setCategoryLanguageKey(items, "d3.cmd.config.items"); configuration.addCustomCategoryComment(items, "Make new categories like the example to add new commands that give a specific item."); configuration.setCategoryRequiresWorldRestart(items, true); { final String example = items + ".key"; configuration.addCustomCategoryComment(example, "Example, don't delete, just disable if you don't want it. Values in here are defaults, except for enabled.\n" + "CHANGES: modid became modids! All mods have to be present for the command to work. Useful for compatibility items."); configuration.getString("name", example, "key", "The name of the command. aka the part after the slash. Cannot have spaces. Case sensitive! Required!"); configuration.getStringList("aliases", example, new String[] {"spectre", "spectrekey"}, "A list of alternative names. Case sensitive!"); configuration.getBoolean("allowUsername", example, true, "Allow a username to be specified, to give the item to someone else."); configuration.getStringList("modids", example, new String[] {"RandomThings"}, "The modid that needs to be loaded for this command to work. Case sensitive!"); configuration.getString("item", example, "RandomThings:spectreKey", "Like you would use in '/give' Required!"); configuration.getInt("meta", example, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, "Metadata or Damage value of the item."); configuration.getInt("stacksize", example, 1, 0, 64, "The stacksize. 0 is a nice troll btw :p"); configuration.getString("message", example, "Here you go!", "The message that appears after a successful command."); configuration.getString("displayname", example, "", "Set a custom display name if you want it."); configuration.getBoolean("enabled", example, false, "Easy enable / disable here. Enabled by default!"); } ConfigCategory root = configuration.getCategory(items); for (ConfigCategory cat : root.getChildren()) { if (!commandsMap.containsKey(cat.getQualifiedName())) { ItemCommandEntry entry = new ItemCommandEntry(cat); commandsMap.put(entry.getUniqueName(), entry); } } configuration.setCategoryLanguageKey(MODID, "d3.cmd.config.cmd"); configuration.addCustomCategoryComment(MODID, "Set any value to false to disable the command."); configuration.setCategoryRequiresWorldRestart(MODID, true); if (pastStart) { CommandHandler ch = (CommandHandler) FMLCommonHandler.instance().getMinecraftServerInstance().getCommandManager(); for (CommandEntry e : commandsMap.values()) { boolean was = e.isEnabled(); e.doConfig(configuration); boolean is = e.isEnabled(); if (pastStart && was != is) // If we are past start, and the status has changed { if (!is) // Remove { ch.getCommands().remove(e.getInstance().getCommandName()); for (String s : e.getInstance().getCommandAliases()) ch.getCommands().remove(s); } else // Add { ch.registerCommand(e.getInstance()); } } } } if (configuration.hasChanged()) configuration.save(); }
public CommandAbstract register() { CommandHandler ch = (CommandHandler) MinecraftServer.getServer().getCommandManager(); ch.registerCommand(this); return this; }
@EventHandler public void serverStarting(FMLServerStartingEvent event) { CommandHandler commandManager = (CommandHandler) event.getServer().getCommandManager(); commandManager.registerCommand(new CommandBending()); commandManager.registerCommand(new CommandRegion()); }
@SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { if (event.phase == TickEvent.Phase.START && event.side == Side.SERVER) { if (!event.player.capabilities.isCreativeMode) { for (int i = 0; i < event.player.inventory.getSizeInventory(); i++) { ItemStack stack = event.player.inventory.getStackInSlot(i); if (stack != null && stack.getItem() == LoreExpansion.lorePage) { LoreKey key = ItemLorePage.getLore(stack); if (key != null) { Lore lore = LoreLoader.getLore(key); if (lore == null) { return; } LoreProperties collectedLore = PlayerHandler.getCollectedLore(event.player); if (!collectedLore.hasLore(key)) { collectedLore.addLore(key); PacketSyncLore.updateLore((EntityPlayerMP) event.player); // Pickup notification packet PacketNotification.notify(event.player, PacketNotification.TYPE_CLIENT_PICKUP, key); // Autoplay handling LoreProperties properties = PlayerHandler.getCollectedLore(event.player); if (lore.autoplay && properties.canAutoplay(key)) { properties.setAutoplayed(key, true); PacketNotification.notify(event.player, PacketNotification.TYPE_CLIENT_AUTOPLAY, key); } if (lore.commands.commands != null) { for (Commands.CommandEntry command : lore.commands.commands) { if (command.delay > 0) { CommandDelayHandler.queueCommand(event.player, command); } else { CommandHandler ch = (CommandHandler) MinecraftServer.getServer().getCommandManager(); LoreCommandSender commandSender = new LoreCommandSender(event.player); for (String c : command.commands) { ch.executeCommand(commandSender, c); } } } } } event.player.inventory.setInventorySlotContents(i, null); event.player.inventory.markDirty(); return; } // Only set this to false if no lore has been updated this tick notifiedThisTick = false; } } } } }
public void registerServerCommands() { ((CommandHandler) MinecraftServer.getServer().getCommandManager()).registerCommand(new nsodCommand()); }
@EventHandler public void serverStarting(FMLServerStartingEvent event){ if (MinecraftServer.getServer().getCommandManager() instanceof ServerCommandManager) { ((CommandHandler) MinecraftServer.getServer().getCommandManager()).registerCommand(new CommandFloor()); } }