本文整理汇总了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();
}
示例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);
}
}
}
示例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;
}
}
示例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();
}
}
}
示例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());
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
示例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");
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
示例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());
}
}
示例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;
}
});
}
}
示例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);
}
}