org.spongepowered.api.command.args.GenericArguments Java Examples
The following examples show how to use
org.spongepowered.api.command.args.GenericArguments.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NationadminEcoExecutor.java From Nations with MIT License | 6 votes |
public static void create(CommandSpec.Builder cmd) { cmd.child(CommandSpec.builder() .description(Text.of("")) .permission("nations.command.nationadmin.eco") .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.doubleNum(Text.of("amount")))) .executor(new NationadminEcoExecutor()) .build(), "eco"); }
Example #2
Source File: HelpCommand.java From RedProtect with GNU General Public License v3.0 | 6 votes |
public CommandSpec register() { return CommandSpec.builder() .description(Text.of("Command to see help page.")) .arguments(GenericArguments.optional(GenericArguments.integer(Text.of("page")))) .permission("redprotect.command.help") .executor((src, args) -> { if (!(src instanceof Player)) { HandleHelpPage(src, 1); } else { if (!args.hasAny("page")) { HandleHelpPage(src, 1); } else { HandleHelpPage(src, args.<Integer>getOne("page").get()); } } return CommandResult.success(); }).build(); }
Example #3
Source File: NuVotifier.java From NuVotifier with GNU General Public License v3.0 | 6 votes |
@Listener public void onServerStart(GameStartedServerEvent event) { this.scheduler = new SpongeScheduler(this); this.loggerAdapter = new SLF4JLogger(logger); CommandSpec nvreloadSpec = CommandSpec.builder() .description(Text.of("Reloads NuVotifier")) .permission("nuvotifier.reload") .executor(new NVReloadCmd(this)).build(); Sponge.getCommandManager().register(this, nvreloadSpec, "nvreload"); CommandSpec testvoteSpec = CommandSpec.builder() .arguments(GenericArguments.allOf(GenericArguments.string(Text.of("args")))) .description(Text.of("Sends a test vote to the server's listeners")) .permission("nuvotifier.testvote") .executor(new TestVoteCmd(this)).build(); Sponge.getCommandManager().register(this, testvoteSpec, "testvote"); if (!loadAndBind()) { gracefulExit(); } }
Example #4
Source File: WelcomeCommand.java From RedProtect with GNU General Public License v3.0 | 6 votes |
public CommandSpec register() { return CommandSpec.builder() .description(Text.of("Command to set a welcome message for a region.")) .arguments(GenericArguments.remainingJoinedStrings(Text.of("message"))) .permission("redprotect.command.welcome") .executor((src, args) -> { if (!(src instanceof Player)) { HandleHelpPage(src, 1); } else { Player player = (Player) src; String arg = args.<String>getOne("message").get(); if (arg.equals("off")) { handleWelcome(player, ""); } else { handleWelcome(player, arg); } } return CommandResult.success(); }).build(); }
Example #5
Source File: TeleportExecutor.java From EssentialCmds with MIT License | 6 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec .builder() .description(Text.of("Teleport Command")) .permission("essentialcmds.teleport.use") .arguments(GenericArguments.firstParsing( GenericArguments.seq( GenericArguments.onlyOne(GenericArguments.player(Text.of("player"))), GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.player(Text.of("target"))))), GenericArguments.seq( GenericArguments.onlyOne(GenericArguments.integer(Text.of("x"))), GenericArguments.onlyOne(GenericArguments.integer(Text.of("y"))), GenericArguments.onlyOne(GenericArguments.integer(Text.of("z"))), GenericArguments.optional(GenericArguments.string(Text.of("world"))), GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.player(Text.of("target"))))))) .executor(this) .build(); }
Example #6
Source File: NationadminFlagExecutor.java From Nations with MIT License | 6 votes |
public static void create(CommandSpec.Builder cmd) { cmd.child(CommandSpec.builder() .description(Text.of("")) .permission("nations.command.nationadmin.flag") .arguments( GenericArguments.optional(new NationNameElement(Text.of("nation"))), GenericArguments.optional(GenericArguments.choices(Text.of("flag"), ConfigHandler.getNode("nations", "flags") .getChildrenMap() .keySet() .stream() .map(key -> key.toString()) .collect(Collectors.toMap(flag -> flag, flag -> flag)))), GenericArguments.optional(GenericArguments.bool(Text.of("bool")))) .executor(new NationadminFlagExecutor()) .build(), "flag"); }
Example #7
Source File: NationadminExtraspawnplayerExecutor.java From Nations with MIT License | 6 votes |
public static void create(CommandSpec.Builder cmd) { cmd.child(CommandSpec.builder() .description(Text.of("")) .permission("nations.command.nationadmin.extraspawnplayer") .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 NationadminExtraspawnplayerExecutor()) .build(), "extraspawnplayer"); }
Example #8
Source File: RegenAllCommand.java From RedProtect with GNU General Public License v3.0 | 6 votes |
public CommandSpec register() { return CommandSpec.builder() .arguments(GenericArguments.string(Text.of("player"))) .description(Text.of("Command to regenerate all player regions.")) .permission("redprotect.command.regenall") .executor((src, args) -> { if (!RedProtect.get().hooks.WE) { return CommandResult.success(); } int regen = RedProtect.get().rm.regenAll(args.<String>getOne("player").get()); if (regen <= 0) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.region.noneregenerated")); } else { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.region.regenerated").replace("{regions}", regen + "").replace("{player}", args.<String>getOne("player").get())); } return CommandResult.success(); }).build(); }
Example #9
Source File: NationadminExtraplayerExecutor.java From Nations with MIT License | 6 votes |
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"); }
Example #10
Source File: VirtualPayCommand.java From EconomyLite with MIT License | 5 votes |
@Override public Builder getCommandSpecBuilder() { return CommandSpec .builder() .executor(this) .arguments(GenericArguments.string(Text.of("account")), GenericArguments.user(Text.of("target")), GenericArguments.doubleNum(Text.of("amount"))); }
Example #11
Source File: KittyCannonExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder() .description(Text.of("Kitty Cannon Command")) .permission("essentialcmds.kittycannon.use") .arguments(GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.player(Text.of("player"))))) .executor(this) .build(); }
Example #12
Source File: UnmuteExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder().description(Text.of("Unmute Command")).permission("essentialcmds.unmute.use") .arguments(GenericArguments.onlyOne(GenericArguments.player(Text.of("player")))).executor(this) .build(); }
Example #13
Source File: WeatherExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec .builder() .description(Text.of("Weather Command")) .permission("essentialcmds.weather.use") .arguments(GenericArguments.seq(GenericArguments.onlyOne(GenericArguments.string(Text.of("weather")))), GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.integer(Text.of("duration"))))) .executor(this).build(); }
Example #14
Source File: MuteExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec .builder() .description(Text.of("Mute Command")) .permission("essentialcmds.mute.use") .arguments( GenericArguments.seq(GenericArguments.onlyOne(GenericArguments.player(Text.of("player"))), GenericArguments.onlyOne(GenericArguments.optional(new TimespanParser(Text.of("time")))))) .executor(this).build(); }
Example #15
Source File: WorldsBase.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec .builder() .description(Text.of("SetGamemode World Command")) .permission("essentialcmds.world.setgamemode") .arguments(GenericArguments.seq(GenericArguments.onlyOne(GenericArguments.catalogedElement(Text.of("gamemode"), CatalogTypes.GAME_MODE))), GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.string(Text.of("world"))))) .executor(this) .build(); }
Example #16
Source File: BanExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec .builder() .description(Text.of("Ban Command")) .permission("essentialcmds.ban.use") .arguments(GenericArguments.seq(GenericArguments.onlyOne(new UserParser(Text.of("player"))), GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.remainingJoinedStrings(Text.of("reason")))))) .executor(this).build(); }
Example #17
Source File: WorldsBase.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder() .description(Text.of("Teleport World Command")) .permission("essentialcmds.tpworld.use") .arguments(GenericArguments.seq(GenericArguments.string(Text.of("name")), GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.player(Text.of("player")))))) .executor(this) .build(); }
Example #18
Source File: SudoExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec .builder() .description(Text.of("Sudo Command")) .permission("essentialcmds.sudo.use") .arguments( GenericArguments.seq(GenericArguments.onlyOne(GenericArguments.player(Text.of("player"))), GenericArguments.remainingJoinedStrings(Text.of("command")))).executor(this).build(); }
Example #19
Source File: InfoCommand.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public CommandSpec register() { return CommandSpec.builder() .description(Text.of("Command to see info about regions.")) .arguments( GenericArguments.optional(GenericArguments.string(Text.of("region"))), GenericArguments.optional(GenericArguments.world(Text.of("world")))) .permission("redprotect.command.info") .executor((src, args) -> { if (!(src instanceof Player) && args.hasAny("region") && args.hasAny("world")) { if (Sponge.getServer().getWorld(args.<WorldProperties>getOne("world").get().getWorldName()).isPresent()) { Region r = RedProtect.get().rm.getRegion(args.<String>getOne("region").get(), args.<WorldProperties>getOne("world").get().getWorldName()); if (r != null) { src.sendMessage(RedProtect.get().getUtil().toText(RedProtect.get().lang.get("general.color") + "-----------------------------------------")); src.sendMessage(r.info()); src.sendMessage(RedProtect.get().getUtil().toText(RedProtect.get().lang.get("general.color") + "-----------------------------------------")); } else { src.sendMessage(RedProtect.get().getUtil().toText(RedProtect.get().lang.get("correct.usage") + "&eInvalid region: " + args.<String>getOne("region").get())); } } else { src.sendMessage(RedProtect.get().getUtil().toText(RedProtect.get().lang.get("correct.usage") + " " + "&eInvalid World: " + args.<WorldProperties>getOne("world").get().getWorldName())); } return CommandResult.success(); } else if (src instanceof Player) { Player player = (Player) src; if (args.hasAny("region") && args.hasAny("world")) { handleInfo(player, args.<String>getOne("region").get(), args.<WorldProperties>getOne("world").get().getWorldName()); } else if (args.hasAny("region")) { handleInfo(player, args.<String>getOne("region").get(), ""); } else { handleInfoTop(player); } return CommandResult.success(); } RedProtect.get().lang.sendCommandHelp(src, "info", true); return CommandResult.success(); }).build(); }
Example #20
Source File: ZoneCoownerExecutor.java From Nations with MIT License | 5 votes |
public static void create(CommandSpec.Builder cmd) { cmd.child(CommandSpec.builder() .description(Text.of("")) .permission("nations.command.zone.coowner") .arguments( GenericArguments.optional(GenericArguments.choices(Text.of("add|remove"), ImmutableMap.<String, String> builder() .put("add", "add") .put("remove", "remove") .build())), GenericArguments.optional(new PlayerNameElement(Text.of("citizen")))) .executor(new ZoneCoownerExecutor()) .build(), "coowner"); }
Example #21
Source File: ZoneRenameExecutor.java From Nations with MIT License | 5 votes |
public static void create(CommandSpec.Builder cmd) { cmd.child(CommandSpec.builder() .description(Text.of("")) .permission("nations.command.zone.rename") .arguments(GenericArguments.optional(GenericArguments.string(Text.of("name")))) .executor(new ZoneRenameExecutor()) .build(), "rename"); }
Example #22
Source File: ZoneFlagExecutor.java From Nations with MIT License | 5 votes |
public static void create(CommandSpec.Builder cmd) { cmd.child(CommandSpec.builder() .description(Text.of("")) .permission("nations.command.zone.flag") .arguments( GenericArguments.choices(Text.of("flag"), ConfigHandler.getNode("nations", "flags") .getChildrenMap() .keySet() .stream() .map(o -> o.toString()) .collect(Collectors.toMap(flag -> flag, flag -> flag))), GenericArguments.optional(GenericArguments.bool(Text.of("bool")))) .executor(new ZoneFlagExecutor()) .build(), "flag"); }
Example #23
Source File: IgniteExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder().description(Text.of("Ignite Command")).permission("essentialcmds.ignite.use") .arguments(GenericArguments.seq( GenericArguments.onlyOne(GenericArguments.integer(Text.of("ticks"))), GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.player(Text.of("player")))))) .executor(this).build(); }
Example #24
Source File: ZoneCreateExecutor.java From Nations with MIT License | 5 votes |
public static void create(CommandSpec.Builder cmd) { cmd.child(CommandSpec.builder() .description(Text.of("")) .permission("nations.command.zone.create") .arguments( GenericArguments.optional(GenericArguments.string(Text.of("name"))), GenericArguments.optional(new PlayerNameElement(Text.of("owner")))) .executor(new ZoneCreateExecutor()) .build(), "create", "add"); }
Example #25
Source File: ZoneSetownerExecutor.java From Nations with MIT License | 5 votes |
public static void create(CommandSpec.Builder cmd) { cmd.child(CommandSpec.builder() .description(Text.of("")) .permission("nations.command.zone.setowner") .arguments(GenericArguments.optional(new PlayerNameElement(Text.of("owner")))) .executor(new ZoneSetownerExecutor()) .build(), "setowner"); }
Example #26
Source File: ExpandVertCommand.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public CommandSpec register() { return CommandSpec.builder() .description(Text.of("Command to expand a region from bedrock to sky.")) .arguments( GenericArguments.optional(GenericArguments.string(Text.of("regionName"))), GenericArguments.optional(GenericArguments.world(Text.of("world"))) ) .permission("redprotect.command.expand-vert") .executor((src, args) -> { if (!(src instanceof Player)) { HandleHelpPage(src, 1); } else { Player player = (Player) src; Region r = RedProtect.get().rm.getTopRegion(player.getLocation(), this.getClass().getName()); if (args.hasAny("regionName")) { r = RedProtect.get().rm.getRegion(args.<String>getOne("regionName").get(), player.getWorld().getName()); } if (args.hasAny("world")) { r = RedProtect.get().rm.getRegion(args.<String>getOne("regionName").get(), args.<World>getOne("world").get().getName()); } if (r == null) { RedProtect.get().lang.sendMessage(player, "cmdmanager.region.todo.that"); return CommandResult.success(); } if (!RedProtect.get().ph.hasRegionPermAdmin(player, "expand-vert", r)) { RedProtect.get().lang.sendMessage(player, "no.permission"); return CommandResult.success(); } r.setMaxY(Sponge.getServer().getWorld(r.getWorld()).get().getDimension().getHeight()); r.setMinY(0); } return CommandResult.success(); }).build(); }
Example #27
Source File: RemoveLeaderCommand.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public CommandSpec register() { return CommandSpec.builder() .description(Text.of("Command to remove leaders to regions.")) .arguments(GenericArguments.string(Text.of("player")), GenericArguments.optional(GenericArguments.requiringPermission(GenericArguments.string(Text.of("region")), "redprotect.command.admin.removeleader")), GenericArguments.optional(GenericArguments.requiringPermission(GenericArguments.world(Text.of("world")), "redprotect.command.admin.removeleader"))) .permission("redprotect.command.removeleader") .executor((src, args) -> { if (args.hasAny("region") && args.hasAny("world")) { String region = args.<String>getOne("region").get(); WorldProperties worldProperties = args.<WorldProperties>getOne("world").get(); if (!RedProtect.get().getServer().getWorld(worldProperties.getWorldName()).isPresent()) { src.sendMessage(RedProtect.get().getUtil().toText(RedProtect.get().lang.get("cmdmanager.region.invalidworld"))); return CommandResult.success(); } Region r = RedProtect.get().rm.getRegion(region, worldProperties.getWorldName()); if (r == null) { src.sendMessage(RedProtect.get().getUtil().toText(RedProtect.get().lang.get("cmdmanager.region.doesntexist") + ": " + region)); return CommandResult.success(); } handleRemoveLeader(src, args.<String>getOne("player").get(), r); return CommandResult.success(); } else if (src instanceof Player) { Player player = (Player) src; handleRemoveLeader(player, args.<String>getOne("player").get(), null); return CommandResult.success(); } RedProtect.get().lang.sendCommandHelp(src, "removeleader", true); return CommandResult.success(); }).build(); }
Example #28
Source File: PowertoolExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder().description(Text.of("Powertool Command")).permission("essentialcmds.powertool.use") .arguments(GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.remainingJoinedStrings(Text.of("command"))))) .executor(this).build(); }
Example #29
Source File: NationadminSetnameExecutor.java From Nations with MIT License | 5 votes |
public static void create(CommandSpec.Builder cmd) { cmd.child(CommandSpec.builder() .description(Text.of("")) .permission("nations.command.nationadmin.setname") .arguments( GenericArguments.optional(new NationNameElement(Text.of("oldname"))), GenericArguments.optional(GenericArguments.string(Text.of("newname")))) .executor(new NationadminSetnameExecutor()) .build(), "setname", "rename"); }
Example #30
Source File: NationadminDelspawnExecutor.java From Nations with MIT License | 5 votes |
public static void create(CommandSpec.Builder cmd) { cmd.child(CommandSpec.builder() .description(Text.of("")) .permission("nations.command.nationadmin.delspawn") .arguments( GenericArguments.optional(new NationNameElement(Text.of("nation"))), GenericArguments.optional(GenericArguments.string(Text.of("name")))) .executor(new NationadminDelspawnExecutor()) .build(), "delspawn"); }