Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.easyage.core.managers;
- import java.util.*;
- import pl.easyage.api.*;
- import org.apache.commons.lang.*;
- import pl.easyage.api.utils.*;
- import java.sql.*;
- public final class NickManager
- {
- private static final HashMap<UUID, String> blackListed;
- static {
- blackListed = new HashMap<UUID, String>();
- }
- public static void addBlackListed(final UUID uuid, final String reason) {
- if (!isNickListed(uuid)) {
- NickManager.blackListed.put(uuid, reason);
- API.getStore().update(false, "INSERT INTO `mh_nicklisted`(`id`, `uuid`, `reason`) VALUES (NULL,'" + uuid + "','" + StringEscapeUtils.escapeSql(reason) + "')");
- }
- }
- public static boolean isNickListed(final UUID uuid) {
- return NickManager.blackListed.containsKey(uuid);
- }
- public static void removeNickListed(final UUID uuid) {
- NickManager.blackListed.remove(uuid);
- API.getStore().update(false, "DELETE FROM `mh_nicklisted` WHERE `uuid` = '" + uuid + "'");
- }
- public static String getNickListed(final UUID uuid) {
- return NickManager.blackListed.get(uuid);
- }
- public static void setup() {
- final ResultSet rs = API.getStore().query("SELECT * FROM `mh_nicklisted`");
- try {
- while (rs.next()) {
- NickManager.blackListed.put(UUID.fromString(rs.getString("uuid")), rs.getString("reason"));
- }
- Logger.info(new String[] { "Loaded " + NickManager.blackListed.size() + " nickcolor users!" });
- }
- catch (SQLException sqlexception) {
- Logger.warning(new String[] { "An error occurred while loading blacklisted users!", "Error: " + sqlexception.getMessage() });
- sqlexception.printStackTrace();
- }
- }
- public static HashMap<UUID, String> getBlackListed() {
- return NickManager.blackListed;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement