org.bukkit.BanList#com.sk89q.minecraft.util.commands.CommandException源码实例Demo

下面列出了org.bukkit.BanList#com.sk89q.minecraft.util.commands.CommandException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ProjectAres   文件: FreeForAllCommands.java
@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());
}
 
源代码2 项目: CardinalPGM   文件: SettingCommands.java
@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));
}
 
源代码3 项目: ProjectAres   文件: AdminCommands.java
@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");
}
 
源代码4 项目: CardinalPGM   文件: StartAndEndCommand.java
@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());
        }
    }
}
 
源代码5 项目: ProjectAres   文件: DebugCommands.java
@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");
    }
}
 
源代码6 项目: ProjectAres   文件: MapCommands.java
@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 */);
}
 
源代码7 项目: ProjectAres   文件: PunishmentCommands.java
@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()
                )
        );
    }
}
 
源代码8 项目: CardinalPGM   文件: ChatCommands.java
@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);
    }
}
 
源代码9 项目: ProjectAres   文件: TeamCommands.java
@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);
    }
}
 
源代码10 项目: ProjectAres   文件: TeamCommands.java
@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"));
    }
}
 
源代码11 项目: ProjectAres   文件: DebugCommands.java
@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);
    }
}
 
源代码12 项目: ProjectAres   文件: MapDevelopmentCommands.java
@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));
}
 
源代码13 项目: CardinalPGM   文件: PunishmentCommands.java
@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 + "-------");
}
 
源代码14 项目: ProjectAres   文件: TraceCommands.java
@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");
        }
    }
}
 
源代码15 项目: CardinalPGM   文件: PunishmentCommands.java
@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);
}
 
源代码16 项目: ProjectAres   文件: DestroyableCommands.java
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());
    }
}
 
源代码17 项目: ProjectAres   文件: TeamCommands.java
@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));
}
 
源代码18 项目: ProjectAres   文件: FreezeCommands.java
@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()))
    );
}
 
源代码19 项目: CardinalPGM   文件: ChatUtil.java
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());
}
 
源代码20 项目: ProjectAres   文件: WhisperCommands.java
@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);
        })
    );
}
 
源代码21 项目: ProjectAres   文件: ServerCommands.java
@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());
    }
}
 
源代码22 项目: CardinalPGM   文件: PollCommands.java
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;
    }
}
 
源代码23 项目: ProjectAres   文件: TicketCommands.java
@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;
}
 
源代码24 项目: ProjectAres   文件: RestartCommands.java
@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"));
        })
    );
}
 
源代码25 项目: ProjectAres   文件: PunishmentCommands.java
@Command(
    aliases = { "tb", "tempban" },
    flags = "aso",
    usage = "<player> <duration> <reason>",
    desc = "Temporarily ban a player for a reason.",
    min = 3
)
public void tempban(CommandContext args, CommandSender sender) throws CommandException {
    create(args, sender, BAN, CommandUtils.getDuration(args, 1, Duration.ofDays(7)));
}
 
源代码26 项目: FastAsyncWorldedit   文件: EntityRemover.java
public void fromString(String str) throws CommandException {
    Type type = Type.findByPattern(str);
    if (type != null) {
        this.type = type;
    } else {
        throw new CommandException("Acceptable types: projectiles, items, paintings, itemframes, boats, minecarts, tnt, xp, or all");
    }
}
 
源代码27 项目: ProjectAres   文件: AdminCommands.java
@Command(
    aliases = {"end", "finish"},
    desc = "Ends the current running match, optionally with a winner",
    usage = "[competitor]",
    min = 0,
    max = -1
)
@CommandPermissions("pgm.end")
public void end(CommandContext args, CommandSender sender) throws CommandException {
    Match match = PGM.getMatchManager().getCurrentMatch(sender);

    Competitor winner = null;
    if(args.argsLength() > 0) {
        winner = CommandUtils.getCompetitor(args.getJoinedStrings(0), sender);
    }

    if(match.isFinished()) {
        throw new TranslatableCommandException("command.admin.start.matchFinished");
    } else if(!match.canTransitionTo(MatchState.Finished)) {
        throw new TranslatableCommandException("command.admin.end.unknownError");
    }

    if(winner != null) {
        match.needMatchModule(VictoryMatchModule.class).setImmediateWinner(winner);
    }

    match.end();
}
 
