Search in sources :

Example 6 with Player

use of com.gamebuster19901.excite.Player in project ExciteBot by TheGameCommunity.

the class BanCommand method banProfileForever.

@SuppressWarnings("rawtypes")
private static int banProfileForever(MessageContext context, Player[] profile, String reason) {
    if (profile.length != 1) {
        context.sendMessage("Ambigious name, enter a PID or FC");
        return 0;
    }
    if (context.isAdmin()) {
        if (profile[0] instanceof UnknownPlayer) {
            context.sendMessage("There is no profile known as " + profile);
            return 0;
        }
        Duration duration = ChronoUnit.FOREVER.getDuration();
        profile[0].ban(context, duration, parseReason(duration, reason));
    } else {
        context.sendMessage("You do not have permission to execute this command");
    }
    return 0;
}
Also used : Duration(java.time.Duration) UnknownPlayer(com.gamebuster19901.excite.UnknownPlayer)

Example 7 with Player

use of com.gamebuster19901.excite.Player in project ExciteBot by TheGameCommunity.

the class DiscordUser method getProfiles.

@SuppressWarnings("rawtypes")
public Set<Player> getProfiles(MessageContext context) {
    try {
        HashSet<Player> players = new HashSet<Player>();
        Result results = Table.selectColumnsFromWhere(ConsoleContext.INSTANCE, PLAYER_ID, PLAYERS, new Comparison(DISCORD_ID, EQUALS, getID()));
        while (results.next()) {
            players.add(Player.getPlayerByID(context, results.getInt(PLAYER_ID)));
        }
        return players;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : Player(com.gamebuster19901.excite.Player) Comparison(com.gamebuster19901.excite.bot.database.Comparison) SQLException(java.sql.SQLException) IOError(java.io.IOError) HashSet(java.util.HashSet) Result(com.gamebuster19901.excite.bot.database.Result)

Example 8 with Player

use of com.gamebuster19901.excite.Player in project ExciteBot by TheGameCommunity.

the class DiscordUser method notifyDiscordUsers.

public static void notifyDiscordUsers() throws SQLException {
    int count = Wiimmfi.getAcknowledgedPlayerCount();
    Result result = Table.selectAllFrom(ConsoleContext.INSTANCE, DISCORD_USERS);
    while (result.next()) {
        int threshold = result.getInt(THRESHOLD);
        if (count < threshold) {
            new DiscordUser(result).setDippedBelowThreshold(true);
            continue;
        } else {
            if (Instant.parse(result.getString(LAST_NOTIFICATION)).plus(Duration.parse(result.getString(FREQUENCY))).isBefore(Instant.now())) {
                if (result.getBoolean(BELOW_THRESHOLD)) {
                    DiscordUser user = new DiscordUser(result);
                    if (!result.getBoolean(NOTIFY_CONTINUOUSLY)) {
                        user.setDippedBelowThreshold(false);
                    }
                    if (threshold != -1) {
                        for (Player player : Wiimmfi.getOnlinePlayers()) {
                            if (player.getDiscord() == result.getLong(DISCORD_ID)) {
                                return;
                            }
                        }
                        user.sendMessage("Players Online" + Wiimmfi.getOnlinePlayerList(user.sendDetailedPM()));
                        user.setLastNotification();
                    }
                }
            }
        }
    }
}
Also used : Player(com.gamebuster19901.excite.Player) Result(com.gamebuster19901.excite.bot.database.Result)

Example 9 with Player

use of com.gamebuster19901.excite.Player in project ExciteBot by TheGameCommunity.

the class Banee method getBanee.

@SuppressWarnings("rawtypes")
public static Banee getBanee(MessageContext context, long id) {
    DiscordUser discord = DiscordUser.getDiscordUserIncludingUnknown(context, id);
    Player player = Player.getPlayerByID(context, (int) id);
    if (!player.isKnown()) {
        return discord;
    }
    return player;
}
Also used : DiscordUser(com.gamebuster19901.excite.bot.user.DiscordUser) Player(com.gamebuster19901.excite.Player)

Example 10 with Player

use of com.gamebuster19901.excite.Player in project ExciteBot by TheGameCommunity.

the class Banee method getBanee.

@Nullable
@SuppressWarnings({ "rawtypes", "deprecation" })
public static Banee getBanee(MessageContext context, String name) {
    DiscordUser[] discords = DiscordUser.getDiscordUsersWithUsername(context, name);
    Player[] players = Player.getPlayersByName(context, name);
    int amount = discords.length + players.length;
    if (amount == 1) {
        if (discords.length == 1) {
            return discords[0];
        }
        return players[0];
    } else if (amount < 1) {
        context.sendMessage("Could not find a discord user or player named " + name);
    } else if (amount > 1) {
        String ret = name + " is ambiguous, please supply an ID instead.\n\nAmbiguities\n\n:";
        if (discords.length > 0) {
            ret = ret + "Discord Users:\n";
            for (DiscordUser discord : discords) {
                ret = ret + discord.toDetailedString();
            }
        }
        if (players.length > 0) {
            ret = ret + "Profiles:\n";
            for (Player player : players) {
                ret = ret + player.toFullString();
            }
        }
        context.sendMessage(ret);
    }
    return null;
}
Also used : DiscordUser(com.gamebuster19901.excite.bot.user.DiscordUser) Player(com.gamebuster19901.excite.Player) Nullable(javax.annotation.Nullable)

Aggregations

Player (com.gamebuster19901.excite.Player)7 SQLException (java.sql.SQLException)6 PreparedStatement (com.gamebuster19901.excite.bot.database.sql.PreparedStatement)5 IOError (java.io.IOError)5 DiscordUser (com.gamebuster19901.excite.bot.user.DiscordUser)4 HashSet (java.util.HashSet)4 Result (com.gamebuster19901.excite.bot.database.Result)2 Duration (java.time.Duration)2 UnknownPlayer (com.gamebuster19901.excite.UnknownPlayer)1 Wiimmfi (com.gamebuster19901.excite.Wiimmfi)1 Ban (com.gamebuster19901.excite.bot.audit.ban.Ban)1 MessageContext (com.gamebuster19901.excite.bot.command.MessageContext)1 Comparison (com.gamebuster19901.excite.bot.database.Comparison)1 Wii (com.gamebuster19901.excite.bot.user.Wii)1 WiimmfiErrorResponse (com.gamebuster19901.excite.exception.WiimmfiErrorResponse)1 WiimmfiResponseException (com.gamebuster19901.excite.exception.WiimmfiResponseException)1 Named (com.gamebuster19901.excite.util.Named)1 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 SimpleDateFormat (java.text.SimpleDateFormat)1