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


Java ICommand类代码示例

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


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

示例1: execute

import net.minecraft.command.ICommand; //导入依赖的package包/类
/**
 * Callback for when the command is executed
 */
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if(args.length < 1)
    {
        sender.addChatMessage(new TextComponentString(CommandBase.joinNiceStringFromCollection(commandMap.keySet())));
    }
    else
    {
        ICommand cmd = getCommandMap().get(args[0]);

        if(cmd == null)
        {
            throw new CommandException("commands.tree_base.invalid_cmd", args[0]);
        }
        else if(!cmd.checkPermission(server, sender))
        {
            throw new CommandException("commands.generic.permission");
        }
        else
        {
            cmd.execute(server, sender, shiftArgs(args));
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:29,代码来源:CommandTreeBase.java

示例2: execute

import net.minecraft.command.ICommand; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length == 0) {
        throw new CommandException("nosubcommandspecified");
    }
    final Optional<CommandBase> first = childCommands
            .stream()
            .sorted(Comparator.comparing(ICommand::getCommandName))
            .filter(command -> command.getCommandName().equals(args[0]))
            .findFirst();
    if (!first.isPresent()) {
        throw new CommandException("nosuchsubcommand");
    }
    final CommandBase commandBase = first.get();

    final String[] parameters = Arrays.copyOfRange(args, 1, args.length);

    commandBase.execute(server, sender, parameters);
}
 
开发者ID:AtomicBlom,项目名称:ShearMadness,代码行数:20,代码来源:ShearMadnessCommand.java

示例3: getTabCompletionOptions

import net.minecraft.command.ICommand; //导入依赖的package包/类
@Override
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) {

    if (args.length <= 1) {
        return childCommands
                .stream()
                .map(ICommand::getCommandName)
                .sorted()
                .filter(command -> command.startsWith(args[0]))
                .collect(Collectors.toList());
    }

    final Optional<CommandBase> first = childCommands
            .stream()
            .sorted(Comparator.comparing(ICommand::getCommandName))
            .filter(command -> command.getCommandName() == args[0])
            .findFirst();

    if (!first.isPresent()) {
        return Lists.newArrayList();
    }

    final String[] parameters = Arrays.copyOfRange(args, 1, args.length - 2);

    return first.get().getTabCompletionOptions(server, sender, parameters, pos);
}
 
开发者ID:AtomicBlom,项目名称:ShearMadness,代码行数:27,代码来源:ShearMadnessCommand.java

示例4: CommandHandler

import net.minecraft.command.ICommand; //导入依赖的package包/类
public CommandHandler(TickDynamicMod mod) {
	this.mod = mod;
	
	aliases = new ArrayList<String>();
	aliases.add("tickdynamic");
	aliases.add("td");
	
	subCommandHandlers = new HashMap<String, ICommand>();
	subCommandHandlers.put("reload", new CommandReload(mod));
	subCommandHandlers.put("reloadgroups", new CommandReloadGroups(mod));
	subCommandHandlers.put("listworlds", new CommandListWorlds(mod));
	subCommandHandlers.put("world", new CommandWorld(mod));
	subCommandHandlers.put("enabled", new CommandEnabled(mod));
	
	StringBuilder builderSubCommands = new StringBuilder();
	SubCommands[] subs = SubCommands.values();
	for(SubCommands command : subs) {
		builderSubCommands.append(command).append(", ");
	}
	builderSubCommands.delete(builderSubCommands.length()-2, builderSubCommands.length());
	listSubCommands = builderSubCommands.toString();
}
 
开发者ID:wildex999,项目名称:TickDynamic,代码行数:23,代码来源:CommandHandler.java

示例5: addTabCompletionOptions

import net.minecraft.command.ICommand; //导入依赖的package包/类
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] args) {
	if(args.length == 1)
	{
		List listOut = new LinkedList();
		String lastArg = args[args.length-1];
		SubCommands[] subCommands = SubCommands.values();
		for(SubCommands command : subCommands)
		{
			if(command.toString().contains(lastArg))
				listOut.add(command.toString());
		}
		
		return listOut;
	}
	else
	{
		//Send it over to subCommand handler
		ICommand subHandler = subCommandHandlers.get(args[0]);
		if(subHandler == null)
			return null;
		return subHandler.addTabCompletionOptions(sender, args);
	}
}
 
开发者ID:wildex999,项目名称:TickDynamic,代码行数:25,代码来源:CommandHandler.java

示例6: unregisterInForge

import net.minecraft.command.ICommand; //导入依赖的package包/类
public void unregisterInForge(ICommand command)
{
    Map<String, ICommand> commandMap = this.manager.getCommands();
    Set<ICommand> commandSet = this.manager.commandSet;
    commandSet.remove(command);
    ICommand otherCommand = commandMap.get(command.getCommandName());
    if(otherCommand == command)
        commandMap.remove(command.getCommandName());
    else
        for(Map.Entry<String, ICommand> entry: commandMap.entrySet())
        {
            if(entry.getValue() == command)
            {
                commandMap.remove(entry.getKey());
                break;
            }
        }
}
 
开发者ID:SpongeBukkit,项目名称:SpongeBukkit,代码行数:19,代码来源:BukkitCommandMap.java

示例7: addTabCompletionOptions

import net.minecraft.command.ICommand; //导入依赖的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

示例8: isCommandInList

import net.minecraft.command.ICommand; //导入依赖的package包/类
/**
 * Checks to see if a command is in the whole list.
 * @param testedCommand The command to check to see if it exists.
 * @return Whether or not the command exists.
 */
