Java 类net.minecraft.command.CommandHandler 实例源码

项目:EnderCore    文件:EnderCore.java   
@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();
}
项目:ItemBlacklist    文件:ItemBlacklist.java   
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);
        }
    }
}
项目:ServerTools-PERMISSION    文件:CommandRemovePerm.java   
@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;
    }

}
项目:ServerTools-PERMISSION    文件:CommandAddPerm.java   
@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;
    }

}
项目:LoreExpansion_old    文件:CommandDelayHandler.java   
@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();
        }
    }
}
项目:FirstAid    文件:FirstAid.java   
@Mod.EventHandler
public void beforeServerStart(FMLServerAboutToStartEvent event) {
    ICommandManager manager = event.getServer().getCommandManager();
    if (manager instanceof CommandHandler) {
        ((CommandHandler) manager).registerCommand(new DebugDamageCommand());
    }
}
项目:TaleCraft    文件:TaleCraft.java   
@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);
}
项目:MeddleAPI    文件:MeddleAPI.java   
public static void registerCommandHandler(ICommand cmd)
{
    if (MeddleUtil.isClientJar()) delayedICommands.add(cmd);
    else {
        ((CommandHandler) getServer().getCommandManager()).registerCommand(cmd);
    }
}
项目:MeddleAPI    文件:MeddleAPI.java   
public static void onServerRunHook(MinecraftServer server)
{   
    if (MeddleUtil.isClientJar()) {         
        CommandHandler cmdHandler = (CommandHandler) server.getCommandManager();
        for (ICommand cmd : delayedICommands)
        {
            cmdHandler.registerCommand(cmd);
        }
    }
}
项目:LambdaLib    文件:LambdaLib.java   
@EventHandler()
public void serverStarting(FMLServerStartingEvent event) {
    CommandHandler cm = (CommandHandler) event.getServer().getCommandManager();
    if (DEBUG) {
        cm.registerCommand(new CmdMineStatistics());
    }
    RegistrationManager.INSTANCE.registerAll(this, "StartServer");
}
项目:morecommands    文件:ServerPlayerSettings.java   
@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);
        }
    }
}
项目:NeptuneMod    文件:MixinCommandHandler.java   
/**
 * @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;
    }
}
项目:D3Commands    文件:D3Commands.java   
@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;
}
项目:libsandstone    文件:Sandstone.java   
@EventHandler
public void serverStarted(FMLServerStartedEvent event) {
    CommandHandler handler = (CommandHandler) MinecraftServer.getServer().getCommandManager();

    if ((Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) {
        handler.registerCommand(new CommandDebug());
    }
}
项目:ServerTools-CORE    文件:CommandManager.java   
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;
            }
        });
    }
}
项目:ServerTools-CORE    文件:CommandManager.java   
/**
 * <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);
    }
}
项目:ForestryLegacy    文件:ForestryCore.java   
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);
            }
        }
}
项目:Hats    文件:ProxyCommon.java   
public void initCommands(MinecraftServer server)
{
    ICommandManager manager = server.getCommandManager();
    if(manager instanceof CommandHandler)
    {
        CommandHandler handler = (CommandHandler)manager;
        handler.registerCommand(new CommandHats());
    }
}
项目:Sojourn    文件:Sojourn.java   
@EventHandler
public void serverStarting(FMLServerStartingEvent event)
{       
    CommandHandler commandManager = (CommandHandler)event.getServer().getCommandManager();
    commandManager.registerCommand(new CommandCreateGroup());
    commandManager.registerCommand(new CommandJoinGroup());
}
项目:Morph    文件:CommonProxy.java   
public void initCommands(MinecraftServer server)
{
    ICommandManager manager = server.getCommandManager();
    if(manager instanceof CommandHandler)
    {
        CommandHandler handler = (CommandHandler)manager;
        handler.registerCommand(new CommandMorph());
    }
}
项目:Gravestone-mod-Graves    文件:Commands.java   
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());
}
项目:EnchancedAdventuronics    文件:EnhancedAdventuronics.java   
@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());

}
项目:CustomWorldGen    文件:FMLServerStartingEvent.java   
public void registerServerCommand(ICommand command)
{
    CommandHandler ch = (CommandHandler) getServer().getCommandManager();
    ch.registerCommand(command);
}
项目:4Space-5    文件:ServerUtils.java   
public static void registerCommand(ICommand command) {
    ((CommandHandler) mc().getCommandManager()).registerCommand(command);
}
项目:TRHS_Club_Mod_2016    文件:FMLServerStartingEvent.java   
public void registerServerCommand(ICommand command)
{
    CommandHandler ch = (CommandHandler) getServer().func_71187_D();
    ch.func_71560_a(command);
}
项目:TaleCraft    文件:TaleCraftCommands.java   
public static void register(CommandHandler registry) {
    for(ICommand cmd : commands) {
        registry.registerCommand(cmd);
    }
}
项目:LambdaLib    文件:CommandRegistration.java   
@Override
protected void register( Class<? extends ICommand> theClass, RegCommand anno) throws Exception {
    CommandHandler ch = (CommandHandler) MinecraftServer.getServer().getCommandManager();
    ch.registerCommand(theClass.newInstance());
}
项目:CauldronGit    文件:FMLServerStartingEvent.java   
public void registerServerCommand(ICommand command)
{
    CommandHandler ch = (CommandHandler) getServer().getCommandManager();
    ch.registerCommand(command);
}
项目:CreativeBlocks    文件:Commands.java   
public static void init(MinecraftServer server)
{
    CommandHandler commandHandler = (CommandHandler) server.getCommandManager();

    commandHandler.registerCommand(new CommandCreativeBlocks());
}
项目:D3Commands    文件:D3Commands.java   
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();
}
项目:Dimensional-Pockets    文件:CommandAbstract.java   
public CommandAbstract register() {
    CommandHandler ch = (CommandHandler) MinecraftServer.getServer().getCommandManager();
    ch.registerCommand(this);
    return this;
}
项目:Cauldron    文件:FMLServerStartingEvent.java   
public void registerServerCommand(ICommand command)
{
    CommandHandler ch = (CommandHandler) getServer().getCommandManager();
    ch.registerCommand(command);
}
项目:Cauldron    文件:FMLServerStartingEvent.java   
public void registerServerCommand(ICommand command)
{
    CommandHandler ch = (CommandHandler) getServer().getCommandManager();
    ch.registerCommand(command);
}
项目:Cauldron    文件:FMLServerStartingEvent.java   
public void registerServerCommand(ICommand command)
{
    CommandHandler ch = (CommandHandler) getServer().getCommandManager();
    ch.registerCommand(command);
}
项目:Blockbender    文件:mod_Avatar.java   
@EventHandler
public void serverStarting(FMLServerStartingEvent event) {
    CommandHandler commandManager = (CommandHandler) event.getServer().getCommandManager();
    commandManager.registerCommand(new CommandBending());
    commandManager.registerCommand(new CommandRegion());
}
项目:LoreExpansion_old    文件:PlayerTickHandler.java   
@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;
                }
            }
        }
    }
}
项目:Hackery    文件:HackeryCommonProxy.java   
public void registerServerCommands() {
    ((CommandHandler) MinecraftServer.getServer().getCommandManager()).registerCommand(new nsodCommand());
}
项目:RuneCraftery    文件:FMLServerStartingEvent.java   
public void registerServerCommand(ICommand command)
{
    CommandHandler ch = (CommandHandler) getServer().func_71187_D();
    ch.func_71560_a(command);
}
项目:RuneCraftery    文件:FMLServerStartingEvent.java   
public void registerServerCommand(ICommand command)
{
    CommandHandler ch = (CommandHandler) getServer().getCommandManager();
    ch.registerCommand(command);
}
项目:Realms-of-Chaos    文件:RealmsOfChaos.java   
@EventHandler
   public void serverStarting(FMLServerStartingEvent event){
    if (MinecraftServer.getServer().getCommandManager() instanceof ServerCommandManager) {
        ((CommandHandler) MinecraftServer.getServer().getCommandManager()).registerCommand(new CommandFloor());
    }
}