当前位置: 首页>>代码示例>>Java>>正文


Java CommandHandler类代码示例

本文整理汇总了Java中net.minecraft.command.CommandHandler的典型用法代码示例。如果您正苦于以下问题:Java CommandHandler类的具体用法?Java CommandHandler怎么用?Java CommandHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CommandHandler类属于net.minecraft.command包,在下文中一共展示了CommandHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
@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();
}
 
开发者ID:SleepyTrousers,项目名称:EnderCore,代码行数:18,代码来源:EnderCore.java

示例2: updateConfig

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:DoubleDoorDevelopment,项目名称:ItemBlacklist,代码行数:20,代码来源:ItemBlacklist.java

示例3: addTabCompletionOptions

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
@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;
    }

}
 
开发者ID:MCServerTools,项目名称:ServerTools-PERMISSION,代码行数:20,代码来源:CommandRemovePerm.java

示例4: tick

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
@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();
        }
    }
}
 
开发者ID:dmillerw,项目名称:LoreExpansion_old,代码行数:23,代码来源:CommandDelayHandler.java

示例5: beforeServerStart

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
@Mod.EventHandler
public void beforeServerStart(FMLServerAboutToStartEvent event) {
    ICommandManager manager = event.getServer().getCommandManager();
    if (manager instanceof CommandHandler) {
        ((CommandHandler) manager).registerCommand(new DebugDamageCommand());
    }
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:8,代码来源:FirstAid.java

示例6: serverStarting

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
@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);
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:14,代码来源:TaleCraft.java

示例7: registerCommandHandler

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
public static void registerCommandHandler(ICommand cmd)
{
	if (MeddleUtil.isClientJar()) delayedICommands.add(cmd);
	else {
		((CommandHandler) getServer().getCommandManager()).registerCommand(cmd);
	}
}
 
开发者ID:FyberOptic,项目名称:MeddleAPI,代码行数:8,代码来源:MeddleAPI.java

示例8: onServerRunHook

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
public static void onServerRunHook(MinecraftServer server)
{	
	if (MeddleUtil.isClientJar()) {			
		CommandHandler cmdHandler = (CommandHandler) server.getCommandManager();
		for (ICommand cmd : delayedICommands)
		{
			cmdHandler.registerCommand(cmd);
		}
	}
}
 
开发者ID:FyberOptic,项目名称:MeddleAPI,代码行数:11,代码来源:MeddleAPI.java

示例9: serverStarting

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
@EventHandler()
public void serverStarting(FMLServerStartingEvent event) {
    CommandHandler cm = (CommandHandler) event.getServer().getCommandManager();
    if (DEBUG) {
        cm.registerCommand(new CmdMineStatistics());
    }
    RegistrationManager.INSTANCE.registerAll(this, "StartServer");
}
 
开发者ID:LambdaInnovation,项目名称:LambdaLib,代码行数:9,代码来源:LambdaLib.java

示例10: registerAliases

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
@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);
		}
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:15,代码来源:ServerPlayerSettings.java

示例11: getTabCompletionOptions

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
/**
 * @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;
    }
}
 
开发者ID:NeptunePowered,项目名称:NeptuneMod,代码行数:42,代码来源:MixinCommandHandler.java

示例12: serverStarting

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
@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;
}
 
开发者ID:DoubleDoorDevelopment,项目名称:D3Commands,代码行数:11,代码来源:D3Commands.java

示例13: serverStarted

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
@EventHandler
public void serverStarted(FMLServerStartedEvent event) {
    CommandHandler handler = (CommandHandler) MinecraftServer.getServer().getCommandManager();

    if ((Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) {
        handler.registerCommand(new CommandDebug());
    }
}
 
开发者ID:EnderWizards,项目名称:libsandstone,代码行数:9,代码来源:Sandstone.java

示例14: overrideHelp

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
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;
            }
        });
    }
}
 
开发者ID:MCServerTools,项目名称:ServerTools-CORE,代码行数:29,代码来源:CommandManager.java

示例15: doRegister

import net.minecraft.command.CommandHandler; //导入依赖的package包/类
/**
 * <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);
    }
}
 
开发者ID:MCServerTools,项目名称:ServerTools-CORE,代码行数:15,代码来源:CommandManager.java


注:本文中的net.minecraft.command.CommandHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。