public boolean isCommandInList(ICommand testedCommand)
{
	ICommand[] commands = getAllCommands();
	
	if (commands != null)
	{
		for (ICommand command : commands)
		{
			if (command == testedCommand)
			{
				return true;
			}
		}
	}
	
	//Should be put in an else block, but that causes an error for some stupid reason.
	return false;
}
 
开发者ID:Niadel,项目名称:N-API,代码行数:24,代码来源:CommandRegistry.java

示例9: func_71560_a

import net.minecraft.command.ICommand; //导入依赖的package包/类
public ICommand func_71560_a(ICommand p_71560_1_) {
   List var2 = p_71560_1_.func_71514_a();
   this.field_71562_a.put(p_71560_1_.func_71517_b(), p_71560_1_);
   this.field_71561_b.add(p_71560_1_);
   if(var2 != null) {
      Iterator var3 = var2.iterator();

      while(var3.hasNext()) {
         String var4 = (String)var3.next();
         ICommand var5 = (ICommand)this.field_71562_a.get(var4);
         if(var5 == null || !var5.func_71517_b().equals(var4)) {
            this.field_71562_a.put(var4, p_71560_1_);
         }
      }
   }

   return p_71560_1_;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:19,代码来源:CommandHandler.java

示例10: func_71558_b

import net.minecraft.command.ICommand; //导入依赖的package包/类
public List func_71558_b(ICommandSender p_71558_1_, String p_71558_2_) {
   String[] var3 = p_71558_2_.split(" ", -1);
   String var4 = var3[0];
   if(var3.length == 1) {
      ArrayList var8 = new ArrayList();
      Iterator var6 = this.field_71562_a.entrySet().iterator();

      while(var6.hasNext()) {
         Entry var7 = (Entry)var6.next();
         if(CommandBase.func_71523_a(var4, (String)var7.getKey()) && ((ICommand)var7.getValue()).func_71519_b(p_71558_1_)) {
            var8.add(var7.getKey());
         }
      }

      return var8;
   } else {
      if(var3.length > 1) {
         ICommand var5 = (ICommand)this.field_71562_a.get(var4);
         if(var5 != null) {
            return var5.func_71516_a(p_71558_1_, func_71559_a(var3));
         }
      }

      return null;
   }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:27,代码来源:CommandHandler.java

示例11: getPermissionNodes

import net.minecraft.command.ICommand; //导入依赖的package包/类
@Override
public Collection<Node> getPermissionNodes()
{
    HashSet<Node> nodes = new HashSet<>();
    MinecraftServer server = MinecraftServer.getServer();
    if (server != null)
    {
        for (Object o : server.getCommandManager().getCommands().values())
        {
            ICommand command = (ICommand) o;
            commands.add(command.getCommandName());
            nodes.add(new Node(NAME, command.getCommandName()));
        }
    }
    else
    {
        nodes.add(new Node(NAME));
    }

    return nodes;
}
 
开发者ID:CCM-Modding,项目名称:Pay2Spawn,代码行数:22,代码来源:CommandType.java

示例12: addCommands

import net.minecraft.command.ICommand; //导入依赖的package包/类
@Override
public void addCommands(Consumer<ICommand> registerCommand) {
    registerCommand.accept(new PositionCommand("pos1", this::setPositionOne));
    registerCommand.accept(new PositionCommand("pos2", this::setPositionTwo));
    registerCommand.accept(new LookPositionCommand("hpos1", this::setPositionOne));
    registerCommand.accept(new LookPositionCommand("hpos2", this::setPositionTwo));
    registerCommand.accept(new ShiftCommand("shift"));
    registerCommand.accept(new ExpandCommand("expand"));
    registerCommand.accept(new ContractCommand("contract"));
    registerCommand.accept(new SelectionWandCommand());
}
 
开发者ID:kenzierocks,项目名称:HardVox,代码行数:12,代码来源:RegionCommands.java

示例13: getTabCompletionOptions

import net.minecraft.command.ICommand; //导入依赖的package包/类
@Override
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
    if(args.length == 1)
    {
        List<String> keys = new ArrayList<String>();

        for(ICommand c : getCommandMap().values())
        {
            if(c.checkPermission(server, sender))
            {
                keys.add(c.getCommandName());
            }
        }

        Collections.sort(keys, null);
        return getListOfStringsMatchingLastWord(args, keys);
    }

    ICommand cmd = getCommandMap().get(args[0]);

    if(cmd != null)
    {
        return cmd.getTabCompletionOptions(server, sender, shiftArgs(args), pos);
    }

    return super.getTabCompletionOptions(server, sender, args, pos);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:29,代码来源:CommandTreeBase.java

示例14: isUsernameIndex

import net.minecraft.command.ICommand; //导入依赖的package包/类
/**
 * Return whether the specified command parameter index is a username parameter.
 */
@Override
public boolean isUsernameIndex(String[] args, int index)
{
    if(index > 0 && args.length > 1)
    {
        ICommand cmd = getCommandMap().get(args[0]);
        if(cmd != null)
        {
            return cmd.isUsernameIndex(shiftArgs(args), index - 1);
        }
    }

    return false;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:CommandTreeBase.java

示例15: commandArguments

import net.minecraft.command.ICommand; //导入依赖的package包/类
public static void commandArguments(Expect e, Function<Parameters, Parameter<String>> start)
{
    e.nextRaw((server1, sender, params, pos1) ->
    {
        Parameter<String> commandParameter = start.apply(params);
        Optional<ICommand> other = commandParameter.tryGet().map(server1.getCommandManager().getCommands()::get);
        return other.map(c -> c.getTabCompletions(server1, sender, commandParameter.move(1).to(NaP::varargs).get(), pos1)).orElse(Collections.emptyList());
    }).descriptionU("args...");
}
 
开发者ID:Ivorforce,项目名称:MCOpts,代码行数:10,代码来源:MCE.java


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