本文整理汇总了Java中cn.nukkit.command.data.CommandOverload类的典型用法代码示例。如果您正苦于以下问题:Java CommandOverload类的具体用法?Java CommandOverload怎么用?Java CommandOverload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandOverload类属于cn.nukkit.command.data包,在下文中一共展示了CommandOverload类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateCustomCommandData
import cn.nukkit.command.data.CommandOverload; //导入依赖的package包/类
/**
* Generates modified command data for the specified player
* for AvailableCommandsPacket.
*
* @return CommandData|null
*/
public CommandDataVersions generateCustomCommandData(Player player) {
if (!this.testPermission(player)) {
return null;
}
CommandData customData = this.commandData.clone();
customData.aliases = this.getAliases();
customData.description = player.getServer().getLanguage().translateString(this.getDescription());
customData.permission = player.hasPermission(this.getPermission()) ? "any" : "false";
this.commandParameters.forEach((key, par) -> {
CommandOverload overload = new CommandOverload();
overload.input.parameters = par;
customData.overloads.put(key, overload);
});
if (customData.overloads.size() == 0) customData.overloads.put("default", new CommandOverload());
CommandDataVersions versions = new CommandDataVersions();
versions.versions.add(customData);
return versions;
}
示例2: encode
import cn.nukkit.command.data.CommandOverload; //导入依赖的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());
}
示例3: getOverloads
import cn.nukkit.command.data.CommandOverload; //导入依赖的package包/类
public Map<String, CommandOverload> getOverloads() {
return this.commandData.overloads;
}