Java Code Examples for com.sk89q.minecraft.util.commands.CommandContext#getJoinedStrings()
The following examples show how to use
com.sk89q.minecraft.util.commands.CommandContext#getJoinedStrings() .
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: MapDevelopmentCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = {"feature", "fl"}, desc = "Prints information regarding a specific feature", min = 1, max = -1 ) @CommandPermissions(Permissions.MAPDEV) public void featureCommand(CommandContext args, CommandSender sender) throws CommandException { final String slug = args.getJoinedStrings(0); final Optional<Feature<?>> feature = matchManager.getCurrentMatch(sender).features().bySlug(slug); if(feature.isPresent()) { sender.sendMessage(ChatColor.GOLD + slug + ChatColor.GRAY + " corresponds to: " + ChatColor.WHITE + feature.get().toString()); } else { sender.sendMessage(ChatColor.RED + "No feature by the name of " + ChatColor.GOLD + slug + ChatColor.RED + " was found."); } }
Example 2
Source File: WhisperCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = {"msg", "message", "whisper", "pm", "tell", "dm"}, usage = "<target> <message...>", desc = "Private message a user", min = 2, max = -1 ) @CommandPermissions("projectares.msg") public void message(final CommandContext args, final CommandSender sender) throws CommandException { final Player player = CommandUtils.senderToPlayer(sender); final Identity from = identityProvider.currentIdentity(player); final String content = args.getJoinedStrings(1); executor.callback( userFinder.findUser(sender, args, 0), CommandFutureCallback.onSuccess(sender, args, response -> { whisperSender.send(sender, from, identityProvider.createIdentity(response), content); }) ); }
Example 3
Source File: BrushOptionsCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Command( aliases = {"primary"}, usage = "[brush-arguments]", desc = "Set the right click brush", help = "Set the right click brush", min = 1 ) public void primary(Player player, LocalSession session, CommandContext args) throws WorldEditException { BaseBlock item = player.getBlockInHand(); BrushTool tool = session.getBrushTool(player, false); session.setTool(item, null, player); String cmd = "brush " + args.getJoinedStrings(0); CommandEvent event = new CommandEvent(player, cmd); CommandManager.getInstance().handleCommandOnCurrentThread(event); BrushTool newTool = session.getBrushTool(item, player, false); if (newTool != null && tool != null) { newTool.setSecondary(tool.getSecondary()); } }
Example 4
Source File: BrushOptionsCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Command( aliases = {"secondary"}, usage = "[brush-arguments]", desc = "Set the left click brush", help = "Set the left click brush", min = 1 ) public void secondary(Player player, LocalSession session, CommandContext args) throws WorldEditException { BaseBlock item = player.getBlockInHand(); BrushTool tool = session.getBrushTool(player, false); session.setTool(item, null, player); String cmd = "brush " + args.getJoinedStrings(0); CommandEvent event = new CommandEvent(player, cmd); CommandManager.getInstance().handleCommandOnCurrentThread(event); BrushTool newTool = session.getBrushTool(item, player, false); if (newTool != null && tool != null) { newTool.setPrimary(tool.getPrimary()); } }
Example 5
Source File: BrushOptionsCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Command( aliases = {"scroll"}, usage = "[none|clipboard|mask|pattern|range|size|visual|target|targetoffset]", desc = "Toggle between different target modes", min = 1, max = -1 ) public void scroll(Player player, EditSession editSession, LocalSession session, @Optional @Switch('h') boolean offHand, CommandContext args) throws WorldEditException { BrushTool bt = session.getBrushTool(player, false); if (bt == null) { BBC.BRUSH_NONE.send(player); return; } BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext(); ScrollAction action = ScrollAction.fromArguments(bt, player, session, args.getJoinedStrings(0), true); settings.setScrollAction(action); if (args.getString(0).equalsIgnoreCase("none")) { BBC.BRUSH_SCROLL_ACTION_UNSET.send(player); } else if (action != null) { String full = args.getJoinedStrings(0); settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full); BBC.BRUSH_SCROLL_ACTION_SET.send(player, full); } bt.update(); }
Example 6
Source File: ChatCommands.java From CardinalPGM with MIT License | 6 votes |
@Command(aliases = {"a", "admin"}, desc = "Talk in admin chat.", usage = "<message>", anyFlags = true) @CommandPermissions("cardinal.chat.admin") public static void admin(final CommandContext cmd, CommandSender sender) throws CommandException { if (!(sender instanceof Player)) { throw new CommandException(ChatConstant.ERROR_CONSOLE_NO_USE.getMessage(ChatUtil.getLocale(sender))); } if (cmd.argsLength() == 0) { if (Settings.getSettingByName("ChatChannel").getValueByPlayer((Player) sender).getValue().equals("admin")) { throw new CommandException(ChatConstant.ERROR_ADMIN_ALREADY_DEAFULT.getMessage(ChatUtil.getLocale(sender))); } Settings.getSettingByName("ChatChannel").setValueByPlayer((Player) sender, Settings.getSettingByName("ChatChannel").getSettingValueByName("admin")); sender.sendMessage(ChatColor.YELLOW + ChatConstant.UI_DEFAULT_CHANNEL_ADMIN.getMessage(ChatUtil.getLocale(sender))); } else { String message = cmd.getJoinedStrings(0); ChatUtil.getAdminChannel().sendMessage("[" + ChatColor.GOLD + "A" + ChatColor.WHITE + "] " + Players.getName(sender) + ChatColor.RESET + ": " + message); Bukkit.getConsoleSender().sendMessage("[" + ChatColor.GOLD + "A" + ChatColor.WHITE + "] " + Players.getName(sender) + ChatColor.RESET + ": " + message); } }
Example 7
Source File: PunishmentCommands.java From CardinalPGM with MIT License | 6 votes |
@Command(aliases = {"warn", "w"}, usage = "<player> [reason]", desc = "Warn a player.", min = 1) @CommandPermissions("cardinal.punish.warn") public static void warn(CommandContext cmd, CommandSender sender) throws CommandException { Player warned = Bukkit.getPlayer(cmd.getString(0)); if (warned == null) { throw new CommandException(ChatConstant.ERROR_NO_PLAYER_MATCH.getMessage(ChatUtil.getLocale(sender))); } String reason = cmd.argsLength() > 1 ? cmd.getJoinedStrings(1) : "You have been warned!"; ChatChannel channel = GameHandler.getGameHandler().getMatch().getModules().getModule(AdminChannel.class); channel.sendMessage("[" + ChatColor.GOLD + "A" + ChatColor.WHITE + "] " + ((sender instanceof Player) ? Teams.getTeamColorByPlayer((Player) sender) + ((Player) sender).getDisplayName() : ChatColor.YELLOW + "*Console") + ChatColor.GOLD + " warned " + Teams.getTeamColorByPlayer(warned) + warned.getDisplayName() + ChatColor.GOLD + " for " + reason); warned.sendMessage(ChatColor.RED + "" + ChatColor.MAGIC + "-------" + ChatColor.YELLOW + "WARNING" + ChatColor.RED + ChatColor.MAGIC + "-------"); warned.sendMessage(ChatColor.GREEN + reason); warned.sendMessage(ChatColor.YELLOW + reason); warned.sendMessage(ChatColor.RED + reason); warned.sendMessage(ChatColor.RED + "" + ChatColor.MAGIC + "-------" + ChatColor.YELLOW + "WARNING" + ChatColor.RED + ChatColor.MAGIC + "-------"); }
Example 8
Source File: AdminCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Command( aliases = {"setnext", "sn"}, desc = "Sets the next map. Note that the rotation will go to this map then resume as normal.", usage = "[map name]", flags = "f", min = 1, max = -1 ) @CommandPermissions("pgm.next.set") public List<String> setnext(CommandContext args, CommandSender sender) throws CommandException { final String mapName = args.argsLength() > 0 ? args.getJoinedStrings(0) : ""; if(args.getSuggestionContext() != null) { return CommandUtils.completeMapName(mapName); } MatchManager mm = PGM.getMatchManager(); boolean restartQueued = restartManager.isRestartRequested(ServerDoc.Restart.Priority.NORMAL); if (restartQueued && !args.hasFlag('f')) { throw new CommandException(PGMTranslations.get().t("command.admin.setNext.restartQueued", sender)); } mm.setNextMap(CommandUtils.getMap(mapName, sender)); if (restartQueued) { restartManager.cancelRestart(); sender.sendMessage(ChatColor.GREEN + PGMTranslations.get().t("command.admin.cancelRestart.restartUnqueued", sender)); } sender.sendMessage(ChatColor.DARK_PURPLE + PGMTranslations.get().t("command.admin.set.success", sender, ChatColor.GOLD + mm.getNextMap().getInfo().name + ChatColor.DARK_PURPLE)); return null; }
Example 9
Source File: TeamCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Command( aliases = {"alias"}, desc = "Rename a team", usage = "<old name> <new name>", min = 2, max = -1 ) @CommandPermissions("pgm.team.alias") public void alias(CommandContext args, CommandSender sender) throws CommandException, SuggestException { TeamMatchModule tmm = utils.module(); Match match = tmm.getMatch(); Team team = utils.teamArgument(args, 0); String newName = args.getJoinedStrings(1); if(newName.length() > 32) { throw new CommandException("Team name cannot be longer than 32 characters"); } if(teams.stream().anyMatch(t -> t.getName().equalsIgnoreCase(newName))) { throw new TranslatableCommandException("command.team.alias.nameAlreadyUsed", newName); } String oldName = team.getColoredName(); team.setName(newName); match.sendMessage(oldName + ChatColor.GRAY + " renamed to " + team.getColoredName()); }
Example 10
Source File: MapDevelopmentCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Command( aliases = {"errors", "xmlerrors"}, usage = "[-p page] [map name]", desc = "Reads back XML errors", min = 0, max = -1, flags = "p:" ) @CommandPermissions(Permissions.MAPERRORS) public List<String> errorsCommand(CommandContext args, final CommandSender sender) throws CommandException { final String mapName = args.argsLength() > 0 ? args.getJoinedStrings(0) : ""; if(args.getSuggestionContext() != null) { return tc.oc.pgm.commands.CommandUtils.completeMapName(mapName); } Multimap<MapDefinition, MapLogRecord> errors = mapErrorTracker.getErrors(); PGMMap filterMap = null; if(!mapName.isEmpty()) { filterMap = tc.oc.pgm.commands.CommandUtils.getMap(mapName, sender); Multimap<MapDefinition, MapLogRecord> filtered = ArrayListMultimap.create(); filtered.putAll(filterMap, errors.get(filterMap)); errors = filtered; } new PrettyPaginatedResult<Map.Entry<MapDefinition, MapLogRecord>>(filterMap == null ? "Map Errors (" + errors.keySet().size() + " maps)" : filterMap.getName() + " Errors") { @Override public String format(Map.Entry<MapDefinition, MapLogRecord> entry, int index) { return entry.getValue().getLegacyFormattedMessage(); } @Override public String formatEmpty() { return ChatColor.GREEN + PGMTranslations.get().t("command.development.listErrors.noErrors", sender); } }.display(new BukkitWrappedCommandSender(sender), errors.entries(), args.getFlagInteger('p', 1)); return null; }
Example 11
Source File: CycleCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Command( aliases = {"cycle"}, desc = "Queues a cycle to the next map in a certain amount of seconds", usage = "[seconds] [mapname]", flags = "f" ) @CommandPermissions(PERMISSION) public List<String> cycle(CommandContext args, CommandSender sender) throws CommandException { if(args.getSuggestionContext() != null) { if(args.getSuggestionContext().getIndex() >= 1) { return CommandUtils.completeMapName(args.getJoinedStrings(1)); } return null; } // Try to parse "<seconds> [mapname]", fall back to "<mapname>" // So the map can be given without the time Duration countdown; try { countdown = tc.oc.commons.bukkit.commands.CommandUtils.getDuration(args, 0); } catch(CommandException e) { countdown = null; } int index = countdown == null ? 0 : 1; String mapName = index < args.argsLength() ? args.getJoinedStrings(index) : null; cycle(sender, countdown, mapName == null ? null : CommandUtils.getMap(mapName, sender), args.hasFlag('f')); return null; }
Example 12
Source File: WhisperCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Command( aliases = {"reply", "r"}, usage = "<message...>", desc = "Reply to last user", min = 1, max = -1 ) @CommandPermissions("projectares.msg") public void reply(final CommandContext args, final CommandSender sender) throws CommandException { final Player player = CommandUtils.senderToPlayer(sender); final User user = userStore.getUser(player); final Audience audience = audiences.get(sender); final String content = args.getJoinedStrings(0); executor.callback( whisperService.forReply(user), CommandFutureCallback.<Whisper>onSuccess(sender, args, original -> { final Identity from, to; if(user.equals(original.sender_uid())) { // Follow-up of previously sent message from = formatter.senderIdentity(original); to = formatter.recipientIdentity(original); } else { // Reply to received message from = formatter.recipientIdentity(original); to = formatter.senderIdentity(original); } whisperSender.send(sender, from, to, content); }).onFailure(NotFound.class, e -> formatter.noReply(sender)) ); }
Example 13
Source File: DebugCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
private void throwError(CommandContext args, CommandSender sender, String type) { final String message; if(args.argsLength() == 0) { message = "Test " + type + " error from " + sender.getName(); } else { message = args.getJoinedStrings(0); } throw new RuntimeException(message); }
Example 14
Source File: ClassCommands.java From CardinalPGM with MIT License | 5 votes |
@Command(aliases = {"class", "cl"}, desc = "Allows you to change your class.") public static void classCommand(final CommandContext cmd, CommandSender sender) throws CommandException { if (!(sender instanceof Player)) { throw new CommandException(ChatConstant.ERROR_CONSOLE_NO_USE.getMessage(ChatUtil.getLocale(sender))); } if (GameHandler.getGameHandler().getMatch().getModules().getModule(ClassModule.class) == null) { throw new CommandException(ChatConstant.ERROR_CLASSES_DISABLED.getMessage(ChatUtil.getLocale(sender))); } if (cmd.argsLength() == 0) { if (ClassModule.getClassByPlayer((Player) sender) != null) { sender.sendMessage(ChatColor.GREEN + new LocalizedChatMessage(ChatConstant.GENERIC_CLASS_CURRENT).getMessage(ChatUtil.getLocale(sender)) + " " + ChatColor.GOLD + "" + ChatColor.UNDERLINE + ClassModule.getClassByPlayer((Player) sender).getName()); String classMessage = new LocalizedChatMessage(ChatConstant.GENERIC_CLASS_LIST).getMessage(((Player) sender).getLocale()); String newClassMessage = ""; for (int i = 0; i < classMessage.split("'").length; i++) { newClassMessage += (i == 1 ? ChatColor.GOLD : ChatColor.DARK_PURPLE) + (i > 0 ? "'" : "") + classMessage.split("'")[i]; } sender.sendMessage(newClassMessage); } } else { String input = cmd.getJoinedStrings(0); if (ClassModule.getClassByName(input) == null) { throw new CommandException(ChatConstant.ERROR_NO_CLASS.getMessage(ChatUtil.getLocale(sender))); } ClassModule.playerClass.put(((Player) sender).getUniqueId(), ClassModule.getClassByName(input)); ClassChangeEvent changeEvent = new ClassChangeEvent((Player) sender, ClassModule.getClassByName(input)); Bukkit.getServer().getPluginManager().callEvent(changeEvent); } }
Example 15
Source File: TeamCommands.java From CardinalPGM with MIT License | 5 votes |
@Command(aliases = {"alias"}, desc = "Renames a the team specified.", usage = "<team> <name>", min = 2) @CommandPermissions("cardinal.team.alias") public static void alias(final CommandContext cmd, CommandSender sender) throws CommandException { Optional<TeamModule> team = Teams.getTeamByName(cmd.getString(0)); if (!team.isPresent()) { throw new CommandException(new LocalizedChatMessage(ChatConstant.ERROR_NO_TEAM_MATCH).getMessage(ChatUtil.getLocale(sender))); } String msg = cmd.getJoinedStrings(1); ChatUtil.getGlobalChannel().sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.GRAY + "{0}", new LocalizedChatMessage(ChatConstant.GENERIC_TEAM_ALIAS, team.get().getCompleteName() + ChatColor.GRAY, team.get().getColor() + msg + ChatColor.GRAY))); team.get().setName(msg); Bukkit.getServer().getPluginManager().callEvent(new TeamNameChangeEvent(team.get())); }
Example 16
Source File: PunishmentCommands.java From CardinalPGM with MIT License | 5 votes |
@Command(aliases = {"kick", "k"}, desc = "Kick a player.", usage = "<player> [reason]", min = 1) @CommandPermissions("cardinal.punish.kick") public static void kick(CommandContext cmd, CommandSender sender) throws CommandException { Player kicked = Bukkit.getPlayer(cmd.getString(0)); if (kicked == null) { throw new CommandException(ChatConstant.ERROR_PLAYER_NOT_FOUND.getMessage(ChatUtil.getLocale(sender))); } if (!sender.isOp() && kicked.isOp()) { throw new CommandException(ChatConstant.ERROR_PLAYER_NOT_AFFECTED.getMessage(ChatUtil.getLocale(sender))); } String reason = cmd.argsLength() > 1 ? cmd.getJoinedStrings(1) : "You have been kicked!"; Bukkit.broadcastMessage(Players.getName(sender) + ChatColor.GOLD + " \u00BB Kicked \u00BB " + Players.getName(kicked) + ChatColor.GOLD + " \u00BB " + reason); kicked.kickPlayer(ChatColor.RED + "Kicked" + ChatColor.GOLD + " \u00BB " + ChatColor.AQUA + reason); }