com.sk89q.minecraft.util.commands.CommandException Java Examples
The following examples show how to use
com.sk89q.minecraft.util.commands.CommandException.
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: ChatUtil.java From CardinalPGM with MIT License | 6 votes |
public static <T> void paginate(CommandSender sender, ChatConstant header, int index, int streamSize, int pageSize, Stream<T> stream, Function<T, ChatMessage> toMessage, Function<T, String> toString, int mark, ChatColor markColor) throws CommandException { int pages = (int) Math.ceil((streamSize + (pageSize - 1)) / pageSize); List<String> page; try { int current = pageSize * (index - 1); page = new Indexer().index(toString(paginate(stream, pageSize, index), toMessage, ChatUtil.getLocale(sender), toString), current, mark + 1, markColor).collect(Collectors.toList()); if (page.size() == 0) throw new IllegalArgumentException(); } catch (IllegalArgumentException e) { throw new CommandException(new LocalizedChatMessage(ChatConstant.ERROR_INVALID_PAGE_NUMBER, pages + "") .getMessage(ChatUtil.getLocale(sender))); } sender.sendMessage(Align.padMessage(new LocalizedChatMessage(header, Strings.page(index, pages)).getMessage(ChatUtil.getLocale(sender)))); page.forEach(sender::sendMessage); sender.sendMessage(Align.getDash()); }
Example #2
Source File: TicketCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = { "play", "replay" }, desc = "Play a game", usage = "[game]", min = 0, max = -1 ) public List<String> play(final CommandContext args, final CommandSender sender) throws CommandException { final String name = args.argsLength() > 0 ? args.getRemainingString(0) : ""; if(args.getSuggestionContext() != null) { return StringUtils.complete(name, ticketBooth.allGames(sender).stream().map(Game::name)); } ticketBooth.playGame(CommandUtils.senderToPlayer(sender), name); return null; }
Example #3
Source File: PollCommands.java From CardinalPGM with MIT License | 6 votes |
private static int findPoll(Integer id, CommandSender sender) throws CommandException { if (id != null) { if (Polls.isPoll(id)) { return id; } else { throw new CommandException(new LocalizedChatMessage(ChatConstant.ERROR_POLL_NO_SUCH_POLL, "" + id).getMessage(ChatUtil.getLocale(sender))); } } else { id = Polls.getPoll(); if (id == -1) { throw new CommandException(ChatConstant.ERROR_POLL_NEED_ID.getMessage(ChatUtil.getLocale(sender))); } else if (id == 0) { throw new CommandException(ChatConstant.ERROR_POLL_NO_POLLS.getMessage(ChatUtil.getLocale(sender))); } return id; } }
Example #4
Source File: ServerCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = {"hub", "lobby"}, desc = "Teleport to the lobby" ) public void hub(final CommandContext args, CommandSender sender) throws CommandException { if(sender instanceof ProxiedPlayer) { final ProxiedPlayer player = (ProxiedPlayer) sender; final Server server = Futures.getUnchecked(executor.submit(() -> serverTracker.byPlayer(player))); if(server.role() == ServerDoc.Role.LOBBY || server.role() == ServerDoc.Role.PGM) { // If Bukkit server is running Commons, let it handle the command throw new CommandBypassException(); } player.connect(proxy.getServerInfo("default")); player.sendMessage(new ComponentBuilder("Teleporting you to the lobby").color(ChatColor.GREEN).create()); } else { sender.sendMessage(new ComponentBuilder("Only players may use this command").color(ChatColor.RED).create()); } }
Example #5
Source File: StartAndEndCommand.java From CardinalPGM with MIT License | 6 votes |
@Command(aliases = {"end", "finish"}, desc = "Ends the match.", usage = "[team]", flags = "n") @CommandPermissions("cardinal.match.end") public static void end(CommandContext cmd, CommandSender sender) throws CommandException { if (!GameHandler.getGameHandler().getMatch().isRunning()) { throw new CommandException(ChatConstant.ERROR_NO_END.getMessage(ChatUtil.getLocale(sender))); } if (cmd.argsLength() > 0) { Optional<TeamModule> team = Teams.getTeamByName(cmd.getString(0)); GameHandler.getGameHandler().getMatch().end(team.orNull()); } else { if (cmd.hasFlag('n')) { GameHandler.getGameHandler().getMatch().end(); } else { GameHandler.getGameHandler().getMatch().end(TimeLimit.getMatchWinner()); } } }
Example #6
Source File: MapDevelopmentCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = {"matchfeatures", "features"}, desc = "Lists all features by ID and type", min = 0, max = 1 ) @CommandPermissions(Permissions.MAPDEV) public void featuresCommand(CommandContext args, CommandSender sender) throws CommandException { final Match match = tc.oc.pgm.commands.CommandUtils.getMatch(sender); new PrettyPaginatedResult<Feature>("Match Features") { @Override public String format(Feature feature, int i) { String text = (i + 1) + ". " + ChatColor.RED + feature.getClass().getSimpleName(); if(feature instanceof SluggedFeature) { text += ChatColor.GRAY + " - " +ChatColor.GOLD + ((SluggedFeature) feature).slug(); } return text; } }.display(new BukkitWrappedCommandSender(sender), match.features().all().collect(Collectors.toList()), args.getInteger(0, 1)); }
Example #7
Source File: DebugCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = "throw", desc = "Throw a test RuntimeException", usage = "[message]", flags = "tr", min = 0, max = 1 ) @CommandPermissions(Permissions.DEVELOPER) public void throwError(CommandContext args, CommandSender sender) throws CommandException { if(args.hasFlag('r')) { Logger.getLogger("").severe("Test root logger error from " + sender.getName()); } else if(args.hasFlag('t')) { scheduler.createTask(() -> { throwError(args, sender, "task"); }); } else { throwError(args, sender, "command"); } }
Example #8
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 #9
Source File: FreeForAllCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = {"min"}, desc = "Change the minimum number of players required to start the match.", min = 1, max = 1 ) @CommandPermissions("pgm.team.size") public static void min(CommandContext args, CommandSender sender) throws CommandException { FreeForAllMatchModule ffa = CommandUtils.getMatchModule(FreeForAllMatchModule.class, sender); if("default".equals(args.getString(0))) { ffa.setMinPlayers(null); } else { int minPlayers = args.getInteger(0); if(minPlayers < 0) throw new CommandException("min-players cannot be less than 0"); if(minPlayers > ffa.getMaxPlayers()) throw new CommandException("min-players cannot be greater than max-players"); ffa.setMinPlayers(minPlayers); } sender.sendMessage(ChatColor.WHITE + "Minimum players is now " + ChatColor.AQUA + ffa.getMinPlayers()); }
Example #10
Source File: AdminCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = {"restart"}, desc = "Queues a server restart after a certain amount of time", usage = "[seconds] - defaults to 30 seconds", flags = "f", min = 0, max = 1 ) @CommandPermissions("server.restart") public void restart(CommandContext args, CommandSender sender) throws CommandException { // Countdown defers automatic restart, so don't allow excessively long times Duration countdown = TimeUtils.min( tc.oc.commons.bukkit.commands.CommandUtils.getDuration(args, 0, Duration.ofSeconds(30)), Duration.ofMinutes(5) ); final Match match = CommandUtils.getMatch(sender); if(!match.canAbort() && !args.hasFlag('f')) { throw new CommandException(PGMTranslations.get().t("command.admin.restart.matchRunning", sender)); } restartListener.queueRestart(match, countdown, "/restart command"); }
Example #11
Source File: SettingCommands.java From CardinalPGM with MIT License | 6 votes |
@Command(aliases = {"set"}, desc = "Set a setting to a specific value.", usage = "<setting> <value>", min = 2) public static void set(final CommandContext cmd, CommandSender sender) throws CommandException { if (!(sender instanceof Player)) { throw new CommandException(ChatConstant.ERROR_CONSOLE_NO_USE.getMessage(ChatUtil.getLocale(sender))); } Setting setting = Settings.getSettingByName(cmd.getString(0)); if (setting == null) { throw new CommandException(ChatConstant.ERROR_NO_SETTING_MATCH.getMessage(ChatUtil.getLocale(sender))); } SettingValue value = setting.getSettingValueByName(cmd.getString(1)); if (value == null) { throw new CommandException(ChatConstant.ERROR_NO_VALUE_MATCH.getMessage(ChatUtil.getLocale(sender))); } SettingValue oldValue = setting.getValueByPlayer((Player) sender); setting.setValueByPlayer((Player) sender, value); sender.sendMessage(ChatColor.YELLOW + setting.getNames().get(0) + ": " + ChatColor.WHITE + value.getValue()); Bukkit.getServer().getPluginManager().callEvent(new PlayerSettingChangeEvent((Player) sender, setting, oldValue, value)); }
Example #12
Source File: RestartCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = {"cancelrestart", "cr"}, desc = "Cancels a previously requested restart", min = 0, max = 0 ) @CommandPermissions("server.cancelrestart") @Console public void cancelRestart(CommandContext args, final CommandSender sender) throws CommandException { if(!restartManager.isRestartRequested()) { throw new TranslatableCommandException("command.admin.cancelRestart.noActionTaken"); } syncExecutor.callback( restartManager.cancelRestart(), CommandFutureCallback.onSuccess(sender, args, o -> { audiences.get(sender).sendMessage(new TranslatableComponent("command.admin.cancelRestart.restartUnqueued")); }) ); }
Example #13
Source File: FreezeCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = { "freeze", "f" }, usage = "<player>", desc = "Freeze a player", min = 1, max = 1 ) @CommandPermissions(Freeze.PERMISSION) public void freeze(final CommandContext args, final CommandSender sender) throws CommandException { if(!freeze.enabled()) { throw new ComponentCommandException(new TranslatableComponent("command.freeze.notEnabled")); } executor.callback( userFinder.findLocalPlayer(sender, args, 0), CommandFutureCallback.onSuccess(sender, args, response -> freeze.toggleFrozen(sender, response.player())) ); }
Example #14
Source File: TeamCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = {"teams", "listteams"}, desc = "Lists the teams registered for competition on this server.", min = 0, max = 1, usage = "[page]" ) @Console @CommandPermissions("tourney.listteams") public void listTeams(final CommandContext args, final CommandSender sender) throws CommandException { new Paginator<team.Id>() .title(new TranslatableComponent("tourney.teams.title", tournamentName)) .entries((team, index) -> teamName(team)) .display(audiences.get(sender), tournament.accepted_teams(), args.getInteger(0, 1)); }
Example #15
Source File: MapCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = {"maplist", "maps", "ml"}, desc = "Shows the maps that are currently loaded", usage = "[page]", min = 0, max = 1, help = "Shows all the maps that are currently loaded including ones that are not in the rotation." ) @CommandPermissions("pgm.maplist") public static void maplist(CommandContext args, final CommandSender sender) throws CommandException { final Set<PGMMap> maps = ImmutableSortedSet.copyOf(new PGMMap.DisplayOrder(), PGM.getMatchManager().getMaps()); new PrettyPaginatedResult<PGMMap>(PGMTranslations.get().t("command.map.mapList.title", sender)) { @Override public String format(PGMMap map, int index) { return (index + 1) + ". " + map.getInfo().getShortDescription(sender); } }.display(new BukkitWrappedCommandSender(sender), maps, args.getInteger(0, 1) /* page */); }
Example #16
Source File: PunishmentCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = { "rp", "repeatpunish" }, usage = "[player]", desc = "Show the last punishment you issued or repeat it for a different player", min = 0, max = 1 ) public void repeat(CommandContext args, CommandSender sender) throws CommandException { final User punisher = userFinder.getLocalUser(sender); final Audience audience = audiences.get(sender); if(permission(sender, null)) { syncExecutor.callback( userFinder.findUser(sender, args, 0, NULL), punished -> syncExecutor.callback( punishmentService.find(PunishmentSearchRequest.punisher(punisher, 1)), punishments -> punishments.documents().stream().findFirst().<Runnable>map(last -> () -> { if (punished != null) { punishmentCreator.repeat(last, punished.user); } else { audience.sendMessages(punishmentFormatter.format(last, false, false)); } }).orElse(() -> audience.sendMessage(new WarningComponent("punishment.noneIssued"))).run() ) ); } }
Example #17
Source File: DestroyableCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
public void setCompletion(CommandContext args, CommandSender sender, Destroyable destroyable, String value) throws CommandException { assertEditPerms(sender); Double completion; Integer breaks; if(value.endsWith("%")) { completion = Double.parseDouble(value.substring(0, value.length() - 1)) / 100d; breaks = null; } else { completion = null; breaks = Integer.parseInt(value); } try { if(completion != null) { destroyable.setDestructionRequired(completion); } else if(breaks != null) { destroyable.setBreaksRequired(breaks); } } catch(IllegalArgumentException e) { throw new CommandException(e.getMessage()); } }
Example #18
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 #19
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 #20
Source File: TraceCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = {"off", "stop"}, desc = "Stop logging packets", min = 0, max = 1 ) public void stop(CommandContext args, CommandSender sender) throws CommandException { if(sender instanceof Player || args.argsLength() >= 1) { final Player player = (Player) getCommandSenderOrSelf(args, sender, 0); if(PacketTracer.stop(player)) { sender.sendMessage("Stopped packet trace for " + player.getName(sender)); } } else { traceAll.set(false); if(onlinePlayers.all().stream().anyMatch(PacketTracer::stop)) { sender.sendMessage("Stopped all packet tracing"); } } }
Example #21
Source File: DebugCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = "sleep", desc = "Put the main server thread to sleep for the given duration", usage = "<time>", flags = "", min = 1, max = 1 ) @CommandPermissions(Permissions.DEVELOPER) public void sleep(CommandContext args, CommandSender sender) throws CommandException { try { Thread.sleep(durationParser.parse(args.getString(0)).toMillis()); } catch(InterruptedException e) { throw new CommandException("Sleep was interrupted", e); } }
Example #22
Source File: PunishmentCommands.java From CardinalPGM with MIT License | 6 votes |
@Command(aliases = {"unmute"}, usage = "<player>", desc = "Allows a player to talk after being muted.", min = 1) @CommandPermissions("cardinal.punish.mute") public static void unmute(CommandContext cmd, CommandSender sender) throws CommandException { Player player = Bukkit.getPlayer(cmd.getString(0)); if (player == null) { throw new CommandException(ChatConstant.ERROR_NO_PLAYER_MATCH.getMessage(ChatUtil.getLocale(sender))); } if (!sender.isOp() && player.isOp()) { throw new CommandException(ChatConstant.ERROR_PLAYER_NOT_AFFECTED.getMessage(ChatUtil.getLocale(sender))); } if (!GameHandler.getGameHandler().getMatch().getModules().getModule(PermissionModule.class).isMuted(player)) { throw new CommandException(ChatConstant.ERROR_PLAYER_NOT_MUTED.getMessage(ChatUtil.getLocale(sender))); } sender.sendMessage(new UnlocalizedChatMessage(ChatColor.GREEN + "{0}", new LocalizedChatMessage(ChatConstant.GENERIC_UNMUTED, Players.getName(player))).getMessage(ChatUtil.getLocale(sender))); player.sendMessage(new UnlocalizedChatMessage(ChatColor.GREEN + "{0}", new LocalizedChatMessage(ChatConstant.GENERIC_UNMUTED_BY, Players.getName(sender))).getMessage(ChatUtil.getLocale(player))); GameHandler.getGameHandler().getMatch().getModules().getModule(PermissionModule.class).unmute(player); }
Example #23
Source File: TeamCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = {"shuffle"}, desc = "Shuffle the teams", min = 0, max = 0 ) @CommandPermissions("pgm.team.shuffle") public void shuffle(CommandContext args, CommandSender sender) throws CommandException { TeamMatchModule tmm = utils.module(); Match match = tmm.getMatch(); if(match.isRunning()) { throw new CommandException(Translations.get().t("command.team.shuffle.matchRunning", sender)); } else { List<Team> teams = new ArrayList<>(this.teams); List<MatchPlayer> participating = new ArrayList<>(match.getParticipatingPlayers()); Collections.shuffle(participating); for(int i = 0; i < participating.size(); i++) { tmm.forceJoin(participating.get(i), teams.get((i * teams.size()) / participating.size())); } match.sendMessage(new TranslatableComponent("command.team.shuffle.success")); } }
Example #24
Source File: TeamCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Command( aliases = {"force"}, desc = "Force a player onto a team", usage = "<player> [team]", min = 1, max = 2 ) @CommandPermissions("pgm.team.force") public void force(CommandContext args, CommandSender sender) throws CommandException, SuggestException { MatchPlayer player = CommandUtils.findSingleMatchPlayer(args, sender, 0); if(args.argsLength() >= 2) { String name = args.getString(1); if(name.trim().toLowerCase().startsWith("obs")) { player.getMatch().setPlayerParty(player, player.getMatch().getDefaultParty()); } else { Team team = utils.teamArgument(args, 1); utils.module().forceJoin(player, team); } } else { utils.module().forceJoin(player, null); } }
Example #25
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 #26
Source File: WhitelistCommands.java From CardinalPGM with MIT License | 5 votes |
@Command(aliases = {"all"}, desc = "Add everyone that's online to the whitelist.", min = 0, max = 0) @CommandPermissions("cardinal.whitelist.all") public static void all(final CommandContext args, final CommandSender sender) throws CommandException { for (Player player : Bukkit.getOnlinePlayers()) { player.setWhitelisted(true); } sender.sendMessage(ChatColor.GREEN + new LocalizedChatMessage(ChatConstant.GENERIC_ADDED_PLAYERS_WHITELIST, "" + ChatColor.GOLD + Bukkit.getOnlinePlayers().size() + ChatColor.GREEN).getMessage(ChatUtil.getLocale(sender))); }
Example #27
Source File: MapDevelopmentCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Command( aliases = {"debugvelocity"}, desc = "Dump debug info about a player's velocity to the console", usage = "[player]", min = 0, max = 1 ) @CommandPermissions(Permissions.MAPDEV) public void debugVelocity(CommandContext args, CommandSender sender) throws CommandException { final MatchPlayer player = tc.oc.pgm.commands.CommandUtils.getMatchPlayerOrSelf(args, sender, 0); final DebugVelocityPlayerFacet facet = player.facet(DebugVelocityPlayerFacet.class); final boolean enabled = !facet.isEnabled(); facet.setEnabled(enabled); sender.sendMessage(new Component("Velocity debug for " + player.getName() + " is " + (enabled ? "ENABLED" : "DISABLED"))); }
Example #28
Source File: TicketCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Command( aliases = { "games" }, desc = "List all the games you can play", min = 0, max = 0 ) public void games(final CommandContext args, final CommandSender sender) throws CommandException { ticketBooth.showGames(sender); }
Example #29
Source File: PunishmentCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Command( aliases = { "p", "punish" }, flags = "aso", usage = "<player> <reason>", desc = "Punish a player for a reason.", min = 2 ) public void punish(CommandContext args, CommandSender sender) throws CommandException { create(args, sender, null, null); // Website will handle choosing which punishment }
Example #30
Source File: WhitelistCommands.java From CardinalPGM with MIT License | 5 votes |
@Command(aliases = {"clear"}, desc = "Clear the whitelist.", min = 0, max = 0) @CommandPermissions("cardinal.whitelist.clear") public static void clear(final CommandContext args, final CommandSender sender) throws CommandException { int count = 0; for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) { player.setWhitelisted(false); count++; } sender.sendMessage(ChatColor.RED + new LocalizedChatMessage(ChatConstant.GENERIC_REMOVED_PLAYERS_WHITELIST, "" + ChatColor.GOLD + count + ChatColor.RED).getMessage(ChatUtil.getLocale(sender))); }