Search in sources :

Example 1 with PlayerNotFoundException

use of gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException in project Nexus by ProjectEdenGG.

the class AltBanCommand method bots.

@Permission(Group.ADMIN)
@Path("bots <names> [--dryrun]")
void bots(@Arg(type = String.class) List<String> names, @Switch boolean dryrun) {
    int banned = 0;
    int ignored = 0;
    for (String name : names) {
        try {
            Nerd nerd = Nerd.of(name);
            if (!nerd.getPastNames().contains(name))
                throw new PlayerNotFoundException(name);
            ++banned;
            if (dryrun)
                send("Banning " + name);
            else
                Punishments.of(nerd).add(Punishment.ofType(PunishmentType.ALT_BAN).punisher(uuid()).input("Spam bot").now(true));
        } catch (PlayerNotFoundException ex) {
            send("Ignoring " + name);
            ++ignored;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    send("Banned " + banned + ", ignored " + ignored);
}
Also used : PlayerNotFoundException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException) Nerd(gg.projecteden.nexus.models.nerd.Nerd) PlayerNotFoundException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 2 with PlayerNotFoundException

use of gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException in project Nexus by ProjectEdenGG.

the class HallOfHistoryCommand method create.

@Permission(Group.STAFF)
@Path("create <player>")
void create(@Arg(tabCompleter = Nerd.class) String player) {
    runCommand("blockcenter");
    String name;
    String skin;
    try {
        Nerd nerd = Nerd.of(convertToOfflinePlayer(player));
        name = nerd.getColoredName();
        skin = nerd.getName();
    } catch (PlayerNotFoundException e) {
        // probably a veteran
        name = Rank.VETERAN.colored().getHex() + player;
        skin = player;
    }
    // is there a better workaround for this? :P
    final String name1 = name;
    final String skin1 = skin;
    Tasks.wait(5, () -> runCommand("npc create " + name1));
    Tasks.wait(10, () -> runCommand("npc skin " + skin1));
}
Also used : PlayerNotFoundException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException) Nerd(gg.projecteden.nexus.models.nerd.Nerd) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Aggregations

Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)2 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)2 PlayerNotFoundException (gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException)2 Nerd (gg.projecteden.nexus.models.nerd.Nerd)2