org.spongepowered.api.command.spec.CommandSpec Java Examples
The following examples show how to use
org.spongepowered.api.command.spec.CommandSpec.
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: NationadminExtraExecutor.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.extra") .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 NationadminExtraExecutor()) .build(), "extra"); }
Example #2
Source File: NearCommand.java From Prism with MIT License | 6 votes |
public static CommandSpec getCommand() { return CommandSpec.builder() .description(Text.of("Alias of /pr l r:(default radius)")) .permission("prism.lookup") .executor((source, args) -> { int radius = Prism.getInstance().getConfig().getDefaultCategory().getRadius(); source.sendMessage(Format.heading("Querying records...")); // Create a new query session final QuerySession session = new QuerySession(source); session.newQuery().addCondition(ConditionGroup.from(((Player) source).getLocation(), radius)); // Pass off to an async lookup helper AsyncUtil.lookup(session); return CommandResult.success(); }).build(); }
Example #3
Source File: ZonePermExecutor.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.zone.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) .put(Nation.TYPE_COOWNER, Nation.TYPE_COOWNER) .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 ZonePermExecutor()) .build(), "perm"); }
Example #4
Source File: PurgeLimitCommand.java From RedProtect with GNU General Public License v3.0 | 6 votes |
public CommandSpec register() { return CommandSpec.builder() .description(Text.of("Command to check purge limit.")) .permission("redprotect.command.purge-limit") .executor((src, args) -> { if (!(src instanceof Player) || !RedProtect.get().config.configRoot().purge.enabled) { HandleHelpPage(src, 1); } else { Player player = (Player) src; int limit = RedProtect.get().ph.getPurgeLimit(player); long amount = RedProtect.get().rm.getCanPurgePlayer(player.getUniqueId().toString(), player.getWorld().getName()); RedProtect.get().lang.sendMessage(player, "playerlistener.region.purge-limit", new Replacer[]{ new Replacer("{limit}", String.valueOf(limit)), new Replacer("{total}", String.valueOf(amount)) }); } return CommandResult.success(); }).build(); }
Example #5
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 #6
Source File: UCCommands.java From UltimateChat with GNU General Public License v3.0 | 6 votes |
private void registerUbroadcastAliases() { //register ubroadcast aliases for (String brod : UChat.get().getConfig().getBroadcastAliases()) { unregisterCmd(brod); manager.register(UChat.get().instance(), CommandSpec.builder() .arguments(GenericArguments.remainingJoinedStrings(Text.of("message"))) .permission("uchat.cmd.broadcast") .description(Text.of("Command to send broadcast to server.")) .executor((src, args) -> { { if (!UCUtil.sendBroadcast(src, args.<String>getOne("message").get().split(" "), false)) { sendHelp(src); } return CommandResult.success(); } }) .build(), brod); } }
Example #7
Source File: NationadminPermExecutor.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.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"); }
Example #8
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 #9
Source File: GCExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder() .description(Text.of("TickStat Command")) .permission("essentialcmds.tickstat.use") .executor(this) .build(); }
Example #10
Source File: WorldsBase.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder() .description(Text.of("List World Command")) .permission("essentialcmds.worlds.list") .executor(this) .build(); }
Example #11
Source File: ResetPasswordCommand.java From FlexibleLogin with MIT License | 5 votes |
@Override public CommandSpec buildSpec(Settings settings) { return CommandSpec.builder() .executor(this) .arguments( onlyOne( user(of("user")) ), onlyOne( string(of("password")) ) ) .build(); }
Example #12
Source File: PasswordRegisterCommand.java From FlexibleLogin with MIT License | 5 votes |
@Override public CommandSpec buildSpec(Settings settings) { return buildPlayerCommand(settings, "register") .executor(this) .arguments( repeated( string(of("password")), 2) ) .build(); }
Example #13
Source File: KillExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder() .description(Text.of("Kill Command")) .permission("essentialcmds.kill.use") .arguments(GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.player(Text.of("player"))))) .executor(this).build(); }
Example #14
Source File: NationadminExecutor.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.help") .arguments() .executor(new NationadminExecutor()) .build(), "help", "?"); }
Example #15
Source File: BlacklistBase.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder() .description(Text.of("List Blacklist Command")) .permission("essentialcmds.blacklist.list") .executor(this) .build(); }
Example #16
Source File: KickExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec .builder() .description(Text.of("Kick Command")) .permission("essentialcmds.kick.use") .arguments(GenericArguments.seq( GenericArguments.onlyOne(GenericArguments.player(Text.of("player")))), GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.remainingJoinedStrings(Text.of("reason"))))) .executor(this) .build(); }
Example #17
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 #18
Source File: AsConsoleExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder().description(Text.of("AsConsole Command")).permission("essentialcmds.asconsole.use") .arguments(GenericArguments.onlyOne(GenericArguments.remainingJoinedStrings(Text.of("command")))) .executor(this).build(); }
Example #19
Source File: HelpOpExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder() .description(Text.of("Help-Op Command")) .arguments(GenericArguments.onlyOne(GenericArguments.remainingJoinedStrings(Text.of("question")))) .permission("essentialcmds.helpop.use") .executor(this) .build(); }
Example #20
Source File: LightningExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder().description(Text.of("Lightning Command")).permission("essentialcmds.lightning.use") .arguments(GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.player(Text.of("player"))))) .executor(this).build(); }
Example #21
Source File: TimeExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec .builder() .description(Text.of("Time Command")) .permission("essentialcmds.time.use") .children(getChildrenList(new SetExecutor(), new AddExecutor())) .arguments(GenericArguments.firstParsing(GenericArguments.integer(Text.of("ticks")), GenericArguments.string(Text.of("time")))) .executor(this).build(); }
Example #22
Source File: LDenyCommand.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public CommandSpec register() { return CommandSpec.builder() .description(Text.of("Command to deny leader requests.")) .permission("redprotect.command.ldeny") .executor((src, args) -> { if (!(src instanceof Player)) { HandleHelpPage(src, 1); } else { Player player = (Player) src; if (RedProtect.get().alWait.containsKey(player)) { //info = region+world+pname String info = RedProtect.get().alWait.get(player); Optional<Player> lsender = Sponge.getServer().getPlayer(info.split("@")[2]); Region r = RedProtect.get().rm.getRegion(info.split("@")[0], info.split("@")[1]); if (r != null) { RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.region.leader.youdenied").replace("{region}", r.getName()).replace("{player}", info.split("@")[2])); lsender.ifPresent(value -> RedProtect.get().lang.sendMessage(value, RedProtect.get().lang.get("cmdmanager.region.leader.denied").replace("{region}", r.getName()).replace("{player}", player.getName()))); } else { RedProtect.get().lang.sendMessage(player, "cmdmanager.region.doesexists"); } RedProtect.get().alWait.remove(player); } else { RedProtect.get().lang.sendMessage(player, "cmdmanager.norequests"); } } return CommandResult.success(); }).build(); }
Example #23
Source File: NationLeaveExecutor.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.nation.leave") .arguments() .executor(new NationLeaveExecutor()) .build(), "leave", "quit"); }
Example #24
Source File: JailExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder() .description(Text.of("Jail Remove Command")) .permission("essentialcmds.jail.remove.use") .arguments(GenericArguments.integer(Text.of("number"))) .executor(this) .build(); }
Example #25
Source File: NationMinisterExecutor.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.nation.minister") .arguments( GenericArguments.optional(GenericArguments.choices(Text.of("add|remove"), ImmutableMap.<String, String> builder() .put("add", "add") .put("remove", "remove") .build())), GenericArguments.optional(new CitizenNameElement(Text.of("citizen")))) .executor(new NationMinisterExecutor()) .build(), "minister"); }
Example #26
Source File: PardonExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder() .description(Text.of("Unban Command")) .permission("essentialcmds.unban.use") .arguments(GenericArguments.onlyOne(new UserParser(Text.of("player")))) .executor(this) .build(); }
Example #27
Source File: RemoveAdminCommand.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public CommandSpec register() { return CommandSpec.builder() .description(Text.of("Command to remove admins to regions.")) .arguments(GenericArguments.string(Text.of("player")), GenericArguments.optional(GenericArguments.requiringPermission(GenericArguments.string(Text.of("region")), "redprotect.command.admin.removeadmin")), GenericArguments.optional(GenericArguments.requiringPermission(GenericArguments.world(Text.of("world")), "redprotect.command.admin.removeadmin"))) .permission("redprotect.command.removeadmin") .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(); } handleRemoveAdmin(src, args.<String>getOne("player").get(), r); return CommandResult.success(); } else if (src instanceof Player) { Player player = (Player) src; handleRemoveAdmin(player, args.<String>getOne("player").get(), null); return CommandResult.success(); } RedProtect.get().lang.sendCommandHelp(src, "removeadmin", true); return CommandResult.success(); }).build(); }
Example #28
Source File: NationCostExecutor.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.nation.cost") .arguments() .executor(new NationCostExecutor()) .build(), "cost", "costs", "price", "prices", "fare", "fares"); }
Example #29
Source File: TPAHereExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder().description(Text.of("TPA Here Command")).permission("essentialcmds.tpahere.use") .arguments(GenericArguments.onlyOne(GenericArguments.player(Text.of("player")))).executor(this) .build(); }
Example #30
Source File: ClearInventoryExecutor.java From EssentialCmds with MIT License | 5 votes |
@Nonnull @Override public CommandSpec getSpec() { return CommandSpec.builder() .description(Text.of("ClearInventory Command")) .permission("essentialcmds.clearinventory.use") .arguments(GenericArguments.optional(GenericArguments.onlyOne(GenericArguments.player(Text.of("target"))))) .executor(this) .build(); }