本文整理汇总了Java中cn.nukkit.command.data.CommandParameter类的典型用法代码示例。如果您正苦于以下问题:Java CommandParameter类的具体用法?Java CommandParameter怎么用?Java CommandParameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommandParameter类属于cn.nukkit.command.data包,在下文中一共展示了CommandParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GiveCommand
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public GiveCommand(String name) {
super(name, "%nukkit.command.give.description", "%nukkit.command.give.usage");
this.setPermission("nukkit.command.give");
this.commandParameters.clear();
this.commandParameters.put("default", new CommandParameter[]{
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false),
new CommandParameter("item", false, CommandParameter.ENUM_TYPE_ITEM_LIST),
new CommandParameter("amount", CommandParameter.ARG_TYPE_INT, true),
new CommandParameter("meta", CommandParameter.ARG_TYPE_INT, true),
new CommandParameter("tags...", CommandParameter.ARG_TYPE_RAW_TEXT, true)
});
this.commandParameters.put("toPlayerById", new CommandParameter[]{
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false),
new CommandParameter("item ID", CommandParameter.ARG_TYPE_INT, false),
new CommandParameter("amount", CommandParameter.ARG_TYPE_INT, true),
new CommandParameter("tags...", CommandParameter.ARG_TYPE_RAW_TEXT, true)
});
this.commandParameters.put("toPlayerByIdMeta", new CommandParameter[]{
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false),
new CommandParameter("item ID:meta", CommandParameter.ARG_TYPE_RAW_TEXT, false),
new CommandParameter("amount", CommandParameter.ARG_TYPE_INT, true),
new CommandParameter("tags...", CommandParameter.ARG_TYPE_RAW_TEXT, true)
});
}
示例2: TeleportCommand
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public TeleportCommand(String name) {
super(name, "%nukkit.command.tp.description", "%commands.tp.usage");
this.setPermission("nukkit.command.teleport");
this.commandParameters.clear();
this.commandParameters.put("->Player", new CommandParameter[]{
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false),
});
this.commandParameters.put("Player->Player", new CommandParameter[]{
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false),
new CommandParameter("target", CommandParameter.ARG_TYPE_TARGET, false),
});
this.commandParameters.put("Player->Pos", new CommandParameter[]{
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false),
new CommandParameter("blockPos", CommandParameter.ARG_TYPE_BLOCK_POS, false),
});
this.commandParameters.put("->Pos", new CommandParameter[]{
new CommandParameter("blockPos", CommandParameter.ARG_TYPE_BLOCK_POS, false),
});
}
示例3: EffectCommand
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public EffectCommand(String name) {
super(name, "%nukkit.command.effect.description", "%commands.effect.usage");
this.setPermission("nukkit.command.effect");
this.commandParameters.clear();
this.commandParameters.put("default", new CommandParameter[]{
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false),
new CommandParameter("effect", CommandParameter.ARG_TYPE_STRING, false), //Do not use Enum here because of buggy behavior
new CommandParameter("seconds", CommandParameter.ARG_TYPE_INT, true),
new CommandParameter("amplifier", true),
new CommandParameter("hideParticle", CommandParameter.ARG_TYPE_BOOL, true)
});
this.commandParameters.put("clear", new CommandParameter[]{
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false),
new CommandParameter("clear", new String[]{"clear"})
});
}
示例4: TimeCommand
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public TimeCommand(String name) {
super(name, "%nukkit.command.time.description", "%nukkit.command.time.usage");
this.setPermission("nukkit.command.time.add;" +
"nukkit.command.time.set;" +
"nukkit.command.time.start;" +
"nukkit.command.time.stop");
this.commandParameters.clear();
this.commandParameters.put("1arg", new CommandParameter[]{
new CommandParameter("start|stop", CommandParameter.ARG_TYPE_STRING, false)
});
this.commandParameters.put("2args", new CommandParameter[]{
new CommandParameter("add|set", CommandParameter.ARG_TYPE_STRING, false),
new CommandParameter("value", CommandParameter.ARG_TYPE_INT, false)
});
this.commandParameters.put("2args_", new CommandParameter[]{
new CommandParameter("add|set", CommandParameter.ARG_TYPE_STRING, false),
new CommandParameter("value", CommandParameter.ARG_TYPE_STRING, false)
});
}
示例5: getFlag
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
int getFlag(String type) {
switch (type) {
case CommandParameter.ARG_TYPE_BLOCK_POS:
return ARG_TYPE_POSITION;
case CommandParameter.ARG_TYPE_INT:
return ARG_TYPE_INT;
case CommandParameter.ARG_TYPE_PLAYER:
return ARG_TYPE_TARGET;
case CommandParameter.ARG_TYPE_RAW_TEXT:
return ARG_TYPE_RAWTEXT;
case CommandParameter.ARG_TYPE_STRING:
case CommandParameter.ARG_TYPE_STRING_ENUM:
return ARG_TYPE_STRING;
default:
return 0;
}
}
示例6: WhitelistCommand
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public WhitelistCommand(String name) {
super(name, "%nukkit.command.whitelist.description", "%commands.whitelist.usage");
this.setPermission(
"nukkit.command.whitelist.reload;" +
"nukkit.command.whitelist.enable;" +
"nukkit.command.whitelist.disable;" +
"nukkit.command.whitelist.list;" +
"nukkit.command.whitelist.add;" +
"nukkit.command.whitelist.remove"
);
this.commandParameters.clear();
this.commandParameters.put("1arg", new CommandParameter[]{
new CommandParameter("type", false, new String[]{"on", "off", "list", "reload"})
});
this.commandParameters.put("2args", new CommandParameter[]{
new CommandParameter("type", false, new String[]{"add", "remove"}),
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false)
});
}
示例7: TeleportCommand
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public TeleportCommand(String name) {
super(name, "%nukkit.command.tp.description", "%commands.tp.usage");
this.setPermission("nukkit.command.teleport");
this.commandParameters.clear();
this.commandParameters.put("->Player", new CommandParameter[]{
new CommandParameter("destination", CommandParameter.ARG_TYPE_TARGET, false),
});
this.commandParameters.put("Player->Player", new CommandParameter[]{
new CommandParameter("victim", CommandParameter.ARG_TYPE_TARGET, false),
new CommandParameter("destination", CommandParameter.ARG_TYPE_TARGET, false),
});
this.commandParameters.put("Player->Pos", new CommandParameter[]{
new CommandParameter("victim", CommandParameter.ARG_TYPE_TARGET, false),
new CommandParameter("destination", CommandParameter.ARG_TYPE_BLOCK_POS, false),
/*new CommandParameter("y-rot", CommandParameter.ARG_TYPE_INT, true), //TODO
new CommandParameter("x-rot", CommandParameter.ARG_TYPE_INT, true)*/
});
this.commandParameters.put("->Pos", new CommandParameter[]{
new CommandParameter("destination", CommandParameter.ARG_TYPE_BLOCK_POS, false),
/*new CommandParameter("y-rot", CommandParameter.ARG_TYPE_INT, true), //TODO
new CommandParameter("x-rot", CommandParameter.ARG_TYPE_INT, true)*/
});
}
示例8: GamemodeCommand
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public GamemodeCommand(String name) {
super(name, "%nukkit.command.gamemode.description", "%commands.gamemode.usage",
new String[]{"gm"});
this.setPermission("nukkit.command.gamemode.survival;" +
"nukkit.command.gamemode.creative;" +
"nukkit.command.gamemode.adventure;" +
"nukkit.command.gamemode.spectator;" +
"nukkit.command.gamemode.other");
this.commandParameters.clear();
this.commandParameters.put("default", new CommandParameter[]{
new CommandParameter("gameMode", CommandParameter.ARG_TYPE_INT, false),
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, true)
});
this.commandParameters.put("byString", new CommandParameter[]{
new CommandParameter("gameMode", new String[]{"survival", "s", "creative", "c",
"adventure", "a", "spectator", "spc", "view", "v"}),
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, true)
});
}
示例9: ParticleCommand
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public ParticleCommand(String name) {
super(name, "%nukkit.command.particle.description", "%nukkit.command.particle.usage");
this.setPermission("nukkit.command.particle");
//<name> <x> <y> <z> <xd> <yd> <zd> [count] [data]
this.commandParameters.clear();
this.commandParameters.put("default", new CommandParameter[]{
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false),
new CommandParameter("x", CommandParameter.ARG_TYPE_STRING, false),
new CommandParameter("y", CommandParameter.ARG_TYPE_STRING, false),
new CommandParameter("z", CommandParameter.ARG_TYPE_STRING, false),
new CommandParameter("zd", CommandParameter.ARG_TYPE_STRING, false),
new CommandParameter("yd", CommandParameter.ARG_TYPE_STRING, false),
new CommandParameter("zd", CommandParameter.ARG_TYPE_STRING, false),
new CommandParameter("count", CommandParameter.ARG_TYPE_INT, true),
new CommandParameter("data", true)
});
}
示例10: WhitelistCommand
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public WhitelistCommand(String name) {
super(name, "%nukkit.command.whitelist.description", "%commands.whitelist.usage");
this.setPermission(
"nukkit.command.whitelist.reload;" +
"nukkit.command.whitelist.enable;" +
"nukkit.command.whitelist.disable;" +
"nukkit.command.whitelist.list;" +
"nukkit.command.whitelist.add;" +
"nukkit.command.whitelist.remove"
);
this.commandParameters.clear();
this.commandParameters.put("1arg", new CommandParameter[]{
new CommandParameter("on|off|list|reload", CommandParameter.ARG_TYPE_STRING, false)
});
this.commandParameters.put("2args", new CommandParameter[]{
new CommandParameter("add|remove", CommandParameter.ARG_TYPE_STRING, false),
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false)
});
}
示例11: encode
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
@Override
public void encode() {
this.reset();
BinaryStream commandsStream = new BinaryStream();
this.commands.forEach((name, versions) -> {
if (name.equals("help")) return;
ArrayList<String> aliases = new ArrayList<>();
aliases.addAll(Arrays.asList(versions.versions.get(0).aliases));
aliases.add(name);
for (String alias : aliases) {
commandsStream.putString(alias);
commandsStream.putString(versions.versions.get(0).description);
commandsStream.putByte((byte) 0);
commandsStream.putByte((byte) 0);
commandsStream.putLInt(-1);
commandsStream.putUnsignedVarInt(versions.versions.get(0).overloads.size());
for (CommandOverload overload : versions.versions.get(0).overloads.values()) {
commandsStream.putUnsignedVarInt(overload.input.parameters.length);
for (CommandParameter parameter : overload.input.parameters) {
commandsStream.putString(parameter.name);
commandsStream.putLInt(ARG_FLAG_VALID | getFlag(parameter.type));
commandsStream.putBoolean(parameter.optional);
}
}
}
aliasCommands += (aliases.size() - 1);
});
this.putUnsignedVarInt(0);
this.putUnsignedVarInt(0);
this.putUnsignedVarInt(0);
this.putUnsignedVarInt(this.commands.size() + aliasCommands);
this.put(commandsStream.getBuffer());
}
示例12: Set2Command
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public Set2Command(String name, Money owner, String[] aliases) {
super(name, owner, aliases);
this.setPermission("money.command.set2");
this.setCommandParameters(new HashMap<String, CommandParameter[]>() {
{
put("set-2", new CommandParameter[]{
new CommandParameter("player", CommandParameter.ARG_TYPE_STRING, false),
new CommandParameter("amount", CommandParameter.ARG_TYPE_INT, false)
});
}
});
}
示例13: DifficultyCommand
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public DifficultyCommand(String name) {
super(name, "%nukkit.command.difficulty.description", "%commands.difficulty.usage");
this.setPermission("nukkit.command.difficulty");
this.commandParameters.clear();
this.commandParameters.put("default", new CommandParameter[]{
new CommandParameter("difficulty", CommandParameter.ARG_TYPE_INT, false)
});
this.commandParameters.put("byString", new CommandParameter[]{
new CommandParameter("difficulty", new String[]{"peaceful", "p", "easy", "e",
"normal", "n", "hard", "h"})
});
}
示例14: Command
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public Command(String name, String description, String usageMessage, String[] aliases) {
this.commandData = new CommandData();
this.name = name;
this.nextLabel = name;
this.label = name;
this.description = description;
this.usageMessage = usageMessage == null ? "/" + name : usageMessage;
this.aliases = aliases;
this.activeAliases = aliases;
this.timing = Timings.getCommandTiming(this);
this.commandParameters.put("default", new CommandParameter[]{new CommandParameter("args", "rawtext", true)});
}
示例15: DeopCommand
import cn.nukkit.command.data.CommandParameter; //导入依赖的package包/类
public DeopCommand(String name) {
super(name, "%nukkit.command.deop.description", "%commands.deop.description");
this.setPermission("nukkit.command.op.take");
this.commandParameters.put("default", new CommandParameter[]{
new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false)
});
}