源代码28 项目: CardinalPGM   文件: MapCommands.java
@Command(aliases = {"map", "mapinfo"}, flags = "lm:", desc = "Shows information about the currently playing map.")
public static void map(final CommandContext args, CommandSender sender) throws CommandException {
    LoadedMap mapInfo = args.hasFlag('m') ? RepositoryManager.get().getMap(args.getFlagInteger('m')) :
                    args.argsLength() == 0 ? GameHandler.getGameHandler().getMatch().getLoadedMap() :
                            CycleCommand.getMap(sender, args.getJoinedStrings(0));
    if (mapInfo == null) 
        throw new CommandException(ChatConstant.ERROR_NO_MAP_MATCH.getMessage(ChatUtil.getLocale(sender)));
    sender.sendMessage(Align.padMessage(mapInfo.toShortMessage(ChatColor.DARK_AQUA, args.hasFlag('l'), true), ChatColor.RED));
    sender.sendMessage(TITLE_FORM + ChatConstant.UI_MAP_OBJECTIVE.getMessage(ChatUtil.getLocale(sender)) + ": "
            + CONT_FORM + mapInfo.getObjective());
    sendContributors(sender, ChatConstant.UI_MAP_AUTHOR, ChatConstant.UI_MAP_AUTHORS, mapInfo.getAuthors());
    sendContributors(sender, ChatConstant.UI_MAP_CONTRIBUTORS, ChatConstant.UI_MAP_CONTRIBUTORS, mapInfo.getContributors());
    if (mapInfo.getRules().size() > 0) {
        sender.sendMessage(TITLE_FORM + ChatConstant.UI_MAP_RULES.getMessage(ChatUtil.getLocale(sender)) + ":");
        for (int i = 1; i <= mapInfo.getRules().size(); i++)
            sender.sendMessage(ChatColor.WHITE + "" + i + ") " + CONT_FORM + mapInfo.getRules().get(i - 1));
    }
    sender.sendMessage(TITLE_FORM + ChatConstant.UI_MAP_MAX.getMessage(ChatUtil.getLocale(sender)) + ": "
            + CONT_FORM + mapInfo.getMaxPlayers());
    if (args.hasFlag('l')) {
        Repository repo = GameHandler.getGameHandler().getRepositoryManager().getRepo(mapInfo);
        if (repo != null) {
            sender.sendMessage(TITLE_FORM + "Source: " + repo.toChatMessage(sender.isOp()));
            sender.sendMessage(TITLE_FORM + "Folder: " + CONT_FORM +
                    repo.getRoot().toURI().relativize(mapInfo.getFolder().toURI()).getPath());
        } else {
            sender.sendMessage(TITLE_FORM + "Source: " + CONT_FORM + "Unknown");
        }
    }
}
 
源代码29 项目: ProjectAres   文件: AdminCommands.java
@Command(
    aliases = {"cancel"},
    desc = "Cancels all active PGM countdowns and disables auto-start and auto-cycle for the current match",
    min = 0,
    max = 0
)
@CommandPermissions("pgm.cancel")
public void cancel(CommandContext args, CommandSender sender) throws CommandException {
    CommandUtils.getMatch(sender).countdowns().cancelAll(true);
    sender.sendMessage(ChatColor.GREEN + PGMTranslations.get().t("command.admin.cancel.success", sender));
}
 
源代码30 项目: ProjectAres   文件: LoggingCommands.java
@Command(
    aliases = "load",
    desc = "Reload the logging configuration",
    min = 0,
    max = 0
)
public void load(CommandContext args, CommandSender sender) throws CommandException {
    loggingConfig.load();
    sender.sendMessage("Logging configuration reloaded");
}