diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java index f9c28fc95..b7d073814 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java @@ -245,7 +245,7 @@ public class ClansAdmin { public void run() { - if (nameExists) + if (nameExists.booleanValue()) UtilPlayer.message(caller, F.main("Clans Admin", "Clan name cannot be a Player name.")); else { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java index 0b3c63045..dc607b211 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java @@ -1,5 +1,7 @@ package mineplex.game.clans.clans.ban; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -20,6 +22,7 @@ import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.ILoginProcessor; import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -31,7 +34,7 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ban.commands.ClansBanCommand; import mineplex.game.clans.clans.ban.ui.ClansBanShop; -public class ClansBanManager extends MiniPlugin +public class ClansBanManager extends MiniPlugin implements ILoginProcessor { private CoreClientManager _clientManager; private ClansBanRepository _repository; @@ -39,6 +42,8 @@ public class ClansBanManager extends MiniPlugin private Map> _cache; private ClansBanShop _shop; + private Map _toKick = new HashMap<>(); + private Object _lock = new Object(); public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) @@ -53,6 +58,8 @@ public class ClansBanManager extends MiniPlugin _cache = new HashMap<>(); _shop = new ClansBanShop(this, clientManager, donationManager); + + clientManager.addStoredProcedureLoginProcessor(this); } @Override @@ -229,4 +236,27 @@ public class ClansBanManager extends MiniPlugin LoadClient(name, callback); } + + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + { + _repository.loadBans(playerName, client -> { + if (client.isBanned()) + { + String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT); + + if (client.getLongestBan().isPermanent()) + time = "Permanent"; + + String reason = C.cRedB + "You are banned from Clans for " + time + + "\n" + C.cWhite + client.getLongestBan().getReason(); + + _toKick.put(playerName, reason); + } + }); + } + + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT * FROM clanBans WHERE uuid = '" + uuid + "';"; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java index 81513e371..0c4efadf1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java @@ -1,5 +1,6 @@ package mineplex.game.clans.clans.ban; +import java.sql.ResultSet; import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; @@ -47,15 +48,10 @@ public class ClansBanRepository extends MinecraftRepository public void loadBans(final String name, final Callback callback) { - System.out.println(">> Attempting to load Clans Bans for \"" + name + "\""); loadClientByName(name, client -> { - System.out.println("> Successfully loaded CoreClient"); - String uuid = UUIDFetcher.getUUIDOf(client.GetPlayerName()).toString(); executeQuery(GET_ALL_BANS, resultSet -> { - System.out.println("> Successfully executed query, result set object: " + resultSet); - final List list = new ArrayList(); while (resultSet.next()) @@ -70,18 +66,47 @@ public class ClansBanRepository extends MinecraftRepository boolean removed = resultSet.getBoolean(8); list.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed)); - - System.out.println("Got ban for " + name); } callback.run(new ClansBanClient(uuid, list)); - System.out.println("> Successfully handled result"); - System.out.println(">> FINISH"); }, new ColumnVarChar("uuid", 36, uuid)); }); } + public void loadBans(final String name, final String uuid, final ResultSet resultSet, final Callback callback) + { + try + { + final List list = new ArrayList(); + + while (resultSet.next()) + { + int id = resultSet.getInt(1); + String ruuid = resultSet.getString(2); + String admin = resultSet.getString(3); + String reason = resultSet.getString(4); + Timestamp banTime = resultSet.getTimestamp(5); + Timestamp unbanTime = resultSet.getTimestamp(6); + boolean permanent = resultSet.getBoolean(7); + boolean removed = resultSet.getBoolean(8); + + list.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed)); + + System.out.println("Got ban for " + name); + } + + callback.run(new ClansBanClient(uuid, list)); + + System.out.println("> Successfully handled result"); + System.out.println(">> FINISH"); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + private void loadClientByName(String name, Callback client) { if (_manager.getClientManager().Contains(name))