diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index cd62cf6fc..3fd42bebe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -142,6 +142,11 @@ public class CoreClientManager extends MiniPlugin } } + public boolean Contains(String name) + { + return _clientList.containsKey(name); + } + public CoreClient Get(Player player) { return Get(player.getName()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java index 37a1204cd..681eb9c57 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java @@ -73,11 +73,6 @@ public class Task _cancel.run(_client); } - if (_end != null) - { - _end.run(_client); - } - _client.cleanup(_name); return; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 5d8be3794..209ae38a3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -53,7 +53,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer; public class Clans extends JavaPlugin { - public static final String VERSION = "0.18"; + public static final String VERSION = "0.18b"; private String WEB_CONFIG = "webServer"; // Modules diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 91e4d7f0b..8fc7a459a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -649,17 +649,17 @@ public class ClansManager extends MiniClientPluginimplements IRelati } } - private void handleClanChat(AsyncPlayerChatEvent event, ClanInfo clan, String rank) + private void handleClanChat(Player player, String message, ClanInfo clan, String rank) { for (Player cur : clan.getOnlinePlayers()) { - String message = _chat.getFilteredMessage(event.getPlayer(), event.getMessage()); + message = _chat.getFilteredMessage(player, message); - UtilPlayer.message(cur, String.format(rank + C.cAqua + "%s " + C.cDAqua + "%s", event.getPlayer().getName(), message)); + UtilPlayer.message(cur, String.format(rank + C.cAqua + "%s " + C.cDAqua + "%s", player.getName(), message)); } } - private void handleAllyChat(AsyncPlayerChatEvent event, ClanInfo clan, String rank) + private void handleAllyChat(Player player, String message, ClanInfo clan, String rank) { List recipients = new ArrayList<>(); @@ -673,9 +673,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati ally.getOnlinePlayers().forEach(recipients::add); } - String message = _chat.getFilteredMessage(event.getPlayer(), event.getMessage()); + final String filtered = _chat.getFilteredMessage(player, message); - recipients.forEach(p -> UtilPlayer.message(p, String.format(rank + C.cDGreen + clan.getName() + " " + C.cDGreen + "%s " + C.cGreen + "%s", event.getPlayer().getName(), message))); + recipients.forEach(p -> UtilPlayer.message(p, String.format(rank + C.cDGreen + clan.getName() + " " + C.cDGreen + "%s " + C.cGreen + "%s", player.getName(), filtered))); recipients.clear(); } @@ -733,11 +733,11 @@ public class ClansManager extends MiniClientPluginimplements IRelati if (client.isClanChat() && clan != null) { - handleClanChat(event, clan, rank); + handleClanChat(event.getPlayer(), event.getMessage(), clan, rank); } else if (client.isAllyChat() && clan != null) { - handleAllyChat(event, clan, rank); + handleAllyChat(event.getPlayer(), event.getMessage(), clan, rank); } else { @@ -776,22 +776,22 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void chatClan(ClanInfo clan, Player caller, String message) { - messageClan(clan, C.cAqua + caller.getName() + " " + C.cDAqua + message); + String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; + + if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + rank = ""; + + handleClanChat(caller, message, clan, rank); } public void chatAlly(ClanInfo clan, Player caller, String message) { - String sendMessage = C.cDGreen + clan.getName() + " " + C.cDGreen + caller.getName() + " " + C.cGreen + message; + String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; - messageClan(clan, sendMessage); + if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + rank = ""; - for (String allyName : clan.getAllyMap().keySet()) - { - ClanInfo ally = _clanUtility.getClanByClanName(allyName); - if (ally == null) continue; - - messageClan(ally, sendMessage); - } + handleAllyChat(caller, message, clan, rank); } public int getNameMin() 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 9860e8d5d..5ec0f6fc0 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 @@ -8,6 +8,7 @@ import java.util.List; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.account.CoreClient; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NonFinalInteger; import mineplex.core.database.DBPool; @@ -50,80 +51,32 @@ public class ClansBanRepository extends RepositoryBase public void loadBans(final String name, final Callback callback) { System.out.println(">> Attempting to load Clans Bans for \"" + name + "\""); - _manager.getClientManager().loadClientByName(name, new Runnable() { - public void run() - { - System.out.println("> Successfully loaded CoreClient"); - - executeQuery(GET_ALL_BANS, new ResultSetCallable() - { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException + loadClientByName(name, client -> { + System.out.println("> Successfully loaded CoreClient"); + + executeQuery(GET_ALL_BANS, resultSet -> { + System.out.println("> Successfully executed query, result set object: " + resultSet); + + final List list = new ArrayList(); + + while (resultSet.next()) { - System.out.println("> Successfully executed query, result set object: " + resultSet); - - final List list = new ArrayList(); - - while (resultSet.next()) - { - int id = resultSet.getInt(1); - int accountId = resultSet.getInt(2); - String reason = resultSet.getString(3); - Timestamp banTime = resultSet.getTimestamp(4); - Timestamp unbanTime = resultSet.getTimestamp(5); - boolean permanent = resultSet.getBoolean(6); - boolean removed = resultSet.getBoolean(7); - - list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); - } - - callback.run(new ClansBanClient(_manager.getClientManager().Get(name).getAccountId(), list)); - - System.out.println("> Successfully handled result"); - System.out.println(">> FINISH"); - } - }, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId())); - } - }); - } + int id = resultSet.getInt(1); + int accountId = resultSet.getInt(2); + String reason = resultSet.getString(3); + Timestamp banTime = resultSet.getTimestamp(4); + Timestamp unbanTime = resultSet.getTimestamp(5); + boolean permanent = resultSet.getBoolean(6); + boolean removed = resultSet.getBoolean(7); - public void loadBansSync(final String name, final Callback callback) - { - System.out.println(">> Attempting to load Clans Bans for \"" + name + "\""); - _manager.getClientManager().loadClientByNameSync(name, new Runnable() { - public void run() - { - System.out.println("> Successfully loaded CoreClient"); - - executeQuery(GET_ALL_BANS, new ResultSetCallable() - { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException - { - System.out.println("> Successfully executed query, result set object: " + resultSet); - - final List list = new ArrayList(); - - while (resultSet.next()) - { - int id = resultSet.getInt(1); - int accountId = resultSet.getInt(2); - String reason = resultSet.getString(3); - Timestamp banTime = resultSet.getTimestamp(4); - Timestamp unbanTime = resultSet.getTimestamp(5); - boolean permanent = resultSet.getBoolean(6); - boolean removed = resultSet.getBoolean(7); - - list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); - } - - callback.run(new ClansBanClient(_manager.getClientManager().Get(name).getAccountId(), list)); - - System.out.println("> Successfully handled result"); - System.out.println(">> FINISH"); + list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); } - }, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId())); - } + + callback.run(new ClansBanClient(client.getAccountId(), list)); + + System.out.println("> Successfully handled result"); + System.out.println(">> FINISH"); + }, new ColumnInt("accountId", client.getAccountId())); }); } @@ -134,32 +87,36 @@ public class ClansBanRepository extends RepositoryBase return; } - _manager.getClientManager().loadClientByName(name, new Runnable(){ - public void run() - { - executeQuery(GET_LONGEST_BAN, new ResultSetCallable() + loadClientByName(name, client -> { + executeQuery(GET_LONGEST_BAN, resultSet -> { + while (resultSet.next()) { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException - { - while (resultSet.next()) - { - int id = resultSet.getInt(1); - int accountId = resultSet.getInt(2); - String reason = resultSet.getString(3); - Timestamp banTime = resultSet.getTimestamp(4); - Timestamp unbanTime = resultSet.getTimestamp(5); - boolean permanent = resultSet.getBoolean(6); - boolean removed = resultSet.getBoolean(7); - - callback.run(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); - } - } - }, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId())); - } + int id = resultSet.getInt(1); + int accountId = resultSet.getInt(2); + String reason = resultSet.getString(3); + Timestamp banTime = resultSet.getTimestamp(4); + Timestamp unbanTime = resultSet.getTimestamp(5); + boolean permanent = resultSet.getBoolean(6); + boolean removed = resultSet.getBoolean(7); + + callback.run(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); + } + }, new ColumnInt("accountId", client.getAccountId())); }); } + public void loadClientByName(String name, Callback client) + { + if (_manager.getClientManager().Contains(name)) + { + client.run(_manager.getClientManager().Get(name)); + } + else + { + _manager.getClientManager().loadClientByName(name, () -> client.run(_manager.getClientManager().Get(name))); + } + } + public void loadAll(Callback> callback) { _manager.runAsync(() -> { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java index 40bebfb6e..36619c1ef 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java @@ -38,7 +38,7 @@ public class ClansChatCommand extends CommandBase if (!Plugin.Get(caller).isClanChat()) { ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); - if (clan == null) + if (clan == null) UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); else Plugin.chatClan(clan, caller, F.combine(args, 0, null, false)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 28d32055f..838565d0c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -807,7 +807,7 @@ public class ClansCommand extends CommandBase }, new Callback() { public void run(DelayedTaskClient client) { - UtilTextMiddle.display("", "Teleporting to Clan Home in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Home Teleport")))), 0, 5, 0); + UtilTextMiddle.display("", "Teleporting to Clan Home in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Home Teleport")))), 0, 5, 0, client.getPlayer()); } }, new Callback() { public void run(DelayedTaskClient client) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java index 1f9ecfdc2..1820277ad 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java @@ -65,7 +65,7 @@ public class PlayerGear { legendary.OriginalOwner = getPlayer().getUniqueId().toString(); UtilServer.broadcast(F.main("Clans", F.elem(getPlayer().getName()) + " has picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.mBody + ".")); - UtilTextMiddle.display(C.cDPurple + "Legendary", F.elem(getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.cWhite + "."); + UtilTextMiddle.display(C.cDPurple + "Legendary", F.elem(getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.cWhite + ".", 20, 60, 20); getPlayer().setItemInHand(legendary.toItemStack()); }