本文整理匯總了Java中org.spongepowered.api.command.args.GenericArguments類的典型用法代碼示例。如果您正苦於以下問題:Java GenericArguments類的具體用法?Java GenericArguments怎麽用?Java GenericArguments使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GenericArguments類屬於org.spongepowered.api.command.args包,在下文中一共展示了GenericArguments類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerCommand
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
private void registerCommand() {
this.commandProxy = new CommandProxy();
CommandSpec basics = CommandSpec.builder()
.description(Text.of("§2mcrmb.com"))
.executor(commandProxy)
.arguments(
GenericArguments.remainingRawJoinedStrings(Text.of("arg")))
.build();
Sponge.getCommandManager().register(this, basics, McrmbPluginInfo.config.command);
//注冊命令
getCommandProxy().register(new HelpCommand());
getCommandProxy().register(new MoneyCommand());
getCommandProxy().register(new SetupCommand());
getCommandProxy().register(new TakeCommand());
getCommandProxy().register(new GiveCommand());
getCommandProxy().register(new SetCommand());
getCommandProxy().register(new AdminWhiteCommand());
getCommandProxy().register(new TestCommand());
}
示例2: onServerStart
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
@Listener
public void onServerStart(GameStartedServerEvent event) {
instance = this;
ConfigBuilder.configPath = Paths.get(configDir.toString(), "config.json");
RText.impl(new RTextSponge());
RColour.impl(new RColourSponge());
Travellers.impl(new SpongeTravellers());
CommandSpec camCommandSpec = CommandSpec.builder()
.arguments(GenericArguments.optional(GenericArguments.remainingJoinedStrings(Text.of("cmd"))))
.executor(new SpongeCommandManager())
.build();
Sponge.getCommandManager().register(this, camCommandSpec, "cam", "camerastudio");
}
示例3: init
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
@Listener(order=Order.FIRST)
public void init(GameInitializationEvent event) { instance = this; //myL=L.createLang(this);
reload();
Sponge.getServiceManager().setProvider(this, LanguageService.class, new LanguageServiceProvider());
l("The LanguageService is now available!");
Map<String, String> listMap = new HashMap<>();
for (String al : available) listMap.put(al, al);
Sponge.getCommandManager().register(this, CommandSpec.builder().arguments(GenericArguments.onlyOne(GenericArguments.choices(Text.of("Language"), listMap))).executor(new CommandExecutor() {
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if (!(src instanceof Player)) { src.sendMessage(Text.of("Only available for players")); return CommandResult.success(); }
Optional<String> la = args.<String>getOne("Language");
if (!la.isPresent()) {
src.sendMessage(Text.of(playerLang.get(((Player)src).getUniqueId()).toString()));
} else {
String lang = la.get();
lang = lang.replace('_', '-'); //Locales toString used a underscore but the language tag requires a dash
Locale locale = Locale.forLanguageTag(lang);
playerChangedLang(((Player)src).getProfile(), locale);
}
return CommandResult.success();
}
}).build(), "language");
}
示例4: onInitCore
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
@Listener
public void onInitCore(GameInitializationEvent event) {
SpongeDataManager manager = SpongeDataManager.getInstance();
manager.registerDataProcessorAndImpl(AuraNodeData.class, ThaumicAuraNodeData.class, ImmutableAuraNodeData.class,
ImmutableThaumicAuraNodeData.class, new AuraNodeDataProcessor());
manager.registerDataProcessorAndImpl(WarpData.class, ThaumicWarpData.class, ImmutableWarpData.class, ImmutableThaumicWarpData.class,
new PlayerWarpDataProcessor());
CommandManager commandManager = Sponge.getCommandManager();
CommandSpec discoAuraCmd = CommandSpec.builder()
.arguments(GenericArguments.none())
.description(Text.of("Creates a new Aura node and turns it into a disco ball!"))
.executor((executor, args) -> {
if (executor instanceof Player) {
Entity auraNode = ((Player) executor).getLocation().getExtent().createEntity(ThaumicEntityTypes.AURA_NODE, ((Player) executor).getLocation().getPosition()).get();
AuraNodeData nodeData = new ThaumicAuraNodeData(50, Aspects.AER, false, AuraNodeTypes.NORMAL);
auraNode.offer(nodeData);
auraNode.getWorld().spawnEntity(auraNode, Cause.of(NamedCause.source(this)));
this.auraMap.put(auraNode.getWorld().getUniqueId(), auraNode.getUniqueId());
return CommandResult.success();
}
return CommandResult.empty();
})
.build();
commandManager.register(this, discoAuraCmd, "disco");
}
示例5: getCommand
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
public static CommandSpec getCommand() {
return CommandSpec.builder()
.arguments(
GenericArguments.vector3d(Text.of("location"))
)
.description(Text.of("Teleport to a location."))
.permission("bedrock.tppos")
.executor((source, args) -> {
if (!(source instanceof Player)) {
source.sendMessage(Format.error("Only players may use this command."));
return CommandResult.empty();
}
Player player = (Player) source;
if (Bedrock.getJailManager().isFrozen(player)) {
player.sendMessage(Format.error("You're frozen and may not travel."));
return CommandResult.empty();
}
Bedrock.getTeleportManager().teleport(player, args.<Vector3d>getOne("location").get());
return CommandResult.success();
}).build();
}
示例6: getCommand
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
public static CommandSpec getCommand() {
return CommandSpec.builder()
.description(Text.of("Kick all players."))
.arguments(
GenericArguments.optional(GenericArguments.remainingJoinedStrings(Text.of("reason")))
)
.permission("bedrock.kick")
.executor((source, args) -> {
String reason = args.<String>getOne("reason").orElse("You have been kicked from the server.");
for (Player player : Bedrock.getGame().getServer().getOnlinePlayers()) {
player.kick(Format.heading(reason));
}
return CommandResult.success();
}).build();
}
示例7: getCommand
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
public static CommandSpec getCommand() {
return CommandSpec.builder()
.arguments(
GenericArguments.string(Text.of("name"))
)
.description(Text.of("Sets a warp."))
.permission("bedrock.setwarp")
.executor((source, args) -> {
if (!(source instanceof Player)) {
source.sendMessage(Format.error("Only players may use this command."));
return CommandResult.empty();
}
String name = args.<String>getOne("name").get();
Bedrock.getWarpManager().create(name, ((Player) source).getLocation());
source.sendMessage(Format.heading(String.format("Created warp %s.", name)));
return CommandResult.success();
}).build();
}
示例8: getCommand
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
public static CommandSpec getCommand() {
return CommandSpec.builder()
.arguments(
GenericArguments.player(Text.of("player")),
GenericArguments.remainingJoinedStrings(Text.of("message"))
)
.description(Text.of("Direct message another player."))
.permission("bedrock.message")
.executor((source, args) -> {
if (!(source instanceof Player)) {
source.sendMessage(Format.error("Only players may use this command."));
return CommandResult.empty();
}
Player sender = (Player) source;
Player recipient = args.<Player>getOne("player").get();
Bedrock.getMessageManager().message(sender, recipient, args.<String>getOne("message").get());
return CommandResult.success();
}).build();
}
示例9: vipTime
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
/**Command to check the vip time.
*
* @return CommandSpec
*/
public CommandSpec vipTime() {
return CommandSpec.builder()
.description(Text.of("Use to check the vip time."))
.permission("pixelvip.cmd.player")
.arguments(GenericArguments.optional(GenericArguments.user(Text.of("player"))))
.executor((src, args) -> { {
if (!(src instanceof Player) && !args.hasAny("player")){
throw new CommandException(plugin.getUtil().toText(plugin.getConfig().getLang("_pluginTag","onlyPlayers")), true);
}
if (src.hasPermission("pixelvip.cmd.player.others") && args.hasAny("player")){
Optional<User> optp = args.<User>getOne("player");
if (optp.isPresent()){
User p = optp.get();
return plugin.getUtil().sendVipTime(src, p.getUniqueId().toString(), p.getName());
} else {
throw new CommandException(plugin.getUtil().toText(plugin.getConfig().getLang("_pluginTag","noPlayersByName")));
}
} else {
return plugin.getUtil().sendVipTime(src, ((Player)src).getUniqueId().toString(), ((Player)src).getName());
}
}
})
.build();
}
示例10: getCommand
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
public static CommandSpec getCommand() {
return CommandSpec.builder()
.arguments(
GenericArguments.player(Text.of("player"))
)
.description(Text.of("Request another player teleport to you."))
.permission("bedrock.tpa")
.executor((source, args) -> {
if (!(source instanceof Player)) {
source.sendMessage(Format.error("Only players may use this command."));
return CommandResult.empty();
}
Player sender = (Player) source;
Player recipient = args.<Player>getOne("player").get();
// Request...
Teleport teleport = new Teleport(recipient, sender, sender, recipient);
Bedrock.getTeleportManager().request(teleport);
return CommandResult.success();
}).build();
}
示例11: getCommand
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
public static CommandSpec getCommand() {
return CommandSpec.builder()
.arguments(
GenericArguments.string(Text.of("name"))
)
.description(Text.of("Delete a warp."))
.permission("bedrock.delwarp")
.executor((source, args) -> {
String name = args.<String>getOne("name").get();
if (Bedrock.getWarpManager().delete(name)) {
source.sendMessage(Format.heading(String.format("Warp %s deleted.", name)));
} else {
source.sendMessage(Format.error("Invalid warp name."));
}
return CommandResult.success();
}).build();
}
示例12: create
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
public static void create(CommandSpec.Builder cmd) {
cmd.child(CommandSpec.builder()
.description(Text.of(""))
.permission("nations.command.nation.perm")
.arguments(
GenericArguments.choices(Text.of("type"),
ImmutableMap.<String, String> builder()
.put(Nation.TYPE_OUTSIDER, Nation.TYPE_OUTSIDER)
.put(Nation.TYPE_CITIZEN, Nation.TYPE_CITIZEN)
.build()),
GenericArguments.choices(Text.of("perm"),
ImmutableMap.<String, String> builder()
.put(Nation.PERM_BUILD, Nation.PERM_BUILD)
.put(Nation.PERM_INTERACT, Nation.PERM_INTERACT)
.build()),
GenericArguments.optional(GenericArguments.bool(Text.of("bool"))))
.executor(new NationPermExecutor())
.build(), "perm");
}
示例13: create
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
public static void create(CommandSpec.Builder cmd) {
cmd.child(CommandSpec.builder()
.description(Text.of(""))
.permission("nations.command.nationadmin.perm")
.arguments(
GenericArguments.optional(new NationNameElement(Text.of("nation"))),
GenericArguments.optional(GenericArguments.choices(Text.of("type"),
ImmutableMap.<String, String> builder()
.put(Nation.TYPE_OUTSIDER, Nation.TYPE_OUTSIDER)
.put(Nation.TYPE_CITIZEN, Nation.TYPE_CITIZEN)
.put(Nation.TYPE_COOWNER, Nation.TYPE_COOWNER)
.build())),
GenericArguments.optional(GenericArguments.choices(Text.of("perm"),
ImmutableMap.<String, String> builder()
.put(Nation.PERM_BUILD, Nation.PERM_BUILD)
.put(Nation.PERM_INTERACT, Nation.PERM_INTERACT)
.build())),
GenericArguments.optional(GenericArguments.bool(Text.of("bool"))))
.executor(new NationadminPermExecutor())
.build(), "perm");
}
示例14: create
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
public static void create(CommandSpec.Builder cmd) {
cmd.child(CommandSpec.builder()
.description(Text.of(""))
.permission("nations.command.nationadmin.extraplayer")
.arguments(
GenericArguments.optional(GenericArguments.choices(Text.of("give|take|set"),
ImmutableMap.<String, String> builder()
.put("give", "give")
.put("take", "take")
.put("set", "set")
.build())),
GenericArguments.optional(new PlayerNameElement(Text.of("player"))),
GenericArguments.optional(GenericArguments.integer(Text.of("amount"))))
.executor(new NationadminExtraplayerExecutor())
.build(), "extraplayer");
}
示例15: create
import org.spongepowered.api.command.args.GenericArguments; //導入依賴的package包/類
public static void create(CommandSpec.Builder cmd) {
cmd.child(CommandSpec.builder()
.description(Text.of(""))
.permission("nations.command.nationadmin.extraspawn")
.arguments(
GenericArguments.optional(GenericArguments.choices(Text.of("give|take|set"),
ImmutableMap.<String, String> builder()
.put("give", "give")
.put("take", "take")
.put("set", "set")
.build())),
GenericArguments.optional(new NationNameElement(Text.of("nation"))),
GenericArguments.optional(GenericArguments.integer(Text.of("amount"))))
.executor(new NationadminExtraspawnExecutor())
.build(), "extraspawn");
}