From 7865b1ef800c9bf4695724ed69da4fc6a60cfb76 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Jul 2016 17:37:32 +0100 Subject: [PATCH 01/89] PC-692 Allows humans in Wither Assault to place blocks anywhere so that players are not able to get stuck in the ground --- .../nautilus/game/arcade/game/games/wither/WitherGame.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java index 20e743fc8..670f13771 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java @@ -271,13 +271,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer return; } - if(event.getBlock().getLocation().getBlockY() < _maxY - 4) - { - event.getPlayer().sendMessage(F.main("BlockChecker", "You may not build under this height!")); - event.setCancelled(true); - return; - } - _locationsOfBlocks.add(event.getBlock().getLocation()); } From aae24d862ac17cbf8f052a56352d03367b949306 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Jul 2016 17:38:53 +0100 Subject: [PATCH 02/89] Revert "PC-692" This reverts commit 7865b1ef800c9bf4695724ed69da4fc6a60cfb76. --- .../nautilus/game/arcade/game/games/wither/WitherGame.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java index 670f13771..20e743fc8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java @@ -271,6 +271,13 @@ public class WitherGame extends TeamGame implements IBlockRestorer return; } + if(event.getBlock().getLocation().getBlockY() < _maxY - 4) + { + event.getPlayer().sendMessage(F.main("BlockChecker", "You may not build under this height!")); + event.setCancelled(true); + return; + } + _locationsOfBlocks.add(event.getBlock().getLocation()); } From 7940eeb0eee2e4507368c6004b3edf1d448f075d Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Jul 2016 17:49:38 +0100 Subject: [PATCH 03/89] PC-633 Allows humans in Wither Assault to place blocks under the map, allowing them to no longer get stuck --- .../nautilus/game/arcade/game/games/wither/WitherGame.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java index 20e743fc8..670f13771 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java @@ -271,13 +271,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer return; } - if(event.getBlock().getLocation().getBlockY() < _maxY - 4) - { - event.getPlayer().sendMessage(F.main("BlockChecker", "You may not build under this height!")); - event.setCancelled(true); - return; - } - _locationsOfBlocks.add(event.getBlock().getLocation()); } From c607654c51066e782c1bb757ab4aa8919fe34ee4 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Jul 2016 17:50:33 +0100 Subject: [PATCH 04/89] PC-692 Fixes an issue that allowed staff spectators to damage the King in Castle Siege --- .../game/arcade/game/games/castlesiege/CastleSiege.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index 2aced88d1..a2c6951ac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -444,6 +444,11 @@ public class CastleSiege extends TeamGame { if (!Recharge.Instance.use(damager, "Damage King", 400, false, false)) return; + + if (!IsAlive(damager)) + { + return; + } _king.playEffect(EntityEffect.HURT); From c16f9ec9ec31e60e8c14015df03eb1c9a1a1adc9 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Jul 2016 17:53:22 +0100 Subject: [PATCH 05/89] PC-688 Changes the description in Draw My Thing so that it reflects changes made to the tip system. --- .../src/nautilus/game/arcade/game/games/draw/Draw.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 8b6c61a77..20e6b50d2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -108,7 +108,7 @@ public class Draw extends SoloGame { "Take turns to draw something", "Right-Click with items to draw", - "Hints are given at top of screen", + "Hints are given at the bottom of screen", }); StrictAntiHack = true; From 42c578be9d87f78857ee544ea5f722e93b47d4cd Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Jul 2016 17:54:42 +0100 Subject: [PATCH 06/89] PC-612 Fixes an issue that removing Co-host from someone would remove their creative mode in Master Builders. --- .../src/nautilus/game/arcade/managers/GameHostManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 7e877fba7..3b3e298d6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -677,11 +677,12 @@ public class GameHostManager implements Listener player.closeInventory(); } UtilPlayer.message(player, F.main("Server", "Your Co-Host privileges were removed.")); - - player.setGameMode(GameMode.SURVIVAL); - + if (isEventServer()) + { + player.setGameMode(GameMode.SURVIVAL); worldeditPermissionSet(player, false); + } } } From 07b65ad1c95a6cf74ba2a07fd049e0731af80fc9 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Jul 2016 21:01:15 +0100 Subject: [PATCH 07/89] PC-621 Doors can now be opened in Block Hunt --- .../nautilus/game/arcade/game/games/hideseek/HideSeek.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index 55535e846..4765b99ab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -1329,6 +1329,11 @@ public class HideSeek extends TeamGame if (UtilBlock.usable(event.getClickedBlock())) event.setCancelled(true); + + if (event.getClickedBlock().getType() == Material.WOODEN_DOOR) + { + event.setCancelled(false); + } } public GameTeam getHiders() From 34565b2975dc1b65438434b509c0d7fb4fa81b59 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Jul 2016 22:09:48 +0100 Subject: [PATCH 08/89] PC-699 /bc in MPS is now protected by the filter --- .../nautilus/game/arcade/managers/GameHostManager.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 3b3e298d6..2d8ce0e93 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -426,7 +426,14 @@ public class GameHostManager implements Listener msg += event.getMessage().split(" ")[i] + " "; } msg = msg.trim(); - + + msg = Manager.GetChat().getFilteredMessage(event.getPlayer(), msg); + + if (msg == null) + { + return; + } + Bukkit.broadcastMessage(C.cDGreen + C.Bold + event.getPlayer().getName() + " " + C.cGreen + msg); } From ab9bf2f405dced16206e49c394aee857cee1c750 Mon Sep 17 00:00:00 2001 From: TadahTech Date: Thu, 28 Jul 2016 03:40:24 -0500 Subject: [PATCH 09/89] Fixes possible bug with party leaders not seeing chat. Adds pling when you received an invite. --- .../party/manager/PartyInviteManager.java | 2 + .../core/party/manager/PartyRedisManager.java | 37 +++++++++---------- .../src/mineplex/core/portal/Portal.java | 6 +++ .../src/mineplex/hub/HubManager.java | 10 +---- .../arcade/managers/chat/GameChatManager.java | 16 +++----- 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java index b05477683..bfff39b40 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java @@ -17,6 +17,7 @@ import net.md_5.bungee.api.chat.ClickEvent.Action; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; @@ -124,6 +125,7 @@ public class PartyInviteManager inviteTo(player.getUniqueId(), sender, sender, serverFrom); Lang.INVITE_RECEIVED.send(player, sender); sendAcceptOrDeny(player, sender); + player.playSound(player.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F); } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java index 4f1d01473..993fe1a5f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java @@ -139,12 +139,7 @@ public class PartyRedisManager case PLAYER_FIND_RESPONSE: UUID uuid = UUID.fromString(third); - BukkitTask task = TASKS.remove(second); - - if (task != null) - { - task.cancel(); - } + cancelTask(second); Player inviter = Bukkit.getPlayerExact(contents[3]); if (_plugin.getInviteManager().isInvitedTo(uuid, inviter.getName())) @@ -177,12 +172,7 @@ public class PartyRedisManager private void handleNotAccepting(String second, String[] contents) { - BukkitTask task = TASKS.remove(second); - - if (task != null) - { - task.cancel(); - } + cancelTask(second); Player inviter = Bukkit.getPlayerExact(contents[3]); inviter.sendMessage(F.main("Party", F.name(second) + " is not accepting invites at this time.")); @@ -190,13 +180,7 @@ public class PartyRedisManager private void handleAlreadyIn(String second, String[] contents) { - BukkitTask task = TASKS.remove(second); - - if (task != null) - { - task.cancel(); - } - + cancelTask(second); Player inviter = Bukkit.getPlayerExact(contents[3]); Lang.ALREADY_IN.send(inviter, second); } @@ -215,6 +199,11 @@ public class PartyRedisManager @Override public void run() { + if(!TASKS.containsKey(player)) + { + cancel(); + return; + } TASKS.remove(player); Player senderPlayer = Bukkit.getPlayerExact(sender); if (senderPlayer == null) @@ -293,4 +282,14 @@ public class PartyRedisManager { return FIND_PLAYERS_CHANNEL; } + + public void cancelTask(String player) + { + BukkitTask task = TASKS.remove(player); + + if (task != null) + { + task.cancel(); + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 1b02de296..0e872a0c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -9,6 +9,7 @@ import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTabTitle; +import mineplex.core.party.Lang; import mineplex.core.party.Party; import mineplex.core.party.event.PartySendToServerEvent; import mineplex.core.portal.Commands.SendCommand; @@ -101,6 +102,11 @@ public class Portal extends MiniPlugin if (event.getParty() != null && override) { Party party = event.getParty(); + if(!party.getOwner().equalsIgnoreCase(player.getName())) + { + Lang.NOT_OWNER_SERVER.send(player); + return; + } sendParty(party); return; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index c983c9cbb..88fc33b11 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -102,6 +102,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Random; +import java.util.stream.Collectors; public class HubManager extends MiniClientPlugin { @@ -601,14 +602,7 @@ public class HubManager extends MiniClientPlugin event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s"); - - for (String name : party.getMembers()) - { - Player other = UtilPlayer.searchExact(name); - - if (other != null) - event.getRecipients().add(other); - } + event.getRecipients().addAll(party.getMembersByUUID().stream().map(Bukkit::getPlayer).collect(Collectors.toList())); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java index 368746c24..00beb0a37 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -11,6 +11,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -25,6 +26,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; +import java.util.stream.Collectors; public class GameChatManager implements Listener { @@ -131,20 +133,14 @@ public class GameChatManager implements Listener event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + event.getPlayer().getName() + " " + C.cPurple + "%2$s"); - - for (String member : party.getMembers()) - { - Player other = UtilPlayer.searchExact(member); - - if (other != null) - event.getRecipients().add(other); - } + event.getRecipients().addAll(party.getMembersByUUID().stream().map(Bukkit::getPlayer).collect(Collectors.toList())); } else { - UtilPlayer.message(sender, F.main("Party", "You are not in a Party.")); + UtilPlayer.message(event.getPlayer(), F.main("Party", "You are not in a Party.")); event.setCancelled(true); } + return; } @@ -156,7 +152,7 @@ public class GameChatManager implements Listener format = event.getFormat().split(rankStr)[0]; name = _manager.GetColor(sender) + sender.getName() + C.Reset; - if (event.getMessage().charAt(0) == '@') + if (event.getMessage().charAt(0) == '#') message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage().substring(1, event.getMessage().length())); else message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage()); From f0be7794f5a3c9f132d8163f4a703153db291e3f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 06:16:20 -0400 Subject: [PATCH 10/89] Lower skeleton king passive rate --- .../game/core/boss/skeletonking/abilities/SkeletonPassive.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPassive.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPassive.java index 28577f521..b8ce6b1c2 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPassive.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPassive.java @@ -26,7 +26,7 @@ public class SkeletonPassive extends BossPassive { private static final int MAX_ARCHERS = 10; private static final int MAX_WARRIORS = 8; - private static final long SPAWN_RATE = 1000; + private static final long SPAWN_RATE = 5000; private List _queuedArchers = Lists.newArrayList(); private List _queuedWarriors = Lists.newArrayList(); private long _lastASpawned; From a498bc13dbc0261074fc0a72c69d9cc367db0369 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 28 Jul 2016 14:59:12 -0500 Subject: [PATCH 11/89] Reinstate async wrappers for clans gold access --- .../game/clans/economy/GoldRepository.java | 73 +++++++++++-------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java index ad08ef462..10fdd5270 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java @@ -1,7 +1,9 @@ package mineplex.game.clans.economy; import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilServer; import mineplex.serverdata.database.DBPool; +import org.bukkit.Bukkit; import java.sql.Connection; import java.sql.PreparedStatement; @@ -20,28 +22,32 @@ public class GoldRepository { public void rewardGold(final Callback callback, final int accountId, final int gold) { - try (Connection connection = DBPool.getAccount().getConnection()) + Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () -> { - PreparedStatement statement = connection.prepareStatement(UPDATE_ACCOUNT_GOLD); - statement.setInt(1, _serverId); - statement.setInt(2, accountId); - statement.setInt(3, gold); - statement.setInt(4, gold); - statement.executeUpdate(); - - if (callback != null) + try (Connection connection = DBPool.getAccount().getConnection()) { - callback.run(true); - } + PreparedStatement statement = connection.prepareStatement(UPDATE_ACCOUNT_GOLD); + statement.setInt(1, _serverId); + statement.setInt(2, accountId); + statement.setInt(3, gold); + statement.setInt(4, gold); + statement.executeUpdate(); - } catch (SQLException e) { - e.printStackTrace(); + if (callback != null) + { + callback.run(true); + } - if (callback != null) + } catch (SQLException e) { - callback.run(false); + e.printStackTrace(); + + if (callback != null) + { + callback.run(false); + } } - } + }); } public void setGold(final Callback callback, final int accountId, final int gold) @@ -51,26 +57,29 @@ public class GoldRepository { throw new IllegalArgumentException("gold cannot be negative"); } - try (Connection connection = DBPool.getAccount().getConnection()) + Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () -> { - PreparedStatement statement = connection.prepareStatement(SET_ACCOUNT_GOLD); - statement.setInt(1, _serverId); - statement.setInt(2, accountId); - statement.setInt(3, gold); - statement.setInt(4, gold); - statement.executeUpdate(); - if (callback != null) + try (Connection connection = DBPool.getAccount().getConnection()) { - callback.run(true); - } + PreparedStatement statement = connection.prepareStatement(SET_ACCOUNT_GOLD); + statement.setInt(1, _serverId); + statement.setInt(2, accountId); + statement.setInt(3, gold); + statement.setInt(4, gold); + statement.executeUpdate(); + if (callback != null) { + callback.run(true); + } - } catch (SQLException e) { - e.printStackTrace(); - - if (callback != null) + } catch (SQLException e) { - callback.run(false); + e.printStackTrace(); + + if (callback != null) + { + callback.run(false); + } } - } + }); } } From f3944527f8a85619e97a1ca7996b5608f093ef73 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 19:08:24 -0400 Subject: [PATCH 12/89] Display clans purchases properly in support server --- .../customerSupport/CustomerSupport.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 157226516..afbaea2d9 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -129,6 +129,8 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable int valentinesGiftsReceived = 0; int boostersReceived = 0; int freedomChestsReceived = 0; + int runeAmplifier20 = 0; + int runeAmplifier60 = 0; for (CoinTransactionToken transaction : donor.getCoinTransactions()) { @@ -227,7 +229,26 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable else if (transaction.SalesPackageName.split(" ").length == 2) boostersReceived += 1; } - + } + if (transaction.SalesPackageName.startsWith("Rune Amplifier 20")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 4) + runeAmplifier20 += Integer.parseInt(transaction.SalesPackageName.split(" ")[3]); + else if (transaction.SalesPackageName.split(" ").length == 3) + runeAmplifier20 += 1; + } + } + if (transaction.SalesPackageName.startsWith("Rune Amplifier 60")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 4) + runeAmplifier60 += Integer.parseInt(transaction.SalesPackageName.split(" ")[3]); + else if (transaction.SalesPackageName.split(" ").length == 3) + runeAmplifier60 += 1; + } } } @@ -238,6 +259,8 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Mythical Chests Received: " + C.cYellow + mythicalChestsReceived); caller.sendMessage(C.cBlue + "Illuminated Chests Received: " + C.cYellow + illuminatedChestsReceived); caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived); + caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min) Received: " + C.cYellow + runeAmplifier20); + caller.sendMessage(C.cBlue + "Rune Amplifiers (60 min) Received: " + C.cYellow + runeAmplifier60); caller.sendMessage(C.cBlue + "Freedom Chests Received: " + C.cYellow + freedomChestsReceived); caller.sendMessage(C.cBlue + "Monthly Bonus Log (Last 6 entries):"); @@ -260,6 +283,9 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Price of Freedom: " + getLockedFreedomStr(playerName, "Price of Freedom")); caller.sendMessage(C.cBlue + "Uncle Sam Hat: " + getLockedFreedomStr(playerName, "Uncle Sam Hat")); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); + caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(playerName, "Clan Banner Usage")); + caller.sendMessage(C.cBlue + "Uncle Sam Morph: " + getLockedFreedomStr(playerName, "Clan Banner Editor")); + caller.sendMessage(C.cDGreen + C.Strike + "============================================="); _accountBonusLog.remove(client.getAccountId()); } From 47d79bbad5f9527252825748be84e440d7db703f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 19:08:47 -0400 Subject: [PATCH 13/89] Fix bugs arising during clans release --- .../core/scoreboard/PlayerScoreboard.java | 55 ++++++++++--------- .../clans/clans/nether/BossNetherPortal.java | 32 +++++++++++ .../clans/clans/nether/NetherManager.java | 2 +- .../game/clans/clans/nether/NetherPortal.java | 32 +++++++++++ .../game/core/boss/EventCreature.java | 2 +- .../skeletonking/minion/WraithCreature.java | 2 +- 6 files changed, 96 insertions(+), 29 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java index 6a63bf257..272f24733 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java @@ -96,36 +96,39 @@ public class PlayerScoreboard for (int i=0 ; i i) + if ((15-i) >= 0) { - String oldLine = _currentLines.get(i); + //Get New Line + String newLine = lines.get(i); - if (oldLine.equals(newLine)) + //Check if Unchanged + if (_currentLines.size() > i) + { + String oldLine = _currentLines.get(i); + + if (oldLine.equals(newLine)) + continue; + } + + // Ignore extra lines + if (i >= _teamNames.length) continue; + + //Update + Team team = _scoreboard.getTeam(_teamNames[i]); + if (team == null) + { + System.out.println("Scoreboard Error: Line Team Not Found!"); + return; + } + + //Set Line Prefix/Suffix + team.setPrefix(newLine.substring(0, Math.min(newLine.length(), 16))); + team.setSuffix(ChatColor.getLastColors(team.getPrefix()) + newLine.substring(team.getPrefix().length(), Math.min(newLine.length(), 32))); + + //Line + _sideObjective.getScore(_teamNames[i]).setScore(15-i); } - - // Ignore extra lines - if (i >= _teamNames.length) - continue; - - //Update - Team team = _scoreboard.getTeam(_teamNames[i]); - if (team == null) - { - System.out.println("Scoreboard Error: Line Team Not Found!"); - return; - } - - //Set Line Prefix/Suffix - team.setPrefix(newLine.substring(0, Math.min(newLine.length(), 16))); - team.setSuffix(ChatColor.getLastColors(team.getPrefix()) + newLine.substring(team.getPrefix().length(), Math.min(newLine.length(), 32))); - - //Line - _sideObjective.getScore(_teamNames[i]).setScore(15-i); } //Hide Old Unused diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java index d09407609..63f6045c5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java @@ -1,9 +1,13 @@ package mineplex.game.clans.clans.nether; +import java.util.LinkedList; import java.util.List; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanTips.TipType; @@ -40,6 +44,7 @@ public class BossNetherPortal implements Listener private Location[] _corners; private boolean _returnPortal; private byte _portalFacing; + private LinkedList _closeWarnings = new LinkedList<>(); public boolean Open = false; public long Expire = -1; @@ -97,6 +102,16 @@ public class BossNetherPortal implements Listener { _portalFacing = (byte)0; } + + _closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(30000L); + _closeWarnings.add(10000L); + _closeWarnings.add(5000L); + _closeWarnings.add(4000L); + _closeWarnings.add(3000L); + _closeWarnings.add(2000L); + _closeWarnings.add(1000L); } private boolean isInPortal(Block block) @@ -261,6 +276,23 @@ public class BossNetherPortal implements Listener { return; } + if (Open && Expire != -1) + { + Long warning = -1L; + for (Long test : _closeWarnings) + { + if ((Expire - System.currentTimeMillis()) < warning) + { + warning = test; + break; + } + } + if (warning != -1) + { + _closeWarnings.remove(warning); + Bukkit.broadcastMessage(F.main(ClansManager.getInstance().getNetherManager().getName(), "The " + F.clansNether("Nether Portal") + " at " + F.elem(UtilWorld.locToStrClean(getLocation())) + " will close in " + F.elem(UtilTime.MakeStr(warning)) + "!")); + } + } if (Open && Expire != -1 && System.currentTimeMillis() >= Expire) { close(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index b872f9984..0c5c39fa7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -260,7 +260,7 @@ public class NetherManager extends MiniPlugin { return; } - BossNetherPortal portal = new BossNetherPortal(bossSpawn.clone().add(-2, 5, 0), bossSpawn.clone().add(0, 0, 2), false); + BossNetherPortal portal = new BossNetherPortal(bossSpawn.clone().add(-2, 5, 0), bossSpawn.clone().add(2, 0, 0), false); portal.open(PORTAL_OPEN_DURATION); for (NetherPortal returnPortal : _returnPortals) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java index e1ba574c0..ff220fc7a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -1,9 +1,13 @@ package mineplex.game.clans.clans.nether; +import java.util.LinkedList; import java.util.List; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanTips.TipType; @@ -41,6 +45,7 @@ public class NetherPortal implements Listener private Location[] _corners; private boolean _returnPortal; private byte _portalFacing; + private LinkedList _closeWarnings = new LinkedList<>(); public boolean Open = false; public long Expire = -1; @@ -99,6 +104,16 @@ public class NetherPortal implements Listener { _portalFacing = (byte)0; } + + _closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(30000L); + _closeWarnings.add(10000L); + _closeWarnings.add(5000L); + _closeWarnings.add(4000L); + _closeWarnings.add(3000L); + _closeWarnings.add(2000L); + _closeWarnings.add(1000L); } private boolean isInPortal(Block block) @@ -272,6 +287,23 @@ public class NetherPortal implements Listener { return; } + if (Open && Expire != -1) + { + Long warning = -1L; + for (Long test : _closeWarnings) + { + if ((Expire - System.currentTimeMillis()) < warning) + { + warning = test; + break; + } + } + if (warning != -1) + { + _closeWarnings.remove(warning); + Bukkit.broadcastMessage(F.main(ClansManager.getInstance().getNetherManager().getName(), "The " + F.clansNether("Nether Portal") + " at " + F.elem(UtilWorld.locToStrClean(getLocation())) + " will close in " + F.elem(UtilTime.MakeStr(warning)) + "!")); + } + } if (Open && Expire != -1 && System.currentTimeMillis() >= Expire) { close(); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java index 5093b0370..6746f9187 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java @@ -282,7 +282,7 @@ public abstract class EventCreature implements Listener spawnEntity(); } - if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 34) + if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 30) { if (_teleportHome != -1 && System.currentTimeMillis() >= _teleportHome) { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java index c8bc96291..6a71d40f6 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java @@ -135,7 +135,7 @@ public class WraithCreature extends EventCreature return; Location teleport = zombie.getTarget().getLocation().add(Math.random() + 1, 0, Math.random() + 1); - if (UtilMath.offset(getSpawnLocation(), teleport) > 34) + if (UtilMath.offset(getSpawnLocation(), teleport) > 30) { return; } From 3aad06cc8a6c342dc941cb4430db12195491dbac Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 19:11:14 -0400 Subject: [PATCH 14/89] Make Clans displayed as FULL instead of BETA in server compass --- .../Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index a176467a8..711602e2d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -190,7 +190,7 @@ public class ServerGameMenu extends ShopPageBase add(40, Material.IRON_DOOR, C.cYellowB + "Mineplex Clans " + C.cGray + "Factions PvP", new String[] { - (_extraValue ? C.cAquaB : C.cWhiteB) + "BETA RELEASE", + (_extraValue ? C.cAquaB : C.cWhiteB) + "FULL RELEASE", C.Reset + "", C.Reset + "Equip custom skills and builds", C.Reset + "and join your clan to destroy", From 97d5d21a55e65de5e3e1499e2d925780116de80f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 19:43:43 -0400 Subject: [PATCH 15/89] Fix lightning orb duping --- .../classcombat/Skill/Mage/LightningOrb.java | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LightningOrb.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LightningOrb.java index 027fee62a..79cbdc825 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LightningOrb.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LightningOrb.java @@ -1,31 +1,36 @@ package mineplex.minecraft.game.classcombat.Skill.Mage; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; -import org.bukkit.*; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.updater.UpdateType; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.minecraft.game.classcombat.Skill.SkillActive; +import mineplex.minecraft.game.classcombat.Skill.SkillFactory; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.event.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.core.common.util.F; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.updater.UpdateType; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.minecraft.game.classcombat.Skill.SkillActive; -import mineplex.minecraft.game.classcombat.Skill.SkillFactory; - -import org.bukkit.event.player.*; +import org.bukkit.event.player.PlayerEvent; public class LightningOrb extends SkillActive implements IThrown { @@ -99,7 +104,7 @@ public class LightningOrb extends SkillActive implements IThrown public void Skill(Player player, int level) { //Action - Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(57)); + Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()),new ItemBuilder(Material.DIAMOND_BLOCK).setTitle(UtilMath.random.nextDouble() + "").build()); item.setVelocity(player.getLocation().getDirection()); Factory.Projectile().AddThrow(item, player, this, 5000 - (400 * level), true, true, false, false, Sound.FIZZ, 0.6f, 1.6f, ParticleType.FIREWORKS_SPARK, UpdateType.TICK, 0.4f); From 16804a860ca92a2fc2f0394cd6456f072b93d4ab Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 20:22:30 -0400 Subject: [PATCH 16/89] Made duping usage for class shop impossible --- .../mineplex/game/clans/clans/ClansGame.java | 41 +++++++++++++++++++ .../game/clans/clans/siege/weapon/Cannon.java | 20 ++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index f59db05d6..8156714a2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -4,6 +4,7 @@ import java.sql.Timestamp; import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestoreData; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; @@ -23,6 +24,7 @@ import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Location; @@ -62,6 +64,25 @@ public class ClansGame extends MiniPlugin _clans = clans; } + public static boolean isDupedFromClassShop(ItemStack item) + { + if (item == null || item.getType() == Material.AIR) + { + return false; + } + if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) + { + return false; + } + String name = ChatColor.stripColor(item.getItemMeta().getDisplayName()).toUpperCase(); + if (name.contains("APPLY DEFAULT BUILD") || name.contains("APPLY BUILD") || name.contains("EDIT BUILD") || name.contains("DELETE BUILD")) + { + return true; + } + + return false; + } + @EventHandler(ignoreCancelled = true) public void openClanShop(PlayerInteractEvent event) { @@ -102,6 +123,26 @@ public class ClansGame extends MiniPlugin if (event.getBlock().getType() != Material.LADDER) return; + if (isDupedFromClassShop(event.getItemInHand())) + { + event.setCancelled(true); + for (Player p : Bukkit.getOnlinePlayers()) + { + if (ClansManager.getInstance().getClientManager().hasRank(p, Rank.HELPER)) + { + UtilPlayer.message(p, F.elem("[" + C.cRedB + "!" + C.cGray + "] ") + event.getPlayer().getName() + " just tried to use a duped item/block!"); + } + } + final int slot = event.getPlayer().getInventory().getHeldItemSlot(); + ClansManager.getInstance().runSyncLater(() -> + { + event.getPlayer().getInventory().setItem(slot, new ItemStack(Material.AIR)); + event.getPlayer().updateInventory(); + }, 1L); + + return; + } + if (_clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF) return; final Block block = event.getBlock(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java index 0dc3b7a9a..fce9ea9d2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -22,6 +23,7 @@ import org.bukkit.util.Vector; import com.google.common.collect.Lists; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -36,6 +38,8 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansGame; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; @@ -216,6 +220,7 @@ public class Cannon extends SiegeWeapon })); } + @SuppressWarnings("deprecation") @EventHandler protected void InventoryClick(InventoryClickEvent event) { @@ -224,7 +229,7 @@ public class Cannon extends SiegeWeapon return; } - if (event.getClick() == ClickType.SHIFT_RIGHT || event.getClick() == ClickType.SHIFT_RIGHT) + if (event.getClick() == ClickType.SHIFT_RIGHT || event.getClick() == ClickType.SHIFT_LEFT) { if(_inventory.getViewers().contains(event.getWhoClicked())) { @@ -282,6 +287,19 @@ public class Cannon extends SiegeWeapon { event.setCancelled(true); } + else if (event.getSlot() == _ammunitionSlot && ClansGame.isDupedFromClassShop(event.getCursor())) + { + event.setCancelled(true); + for (Player p : Bukkit.getOnlinePlayers()) + { + if (ClansManager.getInstance().getClientManager().hasRank(p, Rank.HELPER)) + { + UtilPlayer.message(p, F.elem("[" + C.cRedB + "!" + C.cGray + "] ") + event.getWhoClicked().getName() + " just tried to use a duped item/block!"); + } + } + event.setCursor(new ItemStack(Material.AIR)); + ((Player)event.getWhoClicked()).updateInventory(); + } } private void updateInventory() From 841a44b8a63d3c5f95f8cf3f64ba72c4bbb3b377 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 21:02:04 -0400 Subject: [PATCH 17/89] Make clan create button functional --- .../clans/gui/button/ClanCreateButton.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java index 39815a0f8..3b917b2e1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java @@ -1,15 +1,15 @@ package mineplex.game.clans.clans.gui.button; import mineplex.core.common.util.UtilServer; +import mineplex.core.shop.item.IButton; import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.TextComponent; + import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import mineplex.core.common.jsonchat.ClickEvent; -import mineplex.core.common.jsonchat.JsonMessage; -import mineplex.core.common.util.C; -import mineplex.core.shop.item.IButton; - public class ClanCreateButton implements IButton { public ClanCreateButton() @@ -20,6 +20,14 @@ public class ClanCreateButton implements IButton @Override public void onClick(Player player, ClickType clickType) { - UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Create)); + if (!UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Create)).isCancelled()) + { + return; + } + + TextComponent message = new TextComponent("Click Here to create a Clan!"); + message.setColor(ChatColor.AQUA); + message.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/c create ")); + player.spigot().sendMessage(message); } } From dddfb4420cac4a82cb40b5948ff78fdcaffff2a9 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 21:05:25 -0400 Subject: [PATCH 18/89] Fix players being allowed to recall through worlds --- .../minecraft/game/classcombat/Skill/Assassin/Recall.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java index 16b032c06..98e8cddaa 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java @@ -92,6 +92,9 @@ public class Recall extends Skill LinkedList health = _healthMap.remove(player); if (health == null) return; + + if (!player.getWorld().equals(locs.getLast().getWorld())) + return; Factory.runSync(() -> { if (player.isDead()) From f53503f16a900b3a74358c30b535e7237479dd61 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 21:07:29 -0400 Subject: [PATCH 19/89] Move code in sync runnable --- .../minecraft/game/classcombat/Skill/Assassin/Recall.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java index 98e8cddaa..f293f5c7f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java @@ -92,15 +92,16 @@ public class Recall extends Skill LinkedList health = _healthMap.remove(player); if (health == null) return; - - if (!player.getWorld().equals(locs.getLast().getWorld())) - return; Factory.runSync(() -> { if (player.isDead()) { return; } + if (!player.getWorld().equals(locs.getLast().getWorld())) + { + return; + } //Heal double newHealth = Math.min(health.getLast(), player.getHealth() + 3 + level); player.setHealth(newHealth); From 62e0a39ee8a28a29463a48365287eb7001315d7f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 23:28:47 -0400 Subject: [PATCH 20/89] Fix some medium graphics issues --- .../src/mineplex/game/clans/clans/ClanTips.java | 4 ++-- .../src/mineplex/game/clans/tutorial/TutorialManager.java | 3 ++- .../clans/tutorial/tutorials/clans/ClansMainTutorial.java | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java index 117d5d648..b50aa8601 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java @@ -191,14 +191,14 @@ public class ClanTips extends MiniPlugin new String[] { C.cDAquaB + "Lost War Point", C.cAqua + "You were killed by another Clan and they have gained 1 War Point against you.", - C.cAqua + "If your War Points with them reaches -20, they will get to invade your Territory, giving them full access for 15 minutes." + C.cAqua + "If your War Points with them reaches -25, they will get to besiege your Territory, giving them access to cannon it for 30 minutes." }), DOMINANCE_NOOICE( new String[] { C.cDAquaB + "Gained War Point", C.cAqua + "You killed someone in another Clan and you have gained 1 War Point against them.", - C.cAqua + "If your War Points with them reaches +20, you will get to invade their Territory, giving you full access for 15 minutes." + C.cAqua + "If your War Points with them reaches +25, you will get to besiege their Territory, giving you access to cannon it for 30 minutes." }), ENERGY( diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java index 4f9da06f8..826fbccc1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java @@ -23,6 +23,7 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.message.ClansMessageManager; import mineplex.game.clans.tutorial.command.TutorialCommand; import mineplex.game.clans.tutorial.gui.TutorialShop; +import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -48,7 +49,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement _tutorialMap = new EnumMap(TutorialType.class); _shopMap = new EnumMap(TutorialType.class); - //addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, clansManager, _clansMessageManager, hologram, npcManager, taskManager)); + addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, clansManager, _clansMessageManager, hologram, npcManager, taskManager)); chat.AddFilter(event -> { if (inTutorial(event.getPlayer())) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java index f9d21b850..804966bb3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java @@ -469,7 +469,7 @@ public class ClansMainTutorial extends Tutorial // } // }); - if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier())) + /*if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier())) { ClanInfo clan = ClansManager.getInstance().getClan(event.getPlayer()); if (clan == null) @@ -481,7 +481,7 @@ public class ClansMainTutorial extends Tutorial UtilPlayer.message(event.getPlayer(), F.main("Clans", "It seems you already have a clan here, so we can skip the tutorial")); } } - else if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld())) + else */if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld())) { Spawn.getInstance().teleport(event.getPlayer(), Spawn.getInstance().getSpawnLocation(), 2); } From 952978915976d24371f6fdea7b7e57e64796b204 Mon Sep 17 00:00:00 2001 From: TadahTech Date: Sun, 24 Jul 2016 22:20:55 -0500 Subject: [PATCH 21/89] Remove 3 second chat delay. --- .../src/mineplex/core/chat/Chat.java | 83 ++++++++----------- 1 file changed, 33 insertions(+), 50 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index effa0f484..c27c6a00a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -1,40 +1,5 @@ package mineplex.core.chat; -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.nio.charset.Charset; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; -import java.util.function.Function; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import org.apache.commons.lang3.Validate; -import org.bukkit.block.Sign; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.SignChangeEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -53,6 +18,39 @@ import mineplex.core.preferences.PreferencesManager; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.apache.commons.lang3.Validate; +import org.bukkit.block.Sign; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.SignChangeEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.nio.charset.Charset; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; +import java.util.function.Function; public class Chat extends MiniPlugin { @@ -69,7 +67,6 @@ public class Chat extends MiniPlugin private int _chatSlow = 0; private long _silenced = 0; - private boolean _threeSecondDelay = true; private List> _highPriorityFilters = new ArrayList<>(); private List> _lowPriorityFilters = new ArrayList<>(); @@ -349,15 +346,6 @@ public class Chat extends MiniPlugin event.setCancelled(true); return; } - else if (_threeSecondDelay && - _clientManager.Get(sender).GetRank() == Rank.ALL && - _achievements.getMineplexLevelNumber(sender, Rank.ALL) < 25 && - !Recharge.Instance.use(sender, "All Chat Message", 3000, false, false)) - { - UtilPlayer.message(sender, C.cYellow + "You can only chat once every 3 seconds to prevent spam."); - UtilPlayer.message(sender, C.cYellow + "Buy a Rank at " + C.cGreen + "www.mineplex.com/shop" + C.cYellow + " to remove this limit!"); - event.setCancelled(true); - } else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) && !Recharge.Instance.use(sender, "Chat Message", 400, false, false)) { @@ -645,11 +633,6 @@ public class Chat extends MiniPlugin _playerLastMessage.remove(event.getPlayer().getUniqueId()); } - public void setThreeSecondDelay(boolean b) - { - _threeSecondDelay = b; - } - /** * If the function returns Boolean.TRUE then the message will be CANCELLED. */ From 96e0625548d197635326f93398404374a4bbf4f3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 29 Jul 2016 03:15:22 -0400 Subject: [PATCH 22/89] Fix mislabeling of shop item in user display --- .../mineplex/staffServer/customerSupport/CustomerSupport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index afbaea2d9..d64184f6c 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -284,7 +284,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Uncle Sam Hat: " + getLockedFreedomStr(playerName, "Uncle Sam Hat")); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(playerName, "Clan Banner Usage")); - caller.sendMessage(C.cBlue + "Uncle Sam Morph: " + getLockedFreedomStr(playerName, "Clan Banner Editor")); + caller.sendMessage(C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(playerName, "Clan Banner Editor")); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); _accountBonusLog.remove(client.getAccountId()); From ecb56bf450db516a6e6de96e8a48071a94fcdd02 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 29 Jul 2016 13:35:09 -0400 Subject: [PATCH 23/89] Fix players being able to use de-blink to teleport between worlds --- .../minecraft/game/classcombat/Skill/Assassin/Blink.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java index 2a87b1c30..2da9df000 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java @@ -170,6 +170,12 @@ public class Blink extends SkillActive public void Deblink(Player player, int level) { + Location target = _loc.remove(player); + if (!player.getWorld().equals(target.getWorld())) + { + UtilPlayer.message(player, F.main(GetClassType().name(), "You cannot use " + F.skill("De-Blink") + " between worlds!")); + return; + } UtilPlayer.message(player, F.main(GetClassType().name(), "You used " + F.skill("De-Blink") + ".")); //Smoke Trail @@ -177,8 +183,6 @@ public class Blink extends SkillActive double curRange = 0; - Location target = _loc.remove(player); - boolean done = false; while (!done) { From 9e2ba8c65327de1ff53acaaa7e0a0ced53b52c50 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 30 Jul 2016 09:36:38 -0400 Subject: [PATCH 24/89] Fix fissure applying to anvils --- .../minecraft/game/classcombat/Skill/Mage/FissureData.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java index 8fd59a6d1..e61fd8892 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java @@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent; import org.bukkit.Effect; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -133,6 +134,10 @@ public class FissureData return false; if (block.getRelative(BlockFace.UP).getType().toString().contains("BANNER")) return false; + if (block.getType() == Material.ANVIL) + return false; + if (block.getRelative(BlockFace.UP).getType() == Material.ANVIL) + return false; Block up = block.getRelative(0, _height + 1, 0); From d1d366dcf85b64cba50ca1c7de46fa1813397fb4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 30 Jul 2016 09:46:02 -0400 Subject: [PATCH 25/89] Add a cooldown to clans shops to reduce chance of edge-case negative gold balances --- .../src/mineplex/game/clans/shop/ShopItemButton.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java index 9ea38cf70..1737e68d3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java @@ -15,6 +15,7 @@ import mineplex.core.common.util.InventoryUtil; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ShopPageBase; import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; @@ -57,6 +58,10 @@ public class ShopItemButton> implements IButton @Override public void onClick(final Player player, ClickType clickType) { + if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false)) + { + return; + } boolean shiftClick = (clickType == ClickType.SHIFT_LEFT || clickType == ClickType.SHIFT_RIGHT); if (clickType == ClickType.SHIFT_RIGHT || clickType == ClickType.RIGHT) From fe926338020f766d5b4429b3dc9401e979a6cc9e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 30 Jul 2016 16:49:39 -0400 Subject: [PATCH 26/89] Add claim limit override for admin claiming --- .../src/mineplex/game/clans/clans/ClansAdmin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1c11b514b..33962eb48 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 @@ -771,7 +771,7 @@ public class ClansAdmin if (clientClan.getClaims() >= clientClan.getClaimsMax()) { - UtilPlayer.message(caller, F.main("Clans Admin", "Your Clan cannot claim more Territory.")); + UtilPlayer.message(caller, F.main("Clans Admin", "You have claimed for that clan past their normal limit.")); return; } From 2d39dbfb587f237e6db98ab88865c20ecab31765 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 30 Jul 2016 17:34:03 -0400 Subject: [PATCH 27/89] Move clans admin text --- .../src/mineplex/game/clans/clans/ClansAdmin.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 33962eb48..3b8c45896 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 @@ -767,13 +767,7 @@ public class ClansAdmin ClanInfo clientClan = getMimic(caller, true); if (clientClan == null) - return; - - if (clientClan.getClaims() >= clientClan.getClaimsMax()) - { - UtilPlayer.message(caller, F.main("Clans Admin", "You have claimed for that clan past their normal limit.")); return; - } String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation()); @@ -788,8 +782,12 @@ public class ClansAdmin //Task Clans.getClanDataAccess().claim(clientClan.getName(), chunk, caller.getName(), false); - + //Inform + if (clientClan.getClaims() >= clientClan.getClaimsMax()) + { + UtilPlayer.message(caller, F.main("Clans Admin", "You have claimed for that clan past their normal limit.")); + } UtilPlayer.message(caller, F.main("Clans Admin", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".")); clientClan.inform(caller.getName() + " claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName()); } From d12d353c20ef2d9c7740902c95104c3717a3de1c Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 30 Jul 2016 17:36:03 -0400 Subject: [PATCH 28/89] Fix pronoun in message autoreply --- .../Mineplex.Core/src/mineplex/core/message/MessageManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index cc1c8d686..daac3f231 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -218,7 +218,7 @@ public class MessageManager extends MiniClientPlugin if (GetClientManager().Get(to).GetRank() == Rank.DEVELOPER) { UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); - UtilPlayer.message(from, C.cPurple + "Please be patient if she does not reply instantly."); + UtilPlayer.message(from, C.cPurple + "Please be patient if they do not reply instantly."); } // Log From cd237b8d3b2a58ad7044107fa625b9db54f40def Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 30 Jul 2016 17:42:57 -0400 Subject: [PATCH 29/89] Make players teleport to shops once they return to the nether --- .../src/mineplex/game/clans/clans/nether/BossNetherPortal.java | 1 - .../src/mineplex/game/clans/clans/nether/NetherManager.java | 2 +- .../src/mineplex/game/clans/clans/nether/NetherPortal.java | 1 - .../game/clans/clans/nether/command/ForceTeleportCommand.java | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java index 63f6045c5..3c44bcb40 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java @@ -250,7 +250,6 @@ public class BossNetherPortal implements Listener { ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); Location from = event.getEntity().getLocation(); - ClansManager.getInstance().getNetherManager().OverworldOrigins.put((Player)event.getEntity(), from); event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 0c5c39fa7..0fb01e99e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -155,7 +155,7 @@ public class NetherManager extends MiniPlugin */ public Location getReturnLocation(Player player) { - return OverworldOrigins.getOrDefault(player, Spawn.getNorthSpawn()); + return OverworldOrigins.getOrDefault(player, Spawn.getWestTown()); } /** diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java index ff220fc7a..828bc2274 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -261,7 +261,6 @@ public class NetherPortal implements Listener { ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); Location from = event.getEntity().getLocation(); - ClansManager.getInstance().getNetherManager().OverworldOrigins.put((Player)event.getEntity(), from); event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java index 18ce12cc1..e798412a0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java @@ -54,7 +54,6 @@ public class ForceTeleportCommand extends CommandBase if (natural) { Plugin.InNether.put(caller, System.currentTimeMillis() + UtilTime.convert(10, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); - Plugin.OverworldOrigins.put(caller, caller.getLocation()); caller.teleport(Plugin.getNetherWorld().getSpawnLocation()); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, caller); } From 4fdbb1fc9dd8cccd130521b017be99b79cb8f4d9 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 1 Aug 2016 14:48:44 -0400 Subject: [PATCH 30/89] Fix assorted bugs --- .../game/clans/clans/ClansManager.java | 3 + .../clans/clans/banners/BannerManager.java | 127 +++++++++++++----- .../clans/invsee/ui/InvseeInventory.java | 13 +- .../clans/clans/nether/BossNetherPortal.java | 25 ++-- .../clans/clans/nether/NetherManager.java | 59 ++++---- .../game/clans/clans/nether/NetherPortal.java | 27 ++-- .../nether/command/ForceTeleportCommand.java | 4 + .../game/clans/economy/GoldManager.java | 27 +++- 8 files changed, 190 insertions(+), 95 deletions(-) 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 03a19b238..7736952a9 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 @@ -1192,6 +1192,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati _worldEvent.onDisable(); _goldManager.onDisable(); _playTracker.onDisable(); + _bannerManager.onDisable(); + _amplifierManager.onDisable(); + _netherManager.onDisable(); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java index ec022d057..d613f2939 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java @@ -2,21 +2,6 @@ package mineplex.game.clans.clans.banners; import java.util.HashMap; -import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.banners.command.BannerCommand; -import mineplex.game.clans.core.repository.ClanTerritory; - import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Banner; @@ -25,18 +10,36 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.inventory.CraftItemEvent; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.command.BannerCommand; +import mineplex.game.clans.core.repository.ClanTerritory; +import net.minecraft.server.v1_8_R3.MinecraftServer; + /** * Manager class for cosmetic clans banners */ public class BannerManager extends MiniPlugin { - private static final long BANNER_PLACE_DURATION = UtilTime.convert(30, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); public final HashMap LoadedBanners = new HashMap<>(); - private final HashMap _placedBanners = new HashMap<>(); + private final BlockFace[] _radial = { BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST }; private BannerRepository _repo; public BannerManager(JavaPlugin plugin) @@ -48,18 +51,6 @@ public class BannerManager extends MiniPlugin addCommand(new BannerCommand(this)); } - /** - * Resets all placed banners to air - */ - @Override - public void disable() - { - for (Block changed : _placedBanners.keySet()) - { - changed.setType(Material.AIR); - } - } - /** * Checks what type of banner unlock a player has * @param player The player to check @@ -149,8 +140,17 @@ public class BannerManager extends MiniPlugin Banner state = (Banner) block.getState(); state.setBaseColor(banner.getBaseColor()); state.setPatterns(((BannerMeta)banner.getBanner().getItemMeta()).getPatterns()); + org.bukkit.material.Banner data = (org.bukkit.material.Banner) state.getData(); + try + { + data.setFacingDirection(_radial[Math.round(placing.getLocation().getYaw() / 45f) & 0x7]); + } + catch (Exception e) + { + e.printStackTrace(); + } + state.setData(data); state.update(); - _placedBanners.put(block, System.currentTimeMillis()); } else { @@ -163,26 +163,79 @@ public class BannerManager extends MiniPlugin @EventHandler public void onBreak(BlockBreakEvent event) { - if (_placedBanners.containsKey(event.getBlock())) + if (event.getBlock().getType() == Material.STANDING_BANNER || event.getBlock().getType() == Material.WALL_BANNER) { - _placedBanners.remove(event.getBlock()); event.setCancelled(true); event.getBlock().setType(Material.AIR); } } @EventHandler - public void onUpdate(UpdateEvent event) + public void onDropBanner(BlockPhysicsEvent event) { - if (event.getType() == UpdateType.FAST) + if (event.getBlock().getType() == Material.STANDING_BANNER || event.getBlock().getType() == Material.WALL_BANNER) { - for (Block reset : _placedBanners.keySet()) + event.setCancelled(true); + } + } + + @EventHandler + public void onCraftBanner(PrepareItemCraftEvent event) + { + if (event.getInventory().getResult() == null || event.getInventory().getResult().getType() != Material.BANNER) + { + return; + } + + event.getInventory().setResult(null); + } + + @EventHandler + public void onCraftBanner(CraftItemEvent event) + { + if (event.getInventory().getResult() == null || event.getInventory().getResult().getType() != Material.BANNER) + { + return; + } + + event.setCancelled(true); + } + + @EventHandler + public void onJoinWithBanner(PlayerJoinEvent event) + { + if (MinecraftServer.getServer().recentTps[0] < 19) + { + return; + } + runSyncLater(() -> + { + for (ItemStack item : event.getPlayer().getInventory().getContents()) { - if (UtilTime.elapsed(_placedBanners.get(reset), BANNER_PLACE_DURATION)) + if (item != null && item.getType() == Material.BANNER) { - reset.setType(Material.AIR); + event.getPlayer().getInventory().remove(item); } } + }, 20); + } + + @EventHandler + public void onPickupBanner(PlayerPickupItemEvent event) + { + if (event.getItem().getItemStack().getType() == Material.BANNER) + { + event.setCancelled(true); + event.getItem().remove(); + } + } + + @EventHandler + public void onPickupBanner(PlayerDropItemEvent event) + { + if (event.getItemDrop().getItemStack().getType() == Material.BANNER) + { + event.getItemDrop().remove(); } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java index 69283e71a..61fcf7cd7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java @@ -110,17 +110,20 @@ public class InvseeInventory implements Listener else { // This should always work - _targetPlayer = Bukkit.getOfflinePlayer(_uuid); - updateInventory(); + if (_uuid.equals(event.getPlayer().getUniqueId())) + { + _targetPlayer = Bukkit.getOfflinePlayer(_uuid); + updateInventory(); + } } } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void on(InventoryOpenEvent event) { - if (event.getPlayer().getUniqueId().equals(_targetPlayer.getUniqueId()) && !_canOpenInventory) + if (event.getPlayer().getUniqueId().equals(_uuid) && !_canOpenInventory) { - event.setCancelled(true); + Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> {event.getPlayer().closeInventory();}, 20); } } @@ -295,7 +298,7 @@ public class InvseeInventory implements Listener } } - /* + /** * Update the player inventory and invsee inventory. * * @param targetClick If true, then it means the player being invseen has modified their inventory. Otherwise, it's the admin who has modified something diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java index 3c44bcb40..815897c4e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java @@ -102,16 +102,6 @@ public class BossNetherPortal implements Listener { _portalFacing = (byte)0; } - - _closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); - _closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); - _closeWarnings.add(30000L); - _closeWarnings.add(10000L); - _closeWarnings.add(5000L); - _closeWarnings.add(4000L); - _closeWarnings.add(3000L); - _closeWarnings.add(2000L); - _closeWarnings.add(1000L); } private boolean isInPortal(Block block) @@ -177,6 +167,15 @@ public class BossNetherPortal implements Listener block.setType(Material.PORTAL); block.setData(_portalFacing); } + _closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(30000L); + _closeWarnings.add(10000L); + _closeWarnings.add(5000L); + _closeWarnings.add(4000L); + _closeWarnings.add(3000L); + _closeWarnings.add(2000L); + _closeWarnings.add(1000L); } } @@ -196,6 +195,7 @@ public class BossNetherPortal implements Listener block.setType(Material.AIR); } HandlerList.unregisterAll(this); + _closeWarnings.clear(); } @EventHandler(priority = EventPriority.HIGHEST) @@ -245,11 +245,14 @@ public class BossNetherPortal implements Listener ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); ((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + ClansManager.getInstance().runSyncLater(() -> + { + ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis()); + }, 20); } else { ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); - Location from = event.getEntity().getLocation(); event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 0fb01e99e..9f139f30e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -4,6 +4,32 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.WorldBorder; +import org.bukkit.WorldCreator; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityPortalEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import com.google.common.collect.Lists; + import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; import mineplex.core.common.generator.VoidGenerator; @@ -31,32 +57,6 @@ import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.WorldBorder; -import org.bukkit.WorldCreator; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityPortalEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerPortalEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import com.google.common.collect.Lists; - /** * Manager for all nether features */ @@ -155,7 +155,12 @@ public class NetherManager extends MiniPlugin */ public Location getReturnLocation(Player player) { - return OverworldOrigins.getOrDefault(player, Spawn.getWestTown()); + Location defaultLoc = Spawn.getWestTown(); + if (UtilMath.random.nextDouble() <= .5) + { + defaultLoc = Spawn.getEastTown(); + } + return OverworldOrigins.getOrDefault(player, defaultLoc); } /** diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java index 828bc2274..2e3ea55d4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -104,16 +104,6 @@ public class NetherPortal implements Listener { _portalFacing = (byte)0; } - - _closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); - _closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); - _closeWarnings.add(30000L); - _closeWarnings.add(10000L); - _closeWarnings.add(5000L); - _closeWarnings.add(4000L); - _closeWarnings.add(3000L); - _closeWarnings.add(2000L); - _closeWarnings.add(1000L); } private boolean isInPortal(Block block) @@ -188,6 +178,15 @@ public class NetherPortal implements Listener block.setType(Material.PORTAL); block.setData(_portalFacing); } + _closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(30000L); + _closeWarnings.add(10000L); + _closeWarnings.add(5000L); + _closeWarnings.add(4000L); + _closeWarnings.add(3000L); + _closeWarnings.add(2000L); + _closeWarnings.add(1000L); } } @@ -207,6 +206,7 @@ public class NetherPortal implements Listener block.setType(Material.AIR); } HandlerList.unregisterAll(this); + _closeWarnings.clear(); } @EventHandler(priority = EventPriority.HIGHEST) @@ -256,11 +256,14 @@ public class NetherPortal implements Listener ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); ((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + ClansManager.getInstance().runSyncLater(() -> + { + ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis()); + }, 20); } else { ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); - Location from = event.getEntity().getLocation(); event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); } @@ -291,7 +294,7 @@ public class NetherPortal implements Listener Long warning = -1L; for (Long test : _closeWarnings) { - if ((Expire - System.currentTimeMillis()) < warning) + if ((Expire - System.currentTimeMillis()) < test) { warning = test; break; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java index e798412a0..0bc4ac0be 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java @@ -43,6 +43,10 @@ public class ForceTeleportCommand extends CommandBase Plugin.OverworldOrigins.remove(caller); caller.removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(caller, F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + ClansManager.getInstance().runSyncLater(() -> + { + ClansManager.getInstance().getCombatManager().Get(caller).SetLastCombatEngaged(System.currentTimeMillis()); + }, 20); } else { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java index fdd40a847..0979e7148 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -398,20 +398,41 @@ public class GoldManager extends MiniDbClientPlugin @Override - public String getQuery(int accountId, String uuid, String name) { + public String getQuery(int accountId, String uuid, String name) + { return "SELECT gold FROM clansGold WHERE id = '" + accountId + "' AND serverId=" + _serverId + ";"; } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + { if (resultSet.next()) { Get(playerName).setBalance(resultSet.getInt(1)); + + if (resultSet.getInt(1) < 0) + { + setGold(new Callback() + { + public void run(Boolean success) + { + if (success) + { + System.out.println("Fixed negative gold balance for " + playerName + "!"); + } + else + { + System.out.println("Failed to fix negative gold balance for " + playerName + "!"); + } + } + }, "", playerName, accountId, 0, true); + } } } @Override - protected GoldData addPlayer(String player) { + protected GoldData addPlayer(String player) + { return new GoldData(); } } From dad453bd844b2d87962d14eef692f88c675f9f6b Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 2 Aug 2016 11:42:16 +1000 Subject: [PATCH 31/89] Remove Sentry - Unused --- Plugins/Mineplex.Bungee.Mineplexer/pom.xml | 4 ---- .../src/mineplex/bungee/Mineplexer.java | 19 ------------------- 2 files changed, 23 deletions(-) diff --git a/Plugins/Mineplex.Bungee.Mineplexer/pom.xml b/Plugins/Mineplex.Bungee.Mineplexer/pom.xml index b32fcf94a..4b46f2b44 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/pom.xml +++ b/Plugins/Mineplex.Bungee.Mineplexer/pom.xml @@ -28,10 +28,6 @@ commons-codec commons-codec - - net.kencochrane.raven - raven - net.md-5 bungeecord-proxy diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java index e780804a7..91039533d 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java @@ -1,35 +1,16 @@ package mineplex.bungee; -import java.util.logging.Handler; -import java.util.logging.Level; import mineplex.bungee.lobbyBalancer.LobbyBalancer; import mineplex.bungee.motd.MotdManager; import mineplex.bungee.playerCount.PlayerCount; import mineplex.bungee.playerStats.PlayerStats; import mineplex.bungee.playerTracker.PlayerTracker; -import net.kencochrane.raven.DefaultRavenFactory; -import net.kencochrane.raven.dsn.Dsn; -import net.kencochrane.raven.jul.SentryHandler; import net.md_5.bungee.api.plugin.Plugin; public class Mineplexer extends Plugin { @Override public void onEnable() { - getProxy().getScheduler().runAsync(this, new Runnable() - { - @Override - public void run() - { - // Sentry setup - Handler sentry = new SentryHandler(new DefaultRavenFactory().createRavenInstance( - new Dsn("https://470f12378af3453ba089e0c0a0c9aae6:292516b722594784807aebb06db8ec38@app.getsentry.com/66323" - ))); - sentry.setLevel(Level.SEVERE); - getProxy().getLogger().addHandler(sentry); - } - }); - new MotdManager(this); new LobbyBalancer(this); new PlayerCount(this); From f41cd8c104c98c5aaf9834d82b6a199cc6f30fe5 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 2 Aug 2016 00:10:46 -0500 Subject: [PATCH 32/89] Add /thank command. Update jooq files --- .../mineplex/core/bonuses/BonusManager.java | 19 +- .../core/bonuses/commands/GuiCommand.java | 3 +- .../mineplex/core/bonuses/gui/BonusGui.java | 6 +- .../bonuses/gui/buttons/ClaimTipsButton.java | 20 +- .../src/mineplex/core/chat/Chat.java | 2 +- .../mineplex/core/thank/ClaimThankResult.java | 26 ++ .../src/mineplex/core/thank/ThankData.java | 19 + .../src/mineplex/core/thank/ThankManager.java | 142 ++++++ .../mineplex/core/thank/ThankRepository.java | 62 +++ .../src/mineplex/core/thank/ThankResult.java | 14 + .../core/thank/command/ThankCommand.java | 65 +++ .../src/mineplex/database/Account.java | 15 +- .../src/mineplex/database/Keys.java | 46 +- .../src/mineplex/database/Routines.java | 26 ++ .../src/mineplex/database/Tables.java | 55 ++- .../mineplex/database/routines/AddThank.java | 106 +++++ .../database/routines/ClaimThank.java | 67 +++ .../database/tables/AccountThank.java | 104 +++++ .../tables/AccountThankTransactions.java | 147 ++++++ .../tables/AccountWebsiteLinkCode.java | 109 +++++ .../mineplex/database/tables/ClanBanners.java | 101 ++++ .../mineplex/database/tables/ClansGold.java | 109 +++++ .../database/tables/ClansNetherPortals.java | 114 +++++ .../database/tables/Kit_progression.java | 116 ----- .../tables/NonPremiumJoinMessage.java | 75 +++ .../database/tables/PowerPlayClub.java | 109 +++++ .../database/tables/Unicodereplacer.java | 119 +++++ .../src/mineplex/database/tables/Youtube.java | 112 +++++ .../tables/records/AccountThankRecord.java | 159 +++++++ .../AccountThankTransactionsRecord.java | 439 ++++++++++++++++++ .../records/AccountWebsiteLinkCodeRecord.java | 199 ++++++++ .../tables/records/ClanBannersRecord.java | 199 ++++++++ .../tables/records/ClansGoldRecord.java | 199 ++++++++ .../records/ClansNetherPortalsRecord.java | 239 ++++++++++ .../tables/records/Kit_progressionRecord.java | 319 ------------- .../records/NonPremiumJoinMessageRecord.java | 107 +++++ .../tables/records/PowerPlayClubRecord.java | 199 ++++++++ .../tables/records/UnicodereplacerRecord.java | 279 +++++++++++ .../tables/records/YoutubeRecord.java | 159 +++++++ .../src/mineplex/clanshub/ClansHub.java | 4 +- .../src/mineplex/clanshub/HubManager.java | 5 +- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 4 +- .../src/mineplex/hub/HubManager.java | 5 +- .../hub/modules/valentines/Courtship.java | 2 +- .../src/nautilus/game/arcade/Arcade.java | 4 +- .../nautilus/game/arcade/ArcadeManager.java | 5 +- .../arcade/game/games/cards/CardFactory.java | 2 +- 47 files changed, 3955 insertions(+), 481 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/thank/ClaimThankResult.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/thank/ThankData.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/thank/ThankRepository.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/thank/ThankResult.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/routines/AddThank.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/routines/ClaimThank.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThank.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThankTransactions.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/AccountWebsiteLinkCode.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/ClanBanners.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/ClansGold.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/ClansNetherPortals.java delete mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/Kit_progression.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/NonPremiumJoinMessage.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/PowerPlayClub.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/Unicodereplacer.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/Youtube.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankRecord.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankTransactionsRecord.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountWebsiteLinkCodeRecord.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClanBannersRecord.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansGoldRecord.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansNetherPortalsRecord.java delete mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/Kit_progressionRecord.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/NonPremiumJoinMessageRecord.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/PowerPlayClubRecord.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/UnicodereplacerRecord.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/YoutubeRecord.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index f31e9ce0a..52ee5f2f9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -14,7 +14,6 @@ import mineplex.core.bonuses.gui.BonusGui; import mineplex.core.bonuses.gui.SpinGui; import mineplex.core.bonuses.redis.VoteHandler; import mineplex.core.bonuses.redis.VotifierCommand; -import mineplex.core.boosters.BoosterManager; import mineplex.core.common.Rank; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -35,6 +34,7 @@ import mineplex.core.recharge.Recharge; import mineplex.core.reward.RewardManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; +import mineplex.core.thank.ThankManager; import mineplex.core.treasure.TreasureType; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -123,7 +123,7 @@ public class BonusManager extends MiniClientPlugin implements I private StatsManager _statsManager; private FacebookManager _facebookManager; private YoutubeManager _youtubeManager; - private BoosterManager _boosterManager; + private ThankManager _thankManager; public boolean _enabled; private Npc _carlNpc; private AnimationCarl _animation; @@ -162,7 +162,7 @@ public class BonusManager extends MiniClientPlugin implements I updateOffSet(); } - public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, YoutubeManager youtubeManager, GadgetManager gadgetManager, BoosterManager boosterManager) + public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, YoutubeManager youtubeManager, GadgetManager gadgetManager, ThankManager thankManager) { super("Bonus", plugin); _repository = new BonusRepository(plugin, this, donationManager); @@ -171,7 +171,7 @@ public class BonusManager extends MiniClientPlugin implements I _npcManager = npcManager; _hologramManager = hologramManager; _inventoryManager = inventoryManager; - _boosterManager = boosterManager; + _thankManager = thankManager; _rewardManager = new RewardManager(_clientManager, _donationManager, _inventoryManager, petManager, statsManager, gadgetManager); @@ -825,7 +825,7 @@ public class BonusManager extends MiniClientPlugin implements I if (entity.equals(_carlNpc.getEntity())) { updateDailyStreak(event.getPlayer()); - new BonusGui(_plugin, event.getPlayer(), this, _rewardManager, _facebookManager, _youtubeManager, _boosterManager).openInventory(); + new BonusGui(_plugin, event.getPlayer(), this, _rewardManager, _facebookManager, _youtubeManager, _thankManager).openInventory(); } } @@ -841,7 +841,7 @@ public class BonusManager extends MiniClientPlugin implements I if (event.getEntity().equals(_carlNpc.getEntity())) { updateDailyStreak(player); - new BonusGui(_plugin, player, this, _rewardManager, _facebookManager, _youtubeManager, _boosterManager).openInventory(); + new BonusGui(_plugin, player, this, _rewardManager, _facebookManager, _youtubeManager, _thankManager).openInventory(); } } } @@ -908,7 +908,7 @@ public class BonusManager extends MiniClientPlugin implements I if (canDaily(player)) availableRewards++; if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++; if (!_facebookManager.hasRedeemed(player)) availableRewards++; - if (_boosterManager.getTipManager().Get(player).getTips() > 0) availableRewards++; + if (_thankManager.Get(player).getThankToClaim() > 0) availableRewards++; Hologram hologram; @@ -1194,8 +1194,9 @@ public class BonusManager extends MiniClientPlugin implements I return "SELECT * FROM bonus WHERE accountId = '" + accountId + "';"; } - public BoosterManager getBoosterManager() + public ThankManager getThankManager() { - return _boosterManager; + return _thankManager; } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java index 649f964e3..7ed6615fd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java @@ -1,6 +1,5 @@ package mineplex.core.bonuses.commands; -import mineplex.core.boosters.BoosterManager; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; @@ -18,7 +17,7 @@ public class GuiCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager(), Plugin.getYoutubeManager(), Plugin.getBoosterManager()).openInventory(); + new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager(), Plugin.getYoutubeManager(), Plugin.getThankManager()).openInventory(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java index a8fef8c82..d5beff79e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java @@ -2,10 +2,10 @@ package mineplex.core.bonuses.gui; import mineplex.core.bonuses.BonusManager; import mineplex.core.bonuses.gui.buttons.*; -import mineplex.core.boosters.BoosterManager; import mineplex.core.facebook.FacebookManager; import mineplex.core.gui.SimpleGui; import mineplex.core.reward.RewardManager; +import mineplex.core.thank.ThankManager; import mineplex.core.youtube.YoutubeManager; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -15,7 +15,7 @@ public class BonusGui extends SimpleGui private BonusManager manager; - public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager, FacebookManager facebookManager, YoutubeManager youtubeManager, BoosterManager boosterManager) + public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager, FacebookManager facebookManager, YoutubeManager youtubeManager, ThankManager thankManager) { super(plugin, player, player.getName() + "'s Bonuses", 5 * 9); @@ -35,7 +35,7 @@ public class BonusGui extends SimpleGui setItem(23, new TwitterButton(player)); - setItem(25, new ClaimTipsButton(getPlugin(), player, this, manager, boosterManager)); + setItem(25, new ClaimTipsButton(getPlugin(), player, this, manager, thankManager)); setItem(31, new CarlSpinButton(getPlugin(), player, manager, rewardManager)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java index e8a3d062d..95430a8d4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java @@ -1,7 +1,6 @@ package mineplex.core.bonuses.gui.buttons; import mineplex.core.bonuses.BonusManager; -import mineplex.core.boosters.BoosterManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -12,6 +11,7 @@ import mineplex.core.gui.pages.LoadingWindow; import mineplex.core.gui.pages.TimedMessageWindow; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.shop.item.ShopItem; +import mineplex.core.thank.ThankManager; import org.bukkit.*; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; @@ -31,12 +31,12 @@ public class ClaimTipsButton implements GuiItem, Listener private ItemRefresher _gui; private BonusManager _bonusManager; - private BoosterManager _boosterManager; + private ThankManager _thankManager; - public ClaimTipsButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager, BoosterManager boosterManager) + public ClaimTipsButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager, ThankManager thankManager) { _bonusManager = bonusManager; - _boosterManager = boosterManager; + _thankManager = thankManager; _player = player; _plugin = plugin; _gui = gui; @@ -62,8 +62,8 @@ public class ClaimTipsButton implements GuiItem, Listener _item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing..."); refreshItem(); new LoadingWindow(getPlugin(), getPlayer(), 6*9); - _boosterManager.getTipManager().claimTips(getPlayer(), claimed -> { - if (claimed > 0) + _thankManager.claimThanks(getPlayer(), claimThankResult -> { + if (claimThankResult != null && claimThankResult.getClaimed() > 0) { // Woo, success! setItem(); @@ -73,17 +73,17 @@ public class ClaimTipsButton implements GuiItem, Listener new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Amplifier Thanks Collected"), "Thanks Collected", 6*9, 20*3, getGui()).openInventory(); } - UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(GlobalCurrency.TREASURE_SHARD, claimed) + " from Amplifiers!")); + UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(GlobalCurrency.TREASURE_SHARD, claimThankResult.getClaimed()) + " from " + F.elem(claimThankResult.getUniqueThanks()) + "players thanking you!")); // Pending explosions are strange.. Not sure why we are using strings. Either way, lets display a rank reward effect _bonusManager.addPendingExplosion(getPlayer(), "RANK"); getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); } - else if (claimed == 0) + else if (claimThankResult != null && claimThankResult.getClaimed() == 0) { // No tips to claim if (getPlayer().getOpenInventory() != null) { - new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "No Thanks to Claim!"), "You have no thanks to claim!", 6*9, 20*3, getGui()).openInventory(); + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "No Thanks to Claim!"), "You have no thank to claim!", 6*9, 20*3, getGui()).openInventory(); } UtilPlayer.message(getPlayer(), F.main("Carl", "You have no rewards to claim!")); @@ -153,7 +153,7 @@ public class ClaimTipsButton implements GuiItem, Listener private int getTips() { - return _boosterManager.getTipManager().Get(getPlayer()).getTips(); + return _thankManager.Get(_player).getThankToClaim(); } private boolean isAvailable() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index effa0f484..e24ba15b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -287,7 +287,7 @@ public class Chat extends MiniPlugin if (response == null) { - System.out.println("[ERROR] Unable to filter chat message...thanks a lot CleanSpeak."); + System.out.println("[ERROR] Unable to filter chat message...thank a lot CleanSpeak."); return originalMessage; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ClaimThankResult.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ClaimThankResult.java new file mode 100644 index 000000000..c57c977da --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ClaimThankResult.java @@ -0,0 +1,26 @@ +package mineplex.core.thank; + +/** + * @author Shaun Bennett + */ +public class ClaimThankResult +{ + private final int _claimed; + private final int _uniqueThanks; + + public ClaimThankResult(int claimed, int uniqueThanks) + { + _claimed = claimed; + _uniqueThanks = uniqueThanks; + } + + public int getClaimed() + { + return _claimed; + } + + public int getUniqueThanks() + { + return _uniqueThanks; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankData.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankData.java new file mode 100644 index 000000000..361fcc61d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankData.java @@ -0,0 +1,19 @@ +package mineplex.core.thank; + +/** + * @author Shaun Bennett + */ +public class ThankData +{ + private final int _thankToClaim; + + public ThankData(int thankToClaim) + { + _thankToClaim = thankToClaim; + } + + public int getThankToClaim() + { + return _thankToClaim; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java new file mode 100644 index 000000000..7b59a90a2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java @@ -0,0 +1,142 @@ +package mineplex.core.thank; + +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.thank.command.ThankCommand; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ThankManager extends MiniDbClientPlugin +{ + public static final int DEFAULT_RECEIVER_REWARD = 5; + public static final int DEFAULT_SENDER_REWARD = 5; + + private DonationManager _donationManager; + + private ThankRepository _thankRepository; + + public ThankManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super("Thanks", plugin, clientManager); + + _donationManager = donationManager; + + _thankRepository = new ThankRepository(plugin); + } + + @Override + public void addCommands() + { + addCommand(new ThankCommand(this)); + } + + public void thankPlayer(Player receiver, Player sender, int receiverReward, int senderReward, String reason, boolean ignoreCooldown, Callback callback) + { + if (!Recharge.Instance.use(sender, "Thank Player", 1000 * 5, false, false)) + { + UtilPlayer.message(sender, F.main("Thank", "Please wait before trying that again")); + callback.run(ThankResult.COOLDOWN_RECHARGE); + return; + } + + int senderAccountId = ClientManager.getAccountId(sender); + int receiverAccountId = ClientManager.getAccountId(receiver); + thankPlayer(receiver.getName(), receiverAccountId, sender.getName(), senderAccountId, receiverReward, senderReward, reason, ignoreCooldown, callback); + } + + public void claimThanks(Player player, Callback callback) + { + int accountId = ClientManager.getAccountId(player); + + if (accountId == -1) + { + callback.run(null); + return; + } + + runAsync(() -> { + try + { + ClaimThankResult result = _thankRepository.claimThank(accountId); + runSync(() -> { + if (result != null && result.getClaimed() > 0) Set(player, new ThankData(0)); + callback.run(result); + }); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + runSync(() -> callback.run(null)); + } + }); + } + + public void thankPlayer(String receiverName, int receiverAccountId, String senderName, int senderAccountId, int receiverReward, int senderReward, String reason, boolean ignoreCooldown, Callback callback) + { + // Break out on bad account id + if (senderAccountId == -1 || receiverAccountId == -1) + { + callback.run(ThankResult.INVALID_ACCOUNT_ID); + return; + } + + // You can't thank yourself, silly! + if (receiverAccountId == senderAccountId) + { + callback.run(ThankResult.CANNOT_THANK_SELF); + return; + } + + runAsync(() -> { + try + { + boolean success = _thankRepository.thank(receiverAccountId, senderAccountId, receiverReward, reason, ignoreCooldown); + + runSync(() -> { + if (success) + { + _donationManager.rewardCoinsUntilSuccess(null, "Thank", receiverName, receiverAccountId, receiverReward); + _donationManager.rewardCoinsUntilSuccess(null, "Thank", senderName, senderAccountId, senderReward); + } + + callback.run(success ? ThankResult.SUCCESS : ThankResult.COOLDOWN_DATABASE); + }); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + runSync(() -> callback.run(ThankResult.DATABASE_ERROR)); + } + }); + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT SUM(thankAmount) FROM accountThankTransactions WHERE receiverId = " + accountId + " AND claimed = FALSE;"; + } + + @Override + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + { + if (resultSet.next()) + { + int thankToClaim = resultSet.getInt(1); + Set(playerName, new ThankData(thankToClaim)); + } + } + + @Override + protected ThankData addPlayer(String player) + { + return new ThankData(0); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankRepository.java new file mode 100644 index 000000000..fc8c4b594 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankRepository.java @@ -0,0 +1,62 @@ +package mineplex.core.thank; + +import mineplex.core.database.MinecraftRepository; +import mineplex.database.routines.AddThank; +import mineplex.database.routines.ClaimThank; +import mineplex.serverdata.database.DBPool; +import org.bukkit.plugin.java.JavaPlugin; +import org.jooq.Configuration; + +public class ThankRepository extends MinecraftRepository +{ + public ThankRepository(JavaPlugin plugin) + { + super(plugin, DBPool.getAccount()); + } + + @Override + protected void initialize() + { + } + + @Override + protected void update() + { + + } + + /** + * + * @param receiverAccountId + * @param senderAccountId + * @param thankAmount + * @param reason + * @param ignoreCooldown + * @return + */ + public boolean thank(int receiverAccountId, int senderAccountId, int thankAmount, String reason, boolean ignoreCooldown) + { + AddThank addThank = new AddThank(); + addThank.setInReceiverAccountId(receiverAccountId); + addThank.setInSenderAccountId(senderAccountId); + addThank.setInThankAmount(thankAmount); + addThank.setInReason(reason); + addThank.setInIgnoreCooldown(ignoreCooldown ? (byte) 1 : 0); + + addThank.execute(jooq().configuration()); + return addThank.getSuccess() == 1; + } + + /** + * + * @param accountId + * @return + */ + public ClaimThankResult claimThank(int accountId) + { + ClaimThank claimThank = new ClaimThank(); + claimThank.setInAccountId(accountId); + claimThank.execute(jooq().configuration()); + return new ClaimThankResult(claimThank.getAmountClaimed(), claimThank.getUniqueThank()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankResult.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankResult.java new file mode 100644 index 000000000..8b0c8e6c3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankResult.java @@ -0,0 +1,14 @@ +package mineplex.core.thank; + +/** + * @author Shaun Bennett + */ +public enum ThankResult +{ + COOLDOWN_RECHARGE, + COOLDOWN_DATABASE, + SUCCESS, + INVALID_ACCOUNT_ID, + DATABASE_ERROR, + CANNOT_THANK_SELF +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java new file mode 100644 index 000000000..ef950d3a6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java @@ -0,0 +1,65 @@ +package mineplex.core.thank.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.thank.ThankManager; +import mineplex.core.thank.ThankResult; +import org.bukkit.entity.Player; + +/** + * @author Shaun Bennett + */ +public class ThankCommand extends CommandBase +{ + public ThankCommand(ThankManager plugin) + { + super(plugin, Rank.ALL, "thank"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length != 1) + { + UtilPlayer.message(caller, F.main("Thank", "Usage: " + F.elem("/thank "))); + return; + } + + String playerName = args[0]; + Player player = UtilPlayer.searchOnline(caller, playerName, true); + if (player != null) + { + Plugin.thankPlayer(player, caller, ThankManager.DEFAULT_RECEIVER_REWARD, ThankManager.DEFAULT_SENDER_REWARD, + "ThankCommand", false, result -> + { + String message; + + switch (result) + { + case SUCCESS: + message = "You thanked " + F.name(playerName) + "!"; + break; + case CANNOT_THANK_SELF: + message = "You cannot thank yourself!"; + break; + case COOLDOWN_DATABASE: + message = "/thank is on cooldown. Try again later"; + break; + case COOLDOWN_RECHARGE: + message = null; + break; + default: + message = "An error occurred. Try again later"; + } + + if (message != null) + { + UtilPlayer.message(caller, F.main("Thank", message)); + } + }); + } + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Account.java b/Plugins/Mineplex.Database/src/mineplex/database/Account.java index c9e7b6499..80ec9c795 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Account.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Account.java @@ -16,7 +16,7 @@ package mineplex.database; @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Account extends org.jooq.impl.SchemaImpl implements java.io.Serializable, java.lang.Cloneable { - private static final long serialVersionUID = -1965384171; + private static final long serialVersionUID = 1432193236; /** * The reference instance of Account @@ -56,11 +56,14 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali mineplex.database.tables.Accounts.accounts, mineplex.database.tables.AccountStat.accountStat, mineplex.database.tables.AccountTasks.accountTasks, + mineplex.database.tables.AccountThank.accountThank, + mineplex.database.tables.AccountThankTransactions.accountThankTransactions, mineplex.database.tables.AccountTip.accountTip, mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs, mineplex.database.tables.AccountTipLogs.accountTipLogs, mineplex.database.tables.AccountTransactions.accountTransactions, mineplex.database.tables.AccountValentinesGift.accountValentinesGift, + mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode, mineplex.database.tables.ActiveTournaments.activeTournaments, mineplex.database.tables.BattlePets.battlePets, mineplex.database.tables.Bonus.bonus, @@ -68,13 +71,16 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali mineplex.database.tables.BotSpam.botSpam, mineplex.database.tables.Chatsnap.chatsnap, mineplex.database.tables.ClanAlliances.clanAlliances, + mineplex.database.tables.ClanBanners.clanBanners, mineplex.database.tables.ClanBans.clanBans, mineplex.database.tables.ClanEnemies.clanEnemies, mineplex.database.tables.ClanMember.clanMember, mineplex.database.tables.ClanNameBlacklist.clanNameBlacklist, mineplex.database.tables.Clans.clans, mineplex.database.tables.ClanServer.clanServer, + mineplex.database.tables.ClansGold.clansGold, mineplex.database.tables.ClanShopItem.clanShopItem, + mineplex.database.tables.ClansNetherPortals.clansNetherPortals, mineplex.database.tables.ClansOutposts.clansOutposts, mineplex.database.tables.ClansPvpTimer.clansPvpTimer, mineplex.database.tables.ClansSiegeWeapons.clansSiegeWeapons, @@ -95,13 +101,14 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali mineplex.database.tables.Items.items, mineplex.database.tables.Kitpreferences.kitpreferences, mineplex.database.tables.KitProgression.kitProgression, - mineplex.database.tables.Kit_progression.kit_progression, mineplex.database.tables.Mail.mail, mineplex.database.tables.Mailbox.mailbox, + mineplex.database.tables.NonPremiumJoinMessage.nonPremiumJoinMessage, mineplex.database.tables.Npcs.npcs, mineplex.database.tables.Packages.packages, mineplex.database.tables.PlayerMap.playerMap, mineplex.database.tables.Polls.polls, + mineplex.database.tables.PowerPlayClub.powerPlayClub, mineplex.database.tables.RankBenefits.rankBenefits, mineplex.database.tables.RankedBans.rankedBans, mineplex.database.tables.ReportTickets.reportTickets, @@ -121,6 +128,8 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali mineplex.database.tables.TournamentLB.TournamentLB, mineplex.database.tables.Tournaments.tournaments, mineplex.database.tables.TournamentTeams.tournamentTeams, - mineplex.database.tables.Transactions.transactions); + mineplex.database.tables.Transactions.transactions, + mineplex.database.tables.Unicodereplacer.unicodereplacer, + mineplex.database.tables.Youtube.youtube); } } diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Keys.java b/Plugins/Mineplex.Database/src/mineplex/database/Keys.java index 84db331ea..c7819d84d 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Keys.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Keys.java @@ -35,6 +35,7 @@ public class Keys { public static final org.jooq.Identity IDENTITY_accountPurchases = Identities0.IDENTITY_accountPurchases; public static final org.jooq.Identity IDENTITY_accounts = Identities0.IDENTITY_accounts; public static final org.jooq.Identity IDENTITY_accountTasks = Identities0.IDENTITY_accountTasks; + public static final org.jooq.Identity IDENTITY_accountThankTransactions = Identities0.IDENTITY_accountThankTransactions; public static final org.jooq.Identity IDENTITY_accountTipClaimLogs = Identities0.IDENTITY_accountTipClaimLogs; public static final org.jooq.Identity IDENTITY_accountTransactions = Identities0.IDENTITY_accountTransactions; public static final org.jooq.Identity IDENTITY_battlePets = Identities0.IDENTITY_battlePets; @@ -48,6 +49,7 @@ public class Keys { public static final org.jooq.Identity IDENTITY_clans = Identities0.IDENTITY_clans; public static final org.jooq.Identity IDENTITY_clanServer = Identities0.IDENTITY_clanServer; public static final org.jooq.Identity IDENTITY_clanShopItem = Identities0.IDENTITY_clanShopItem; + public static final org.jooq.Identity IDENTITY_clansNetherPortals = Identities0.IDENTITY_clansNetherPortals; public static final org.jooq.Identity IDENTITY_clanTerritory = Identities0.IDENTITY_clanTerritory; public static final org.jooq.Identity IDENTITY_clanWar = Identities0.IDENTITY_clanWar; public static final org.jooq.Identity IDENTITY_customData = Identities0.IDENTITY_customData; @@ -76,6 +78,8 @@ public class Keys { public static final org.jooq.Identity IDENTITY_tournaments = Identities0.IDENTITY_tournaments; public static final org.jooq.Identity IDENTITY_tournamentTeams = Identities0.IDENTITY_tournamentTeams; public static final org.jooq.Identity IDENTITY_transactions = Identities0.IDENTITY_transactions; + public static final org.jooq.Identity IDENTITY_unicodereplacer = Identities0.IDENTITY_unicodereplacer; + public static final org.jooq.Identity IDENTITY_youtube = Identities0.IDENTITY_youtube; // ------------------------------------------------------------------------- // UNIQUE and PRIMARY KEY definitions @@ -104,11 +108,14 @@ public class Keys { public static final org.jooq.UniqueKey KEY_accounts_uuidIndex = UniqueKeys0.KEY_accounts_uuidIndex; public static final org.jooq.UniqueKey KEY_accountStat_PRIMARY = UniqueKeys0.KEY_accountStat_PRIMARY; public static final org.jooq.UniqueKey KEY_accountTasks_PRIMARY = UniqueKeys0.KEY_accountTasks_PRIMARY; + public static final org.jooq.UniqueKey KEY_accountThank_PRIMARY = UniqueKeys0.KEY_accountThank_PRIMARY; + public static final org.jooq.UniqueKey KEY_accountThankTransactions_PRIMARY = UniqueKeys0.KEY_accountThankTransactions_PRIMARY; public static final org.jooq.UniqueKey KEY_accountTip_PRIMARY = UniqueKeys0.KEY_accountTip_PRIMARY; public static final org.jooq.UniqueKey KEY_accountTipClaimLogs_PRIMARY = UniqueKeys0.KEY_accountTipClaimLogs_PRIMARY; public static final org.jooq.UniqueKey KEY_accountTipLogs_PRIMARY = UniqueKeys0.KEY_accountTipLogs_PRIMARY; public static final org.jooq.UniqueKey KEY_accountTransactions_PRIMARY = UniqueKeys0.KEY_accountTransactions_PRIMARY; public static final org.jooq.UniqueKey KEY_accountValentinesGift_PRIMARY = UniqueKeys0.KEY_accountValentinesGift_PRIMARY; + public static final org.jooq.UniqueKey KEY_accountWebsiteLinkCode_PRIMARY = UniqueKeys0.KEY_accountWebsiteLinkCode_PRIMARY; public static final org.jooq.UniqueKey KEY_activeTournaments_PRIMARY = UniqueKeys0.KEY_activeTournaments_PRIMARY; public static final org.jooq.UniqueKey KEY_battlePets_PRIMARY = UniqueKeys0.KEY_battlePets_PRIMARY; public static final org.jooq.UniqueKey KEY_bonus_PRIMARY = UniqueKeys0.KEY_bonus_PRIMARY; @@ -117,6 +124,7 @@ public class Keys { public static final org.jooq.UniqueKey KEY_botSpam_unique_text = UniqueKeys0.KEY_botSpam_unique_text; public static final org.jooq.UniqueKey KEY_chatsnap_PRIMARY = UniqueKeys0.KEY_chatsnap_PRIMARY; public static final org.jooq.UniqueKey KEY_clanAlliances_PRIMARY = UniqueKeys0.KEY_clanAlliances_PRIMARY; + public static final org.jooq.UniqueKey KEY_clanBanners_PRIMARY = UniqueKeys0.KEY_clanBanners_PRIMARY; public static final org.jooq.UniqueKey KEY_clanBans_PRIMARY = UniqueKeys0.KEY_clanBans_PRIMARY; public static final org.jooq.UniqueKey KEY_clanEnemies_PRIMARY = UniqueKeys0.KEY_clanEnemies_PRIMARY; public static final org.jooq.UniqueKey KEY_clanEnemies_unique_clanId = UniqueKeys0.KEY_clanEnemies_unique_clanId; @@ -126,8 +134,10 @@ public class Keys { public static final org.jooq.UniqueKey KEY_clans_clanName = UniqueKeys0.KEY_clans_clanName; public static final org.jooq.UniqueKey KEY_clanServer_PRIMARY = UniqueKeys0.KEY_clanServer_PRIMARY; public static final org.jooq.UniqueKey KEY_clanServer_unique_serverName = UniqueKeys0.KEY_clanServer_unique_serverName; + public static final org.jooq.UniqueKey KEY_clansGold_PRIMARY = UniqueKeys0.KEY_clansGold_PRIMARY; public static final org.jooq.UniqueKey KEY_clanShopItem_PRIMARY = UniqueKeys0.KEY_clanShopItem_PRIMARY; public static final org.jooq.UniqueKey KEY_clanShopItem_shop_page_slot_UNIQUE = UniqueKeys0.KEY_clanShopItem_shop_page_slot_UNIQUE; + public static final org.jooq.UniqueKey KEY_clansNetherPortals_PRIMARY = UniqueKeys0.KEY_clansNetherPortals_PRIMARY; public static final org.jooq.UniqueKey KEY_clansOutposts_PRIMARY = UniqueKeys0.KEY_clansOutposts_PRIMARY; public static final org.jooq.UniqueKey KEY_clansPvpTimer_PRIMARY = UniqueKeys0.KEY_clansPvpTimer_PRIMARY; public static final org.jooq.UniqueKey KEY_clansSiegeWeapons_PRIMARY = UniqueKeys0.KEY_clansSiegeWeapons_PRIMARY; @@ -154,7 +164,6 @@ public class Keys { public static final org.jooq.UniqueKey KEY_items_name_UNIQUE = UniqueKeys0.KEY_items_name_UNIQUE; public static final org.jooq.UniqueKey KEY_items_uniqueNameCategoryIndex = UniqueKeys0.KEY_items_uniqueNameCategoryIndex; public static final org.jooq.UniqueKey KEY_kitProgression_PRIMARY = UniqueKeys0.KEY_kitProgression_PRIMARY; - public static final org.jooq.UniqueKey KEY_kit_progression_PRIMARY = UniqueKeys0.KEY_kit_progression_PRIMARY; public static final org.jooq.UniqueKey KEY_mail_PRIMARY = UniqueKeys0.KEY_mail_PRIMARY; public static final org.jooq.UniqueKey KEY_mailbox_PRIMARY = UniqueKeys0.KEY_mailbox_PRIMARY; public static final org.jooq.UniqueKey KEY_npcs_PRIMARY = UniqueKeys0.KEY_npcs_PRIMARY; @@ -162,6 +171,7 @@ public class Keys { public static final org.jooq.UniqueKey KEY_playerMap_PRIMARY = UniqueKeys0.KEY_playerMap_PRIMARY; public static final org.jooq.UniqueKey KEY_playerMap_playerIndex = UniqueKeys0.KEY_playerMap_playerIndex; public static final org.jooq.UniqueKey KEY_polls_PRIMARY = UniqueKeys0.KEY_polls_PRIMARY; + public static final org.jooq.UniqueKey KEY_powerPlayClub_PRIMARY = UniqueKeys0.KEY_powerPlayClub_PRIMARY; public static final org.jooq.UniqueKey KEY_rankBenefits_PRIMARY = UniqueKeys0.KEY_rankBenefits_PRIMARY; public static final org.jooq.UniqueKey KEY_rankedBans_PRIMARY = UniqueKeys0.KEY_rankedBans_PRIMARY; public static final org.jooq.UniqueKey KEY_reportTickets_PRIMARY = UniqueKeys0.KEY_reportTickets_PRIMARY; @@ -183,6 +193,9 @@ public class Keys { public static final org.jooq.UniqueKey KEY_tournaments_PRIMARY = UniqueKeys0.KEY_tournaments_PRIMARY; public static final org.jooq.UniqueKey KEY_tournamentTeams_PRIMARY = UniqueKeys0.KEY_tournamentTeams_PRIMARY; public static final org.jooq.UniqueKey KEY_transactions_PRIMARY = UniqueKeys0.KEY_transactions_PRIMARY; + public static final org.jooq.UniqueKey KEY_unicodereplacer_PRIMARY = UniqueKeys0.KEY_unicodereplacer_PRIMARY; + public static final org.jooq.UniqueKey KEY_unicodereplacer_unicode = UniqueKeys0.KEY_unicodereplacer_unicode; + public static final org.jooq.UniqueKey KEY_youtube_PRIMARY = UniqueKeys0.KEY_youtube_PRIMARY; // ------------------------------------------------------------------------- // FOREIGN KEY definitions @@ -208,6 +221,9 @@ public class Keys { public static final org.jooq.ForeignKey accountStat_stat = ForeignKeys0.accountStat_stat; public static final org.jooq.ForeignKey ACCOUNTTASKS_ACCOUNTID = ForeignKeys0.ACCOUNTTASKS_ACCOUNTID; public static final org.jooq.ForeignKey ACCOUNTTASKS_TASKID = ForeignKeys0.ACCOUNTTASKS_TASKID; + public static final org.jooq.ForeignKey accountThank_accounts_id_fk = ForeignKeys0.accountThank_accounts_id_fk; + public static final org.jooq.ForeignKey accountThankTransactions_accounts_id_fk2 = ForeignKeys0.accountThankTransactions_accounts_id_fk2; + public static final org.jooq.ForeignKey accountThankTransactions_accounts_id_fk = ForeignKeys0.accountThankTransactions_accounts_id_fk; public static final org.jooq.ForeignKey accountTips_accounts_id_fk = ForeignKeys0.accountTips_accounts_id_fk; public static final org.jooq.ForeignKey accountTipClaimLogs_accounts_id_fk = ForeignKeys0.accountTipClaimLogs_accounts_id_fk; public static final org.jooq.ForeignKey accountTipLogs_accounts_id_fk = ForeignKeys0.accountTipLogs_accounts_id_fk; @@ -215,18 +231,23 @@ public class Keys { public static final org.jooq.ForeignKey ACCOUNTTRANSACTIONS_TRANSACTIONID = ForeignKeys0.ACCOUNTTRANSACTIONS_TRANSACTIONID; public static final org.jooq.ForeignKey accountValentines_sender_fk = ForeignKeys0.accountValentines_sender_fk; public static final org.jooq.ForeignKey accountValentines_target_fk = ForeignKeys0.accountValentines_target_fk; + public static final org.jooq.ForeignKey accountWebsiteLinkCode_ibfk_1 = ForeignKeys0.accountWebsiteLinkCode_ibfk_1; public static final org.jooq.ForeignKey bonus_ibfk_1 = ForeignKeys0.bonus_ibfk_1; public static final org.jooq.ForeignKey bonusLogAccountId = ForeignKeys0.bonusLogAccountId; public static final org.jooq.ForeignKey bonusLogItemId = ForeignKeys0.bonusLogItemId; + public static final org.jooq.ForeignKey clansGold_ibfk_1 = ForeignKeys0.clansGold_ibfk_1; + public static final org.jooq.ForeignKey clansGold_ibfk_2 = ForeignKeys0.clansGold_ibfk_2; public static final org.jooq.ForeignKey ELORATING_ACCOUNTID = ForeignKeys0.ELORATING_ACCOUNTID; public static final org.jooq.ForeignKey facebook_accounts_id_fk = ForeignKeys0.facebook_accounts_id_fk; public static final org.jooq.ForeignKey gadgets_ibfk_1 = ForeignKeys0.gadgets_ibfk_1; public static final org.jooq.ForeignKey mail_ibfk_1 = ForeignKeys0.mail_ibfk_1; public static final org.jooq.ForeignKey mailbox_ibfk_1 = ForeignKeys0.mailbox_ibfk_1; + public static final org.jooq.ForeignKey powerPlayClub_ibfk_1 = ForeignKeys0.powerPlayClub_ibfk_1; public static final org.jooq.ForeignKey rankBenefits_ibfk_1 = ForeignKeys0.rankBenefits_ibfk_1; public static final org.jooq.ForeignKey titanGiveaway_ibfk_1 = ForeignKeys0.titanGiveaway_ibfk_1; public static final org.jooq.ForeignKey TEAM_TOURNAMENT_KEY = ForeignKeys0.TEAM_TOURNAMENT_KEY; public static final org.jooq.ForeignKey TEAM_TOURNAMENT_ACCOUNT_ID = ForeignKeys0.TEAM_TOURNAMENT_ACCOUNT_ID; + public static final org.jooq.ForeignKey youtube_ibfk_1 = ForeignKeys0.youtube_ibfk_1; // ------------------------------------------------------------------------- // [#1459] distribute members to avoid static initialisers > 64kb @@ -247,6 +268,7 @@ public class Keys { public static org.jooq.Identity IDENTITY_accountPurchases = createIdentity(mineplex.database.tables.AccountPurchases.accountPurchases, mineplex.database.tables.AccountPurchases.accountPurchases.id); public static org.jooq.Identity IDENTITY_accounts = createIdentity(mineplex.database.tables.Accounts.accounts, mineplex.database.tables.Accounts.accounts.id); public static org.jooq.Identity IDENTITY_accountTasks = createIdentity(mineplex.database.tables.AccountTasks.accountTasks, mineplex.database.tables.AccountTasks.accountTasks.id); + public static org.jooq.Identity IDENTITY_accountThankTransactions = createIdentity(mineplex.database.tables.AccountThankTransactions.accountThankTransactions, mineplex.database.tables.AccountThankTransactions.accountThankTransactions.id); public static org.jooq.Identity IDENTITY_accountTipClaimLogs = createIdentity(mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs, mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs.id); public static org.jooq.Identity IDENTITY_accountTransactions = createIdentity(mineplex.database.tables.AccountTransactions.accountTransactions, mineplex.database.tables.AccountTransactions.accountTransactions.id); public static org.jooq.Identity IDENTITY_battlePets = createIdentity(mineplex.database.tables.BattlePets.battlePets, mineplex.database.tables.BattlePets.battlePets.petId); @@ -260,6 +282,7 @@ public class Keys { public static org.jooq.Identity IDENTITY_clans = createIdentity(mineplex.database.tables.Clans.clans, mineplex.database.tables.Clans.clans.id); public static org.jooq.Identity IDENTITY_clanServer = createIdentity(mineplex.database.tables.ClanServer.clanServer, mineplex.database.tables.ClanServer.clanServer.id); public static org.jooq.Identity IDENTITY_clanShopItem = createIdentity(mineplex.database.tables.ClanShopItem.clanShopItem, mineplex.database.tables.ClanShopItem.clanShopItem.id); + public static org.jooq.Identity IDENTITY_clansNetherPortals = createIdentity(mineplex.database.tables.ClansNetherPortals.clansNetherPortals, mineplex.database.tables.ClansNetherPortals.clansNetherPortals.id); public static org.jooq.Identity IDENTITY_clanTerritory = createIdentity(mineplex.database.tables.ClanTerritory.clanTerritory, mineplex.database.tables.ClanTerritory.clanTerritory.id); public static org.jooq.Identity IDENTITY_clanWar = createIdentity(mineplex.database.tables.ClanWar.clanWar, mineplex.database.tables.ClanWar.clanWar.id); public static org.jooq.Identity IDENTITY_customData = createIdentity(mineplex.database.tables.CustomData.customData, mineplex.database.tables.CustomData.customData.id); @@ -288,6 +311,8 @@ public class Keys { public static org.jooq.Identity IDENTITY_tournaments = createIdentity(mineplex.database.tables.Tournaments.tournaments, mineplex.database.tables.Tournaments.tournaments.id); public static org.jooq.Identity IDENTITY_tournamentTeams = createIdentity(mineplex.database.tables.TournamentTeams.tournamentTeams, mineplex.database.tables.TournamentTeams.tournamentTeams.id); public static org.jooq.Identity IDENTITY_transactions = createIdentity(mineplex.database.tables.Transactions.transactions, mineplex.database.tables.Transactions.transactions.id); + public static org.jooq.Identity IDENTITY_unicodereplacer = createIdentity(mineplex.database.tables.Unicodereplacer.unicodereplacer, mineplex.database.tables.Unicodereplacer.unicodereplacer.id); + public static org.jooq.Identity IDENTITY_youtube = createIdentity(mineplex.database.tables.Youtube.youtube, mineplex.database.tables.Youtube.youtube.accountId); } private static class UniqueKeys0 extends org.jooq.impl.AbstractKeys { @@ -314,11 +339,14 @@ public class Keys { public static final org.jooq.UniqueKey KEY_accounts_uuidIndex = createUniqueKey(mineplex.database.tables.Accounts.accounts, mineplex.database.tables.Accounts.accounts.uuid); public static final org.jooq.UniqueKey KEY_accountStat_PRIMARY = createUniqueKey(mineplex.database.tables.AccountStat.accountStat, mineplex.database.tables.AccountStat.accountStat.accountId, mineplex.database.tables.AccountStat.accountStat.statId); public static final org.jooq.UniqueKey KEY_accountTasks_PRIMARY = createUniqueKey(mineplex.database.tables.AccountTasks.accountTasks, mineplex.database.tables.AccountTasks.accountTasks.id); + public static final org.jooq.UniqueKey KEY_accountThank_PRIMARY = createUniqueKey(mineplex.database.tables.AccountThank.accountThank, mineplex.database.tables.AccountThank.accountThank.accountId); + public static final org.jooq.UniqueKey KEY_accountThankTransactions_PRIMARY = createUniqueKey(mineplex.database.tables.AccountThankTransactions.accountThankTransactions, mineplex.database.tables.AccountThankTransactions.accountThankTransactions.id); public static final org.jooq.UniqueKey KEY_accountTip_PRIMARY = createUniqueKey(mineplex.database.tables.AccountTip.accountTip, mineplex.database.tables.AccountTip.accountTip.accountId); public static final org.jooq.UniqueKey KEY_accountTipClaimLogs_PRIMARY = createUniqueKey(mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs, mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs.id); public static final org.jooq.UniqueKey KEY_accountTipLogs_PRIMARY = createUniqueKey(mineplex.database.tables.AccountTipLogs.accountTipLogs, mineplex.database.tables.AccountTipLogs.accountTipLogs.accountId, mineplex.database.tables.AccountTipLogs.accountTipLogs.boosterId); public static final org.jooq.UniqueKey KEY_accountTransactions_PRIMARY = createUniqueKey(mineplex.database.tables.AccountTransactions.accountTransactions, mineplex.database.tables.AccountTransactions.accountTransactions.id); public static final org.jooq.UniqueKey KEY_accountValentinesGift_PRIMARY = createUniqueKey(mineplex.database.tables.AccountValentinesGift.accountValentinesGift, mineplex.database.tables.AccountValentinesGift.accountValentinesGift.senderId, mineplex.database.tables.AccountValentinesGift.accountValentinesGift.targetId); + public static final org.jooq.UniqueKey KEY_accountWebsiteLinkCode_PRIMARY = createUniqueKey(mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode, mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode.accountId); public static final org.jooq.UniqueKey KEY_activeTournaments_PRIMARY = createUniqueKey(mineplex.database.tables.ActiveTournaments.activeTournaments, mineplex.database.tables.ActiveTournaments.activeTournaments.name); public static final org.jooq.UniqueKey KEY_battlePets_PRIMARY = createUniqueKey(mineplex.database.tables.BattlePets.battlePets, mineplex.database.tables.BattlePets.battlePets.petId); public static final org.jooq.UniqueKey KEY_bonus_PRIMARY = createUniqueKey(mineplex.database.tables.Bonus.bonus, mineplex.database.tables.Bonus.bonus.accountId); @@ -327,6 +355,7 @@ public class Keys { public static final org.jooq.UniqueKey KEY_botSpam_unique_text = createUniqueKey(mineplex.database.tables.BotSpam.botSpam, mineplex.database.tables.BotSpam.botSpam.text); public static final org.jooq.UniqueKey KEY_chatsnap_PRIMARY = createUniqueKey(mineplex.database.tables.Chatsnap.chatsnap, mineplex.database.tables.Chatsnap.chatsnap.id); public static final org.jooq.UniqueKey KEY_clanAlliances_PRIMARY = createUniqueKey(mineplex.database.tables.ClanAlliances.clanAlliances, mineplex.database.tables.ClanAlliances.clanAlliances.id); + public static final org.jooq.UniqueKey KEY_clanBanners_PRIMARY = createUniqueKey(mineplex.database.tables.ClanBanners.clanBanners, mineplex.database.tables.ClanBanners.clanBanners.clanId); public static final org.jooq.UniqueKey KEY_clanBans_PRIMARY = createUniqueKey(mineplex.database.tables.ClanBans.clanBans, mineplex.database.tables.ClanBans.clanBans.id); public static final org.jooq.UniqueKey KEY_clanEnemies_PRIMARY = createUniqueKey(mineplex.database.tables.ClanEnemies.clanEnemies, mineplex.database.tables.ClanEnemies.clanEnemies.id); public static final org.jooq.UniqueKey KEY_clanEnemies_unique_clanId = createUniqueKey(mineplex.database.tables.ClanEnemies.clanEnemies, mineplex.database.tables.ClanEnemies.clanEnemies.clanId); @@ -336,8 +365,10 @@ public class Keys { public static final org.jooq.UniqueKey KEY_clans_clanName = createUniqueKey(mineplex.database.tables.Clans.clans, mineplex.database.tables.Clans.clans.serverId, mineplex.database.tables.Clans.clans.name); public static final org.jooq.UniqueKey KEY_clanServer_PRIMARY = createUniqueKey(mineplex.database.tables.ClanServer.clanServer, mineplex.database.tables.ClanServer.clanServer.id); public static final org.jooq.UniqueKey KEY_clanServer_unique_serverName = createUniqueKey(mineplex.database.tables.ClanServer.clanServer, mineplex.database.tables.ClanServer.clanServer.serverName); + public static final org.jooq.UniqueKey KEY_clansGold_PRIMARY = createUniqueKey(mineplex.database.tables.ClansGold.clansGold, mineplex.database.tables.ClansGold.clansGold.serverId, mineplex.database.tables.ClansGold.clansGold.id); public static final org.jooq.UniqueKey KEY_clanShopItem_PRIMARY = createUniqueKey(mineplex.database.tables.ClanShopItem.clanShopItem, mineplex.database.tables.ClanShopItem.clanShopItem.id); public static final org.jooq.UniqueKey KEY_clanShopItem_shop_page_slot_UNIQUE = createUniqueKey(mineplex.database.tables.ClanShopItem.clanShopItem, mineplex.database.tables.ClanShopItem.clanShopItem.shopName, mineplex.database.tables.ClanShopItem.clanShopItem.shopPage, mineplex.database.tables.ClanShopItem.clanShopItem.slot); + public static final org.jooq.UniqueKey KEY_clansNetherPortals_PRIMARY = createUniqueKey(mineplex.database.tables.ClansNetherPortals.clansNetherPortals, mineplex.database.tables.ClansNetherPortals.clansNetherPortals.id); public static final org.jooq.UniqueKey KEY_clansOutposts_PRIMARY = createUniqueKey(mineplex.database.tables.ClansOutposts.clansOutposts, mineplex.database.tables.ClansOutposts.clansOutposts.uniqueId); public static final org.jooq.UniqueKey KEY_clansPvpTimer_PRIMARY = createUniqueKey(mineplex.database.tables.ClansPvpTimer.clansPvpTimer, mineplex.database.tables.ClansPvpTimer.clansPvpTimer.accountId); public static final org.jooq.UniqueKey KEY_clansSiegeWeapons_PRIMARY = createUniqueKey(mineplex.database.tables.ClansSiegeWeapons.clansSiegeWeapons, mineplex.database.tables.ClansSiegeWeapons.clansSiegeWeapons.uniqueId); @@ -364,7 +395,6 @@ public class Keys { public static final org.jooq.UniqueKey KEY_items_name_UNIQUE = createUniqueKey(mineplex.database.tables.Items.items, mineplex.database.tables.Items.items.name); public static final org.jooq.UniqueKey KEY_items_uniqueNameCategoryIndex = createUniqueKey(mineplex.database.tables.Items.items, mineplex.database.tables.Items.items.name, mineplex.database.tables.Items.items.categoryId); public static final org.jooq.UniqueKey KEY_kitProgression_PRIMARY = createUniqueKey(mineplex.database.tables.KitProgression.kitProgression, mineplex.database.tables.KitProgression.kitProgression.uuid, mineplex.database.tables.KitProgression.kitProgression.kitId); - public static final org.jooq.UniqueKey KEY_kit_progression_PRIMARY = createUniqueKey(mineplex.database.tables.Kit_progression.kit_progression, mineplex.database.tables.Kit_progression.kit_progression.account_id, mineplex.database.tables.Kit_progression.kit_progression.kit_id); public static final org.jooq.UniqueKey KEY_mail_PRIMARY = createUniqueKey(mineplex.database.tables.Mail.mail, mineplex.database.tables.Mail.mail.id); public static final org.jooq.UniqueKey KEY_mailbox_PRIMARY = createUniqueKey(mineplex.database.tables.Mailbox.mailbox, mineplex.database.tables.Mailbox.mailbox.id); public static final org.jooq.UniqueKey KEY_npcs_PRIMARY = createUniqueKey(mineplex.database.tables.Npcs.npcs, mineplex.database.tables.Npcs.npcs.id); @@ -372,6 +402,7 @@ public class Keys { public static final org.jooq.UniqueKey KEY_playerMap_PRIMARY = createUniqueKey(mineplex.database.tables.PlayerMap.playerMap, mineplex.database.tables.PlayerMap.playerMap.id); public static final org.jooq.UniqueKey KEY_playerMap_playerIndex = createUniqueKey(mineplex.database.tables.PlayerMap.playerMap, mineplex.database.tables.PlayerMap.playerMap.playerName); public static final org.jooq.UniqueKey KEY_polls_PRIMARY = createUniqueKey(mineplex.database.tables.Polls.polls, mineplex.database.tables.Polls.polls.id); + public static final org.jooq.UniqueKey KEY_powerPlayClub_PRIMARY = createUniqueKey(mineplex.database.tables.PowerPlayClub.powerPlayClub, mineplex.database.tables.PowerPlayClub.powerPlayClub.accountId, mineplex.database.tables.PowerPlayClub.powerPlayClub.kvKey); public static final org.jooq.UniqueKey KEY_rankBenefits_PRIMARY = createUniqueKey(mineplex.database.tables.RankBenefits.rankBenefits, mineplex.database.tables.RankBenefits.rankBenefits.id); public static final org.jooq.UniqueKey KEY_rankedBans_PRIMARY = createUniqueKey(mineplex.database.tables.RankedBans.rankedBans, mineplex.database.tables.RankedBans.rankedBans.accountId); public static final org.jooq.UniqueKey KEY_reportTickets_PRIMARY = createUniqueKey(mineplex.database.tables.ReportTickets.reportTickets, mineplex.database.tables.ReportTickets.reportTickets.reportId); @@ -393,6 +424,9 @@ public class Keys { public static final org.jooq.UniqueKey KEY_tournaments_PRIMARY = createUniqueKey(mineplex.database.tables.Tournaments.tournaments, mineplex.database.tables.Tournaments.tournaments.id); public static final org.jooq.UniqueKey KEY_tournamentTeams_PRIMARY = createUniqueKey(mineplex.database.tables.TournamentTeams.tournamentTeams, mineplex.database.tables.TournamentTeams.tournamentTeams.id); public static final org.jooq.UniqueKey KEY_transactions_PRIMARY = createUniqueKey(mineplex.database.tables.Transactions.transactions, mineplex.database.tables.Transactions.transactions.id); + public static final org.jooq.UniqueKey KEY_unicodereplacer_PRIMARY = createUniqueKey(mineplex.database.tables.Unicodereplacer.unicodereplacer, mineplex.database.tables.Unicodereplacer.unicodereplacer.id); + public static final org.jooq.UniqueKey KEY_unicodereplacer_unicode = createUniqueKey(mineplex.database.tables.Unicodereplacer.unicodereplacer, mineplex.database.tables.Unicodereplacer.unicodereplacer.unicode); + public static final org.jooq.UniqueKey KEY_youtube_PRIMARY = createUniqueKey(mineplex.database.tables.Youtube.youtube, mineplex.database.tables.Youtube.youtube.accountId); } private static class ForeignKeys0 extends org.jooq.impl.AbstractKeys { @@ -416,6 +450,9 @@ public class Keys { public static final org.jooq.ForeignKey accountStat_stat = createForeignKey(mineplex.database.Keys.KEY_stats_PRIMARY, mineplex.database.tables.AccountStat.accountStat, mineplex.database.tables.AccountStat.accountStat.statId); public static final org.jooq.ForeignKey ACCOUNTTASKS_ACCOUNTID = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountTasks.accountTasks, mineplex.database.tables.AccountTasks.accountTasks.accountId); public static final org.jooq.ForeignKey ACCOUNTTASKS_TASKID = createForeignKey(mineplex.database.Keys.KEY_tasks_PRIMARY, mineplex.database.tables.AccountTasks.accountTasks, mineplex.database.tables.AccountTasks.accountTasks.taskId); + public static final org.jooq.ForeignKey accountThank_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountThank.accountThank, mineplex.database.tables.AccountThank.accountThank.accountId); + public static final org.jooq.ForeignKey accountThankTransactions_accounts_id_fk2 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountThankTransactions.accountThankTransactions, mineplex.database.tables.AccountThankTransactions.accountThankTransactions.receiverId); + public static final org.jooq.ForeignKey accountThankTransactions_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountThankTransactions.accountThankTransactions, mineplex.database.tables.AccountThankTransactions.accountThankTransactions.senderId); public static final org.jooq.ForeignKey accountTips_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountTip.accountTip, mineplex.database.tables.AccountTip.accountTip.accountId); public static final org.jooq.ForeignKey accountTipClaimLogs_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs, mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs.accountId); public static final org.jooq.ForeignKey accountTipLogs_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountTipLogs.accountTipLogs, mineplex.database.tables.AccountTipLogs.accountTipLogs.accountId); @@ -423,17 +460,22 @@ public class Keys { public static final org.jooq.ForeignKey ACCOUNTTRANSACTIONS_TRANSACTIONID = createForeignKey(mineplex.database.Keys.KEY_transactions_PRIMARY, mineplex.database.tables.AccountTransactions.accountTransactions, mineplex.database.tables.AccountTransactions.accountTransactions.transactionId); public static final org.jooq.ForeignKey accountValentines_sender_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountValentinesGift.accountValentinesGift, mineplex.database.tables.AccountValentinesGift.accountValentinesGift.senderId); public static final org.jooq.ForeignKey accountValentines_target_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountValentinesGift.accountValentinesGift, mineplex.database.tables.AccountValentinesGift.accountValentinesGift.targetId); + public static final org.jooq.ForeignKey accountWebsiteLinkCode_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode, mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode.accountId); public static final org.jooq.ForeignKey bonus_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Bonus.bonus, mineplex.database.tables.Bonus.bonus.accountId); public static final org.jooq.ForeignKey bonusLogAccountId = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.BonusLog.bonusLog, mineplex.database.tables.BonusLog.bonusLog.accountId); public static final org.jooq.ForeignKey bonusLogItemId = createForeignKey(mineplex.database.Keys.KEY_items_PRIMARY, mineplex.database.tables.BonusLog.bonusLog, mineplex.database.tables.BonusLog.bonusLog.itemId); + public static final org.jooq.ForeignKey clansGold_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_clanServer_PRIMARY, mineplex.database.tables.ClansGold.clansGold, mineplex.database.tables.ClansGold.clansGold.serverId); + public static final org.jooq.ForeignKey clansGold_ibfk_2 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.ClansGold.clansGold, mineplex.database.tables.ClansGold.clansGold.id); public static final org.jooq.ForeignKey ELORATING_ACCOUNTID = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.EloRating.eloRating, mineplex.database.tables.EloRating.eloRating.accountId); public static final org.jooq.ForeignKey facebook_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Facebook.facebook, mineplex.database.tables.Facebook.facebook.accountId); public static final org.jooq.ForeignKey gadgets_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Gadgets.gadgets, mineplex.database.tables.Gadgets.gadgets.accountId); public static final org.jooq.ForeignKey mail_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Mail.mail, mineplex.database.tables.Mail.mail.accountId); public static final org.jooq.ForeignKey mailbox_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Mailbox.mailbox, mineplex.database.tables.Mailbox.mailbox.accountId); + public static final org.jooq.ForeignKey powerPlayClub_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.PowerPlayClub.powerPlayClub, mineplex.database.tables.PowerPlayClub.powerPlayClub.accountId); public static final org.jooq.ForeignKey rankBenefits_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.RankBenefits.rankBenefits, mineplex.database.tables.RankBenefits.rankBenefits.accountId); public static final org.jooq.ForeignKey titanGiveaway_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.TitanGiveaway.titanGiveaway, mineplex.database.tables.TitanGiveaway.titanGiveaway.accountId); public static final org.jooq.ForeignKey TEAM_TOURNAMENT_KEY = createForeignKey(mineplex.database.Keys.KEY_tournaments_PRIMARY, mineplex.database.tables.TournamentTeams.tournamentTeams, mineplex.database.tables.TournamentTeams.tournamentTeams.tournamentId); public static final org.jooq.ForeignKey TEAM_TOURNAMENT_ACCOUNT_ID = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.TournamentTeams.tournamentTeams, mineplex.database.tables.TournamentTeams.tournamentTeams.accountId); + public static final org.jooq.ForeignKey youtube_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Youtube.youtube, mineplex.database.tables.Youtube.youtube.accountId); } } diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Routines.java b/Plugins/Mineplex.Database/src/mineplex/database/Routines.java index af540cee5..0b96d1e5a 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Routines.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Routines.java @@ -28,6 +28,21 @@ public class Routines { return p.getSuccess(); } + /** + * Call Account.addThank + */ + public static java.lang.Byte callAddthank(org.jooq.Configuration configuration, java.lang.Integer inReceiverAccountId, java.lang.Integer inSenderAccountId, java.lang.Integer inThankAmount, java.lang.String inReason, java.lang.Byte inIgnoreCooldown) { + mineplex.database.routines.AddThank p = new mineplex.database.routines.AddThank(); + p.setInReceiverAccountId(inReceiverAccountId); + p.setInSenderAccountId(inSenderAccountId); + p.setInThankAmount(inThankAmount); + p.setInReason(inReason); + p.setInIgnoreCooldown(inIgnoreCooldown); + + p.execute(configuration); + return p.getSuccess(); + } + /** * Call Account.addTip */ @@ -105,6 +120,17 @@ public class Routines { return p; } + /** + * Call Account.claimThank + */ + public static mineplex.database.routines.ClaimThank callClaimthank(org.jooq.Configuration configuration, java.lang.Integer inAccountId) { + mineplex.database.routines.ClaimThank p = new mineplex.database.routines.ClaimThank(); + p.setInAccountId(inAccountId); + + p.execute(configuration); + return p; + } + /** * Call Account.claimTips */ diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Tables.java b/Plugins/Mineplex.Database/src/mineplex/database/Tables.java index f4c26f567..65d0986a3 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Tables.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Tables.java @@ -101,6 +101,16 @@ public class Tables { */ public static final mineplex.database.tables.AccountTasks accountTasks = mineplex.database.tables.AccountTasks.accountTasks; + /** + * The table Account.accountThank + */ + public static final mineplex.database.tables.AccountThank accountThank = mineplex.database.tables.AccountThank.accountThank; + + /** + * The table Account.accountThankTransactions + */ + public static final mineplex.database.tables.AccountThankTransactions accountThankTransactions = mineplex.database.tables.AccountThankTransactions.accountThankTransactions; + /** * The table Account.accountTip */ @@ -126,6 +136,11 @@ public class Tables { */ public static final mineplex.database.tables.AccountValentinesGift accountValentinesGift = mineplex.database.tables.AccountValentinesGift.accountValentinesGift; + /** + * The table Account.accountWebsiteLinkCode + */ + public static final mineplex.database.tables.AccountWebsiteLinkCode accountWebsiteLinkCode = mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode; + /** * The table Account.activeTournaments */ @@ -161,6 +176,11 @@ public class Tables { */ public static final mineplex.database.tables.ClanAlliances clanAlliances = mineplex.database.tables.ClanAlliances.clanAlliances; + /** + * The table Account.clanBanners + */ + public static final mineplex.database.tables.ClanBanners clanBanners = mineplex.database.tables.ClanBanners.clanBanners; + /** * The table Account.clanBans */ @@ -191,11 +211,21 @@ public class Tables { */ public static final mineplex.database.tables.ClanServer clanServer = mineplex.database.tables.ClanServer.clanServer; + /** + * The table Account.clansGold + */ + public static final mineplex.database.tables.ClansGold clansGold = mineplex.database.tables.ClansGold.clansGold; + /** * The table Account.clanShopItem */ public static final mineplex.database.tables.ClanShopItem clanShopItem = mineplex.database.tables.ClanShopItem.clanShopItem; + /** + * The table Account.clansNetherPortals + */ + public static final mineplex.database.tables.ClansNetherPortals clansNetherPortals = mineplex.database.tables.ClansNetherPortals.clansNetherPortals; + /** * The table Account.clansOutposts */ @@ -296,11 +326,6 @@ public class Tables { */ public static final mineplex.database.tables.KitProgression kitProgression = mineplex.database.tables.KitProgression.kitProgression; - /** - * The table Account.kit_progression - */ - public static final mineplex.database.tables.Kit_progression kit_progression = mineplex.database.tables.Kit_progression.kit_progression; - /** * The table Account.mail */ @@ -311,6 +336,11 @@ public class Tables { */ public static final mineplex.database.tables.Mailbox mailbox = mineplex.database.tables.Mailbox.mailbox; + /** + * The table Account.nonPremiumJoinMessage + */ + public static final mineplex.database.tables.NonPremiumJoinMessage nonPremiumJoinMessage = mineplex.database.tables.NonPremiumJoinMessage.nonPremiumJoinMessage; + /** * The table Account.npcs */ @@ -331,6 +361,11 @@ public class Tables { */ public static final mineplex.database.tables.Polls polls = mineplex.database.tables.Polls.polls; + /** + * The table Account.powerPlayClub + */ + public static final mineplex.database.tables.PowerPlayClub powerPlayClub = mineplex.database.tables.PowerPlayClub.powerPlayClub; + /** * The table Account.rankBenefits */ @@ -430,4 +465,14 @@ public class Tables { * The table Account.transactions */ public static final mineplex.database.tables.Transactions transactions = mineplex.database.tables.Transactions.transactions; + + /** + * The table Account.unicodereplacer + */ + public static final mineplex.database.tables.Unicodereplacer unicodereplacer = mineplex.database.tables.Unicodereplacer.unicodereplacer; + + /** + * The table Account.youtube + */ + public static final mineplex.database.tables.Youtube youtube = mineplex.database.tables.Youtube.youtube; } diff --git a/Plugins/Mineplex.Database/src/mineplex/database/routines/AddThank.java b/Plugins/Mineplex.Database/src/mineplex/database/routines/AddThank.java new file mode 100644 index 000000000..584e2c830 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/routines/AddThank.java @@ -0,0 +1,106 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.routines; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AddThank extends org.jooq.impl.AbstractRoutine implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -344701696; + + /** + * The parameter Account.addThank.inReceiverAccountId. + */ + public static final org.jooq.Parameter inReceiverAccountId = createParameter("inReceiverAccountId", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.addThank.inSenderAccountId. + */ + public static final org.jooq.Parameter inSenderAccountId = createParameter("inSenderAccountId", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.addThank.inThankAmount. + */ + public static final org.jooq.Parameter inThankAmount = createParameter("inThankAmount", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.addThank.inReason. + */ + public static final org.jooq.Parameter inReason = createParameter("inReason", org.jooq.impl.SQLDataType.VARCHAR.length(32), false); + + /** + * The parameter Account.addThank.inIgnoreCooldown. + */ + public static final org.jooq.Parameter inIgnoreCooldown = createParameter("inIgnoreCooldown", org.jooq.impl.SQLDataType.TINYINT, false); + + /** + * The parameter Account.addThank.success. + */ + public static final org.jooq.Parameter success = createParameter("success", org.jooq.impl.SQLDataType.TINYINT, false); + + /** + * Create a new routine call instance + */ + public AddThank() { + super("addThank", mineplex.database.Account.Account); + + addInParameter(inReceiverAccountId); + addInParameter(inSenderAccountId); + addInParameter(inThankAmount); + addInParameter(inReason); + addInParameter(inIgnoreCooldown); + addOutParameter(success); + } + + /** + * Set the inReceiverAccountId parameter IN value to the routine + */ + public void setInReceiverAccountId(java.lang.Integer value) { + setValue(mineplex.database.routines.AddThank.inReceiverAccountId, value); + } + + /** + * Set the inSenderAccountId parameter IN value to the routine + */ + public void setInSenderAccountId(java.lang.Integer value) { + setValue(mineplex.database.routines.AddThank.inSenderAccountId, value); + } + + /** + * Set the inThankAmount parameter IN value to the routine + */ + public void setInThankAmount(java.lang.Integer value) { + setValue(mineplex.database.routines.AddThank.inThankAmount, value); + } + + /** + * Set the inReason parameter IN value to the routine + */ + public void setInReason(java.lang.String value) { + setValue(mineplex.database.routines.AddThank.inReason, value); + } + + /** + * Set the inIgnoreCooldown parameter IN value to the routine + */ + public void setInIgnoreCooldown(java.lang.Byte value) { + setValue(mineplex.database.routines.AddThank.inIgnoreCooldown, value); + } + + /** + * Get the success parameter OUT value from the routine + */ + public java.lang.Byte getSuccess() { + return getValue(success); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/routines/ClaimThank.java b/Plugins/Mineplex.Database/src/mineplex/database/routines/ClaimThank.java new file mode 100644 index 000000000..d88ec80e7 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/routines/ClaimThank.java @@ -0,0 +1,67 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.routines; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClaimThank extends org.jooq.impl.AbstractRoutine implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 856582355; + + /** + * The parameter Account.claimThank.inAccountId. + */ + public static final org.jooq.Parameter inAccountId = createParameter("inAccountId", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.claimThank.amountClaimed. + */ + public static final org.jooq.Parameter amountClaimed = createParameter("amountClaimed", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.claimThank.uniqueThank. + */ + public static final org.jooq.Parameter uniqueThank = createParameter("uniqueThank", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * Create a new routine call instance + */ + public ClaimThank() { + super("claimThank", mineplex.database.Account.Account); + + addInParameter(inAccountId); + addOutParameter(amountClaimed); + addOutParameter(uniqueThank); + } + + /** + * Set the inAccountId parameter IN value to the routine + */ + public void setInAccountId(java.lang.Integer value) { + setValue(mineplex.database.routines.ClaimThank.inAccountId, value); + } + + /** + * Get the amountClaimed parameter OUT value from the routine + */ + public java.lang.Integer getAmountClaimed() { + return getValue(amountClaimed); + } + + /** + * Get the uniqueThank parameter OUT value from the routine + */ + public java.lang.Integer getUniqueThank() { + return getValue(uniqueThank); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThank.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThank.java new file mode 100644 index 000000000..1ede4b1b3 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThank.java @@ -0,0 +1,104 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountThank extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -1744584483; + + /** + * The reference instance of Account.accountThank + */ + public static final mineplex.database.tables.AccountThank accountThank = new mineplex.database.tables.AccountThank(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.AccountThankRecord.class; + } + + /** + * The column Account.accountThank.accountId. + */ + public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountThank.thanks. + */ + public final org.jooq.TableField thanks = createField("thanks", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); + + /** + * Create a Account.accountThank table reference + */ + public AccountThank() { + this("accountThank", null); + } + + /** + * Create an aliased Account.accountThank table reference + */ + public AccountThank(java.lang.String alias) { + this(alias, mineplex.database.tables.AccountThank.accountThank); + } + + private AccountThank(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private AccountThank(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_accountThank_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_accountThank_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.accountThank_accounts_id_fk); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.AccountThank as(java.lang.String alias) { + return new mineplex.database.tables.AccountThank(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.AccountThank rename(java.lang.String name) { + return new mineplex.database.tables.AccountThank(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThankTransactions.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThankTransactions.java new file mode 100644 index 000000000..dafbe15d1 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThankTransactions.java @@ -0,0 +1,147 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountThankTransactions extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 809892717; + + /** + * The reference instance of Account.accountThankTransactions + */ + public static final mineplex.database.tables.AccountThankTransactions accountThankTransactions = new mineplex.database.tables.AccountThankTransactions(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.AccountThankTransactionsRecord.class; + } + + /** + * The column Account.accountThankTransactions.id. + */ + public final org.jooq.TableField id = createField("id", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountThankTransactions.receiverId. + */ + public final org.jooq.TableField receiverId = createField("receiverId", org.jooq.impl.SQLDataType.INTEGER, this, ""); + + /** + * The column Account.accountThankTransactions.senderId. + */ + public final org.jooq.TableField senderId = createField("senderId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountThankTransactions.thankAmount. + */ + public final org.jooq.TableField thankAmount = createField("thankAmount", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.accountThankTransactions.reason. + */ + public final org.jooq.TableField reason = createField("reason", org.jooq.impl.SQLDataType.VARCHAR.length(32), this, ""); + + /** + * The column Account.accountThankTransactions.ignoreCooldown. + */ + public final org.jooq.TableField ignoreCooldown = createField("ignoreCooldown", org.jooq.impl.SQLDataType.TINYINT.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.accountThankTransactions.claimed. + */ + public final org.jooq.TableField claimed = createField("claimed", org.jooq.impl.SQLDataType.TINYINT.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.accountThankTransactions.sentTime. + */ + public final org.jooq.TableField sentTime = createField("sentTime", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.accountThankTransactions.claimTime. + */ + public final org.jooq.TableField claimTime = createField("claimTime", org.jooq.impl.SQLDataType.TIMESTAMP, this, ""); + + /** + * Create a Account.accountThankTransactions table reference + */ + public AccountThankTransactions() { + this("accountThankTransactions", null); + } + + /** + * Create an aliased Account.accountThankTransactions table reference + */ + public AccountThankTransactions(java.lang.String alias) { + this(alias, mineplex.database.tables.AccountThankTransactions.accountThankTransactions); + } + + private AccountThankTransactions(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private AccountThankTransactions(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Identity getIdentity() { + return mineplex.database.Keys.IDENTITY_accountThankTransactions; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_accountThankTransactions_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_accountThankTransactions_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.accountThankTransactions_accounts_id_fk2, mineplex.database.Keys.accountThankTransactions_accounts_id_fk); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.AccountThankTransactions as(java.lang.String alias) { + return new mineplex.database.tables.AccountThankTransactions(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.AccountThankTransactions rename(java.lang.String name) { + return new mineplex.database.tables.AccountThankTransactions(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountWebsiteLinkCode.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountWebsiteLinkCode.java new file mode 100644 index 000000000..9afc65380 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountWebsiteLinkCode.java @@ -0,0 +1,109 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountWebsiteLinkCode extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 2114439433; + + /** + * The reference instance of Account.accountWebsiteLinkCode + */ + public static final mineplex.database.tables.AccountWebsiteLinkCode accountWebsiteLinkCode = new mineplex.database.tables.AccountWebsiteLinkCode(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.AccountWebsiteLinkCodeRecord.class; + } + + /** + * The column Account.accountWebsiteLinkCode.accountId. + */ + public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountWebsiteLinkCode.confirmationCode. + */ + public final org.jooq.TableField confirmationCode = createField("confirmationCode", org.jooq.impl.SQLDataType.CHAR.length(6).nullable(false), this, ""); + + /** + * The column Account.accountWebsiteLinkCode.date. + */ + public final org.jooq.TableField date = createField("date", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaulted(true), this, ""); + + /** + * Create a Account.accountWebsiteLinkCode table reference + */ + public AccountWebsiteLinkCode() { + this("accountWebsiteLinkCode", null); + } + + /** + * Create an aliased Account.accountWebsiteLinkCode table reference + */ + public AccountWebsiteLinkCode(java.lang.String alias) { + this(alias, mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode); + } + + private AccountWebsiteLinkCode(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private AccountWebsiteLinkCode(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_accountWebsiteLinkCode_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_accountWebsiteLinkCode_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.accountWebsiteLinkCode_ibfk_1); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.AccountWebsiteLinkCode as(java.lang.String alias) { + return new mineplex.database.tables.AccountWebsiteLinkCode(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.AccountWebsiteLinkCode rename(java.lang.String name) { + return new mineplex.database.tables.AccountWebsiteLinkCode(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/ClanBanners.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/ClanBanners.java new file mode 100644 index 000000000..737c017b1 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/ClanBanners.java @@ -0,0 +1,101 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClanBanners extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -633858329; + + /** + * The reference instance of Account.clanBanners + */ + public static final mineplex.database.tables.ClanBanners clanBanners = new mineplex.database.tables.ClanBanners(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.ClanBannersRecord.class; + } + + /** + * The column Account.clanBanners.clanId. + */ + public final org.jooq.TableField clanId = createField("clanId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.clanBanners.baseColor. + */ + public final org.jooq.TableField baseColor = createField("baseColor", org.jooq.impl.SQLDataType.VARCHAR.length(15), this, ""); + + /** + * The column Account.clanBanners.patterns. + */ + public final org.jooq.TableField patterns = createField("patterns", org.jooq.impl.SQLDataType.VARCHAR.length(300), this, ""); + + /** + * Create a Account.clanBanners table reference + */ + public ClanBanners() { + this("clanBanners", null); + } + + /** + * Create an aliased Account.clanBanners table reference + */ + public ClanBanners(java.lang.String alias) { + this(alias, mineplex.database.tables.ClanBanners.clanBanners); + } + + private ClanBanners(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private ClanBanners(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_clanBanners_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_clanBanners_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.ClanBanners as(java.lang.String alias) { + return new mineplex.database.tables.ClanBanners(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.ClanBanners rename(java.lang.String name) { + return new mineplex.database.tables.ClanBanners(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/ClansGold.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/ClansGold.java new file mode 100644 index 000000000..a8618fea5 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/ClansGold.java @@ -0,0 +1,109 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClansGold extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 950104617; + + /** + * The reference instance of Account.clansGold + */ + public static final mineplex.database.tables.ClansGold clansGold = new mineplex.database.tables.ClansGold(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.ClansGoldRecord.class; + } + + /** + * The column Account.clansGold.serverId. + */ + public final org.jooq.TableField serverId = createField("serverId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.clansGold.id. + */ + public final org.jooq.TableField id = createField("id", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.clansGold.gold. + */ + public final org.jooq.TableField gold = createField("gold", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * Create a Account.clansGold table reference + */ + public ClansGold() { + this("clansGold", null); + } + + /** + * Create an aliased Account.clansGold table reference + */ + public ClansGold(java.lang.String alias) { + this(alias, mineplex.database.tables.ClansGold.clansGold); + } + + private ClansGold(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private ClansGold(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_clansGold_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_clansGold_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.clansGold_ibfk_1, mineplex.database.Keys.clansGold_ibfk_2); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.ClansGold as(java.lang.String alias) { + return new mineplex.database.tables.ClansGold(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.ClansGold rename(java.lang.String name) { + return new mineplex.database.tables.ClansGold(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/ClansNetherPortals.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/ClansNetherPortals.java new file mode 100644 index 000000000..200912a7d --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/ClansNetherPortals.java @@ -0,0 +1,114 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClansNetherPortals extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -1556693012; + + /** + * The reference instance of Account.clansNetherPortals + */ + public static final mineplex.database.tables.ClansNetherPortals clansNetherPortals = new mineplex.database.tables.ClansNetherPortals(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.ClansNetherPortalsRecord.class; + } + + /** + * The column Account.clansNetherPortals.id. + */ + public final org.jooq.TableField id = createField("id", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.clansNetherPortals.cornerOne. + */ + public final org.jooq.TableField cornerOne = createField("cornerOne", org.jooq.impl.SQLDataType.VARCHAR.length(30), this, ""); + + /** + * The column Account.clansNetherPortals.cornerTwo. + */ + public final org.jooq.TableField cornerTwo = createField("cornerTwo", org.jooq.impl.SQLDataType.VARCHAR.length(30), this, ""); + + /** + * The column Account.clansNetherPortals.returnPortal. + */ + public final org.jooq.TableField returnPortal = createField("returnPortal", org.jooq.impl.SQLDataType.TINYINT, this, ""); + + /** + * Create a Account.clansNetherPortals table reference + */ + public ClansNetherPortals() { + this("clansNetherPortals", null); + } + + /** + * Create an aliased Account.clansNetherPortals table reference + */ + public ClansNetherPortals(java.lang.String alias) { + this(alias, mineplex.database.tables.ClansNetherPortals.clansNetherPortals); + } + + private ClansNetherPortals(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private ClansNetherPortals(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Identity getIdentity() { + return mineplex.database.Keys.IDENTITY_clansNetherPortals; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_clansNetherPortals_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_clansNetherPortals_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.ClansNetherPortals as(java.lang.String alias) { + return new mineplex.database.tables.ClansNetherPortals(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.ClansNetherPortals rename(java.lang.String name) { + return new mineplex.database.tables.ClansNetherPortals(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/Kit_progression.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/Kit_progression.java deleted file mode 100644 index 836eaf7c7..000000000 --- a/Plugins/Mineplex.Database/src/mineplex/database/tables/Kit_progression.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * This class is generated by jOOQ - */ -package mineplex.database.tables; - -/** - * This class is generated by jOOQ. - */ -@javax.annotation.Generated( - value = { - "http://www.jooq.org", - "jOOQ version:3.5.2" - }, - comments = "This class is generated by jOOQ" -) -@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) -public class Kit_progression extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { - - private static final long serialVersionUID = 144258751; - - /** - * The reference instance of Account.kit_progression - */ - public static final mineplex.database.tables.Kit_progression kit_progression = new mineplex.database.tables.Kit_progression(); - - /** - * The class holding records for this type - */ - @Override - public java.lang.Class getRecordType() { - return mineplex.database.tables.records.Kit_progressionRecord.class; - } - - /** - * The column Account.kit_progression.account_id. - */ - public final org.jooq.TableField account_id = createField("account_id", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); - - /** - * The column Account.kit_progression.kit_id. - */ - public final org.jooq.TableField kit_id = createField("kit_id", org.jooq.impl.SQLDataType.VARCHAR.length(64).nullable(false).defaulted(true), this, ""); - - /** - * The column Account.kit_progression.level. - */ - public final org.jooq.TableField level = createField("level", org.jooq.impl.SQLDataType.INTEGER, this, ""); - - /** - * The column Account.kit_progression.xp. - */ - public final org.jooq.TableField xp = createField("xp", org.jooq.impl.SQLDataType.INTEGER, this, ""); - - /** - * The column Account.kit_progression.upgrade_level. - */ - public final org.jooq.TableField upgrade_level = createField("upgrade_level", org.jooq.impl.SQLDataType.INTEGER, this, ""); - - /** - * The column Account.kit_progression.default. - */ - public final org.jooq.TableField default_ = createField("default", org.jooq.impl.SQLDataType.TINYINT, this, ""); - - /** - * Create a Account.kit_progression table reference - */ - public Kit_progression() { - this("kit_progression", null); - } - - /** - * Create an aliased Account.kit_progression table reference - */ - public Kit_progression(java.lang.String alias) { - this(alias, mineplex.database.tables.Kit_progression.kit_progression); - } - - private Kit_progression(java.lang.String alias, org.jooq.Table aliased) { - this(alias, aliased, null); - } - - private Kit_progression(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { - super(alias, mineplex.database.Account.Account, aliased, parameters, ""); - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.UniqueKey getPrimaryKey() { - return mineplex.database.Keys.KEY_kit_progression_PRIMARY; - } - - /** - * {@inheritDoc} - */ - @Override - public java.util.List> getKeys() { - return java.util.Arrays.>asList(mineplex.database.Keys.KEY_kit_progression_PRIMARY); - } - - /** - * {@inheritDoc} - */ - @Override - public mineplex.database.tables.Kit_progression as(java.lang.String alias) { - return new mineplex.database.tables.Kit_progression(alias, this); - } - - /** - * Rename this table - */ - public mineplex.database.tables.Kit_progression rename(java.lang.String name) { - return new mineplex.database.tables.Kit_progression(name, null); - } -} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/NonPremiumJoinMessage.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/NonPremiumJoinMessage.java new file mode 100644 index 000000000..16d497ab8 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/NonPremiumJoinMessage.java @@ -0,0 +1,75 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class NonPremiumJoinMessage extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 1100695916; + + /** + * The reference instance of Account.nonPremiumJoinMessage + */ + public static final mineplex.database.tables.NonPremiumJoinMessage nonPremiumJoinMessage = new mineplex.database.tables.NonPremiumJoinMessage(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.NonPremiumJoinMessageRecord.class; + } + + /** + * The column Account.nonPremiumJoinMessage.message. + */ + public final org.jooq.TableField message = createField("message", org.jooq.impl.SQLDataType.CLOB, this, ""); + + /** + * Create a Account.nonPremiumJoinMessage table reference + */ + public NonPremiumJoinMessage() { + this("nonPremiumJoinMessage", null); + } + + /** + * Create an aliased Account.nonPremiumJoinMessage table reference + */ + public NonPremiumJoinMessage(java.lang.String alias) { + this(alias, mineplex.database.tables.NonPremiumJoinMessage.nonPremiumJoinMessage); + } + + private NonPremiumJoinMessage(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private NonPremiumJoinMessage(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.NonPremiumJoinMessage as(java.lang.String alias) { + return new mineplex.database.tables.NonPremiumJoinMessage(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.NonPremiumJoinMessage rename(java.lang.String name) { + return new mineplex.database.tables.NonPremiumJoinMessage(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/PowerPlayClub.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/PowerPlayClub.java new file mode 100644 index 000000000..148384d3f --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/PowerPlayClub.java @@ -0,0 +1,109 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class PowerPlayClub extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -521671017; + + /** + * The reference instance of Account.powerPlayClub + */ + public static final mineplex.database.tables.PowerPlayClub powerPlayClub = new mineplex.database.tables.PowerPlayClub(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.PowerPlayClubRecord.class; + } + + /** + * The column Account.powerPlayClub.accountId. + */ + public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.powerPlayClub.kvKey. + */ + public final org.jooq.TableField kvKey = createField("kvKey", org.jooq.impl.SQLDataType.VARCHAR.length(255).nullable(false), this, ""); + + /** + * The column Account.powerPlayClub.kvValue. + */ + public final org.jooq.TableField kvValue = createField("kvValue", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * Create a Account.powerPlayClub table reference + */ + public PowerPlayClub() { + this("powerPlayClub", null); + } + + /** + * Create an aliased Account.powerPlayClub table reference + */ + public PowerPlayClub(java.lang.String alias) { + this(alias, mineplex.database.tables.PowerPlayClub.powerPlayClub); + } + + private PowerPlayClub(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private PowerPlayClub(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_powerPlayClub_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_powerPlayClub_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.powerPlayClub_ibfk_1); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.PowerPlayClub as(java.lang.String alias) { + return new mineplex.database.tables.PowerPlayClub(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.PowerPlayClub rename(java.lang.String name) { + return new mineplex.database.tables.PowerPlayClub(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/Unicodereplacer.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/Unicodereplacer.java new file mode 100644 index 000000000..5e9e15ac0 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/Unicodereplacer.java @@ -0,0 +1,119 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Unicodereplacer extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 613849358; + + /** + * The reference instance of Account.unicodereplacer + */ + public static final mineplex.database.tables.Unicodereplacer unicodereplacer = new mineplex.database.tables.Unicodereplacer(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.UnicodereplacerRecord.class; + } + + /** + * The column Account.unicodereplacer.id. + */ + public final org.jooq.TableField id = createField("id", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.unicodereplacer.unicode. + */ + public final org.jooq.TableField unicode = createField("unicode", org.jooq.impl.SQLDataType.VARCHAR.length(4), this, ""); + + /** + * The column Account.unicodereplacer.replacement. + */ + public final org.jooq.TableField replacement = createField("replacement", org.jooq.impl.SQLDataType.VARCHAR.length(8), this, ""); + + /** + * The column Account.unicodereplacer.created_by. + */ + public final org.jooq.TableField created_by = createField("created_by", org.jooq.impl.SQLDataType.VARCHAR.length(64), this, ""); + + /** + * The column Account.unicodereplacer.removed_by. + */ + public final org.jooq.TableField removed_by = createField("removed_by", org.jooq.impl.SQLDataType.VARCHAR.length(64), this, ""); + + /** + * Create a Account.unicodereplacer table reference + */ + public Unicodereplacer() { + this("unicodereplacer", null); + } + + /** + * Create an aliased Account.unicodereplacer table reference + */ + public Unicodereplacer(java.lang.String alias) { + this(alias, mineplex.database.tables.Unicodereplacer.unicodereplacer); + } + + private Unicodereplacer(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private Unicodereplacer(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Identity getIdentity() { + return mineplex.database.Keys.IDENTITY_unicodereplacer; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_unicodereplacer_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_unicodereplacer_PRIMARY, mineplex.database.Keys.KEY_unicodereplacer_unicode); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.Unicodereplacer as(java.lang.String alias) { + return new mineplex.database.tables.Unicodereplacer(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.Unicodereplacer rename(java.lang.String name) { + return new mineplex.database.tables.Unicodereplacer(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/Youtube.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/Youtube.java new file mode 100644 index 000000000..e150be718 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/Youtube.java @@ -0,0 +1,112 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Youtube extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 1588929727; + + /** + * The reference instance of Account.youtube + */ + public static final mineplex.database.tables.Youtube youtube = new mineplex.database.tables.Youtube(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.YoutubeRecord.class; + } + + /** + * The column Account.youtube.accountId. + */ + public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.youtube.clicktime. + */ + public final org.jooq.TableField clicktime = createField("clicktime", org.jooq.impl.SQLDataType.DATE, this, ""); + + /** + * Create a Account.youtube table reference + */ + public Youtube() { + this("youtube", null); + } + + /** + * Create an aliased Account.youtube table reference + */ + public Youtube(java.lang.String alias) { + this(alias, mineplex.database.tables.Youtube.youtube); + } + + private Youtube(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private Youtube(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Identity getIdentity() { + return mineplex.database.Keys.IDENTITY_youtube; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_youtube_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_youtube_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.youtube_ibfk_1); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.Youtube as(java.lang.String alias) { + return new mineplex.database.tables.Youtube(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.Youtube rename(java.lang.String name) { + return new mineplex.database.tables.Youtube(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankRecord.java new file mode 100644 index 000000000..6b932a8f2 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankRecord.java @@ -0,0 +1,159 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountThankRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record2 { + + private static final long serialVersionUID = -183734569; + + /** + * Setter for Account.accountThank.accountId. + */ + public void setAccountId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.accountThank.accountId. + */ + public java.lang.Integer getAccountId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.accountThank.thanks. + */ + public void setThanks(java.lang.Integer value) { + setValue(1, value); + } + + /** + * Getter for Account.accountThank.thanks. + */ + public java.lang.Integer getThanks() { + return (java.lang.Integer) getValue(1); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record2 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row2 fieldsRow() { + return (org.jooq.Row2) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row2 valuesRow() { + return (org.jooq.Row2) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.AccountThank.accountThank.accountId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.AccountThank.accountThank.thanks; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getAccountId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value2() { + return getThanks(); + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankRecord value1(java.lang.Integer value) { + setAccountId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankRecord value2(java.lang.Integer value) { + setThanks(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankRecord values(java.lang.Integer value1, java.lang.Integer value2) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached AccountThankRecord + */ + public AccountThankRecord() { + super(mineplex.database.tables.AccountThank.accountThank); + } + + /** + * Create a detached, initialised AccountThankRecord + */ + public AccountThankRecord(java.lang.Integer accountId, java.lang.Integer thanks) { + super(mineplex.database.tables.AccountThank.accountThank); + + setValue(0, accountId); + setValue(1, thanks); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankTransactionsRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankTransactionsRecord.java new file mode 100644 index 000000000..d4cd2c004 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankTransactionsRecord.java @@ -0,0 +1,439 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountThankTransactionsRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record9 { + + private static final long serialVersionUID = -1604313652; + + /** + * Setter for Account.accountThankTransactions.id. + */ + public void setId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.accountThankTransactions.id. + */ + public java.lang.Integer getId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.accountThankTransactions.receiverId. + */ + public void setReceiverId(java.lang.Integer value) { + setValue(1, value); + } + + /** + * Getter for Account.accountThankTransactions.receiverId. + */ + public java.lang.Integer getReceiverId() { + return (java.lang.Integer) getValue(1); + } + + /** + * Setter for Account.accountThankTransactions.senderId. + */ + public void setSenderId(java.lang.Integer value) { + setValue(2, value); + } + + /** + * Getter for Account.accountThankTransactions.senderId. + */ + public java.lang.Integer getSenderId() { + return (java.lang.Integer) getValue(2); + } + + /** + * Setter for Account.accountThankTransactions.thankAmount. + */ + public void setThankAmount(java.lang.Integer value) { + setValue(3, value); + } + + /** + * Getter for Account.accountThankTransactions.thankAmount. + */ + public java.lang.Integer getThankAmount() { + return (java.lang.Integer) getValue(3); + } + + /** + * Setter for Account.accountThankTransactions.reason. + */ + public void setReason(java.lang.String value) { + setValue(4, value); + } + + /** + * Getter for Account.accountThankTransactions.reason. + */ + public java.lang.String getReason() { + return (java.lang.String) getValue(4); + } + + /** + * Setter for Account.accountThankTransactions.ignoreCooldown. + */ + public void setIgnoreCooldown(java.lang.Byte value) { + setValue(5, value); + } + + /** + * Getter for Account.accountThankTransactions.ignoreCooldown. + */ + public java.lang.Byte getIgnoreCooldown() { + return (java.lang.Byte) getValue(5); + } + + /** + * Setter for Account.accountThankTransactions.claimed. + */ + public void setClaimed(java.lang.Byte value) { + setValue(6, value); + } + + /** + * Getter for Account.accountThankTransactions.claimed. + */ + public java.lang.Byte getClaimed() { + return (java.lang.Byte) getValue(6); + } + + /** + * Setter for Account.accountThankTransactions.sentTime. + */ + public void setSentTime(java.sql.Timestamp value) { + setValue(7, value); + } + + /** + * Getter for Account.accountThankTransactions.sentTime. + */ + public java.sql.Timestamp getSentTime() { + return (java.sql.Timestamp) getValue(7); + } + + /** + * Setter for Account.accountThankTransactions.claimTime. + */ + public void setClaimTime(java.sql.Timestamp value) { + setValue(8, value); + } + + /** + * Getter for Account.accountThankTransactions.claimTime. + */ + public java.sql.Timestamp getClaimTime() { + return (java.sql.Timestamp) getValue(8); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record9 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row9 fieldsRow() { + return (org.jooq.Row9) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row9 valuesRow() { + return (org.jooq.Row9) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.id; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.receiverId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.senderId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field4() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.thankAmount; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field5() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.reason; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field6() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.ignoreCooldown; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field7() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.claimed; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field8() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.sentTime; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field9() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.claimTime; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value2() { + return getReceiverId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value3() { + return getSenderId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value4() { + return getThankAmount(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value5() { + return getReason(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Byte value6() { + return getIgnoreCooldown(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Byte value7() { + return getClaimed(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.sql.Timestamp value8() { + return getSentTime(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.sql.Timestamp value9() { + return getClaimTime(); + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value1(java.lang.Integer value) { + setId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value2(java.lang.Integer value) { + setReceiverId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value3(java.lang.Integer value) { + setSenderId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value4(java.lang.Integer value) { + setThankAmount(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value5(java.lang.String value) { + setReason(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value6(java.lang.Byte value) { + setIgnoreCooldown(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value7(java.lang.Byte value) { + setClaimed(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value8(java.sql.Timestamp value) { + setSentTime(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value9(java.sql.Timestamp value) { + setClaimTime(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord values(java.lang.Integer value1, java.lang.Integer value2, java.lang.Integer value3, java.lang.Integer value4, java.lang.String value5, java.lang.Byte value6, java.lang.Byte value7, java.sql.Timestamp value8, java.sql.Timestamp value9) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached AccountThankTransactionsRecord + */ + public AccountThankTransactionsRecord() { + super(mineplex.database.tables.AccountThankTransactions.accountThankTransactions); + } + + /** + * Create a detached, initialised AccountThankTransactionsRecord + */ + public AccountThankTransactionsRecord(java.lang.Integer id, java.lang.Integer receiverId, java.lang.Integer senderId, java.lang.Integer thankAmount, java.lang.String reason, java.lang.Byte ignoreCooldown, java.lang.Byte claimed, java.sql.Timestamp sentTime, java.sql.Timestamp claimTime) { + super(mineplex.database.tables.AccountThankTransactions.accountThankTransactions); + + setValue(0, id); + setValue(1, receiverId); + setValue(2, senderId); + setValue(3, thankAmount); + setValue(4, reason); + setValue(5, ignoreCooldown); + setValue(6, claimed); + setValue(7, sentTime); + setValue(8, claimTime); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountWebsiteLinkCodeRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountWebsiteLinkCodeRecord.java new file mode 100644 index 000000000..c71003242 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountWebsiteLinkCodeRecord.java @@ -0,0 +1,199 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountWebsiteLinkCodeRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { + + private static final long serialVersionUID = -505757434; + + /** + * Setter for Account.accountWebsiteLinkCode.accountId. + */ + public void setAccountId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.accountWebsiteLinkCode.accountId. + */ + public java.lang.Integer getAccountId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.accountWebsiteLinkCode.confirmationCode. + */ + public void setConfirmationCode(java.lang.String value) { + setValue(1, value); + } + + /** + * Getter for Account.accountWebsiteLinkCode.confirmationCode. + */ + public java.lang.String getConfirmationCode() { + return (java.lang.String) getValue(1); + } + + /** + * Setter for Account.accountWebsiteLinkCode.date. + */ + public void setDate(java.sql.Timestamp value) { + setValue(2, value); + } + + /** + * Getter for Account.accountWebsiteLinkCode.date. + */ + public java.sql.Timestamp getDate() { + return (java.sql.Timestamp) getValue(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 fieldsRow() { + return (org.jooq.Row3) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 valuesRow() { + return (org.jooq.Row3) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode.accountId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode.confirmationCode; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode.date; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getAccountId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value2() { + return getConfirmationCode(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.sql.Timestamp value3() { + return getDate(); + } + + /** + * {@inheritDoc} + */ + @Override + public AccountWebsiteLinkCodeRecord value1(java.lang.Integer value) { + setAccountId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountWebsiteLinkCodeRecord value2(java.lang.String value) { + setConfirmationCode(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountWebsiteLinkCodeRecord value3(java.sql.Timestamp value) { + setDate(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountWebsiteLinkCodeRecord values(java.lang.Integer value1, java.lang.String value2, java.sql.Timestamp value3) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached AccountWebsiteLinkCodeRecord + */ + public AccountWebsiteLinkCodeRecord() { + super(mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode); + } + + /** + * Create a detached, initialised AccountWebsiteLinkCodeRecord + */ + public AccountWebsiteLinkCodeRecord(java.lang.Integer accountId, java.lang.String confirmationCode, java.sql.Timestamp date) { + super(mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode); + + setValue(0, accountId); + setValue(1, confirmationCode); + setValue(2, date); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClanBannersRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClanBannersRecord.java new file mode 100644 index 000000000..5ae2da306 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClanBannersRecord.java @@ -0,0 +1,199 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClanBannersRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { + + private static final long serialVersionUID = 830973431; + + /** + * Setter for Account.clanBanners.clanId. + */ + public void setClanId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.clanBanners.clanId. + */ + public java.lang.Integer getClanId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.clanBanners.baseColor. + */ + public void setBaseColor(java.lang.String value) { + setValue(1, value); + } + + /** + * Getter for Account.clanBanners.baseColor. + */ + public java.lang.String getBaseColor() { + return (java.lang.String) getValue(1); + } + + /** + * Setter for Account.clanBanners.patterns. + */ + public void setPatterns(java.lang.String value) { + setValue(2, value); + } + + /** + * Getter for Account.clanBanners.patterns. + */ + public java.lang.String getPatterns() { + return (java.lang.String) getValue(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 fieldsRow() { + return (org.jooq.Row3) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 valuesRow() { + return (org.jooq.Row3) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.ClanBanners.clanBanners.clanId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.ClanBanners.clanBanners.baseColor; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.ClanBanners.clanBanners.patterns; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getClanId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value2() { + return getBaseColor(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value3() { + return getPatterns(); + } + + /** + * {@inheritDoc} + */ + @Override + public ClanBannersRecord value1(java.lang.Integer value) { + setClanId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClanBannersRecord value2(java.lang.String value) { + setBaseColor(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClanBannersRecord value3(java.lang.String value) { + setPatterns(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClanBannersRecord values(java.lang.Integer value1, java.lang.String value2, java.lang.String value3) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached ClanBannersRecord + */ + public ClanBannersRecord() { + super(mineplex.database.tables.ClanBanners.clanBanners); + } + + /** + * Create a detached, initialised ClanBannersRecord + */ + public ClanBannersRecord(java.lang.Integer clanId, java.lang.String baseColor, java.lang.String patterns) { + super(mineplex.database.tables.ClanBanners.clanBanners); + + setValue(0, clanId); + setValue(1, baseColor); + setValue(2, patterns); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansGoldRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansGoldRecord.java new file mode 100644 index 000000000..3f693103c --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansGoldRecord.java @@ -0,0 +1,199 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClansGoldRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { + + private static final long serialVersionUID = -90641108; + + /** + * Setter for Account.clansGold.serverId. + */ + public void setServerId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.clansGold.serverId. + */ + public java.lang.Integer getServerId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.clansGold.id. + */ + public void setId(java.lang.Integer value) { + setValue(1, value); + } + + /** + * Getter for Account.clansGold.id. + */ + public java.lang.Integer getId() { + return (java.lang.Integer) getValue(1); + } + + /** + * Setter for Account.clansGold.gold. + */ + public void setGold(java.lang.Integer value) { + setValue(2, value); + } + + /** + * Getter for Account.clansGold.gold. + */ + public java.lang.Integer getGold() { + return (java.lang.Integer) getValue(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record2 key() { + return (org.jooq.Record2) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 fieldsRow() { + return (org.jooq.Row3) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 valuesRow() { + return (org.jooq.Row3) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.ClansGold.clansGold.serverId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.ClansGold.clansGold.id; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.ClansGold.clansGold.gold; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getServerId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value2() { + return getId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value3() { + return getGold(); + } + + /** + * {@inheritDoc} + */ + @Override + public ClansGoldRecord value1(java.lang.Integer value) { + setServerId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansGoldRecord value2(java.lang.Integer value) { + setId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansGoldRecord value3(java.lang.Integer value) { + setGold(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansGoldRecord values(java.lang.Integer value1, java.lang.Integer value2, java.lang.Integer value3) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached ClansGoldRecord + */ + public ClansGoldRecord() { + super(mineplex.database.tables.ClansGold.clansGold); + } + + /** + * Create a detached, initialised ClansGoldRecord + */ + public ClansGoldRecord(java.lang.Integer serverId, java.lang.Integer id, java.lang.Integer gold) { + super(mineplex.database.tables.ClansGold.clansGold); + + setValue(0, serverId); + setValue(1, id); + setValue(2, gold); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansNetherPortalsRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansNetherPortalsRecord.java new file mode 100644 index 000000000..018a7a89e --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansNetherPortalsRecord.java @@ -0,0 +1,239 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClansNetherPortalsRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record4 { + + private static final long serialVersionUID = -1366559485; + + /** + * Setter for Account.clansNetherPortals.id. + */ + public void setId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.clansNetherPortals.id. + */ + public java.lang.Integer getId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.clansNetherPortals.cornerOne. + */ + public void setCornerOne(java.lang.String value) { + setValue(1, value); + } + + /** + * Getter for Account.clansNetherPortals.cornerOne. + */ + public java.lang.String getCornerOne() { + return (java.lang.String) getValue(1); + } + + /** + * Setter for Account.clansNetherPortals.cornerTwo. + */ + public void setCornerTwo(java.lang.String value) { + setValue(2, value); + } + + /** + * Getter for Account.clansNetherPortals.cornerTwo. + */ + public java.lang.String getCornerTwo() { + return (java.lang.String) getValue(2); + } + + /** + * Setter for Account.clansNetherPortals.returnPortal. + */ + public void setReturnPortal(java.lang.Byte value) { + setValue(3, value); + } + + /** + * Getter for Account.clansNetherPortals.returnPortal. + */ + public java.lang.Byte getReturnPortal() { + return (java.lang.Byte) getValue(3); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record4 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row4 fieldsRow() { + return (org.jooq.Row4) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row4 valuesRow() { + return (org.jooq.Row4) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.ClansNetherPortals.clansNetherPortals.id; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.ClansNetherPortals.clansNetherPortals.cornerOne; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.ClansNetherPortals.clansNetherPortals.cornerTwo; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field4() { + return mineplex.database.tables.ClansNetherPortals.clansNetherPortals.returnPortal; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value2() { + return getCornerOne(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value3() { + return getCornerTwo(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Byte value4() { + return getReturnPortal(); + } + + /** + * {@inheritDoc} + */ + @Override + public ClansNetherPortalsRecord value1(java.lang.Integer value) { + setId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansNetherPortalsRecord value2(java.lang.String value) { + setCornerOne(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansNetherPortalsRecord value3(java.lang.String value) { + setCornerTwo(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansNetherPortalsRecord value4(java.lang.Byte value) { + setReturnPortal(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansNetherPortalsRecord values(java.lang.Integer value1, java.lang.String value2, java.lang.String value3, java.lang.Byte value4) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached ClansNetherPortalsRecord + */ + public ClansNetherPortalsRecord() { + super(mineplex.database.tables.ClansNetherPortals.clansNetherPortals); + } + + /** + * Create a detached, initialised ClansNetherPortalsRecord + */ + public ClansNetherPortalsRecord(java.lang.Integer id, java.lang.String cornerOne, java.lang.String cornerTwo, java.lang.Byte returnPortal) { + super(mineplex.database.tables.ClansNetherPortals.clansNetherPortals); + + setValue(0, id); + setValue(1, cornerOne); + setValue(2, cornerTwo); + setValue(3, returnPortal); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/Kit_progressionRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/Kit_progressionRecord.java deleted file mode 100644 index b38e32b8c..000000000 --- a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/Kit_progressionRecord.java +++ /dev/null @@ -1,319 +0,0 @@ -/** - * This class is generated by jOOQ - */ -package mineplex.database.tables.records; - -/** - * This class is generated by jOOQ. - */ -@javax.annotation.Generated( - value = { - "http://www.jooq.org", - "jOOQ version:3.5.2" - }, - comments = "This class is generated by jOOQ" -) -@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) -public class Kit_progressionRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record6 { - - private static final long serialVersionUID = 1893691977; - - /** - * Setter for Account.kit_progression.account_id. - */ - public void setAccount_id(java.lang.Integer value) { - setValue(0, value); - } - - /** - * Getter for Account.kit_progression.account_id. - */ - public java.lang.Integer getAccount_id() { - return (java.lang.Integer) getValue(0); - } - - /** - * Setter for Account.kit_progression.kit_id. - */ - public void setKit_id(java.lang.String value) { - setValue(1, value); - } - - /** - * Getter for Account.kit_progression.kit_id. - */ - public java.lang.String getKit_id() { - return (java.lang.String) getValue(1); - } - - /** - * Setter for Account.kit_progression.level. - */ - public void setLevel(java.lang.Integer value) { - setValue(2, value); - } - - /** - * Getter for Account.kit_progression.level. - */ - public java.lang.Integer getLevel() { - return (java.lang.Integer) getValue(2); - } - - /** - * Setter for Account.kit_progression.xp. - */ - public void setXp(java.lang.Integer value) { - setValue(3, value); - } - - /** - * Getter for Account.kit_progression.xp. - */ - public java.lang.Integer getXp() { - return (java.lang.Integer) getValue(3); - } - - /** - * Setter for Account.kit_progression.upgrade_level. - */ - public void setUpgrade_level(java.lang.Integer value) { - setValue(4, value); - } - - /** - * Getter for Account.kit_progression.upgrade_level. - */ - public java.lang.Integer getUpgrade_level() { - return (java.lang.Integer) getValue(4); - } - - /** - * Setter for Account.kit_progression.default. - */ - public void setDefault(java.lang.Byte value) { - setValue(5, value); - } - - /** - * Getter for Account.kit_progression.default. - */ - public java.lang.Byte getDefault() { - return (java.lang.Byte) getValue(5); - } - - // ------------------------------------------------------------------------- - // Primary key information - // ------------------------------------------------------------------------- - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Record2 key() { - return (org.jooq.Record2) super.key(); - } - - // ------------------------------------------------------------------------- - // Record6 type implementation - // ------------------------------------------------------------------------- - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Row6 fieldsRow() { - return (org.jooq.Row6) super.fieldsRow(); - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Row6 valuesRow() { - return (org.jooq.Row6) super.valuesRow(); - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field1() { - return mineplex.database.tables.Kit_progression.kit_progression.account_id; - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field2() { - return mineplex.database.tables.Kit_progression.kit_progression.kit_id; - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field3() { - return mineplex.database.tables.Kit_progression.kit_progression.level; - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field4() { - return mineplex.database.tables.Kit_progression.kit_progression.xp; - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field5() { - return mineplex.database.tables.Kit_progression.kit_progression.upgrade_level; - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field6() { - return mineplex.database.tables.Kit_progression.kit_progression.default_; - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.Integer value1() { - return getAccount_id(); - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.String value2() { - return getKit_id(); - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.Integer value3() { - return getLevel(); - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.Integer value4() { - return getXp(); - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.Integer value5() { - return getUpgrade_level(); - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.Byte value6() { - return getDefault(); - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord value1(java.lang.Integer value) { - setAccount_id(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord value2(java.lang.String value) { - setKit_id(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord value3(java.lang.Integer value) { - setLevel(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord value4(java.lang.Integer value) { - setXp(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord value5(java.lang.Integer value) { - setUpgrade_level(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord value6(java.lang.Byte value) { - setDefault(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord values(java.lang.Integer value1, java.lang.String value2, java.lang.Integer value3, java.lang.Integer value4, java.lang.Integer value5, java.lang.Byte value6) { - return this; - } - - // ------------------------------------------------------------------------- - // Constructors - // ------------------------------------------------------------------------- - - /** - * Create a detached Kit_progressionRecord - */ - public Kit_progressionRecord() { - super(mineplex.database.tables.Kit_progression.kit_progression); - } - - /** - * Create a detached, initialised Kit_progressionRecord - */ - public Kit_progressionRecord(java.lang.Integer account_id, java.lang.String kit_id, java.lang.Integer level, java.lang.Integer xp, java.lang.Integer upgrade_level, java.lang.Byte default_) { - super(mineplex.database.tables.Kit_progression.kit_progression); - - setValue(0, account_id); - setValue(1, kit_id); - setValue(2, level); - setValue(3, xp); - setValue(4, upgrade_level); - setValue(5, default_); - } -} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/NonPremiumJoinMessageRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/NonPremiumJoinMessageRecord.java new file mode 100644 index 000000000..1c1396a12 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/NonPremiumJoinMessageRecord.java @@ -0,0 +1,107 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class NonPremiumJoinMessageRecord extends org.jooq.impl.TableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record1 { + + private static final long serialVersionUID = 988609111; + + /** + * Setter for Account.nonPremiumJoinMessage.message. + */ + public void setMessage(java.lang.String value) { + setValue(0, value); + } + + /** + * Getter for Account.nonPremiumJoinMessage.message. + */ + public java.lang.String getMessage() { + return (java.lang.String) getValue(0); + } + + // ------------------------------------------------------------------------- + // Record1 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row1 fieldsRow() { + return (org.jooq.Row1) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row1 valuesRow() { + return (org.jooq.Row1) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.NonPremiumJoinMessage.nonPremiumJoinMessage.message; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value1() { + return getMessage(); + } + + /** + * {@inheritDoc} + */ + @Override + public NonPremiumJoinMessageRecord value1(java.lang.String value) { + setMessage(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public NonPremiumJoinMessageRecord values(java.lang.String value1) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached NonPremiumJoinMessageRecord + */ + public NonPremiumJoinMessageRecord() { + super(mineplex.database.tables.NonPremiumJoinMessage.nonPremiumJoinMessage); + } + + /** + * Create a detached, initialised NonPremiumJoinMessageRecord + */ + public NonPremiumJoinMessageRecord(java.lang.String message) { + super(mineplex.database.tables.NonPremiumJoinMessage.nonPremiumJoinMessage); + + setValue(0, message); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/PowerPlayClubRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/PowerPlayClubRecord.java new file mode 100644 index 000000000..cea0382f0 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/PowerPlayClubRecord.java @@ -0,0 +1,199 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class PowerPlayClubRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { + + private static final long serialVersionUID = 1651396391; + + /** + * Setter for Account.powerPlayClub.accountId. + */ + public void setAccountId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.powerPlayClub.accountId. + */ + public java.lang.Integer getAccountId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.powerPlayClub.kvKey. + */ + public void setKvKey(java.lang.String value) { + setValue(1, value); + } + + /** + * Getter for Account.powerPlayClub.kvKey. + */ + public java.lang.String getKvKey() { + return (java.lang.String) getValue(1); + } + + /** + * Setter for Account.powerPlayClub.kvValue. + */ + public void setKvValue(java.lang.Integer value) { + setValue(2, value); + } + + /** + * Getter for Account.powerPlayClub.kvValue. + */ + public java.lang.Integer getKvValue() { + return (java.lang.Integer) getValue(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record2 key() { + return (org.jooq.Record2) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 fieldsRow() { + return (org.jooq.Row3) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 valuesRow() { + return (org.jooq.Row3) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.PowerPlayClub.powerPlayClub.accountId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.PowerPlayClub.powerPlayClub.kvKey; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.PowerPlayClub.powerPlayClub.kvValue; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getAccountId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value2() { + return getKvKey(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value3() { + return getKvValue(); + } + + /** + * {@inheritDoc} + */ + @Override + public PowerPlayClubRecord value1(java.lang.Integer value) { + setAccountId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public PowerPlayClubRecord value2(java.lang.String value) { + setKvKey(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public PowerPlayClubRecord value3(java.lang.Integer value) { + setKvValue(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public PowerPlayClubRecord values(java.lang.Integer value1, java.lang.String value2, java.lang.Integer value3) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached PowerPlayClubRecord + */ + public PowerPlayClubRecord() { + super(mineplex.database.tables.PowerPlayClub.powerPlayClub); + } + + /** + * Create a detached, initialised PowerPlayClubRecord + */ + public PowerPlayClubRecord(java.lang.Integer accountId, java.lang.String kvKey, java.lang.Integer kvValue) { + super(mineplex.database.tables.PowerPlayClub.powerPlayClub); + + setValue(0, accountId); + setValue(1, kvKey); + setValue(2, kvValue); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/UnicodereplacerRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/UnicodereplacerRecord.java new file mode 100644 index 000000000..591491a4e --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/UnicodereplacerRecord.java @@ -0,0 +1,279 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class UnicodereplacerRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record5 { + + private static final long serialVersionUID = -155015394; + + /** + * Setter for Account.unicodereplacer.id. + */ + public void setId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.unicodereplacer.id. + */ + public java.lang.Integer getId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.unicodereplacer.unicode. + */ + public void setUnicode(java.lang.String value) { + setValue(1, value); + } + + /** + * Getter for Account.unicodereplacer.unicode. + */ + public java.lang.String getUnicode() { + return (java.lang.String) getValue(1); + } + + /** + * Setter for Account.unicodereplacer.replacement. + */ + public void setReplacement(java.lang.String value) { + setValue(2, value); + } + + /** + * Getter for Account.unicodereplacer.replacement. + */ + public java.lang.String getReplacement() { + return (java.lang.String) getValue(2); + } + + /** + * Setter for Account.unicodereplacer.created_by. + */ + public void setCreated_by(java.lang.String value) { + setValue(3, value); + } + + /** + * Getter for Account.unicodereplacer.created_by. + */ + public java.lang.String getCreated_by() { + return (java.lang.String) getValue(3); + } + + /** + * Setter for Account.unicodereplacer.removed_by. + */ + public void setRemoved_by(java.lang.String value) { + setValue(4, value); + } + + /** + * Getter for Account.unicodereplacer.removed_by. + */ + public java.lang.String getRemoved_by() { + return (java.lang.String) getValue(4); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record5 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row5 fieldsRow() { + return (org.jooq.Row5) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row5 valuesRow() { + return (org.jooq.Row5) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.Unicodereplacer.unicodereplacer.id; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.Unicodereplacer.unicodereplacer.unicode; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.Unicodereplacer.unicodereplacer.replacement; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field4() { + return mineplex.database.tables.Unicodereplacer.unicodereplacer.created_by; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field5() { + return mineplex.database.tables.Unicodereplacer.unicodereplacer.removed_by; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value2() { + return getUnicode(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value3() { + return getReplacement(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value4() { + return getCreated_by(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value5() { + return getRemoved_by(); + } + + /** + * {@inheritDoc} + */ + @Override + public UnicodereplacerRecord value1(java.lang.Integer value) { + setId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public UnicodereplacerRecord value2(java.lang.String value) { + setUnicode(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public UnicodereplacerRecord value3(java.lang.String value) { + setReplacement(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public UnicodereplacerRecord value4(java.lang.String value) { + setCreated_by(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public UnicodereplacerRecord value5(java.lang.String value) { + setRemoved_by(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public UnicodereplacerRecord values(java.lang.Integer value1, java.lang.String value2, java.lang.String value3, java.lang.String value4, java.lang.String value5) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached UnicodereplacerRecord + */ + public UnicodereplacerRecord() { + super(mineplex.database.tables.Unicodereplacer.unicodereplacer); + } + + /** + * Create a detached, initialised UnicodereplacerRecord + */ + public UnicodereplacerRecord(java.lang.Integer id, java.lang.String unicode, java.lang.String replacement, java.lang.String created_by, java.lang.String removed_by) { + super(mineplex.database.tables.Unicodereplacer.unicodereplacer); + + setValue(0, id); + setValue(1, unicode); + setValue(2, replacement); + setValue(3, created_by); + setValue(4, removed_by); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/YoutubeRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/YoutubeRecord.java new file mode 100644 index 000000000..13fc1242f --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/YoutubeRecord.java @@ -0,0 +1,159 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class YoutubeRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record2 { + + private static final long serialVersionUID = -581486771; + + /** + * Setter for Account.youtube.accountId. + */ + public void setAccountId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.youtube.accountId. + */ + public java.lang.Integer getAccountId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.youtube.clicktime. + */ + public void setClicktime(java.sql.Date value) { + setValue(1, value); + } + + /** + * Getter for Account.youtube.clicktime. + */ + public java.sql.Date getClicktime() { + return (java.sql.Date) getValue(1); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record2 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row2 fieldsRow() { + return (org.jooq.Row2) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row2 valuesRow() { + return (org.jooq.Row2) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.Youtube.youtube.accountId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.Youtube.youtube.clicktime; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getAccountId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.sql.Date value2() { + return getClicktime(); + } + + /** + * {@inheritDoc} + */ + @Override + public YoutubeRecord value1(java.lang.Integer value) { + setAccountId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public YoutubeRecord value2(java.sql.Date value) { + setClicktime(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public YoutubeRecord values(java.lang.Integer value1, java.sql.Date value2) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached YoutubeRecord + */ + public YoutubeRecord() { + super(mineplex.database.tables.Youtube.youtube); + } + + /** + * Create a detached, initialised YoutubeRecord + */ + public YoutubeRecord(java.lang.Integer accountId, java.sql.Date clicktime) { + super(mineplex.database.tables.Youtube.youtube); + + setValue(0, accountId); + setValue(1, clicktime); + } +} diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java index 3b40034b0..bfbb8adf9 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -44,6 +44,7 @@ import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; +import mineplex.core.thank.ThankManager; import mineplex.core.titangiveaway.TitanGiveawayManager; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; @@ -130,8 +131,9 @@ public class ClansHub extends JavaPlugin CustomDataManager customDataManager = new CustomDataManager(this, clientManager); ConditionManager condition = new ConditionManager(this); + ThankManager thankManager = new ThankManager(this, clientManager, donationManager); BoosterManager boosterManager = new BoosterManager(this, "", clientManager, donationManager, inventoryManager); - HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, packetHandler, punish, serverStatusManager, customDataManager, boosterManager); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager); HologramManager hologramManager = new HologramManager(this, packetHandler); ClansTransferManager serverManager = new ClansTransferManager(this, clientManager, donationManager, partyManager, portal, hubManager); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 26f7065f6..0c598db11 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -63,6 +63,7 @@ import mineplex.core.punish.Punish; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; +import mineplex.core.thank.ThankManager; import mineplex.core.treasure.TreasureLocation; import mineplex.core.treasure.TreasureManager; import mineplex.core.updater.UpdateType; @@ -156,7 +157,7 @@ public class HubManager extends MiniPlugin private HashMap> _creativeAdmin = new HashMap>(); - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, BoosterManager boosterManager) + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager) { super("Hub Manager", plugin); @@ -192,7 +193,7 @@ public class HubManager extends MiniPlugin FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); - _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, boosterManager); + _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager); World world = _spawn.getWorld(); _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager()); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index b00dc44f1..d59fe6769 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -1,6 +1,7 @@ package mineplex.hub; import mineplex.core.brawl.fountain.FountainManager; +import mineplex.core.thank.ThankManager; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -148,8 +149,9 @@ public class Hub extends JavaPlugin implements IRelation PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager); String boosterGroup = serverConfiguration.getServerGroup().getBoosterGroup(); + ThankManager thankManager = new ThankManager(this, clientManager, donationManager); BoosterManager boosterManager = new BoosterManager(this, boosterGroup, clientManager, donationManager, inventoryManager); - HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager, boosterManager); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager); HologramManager hologramManager = new HologramManager(this, packetHandler); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index c983c9cbb..c4bc0b93e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -51,6 +51,7 @@ import mineplex.core.punish.Punish; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; +import mineplex.core.thank.ThankManager; import mineplex.core.treasure.TreasureManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -161,7 +162,7 @@ public class HubManager extends MiniClientPlugin // private final String[] _songNames = {"JingleBells.nbs", "TheFirstNoel.nbs", "Hark.nbs", "DeckTheHalls.nbs", "Joy.nbs", "MerryChristmas.nbs"}; private final ArrayList _songs; - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, BoosterManager boosterManager) + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager) { super("Hub Manager", plugin); @@ -198,7 +199,7 @@ public class HubManager extends MiniClientPlugin FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); - _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, boosterManager); + _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager); _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager()); new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java index 948a334aa..aa72a2546 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java @@ -29,7 +29,7 @@ public class Courtship "Mmmmmm, that's delicious! But I still don't like you very much.", "For a moment there, I thought you were my friend... But you're not! Leave me alone!", "Just because I'm drinking your drink, doesn't mean we're friends!", - "Hmmm... I don't know. I think I have enough friends right now, thanks.", + "Hmmm... I don't know. I think I have enough friends right now, thank.", "Ugh why are you always trying to talk to me?", "Just because I eat grass sometimes, doesn't mean I'm desperate enough to be your friend." }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 08de28ad9..d055de995 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.HashMap; import mineplex.core.boosters.BoosterManager; +import mineplex.core.thank.ThankManager; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -159,6 +160,7 @@ public class Arcade extends JavaPlugin PetManager petManager = new PetManager(this, _clientManager, _donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress); MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager); GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager); + ThankManager thankManager = new ThankManager(this, _clientManager, _donationManager); BoosterManager boosterManager = new BoosterManager(this, _serverConfiguration.getServerGroup().getBoosterGroup(), _clientManager, _donationManager, inventoryManager); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager); cosmeticManager.setInterfaceSlot(6); @@ -168,7 +170,7 @@ public class Arcade extends JavaPlugin //Arcade Manager PollManager pollManager = new PollManager(this, _clientManager, _donationManager); - _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, incognito, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish, eloManager, boosterManager); + _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, incognito, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish, eloManager, thankManager, boosterManager); new GlobalPacketManager(this, _clientManager, serverStatusManager, inventoryManager, _donationManager, petManager, statsManager, _gameManager.getBonusManager().getRewardManager()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 7bffad2da..9ad8f7c99 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -47,6 +47,7 @@ import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; +import mineplex.core.thank.ThankManager; import mineplex.core.timing.TimingManager; import mineplex.core.titangiveaway.TitanGiveawayManager; import mineplex.core.valentines.ValentinesGiftManager; @@ -203,7 +204,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation StatsManager statsManager, IncognitoManager incognitoManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat, Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler, CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, - NpcManager npcManager, CustomDataManager customDataManager, Punish punish, EloManager eloManager, BoosterManager boosterManager) + NpcManager npcManager, CustomDataManager customDataManager, Punish punish, EloManager eloManager, ThankManager thankManager, BoosterManager boosterManager) { super("Game Manager", plugin); @@ -288,7 +289,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation new GameStatManager(this); FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); - _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), boosterManager); + _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), thankManager); new GameLootManager(this, petManager, _bonusManager.getRewardManager()); _spectatorManager = new GameSpectatorManager(this); _gameWorldManager = new GameWorldManager(this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java index ac0f3834d..bcbe5ae60 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java @@ -18,7 +18,7 @@ public class CardFactory private String[] _questions = new String[] { - "When I get home from school, I crave _____.", "I was playing One in the Quiver when I ran into ____.", "Ultra+ now get free _____ every month.", "Everything was fine until _____ joined.", "Help me! My mom is _______.", "_________ crashed the server again…", "_______ ate his pet rabbit when he saw __________.", "My mouse batteries died because I was using it for ______.", "______ is the #1 reason of deaths on the server.", "Ugh, I'm lagging thanks to _____!", "I need to go to the doctor, I'm sick with _________!", "My best friend thinks he is _____.", "The cure for all diseases is partially made out of _____.", "When i was little i wanted to become a ______ and use _____ to save the world.", "I painted a beautiful painting of ____!", "When you grow up you will realize that ______ is all you need.", "_______ knew he had made the wrong choice when he realised he was _______.", "While falling asleep, I dreamt of ______ kissing ______.", "I went to a fancy restaurant, but the chef gave me _____!", "What am I supposed to do when I see _____ ______?", "There is absolutely nothing worse in this world than ___________.", "I get all excited and tingly when I see ________!", "I would rather be _________ than _________.", "I think my brother is a big fan of _______.", "Why can't I sleep at night?", "What's that smell?", "I got 99 problems but ________ ain't one.", "What's the next game coming out on Mineplex?", "What is the next trend on YouTube?", "It's a pity that kids these days are getting involved with ________.", "What's that sound?", "What should I look for in a girlfriend?", "I wish I could forget about _______.", "What don't you want to find in your treasure chest?", "I can't take you seriously when you are always _________.", "I'm sorry, but I couldn't finish my homework because of _________.", "What does Batman do in his spare time?", "What's a girl's best friend?", "___________. That's how I want to die.", "For my next trick, I will pull _______ out of ________.", "________ is a slippery slope that leads to ________.", "Instead of coal, Santa now gives the bad children ________.", "An exciting game of The Bridges would be incomplete without _________.", "War! What is it good for?", "While mining diamonds, I like to think about ________.", "What are my parents hiding from me?", "What will always make girls like you?", "What did I bring back from the Nether?", "What don't you want to find in your Mushroom Soup?", "Step 1: __________, Step 2: __________, Step 3: Profit!" ,"What makes you need to fart?", "What do old people smell like?", "What's your secret power?", "The class field trip was completely ruined by _______.", "I never understood _______, until I found ________.", "What does Justin Beiber enjoy in his spare time?", "Why is the Villager sticky?", "Scientists think that Creepers explode because of _________.", "Why do you hurt all over?", "When you are a billionaire, you will spend all of your money on ________.", "How do you cheer up a sad friend?", "What is the new diet everyone is trying?", "What is the secret ingredient in Mountain Dew?", "________ is one of the few things that makes me happy.", "The most important thing you need to build a house is ________.", "What is the best way to get unbanned from Mineplex?", "_________ is the secret to winning at Super Smash Mobs.", + "When I get home from school, I crave _____.", "I was playing One in the Quiver when I ran into ____.", "Ultra+ now get free _____ every month.", "Everything was fine until _____ joined.", "Help me! My mom is _______.", "_________ crashed the server again…", "_______ ate his pet rabbit when he saw __________.", "My mouse batteries died because I was using it for ______.", "______ is the #1 reason of deaths on the server.", "Ugh, I'm lagging thank to _____!", "I need to go to the doctor, I'm sick with _________!", "My best friend thinks he is _____.", "The cure for all diseases is partially made out of _____.", "When i was little i wanted to become a ______ and use _____ to save the world.", "I painted a beautiful painting of ____!", "When you grow up you will realize that ______ is all you need.", "_______ knew he had made the wrong choice when he realised he was _______.", "While falling asleep, I dreamt of ______ kissing ______.", "I went to a fancy restaurant, but the chef gave me _____!", "What am I supposed to do when I see _____ ______?", "There is absolutely nothing worse in this world than ___________.", "I get all excited and tingly when I see ________!", "I would rather be _________ than _________.", "I think my brother is a big fan of _______.", "Why can't I sleep at night?", "What's that smell?", "I got 99 problems but ________ ain't one.", "What's the next game coming out on Mineplex?", "What is the next trend on YouTube?", "It's a pity that kids these days are getting involved with ________.", "What's that sound?", "What should I look for in a girlfriend?", "I wish I could forget about _______.", "What don't you want to find in your treasure chest?", "I can't take you seriously when you are always _________.", "I'm sorry, but I couldn't finish my homework because of _________.", "What does Batman do in his spare time?", "What's a girl's best friend?", "___________. That's how I want to die.", "For my next trick, I will pull _______ out of ________.", "________ is a slippery slope that leads to ________.", "Instead of coal, Santa now gives the bad children ________.", "An exciting game of The Bridges would be incomplete without _________.", "War! What is it good for?", "While mining diamonds, I like to think about ________.", "What are my parents hiding from me?", "What will always make girls like you?", "What did I bring back from the Nether?", "What don't you want to find in your Mushroom Soup?", "Step 1: __________, Step 2: __________, Step 3: Profit!" ,"What makes you need to fart?", "What do old people smell like?", "What's your secret power?", "The class field trip was completely ruined by _______.", "I never understood _______, until I found ________.", "What does Justin Beiber enjoy in his spare time?", "Why is the Villager sticky?", "Scientists think that Creepers explode because of _________.", "Why do you hurt all over?", "When you are a billionaire, you will spend all of your money on ________.", "How do you cheer up a sad friend?", "What is the new diet everyone is trying?", "What is the secret ingredient in Mountain Dew?", "________ is one of the few things that makes me happy.", "The most important thing you need to build a house is ________.", "What is the best way to get unbanned from Mineplex?", "_________ is the secret to winning at Super Smash Mobs.", }; From fb3cfecc797332e8d6298af5f5f21cdb7ed65187 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 2 Aug 2016 20:44:09 -0400 Subject: [PATCH 33/89] Move recharge handler --- .../mineplex/game/clans/clans/banners/BannerManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java index d613f2939..0acc79e5d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java @@ -118,10 +118,6 @@ public class BannerManager extends MiniPlugin */ public void placeBanner(Player placing, ClanBanner banner) { - if (!Recharge.Instance.use(placing, "Place Banner", 30000, true, false)) - { - return; - } Block block = placing.getLocation().getBlock(); BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), block, placing.getItemInHand(), placing, true); Bukkit.getPluginManager().callEvent(event); @@ -136,6 +132,10 @@ public class BannerManager extends MiniPlugin ClansManager.getInstance().getBlockRestore().restore(block); if (block.getType() == Material.AIR && UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN))) { + if (!Recharge.Instance.use(placing, "Place Banner", 30000, true, false)) + { + return; + } block.setType(Material.STANDING_BANNER); Banner state = (Banner) block.getState(); state.setBaseColor(banner.getBaseColor()); From 1ae7f6cb251ebca44af312f10d17bb46d1d509c6 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Wed, 3 Aug 2016 14:03:12 -0500 Subject: [PATCH 34/89] Integrate the new ThankManager into Amplifiers --- .../core/boosters/BoosterManager.java | 15 +- .../core/boosters/command/ThankCommand.java | 8 +- .../boosters/tips/BoosterThankManager.java | 93 ++++++++++++ .../boosters/tips/BoosterThankRepository.java | 52 +++++++ .../core/boosters/tips/BoosterTipManager.java | 133 ------------------ .../boosters/tips/BoosterTipRepository.java | 55 -------- .../core/boosters/tips/TipAddResult.java | 1 + .../src/mineplex/database/Account.java | 3 +- .../src/mineplex/database/Keys.java | 4 + .../src/mineplex/database/Routines.java | 12 ++ .../src/mineplex/database/Tables.java | 5 + .../game/arcade/booster/BoosterPodium.java | 4 +- .../arcade/booster/GameBoosterManager.java | 8 +- 13 files changed, 186 insertions(+), 207 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankRepository.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipManager.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipRepository.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java index 4254f6594..eec3e3c22 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java @@ -1,6 +1,5 @@ package mineplex.core.boosters; -import com.mojang.authlib.properties.PropertyMap; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.boosters.command.BoosterCommand; @@ -10,7 +9,7 @@ import mineplex.core.boosters.event.BoosterItemGiveEvent; import mineplex.core.boosters.event.BoosterUpdateEvent; import mineplex.core.boosters.gui.BoosterShop; import mineplex.core.boosters.redis.BoosterUpdateRepository; -import mineplex.core.boosters.tips.BoosterTipManager; +import mineplex.core.boosters.tips.BoosterThankManager; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilGear; @@ -19,12 +18,12 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.thank.ThankManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; @@ -64,8 +63,8 @@ public class BoosterManager extends MiniPlugin private CoreClientManager _clientManager; private DonationManager _donationManager; private InventoryManager _inventoryManager; + private BoosterThankManager _boosterThankManager; - private BoosterTipManager _tipManager; private BoosterShop _shop; private String _boosterGroup; @@ -74,7 +73,7 @@ public class BoosterManager extends MiniPlugin private long _cacheLastUpdated; private Map> _boosterCache = new HashMap<>(); - public BoosterManager(JavaPlugin plugin, String boosterGroup, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager) + public BoosterManager(JavaPlugin plugin, String boosterGroup, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ThankManager thankManager) { super("Booster Manager", plugin); @@ -84,7 +83,7 @@ public class BoosterManager extends MiniPlugin _donationManager = donationManager; _inventoryManager = inventoryManager; - _tipManager = new BoosterTipManager(plugin, clientManager, donationManager); + _boosterThankManager = new BoosterThankManager(plugin, clientManager, thankManager); _shop = new BoosterShop(this, clientManager, donationManager); try @@ -335,9 +334,9 @@ public class BoosterManager extends MiniPlugin handleBoosterUpdate(event.getBoosterMap()); } - public BoosterTipManager getTipManager() + public BoosterThankManager getBoosterThankManager() { - return _tipManager; + return _boosterThankManager; } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java index 0670ce643..b6a379fc0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java @@ -2,7 +2,7 @@ package mineplex.core.boosters.command; import mineplex.core.boosters.Booster; import mineplex.core.boosters.BoosterManager; -import mineplex.core.boosters.tips.BoosterTipManager; +import mineplex.core.boosters.tips.BoosterThankManager; import mineplex.core.boosters.tips.TipAddResult; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; @@ -56,12 +56,12 @@ public class ThankCommand extends CommandBase } else { - Plugin.getTipManager().addTip(caller, booster, result -> + Plugin.getBoosterThankManager().addTip(caller, booster, result -> { if (result == TipAddResult.SUCCESS) { - UtilPlayer.message(caller, F.main("Tip", "You thanked " + F.name(booster.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_SPONSOR) + " and you got " - + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER)) + " in return!"); + UtilPlayer.message(caller, F.main("Tip", "You thanked " + F.name(booster.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_SPONSOR) + " and you got " + + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER)) + " in return!"); caller.playSound(caller.getLocation(), Sound.LEVEL_UP, 1f, 1f); } else if (result.getFriendlyMessage() != null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankManager.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankManager.java new file mode 100644 index 000000000..c3ae99372 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankManager.java @@ -0,0 +1,93 @@ +package mineplex.core.boosters.tips; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.boosters.Booster; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.thank.ThankManager; +import mineplex.core.thank.ThankResult; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * This class handles "thanking" Amplifiers. This is a way of rewarding players for activating Amplifiers. + * + * @author Shaun Bennett + */ +public class BoosterThankManager extends MiniPlugin +{ + public static final int TIP_FOR_SPONSOR = 5; + public static final int TIP_FOR_TIPPER = 5; + + private BoosterThankRepository _repository; + private CoreClientManager _clientManager; + private ThankManager _thankManager; + + public BoosterThankManager(JavaPlugin plugin, CoreClientManager clientManager, ThankManager thankManager) + { + super("Amplifier Thanks", plugin); + + _clientManager = clientManager; + _repository = new BoosterThankRepository(plugin); + _thankManager = thankManager; + } + + /** + * Attempt to "Thank" an Amplifier. This checks with {@link BoosterThankRepository} if a player hasn't already + * thanked that Amplifier. If they havent, we proceed to use {@link ThankManager} to send a thank you to the player + * who activated that Amplifier. + * + * @param player The player sending the thanks + * @param booster The Amplifier to be thanked + * @param callback Callback with the result of sending the thanks + */ + public void addTip(Player player, Booster booster, Callback callback) + { + if (!Recharge.Instance.use(player, "Amplifier Thanks", 1000 * 5, false, false)) + { + UtilPlayer.message(player, F.main("Amplifier", "Please wait before trying that again")); + callback.run(TipAddResult.ON_COOLDOWN); + return; + } + + int accountId = _clientManager.getAccountId(player); + + // Break out if client manager has a bad account id + if (accountId == -1) + { + callback.run(TipAddResult.INVALID_ACCOUNT_ID); + return; + } + + // You can't tip yourself, silly! + if (accountId == booster.getAccountId()) + { + callback.run(TipAddResult.CANNOT_TIP_SELF); + return; + } + + runAsync(() -> + { + if (_repository.checkAmplifierThank(accountId, booster.getId())) + { + // We can thank that amplifier! + _thankManager.thankPlayer(booster.getPlayerName(), booster.getAccountId(), player.getName(), accountId, + TIP_FOR_SPONSOR, TIP_FOR_TIPPER, "Amplifier", true, thankResult -> + runSync(() -> callback.run(fromThankResult(thankResult)))); + } + else + { + runSync(() -> callback.run(TipAddResult.ALREADY_TIPPED_BOOSTER)); + } + }); + } + + + private TipAddResult fromThankResult(ThankResult result) + { + return result == ThankResult.SUCCESS ? TipAddResult.SUCCESS : TipAddResult.UNKNOWN_ERROR; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankRepository.java new file mode 100644 index 000000000..8fd26265e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankRepository.java @@ -0,0 +1,52 @@ +package mineplex.core.boosters.tips; + +import mineplex.core.database.MinecraftRepository; +import mineplex.database.routines.AddTip; +import mineplex.database.routines.CheckAmplifierThank; +import mineplex.database.routines.ClaimTips; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * @author Shaun Bennett + */ +public class BoosterThankRepository extends MinecraftRepository +{ + public BoosterThankRepository(JavaPlugin plugin) + { + super(plugin, DBPool.getAccount()); + } + + /** + * Checks the database if an accountId is allowed to thank a specific Amplifier. + * This will return true and update the database if the thank is okay, or false + * if that account ID has already thanked that Amplifier ID. + * + * @param accountId Account ID of the player trying to thank the Amplifier + * @param amplifierId The ID of the Amplifier the player is trying to thank + * @return True if the account id can thank the amplifier id, false otherwise + */ + public boolean checkAmplifierThank(int accountId, int amplifierId) + { + CheckAmplifierThank checkAmplifierThank = new CheckAmplifierThank(); + checkAmplifierThank.setInAccountId(accountId); + checkAmplifierThank.setInAmplifierId(amplifierId); + checkAmplifierThank.execute(jooq().configuration()); + return checkAmplifierThank.getCanThank() == 1; + } + + @Override + protected void initialize() + { + + } + + @Override + protected void update() + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipManager.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipManager.java deleted file mode 100644 index ff31ce07e..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipManager.java +++ /dev/null @@ -1,133 +0,0 @@ -package mineplex.core.boosters.tips; - -import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.boosters.Booster; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.donation.DonationManager; -import mineplex.core.recharge.Recharge; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import java.sql.ResultSet; -import java.sql.SQLException; - -/** - * @author Shaun Bennett - */ -public class BoosterTipManager extends MiniDbClientPlugin -{ - public static final int TIP_FOR_SPONSOR = 5; - public static final int TIP_FOR_TIPPER = 5; - - private BoosterTipRepository _repository; - private DonationManager _donationManager; - - public BoosterTipManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) - { - super("Amplifier Thanks", plugin, clientManager); - - _donationManager = donationManager; - _repository = new BoosterTipRepository(plugin); - } - - public void addTip(Player player, Booster booster, Callback callback) - { - if (!Recharge.Instance.use(player, "Amplifier Thanks", 1000 * 5, false, false)) - { - UtilPlayer.message(player, F.main("Amplifier", "Please wait before trying that again")); - callback.run(TipAddResult.ON_COOLDOWN); - return; - } - - int accountId = ClientManager.getAccountId(player); - - // Break out if client manager has a bad account id - if (accountId == -1) - { - callback.run(TipAddResult.INVALID_ACCOUNT_ID); - return; - } - - // You can't tip yourself, silly! - if (accountId == booster.getAccountId()) - { - callback.run(TipAddResult.CANNOT_TIP_SELF); - return; - } - - runAsync(() -> { - TipAddResult result; - if (_repository.addTip(accountId, booster.getAccountId(), booster.getId(), TIP_FOR_SPONSOR)) - { - _donationManager.rewardCoinsUntilSuccess(null, "Tips", player.getName(), accountId, TIP_FOR_TIPPER); - result = TipAddResult.SUCCESS; - } - else - result = TipAddResult.ALREADY_TIPPED_BOOSTER; - - runSync(() -> callback.run(result)); - }); - } - - /** - * Claim all tips for a player and add those tips to their account (Treasure Shards) - * This will call a database routine that handles the tip process. - * - * The callback will return -1 on a failed attempt or 0 if there was no tips to claim - * @param player The player with tips to claim - * @param callback Callback returning the amount of tips claimed - */ - public void claimTips(Player player, Callback callback) - { - String playerName = player.getName(); - int accountId = ClientManager.getAccountId(player); - - if (accountId == -1) - { - // uh oh, invalid account id! - if (callback != null) callback.run(-1); - } - - runAsync(() -> { - int tips = _repository.claimTips(accountId); - runSync(() -> { - if (tips > 0) - { - _donationManager.rewardCoinsUntilSuccess(null, "Tips", playerName, accountId, tips); - } - - // Reset tips back to 0 - if (Get(player) != null) Get(player).setTips(0); - if (callback != null) callback.run(tips); - }); - }); - } - - @Override - public String getQuery(int accountId, String uuid, String name) - { - return "SELECT tips FROM Account.accountTip WHERE accountTip.accountId = " + accountId + ";"; - } - - @Override - protected PlayerTipData addPlayer(String player) - { - return new PlayerTipData(); - } - - @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException - { - PlayerTipData data = new PlayerTipData(); - - while (resultSet.next()) - { - data.setTips(resultSet.getInt(1)); - } - - Set(playerName, data); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipRepository.java deleted file mode 100644 index 6ece1a5b2..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipRepository.java +++ /dev/null @@ -1,55 +0,0 @@ -package mineplex.core.boosters.tips; - -import mineplex.core.database.MinecraftRepository; -import mineplex.database.routines.AddTip; -import mineplex.database.routines.ClaimTips; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnInt; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -/** - * @author Shaun Bennett - */ -public class BoosterTipRepository extends MinecraftRepository -{ - public static String LOG_TIP = "INSERT INTO Account.accountTipLogs (accountId, boosterId) VALUES (?, ?)"; - public static String ADD_TIP = "INSERT INTO Account.accountTip (accountId, tips) VALUES (?, ?) ON DUPLICATE KEY UPDATE tips = tips + ?"; - - public BoosterTipRepository(JavaPlugin plugin) - { - super(plugin, DBPool.getAccount()); - } - - public boolean addTip(int tipperId, int receiverId, int boosterId, int tipAmount) - { - AddTip addTip = new AddTip(); - addTip.setTipperAccountId(tipperId); - addTip.setBoosterAccountId(receiverId); - addTip.setBoosterId(boosterId); - addTip.setTipAmount(tipAmount); - addTip.execute(jooq().configuration()); - return addTip.getSuccess() == 1; - } - - public int claimTips(int accountId) - { - ClaimTips claimTips = new ClaimTips(); - claimTips.setAccountId_in(accountId); - claimTips.execute(jooq().configuration()); - return claimTips.getTipsClaimed(); - } - - @Override - protected void initialize() - { - - } - - @Override - protected void update() - { - - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/TipAddResult.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/TipAddResult.java index 965a8e738..aa657b6e2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/TipAddResult.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/TipAddResult.java @@ -7,6 +7,7 @@ public enum TipAddResult { ALREADY_TIPPED_BOOSTER("You have already thanked this Amplifier!"), INVALID_ACCOUNT_ID("Uh oh, something went wrong. Try relogging"), + UNKNOWN_ERROR("An error occurred. Try again later"), CANNOT_TIP_SELF("You can't thank yourself, silly!"), ON_COOLDOWN(null), SUCCESS(null); diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Account.java b/Plugins/Mineplex.Database/src/mineplex/database/Account.java index 80ec9c795..97cffe5a9 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Account.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Account.java @@ -16,7 +16,7 @@ package mineplex.database; @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Account extends org.jooq.impl.SchemaImpl implements java.io.Serializable, java.lang.Cloneable { - private static final long serialVersionUID = 1432193236; + private static final long serialVersionUID = 1890093529; /** * The reference instance of Account @@ -39,6 +39,7 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali private final java.util.List> getTables0() { return java.util.Arrays.>asList( + mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank, mineplex.database.tables.AccountAuth.accountAuth, mineplex.database.tables.AccountClan.accountClan, mineplex.database.tables.AccountCoinTransactions.accountCoinTransactions, diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Keys.java b/Plugins/Mineplex.Database/src/mineplex/database/Keys.java index c7819d84d..3b8624355 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Keys.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Keys.java @@ -85,6 +85,7 @@ public class Keys { // UNIQUE and PRIMARY KEY definitions // ------------------------------------------------------------------------- + public static final org.jooq.UniqueKey KEY_accountAmplifierThank_PRIMARY = UniqueKeys0.KEY_accountAmplifierThank_PRIMARY; public static final org.jooq.UniqueKey KEY_accountAuth_PRIMARY = UniqueKeys0.KEY_accountAuth_PRIMARY; public static final org.jooq.UniqueKey KEY_accountClan_PRIMARY = UniqueKeys0.KEY_accountClan_PRIMARY; public static final org.jooq.UniqueKey KEY_accountCoinTransactions_PRIMARY = UniqueKeys0.KEY_accountCoinTransactions_PRIMARY; @@ -201,6 +202,7 @@ public class Keys { // FOREIGN KEY definitions // ------------------------------------------------------------------------- + public static final org.jooq.ForeignKey accountAmplifierThank_accounts_id_fk = ForeignKeys0.accountAmplifierThank_accounts_id_fk; public static final org.jooq.ForeignKey accountAuth_accounts_id_fk = ForeignKeys0.accountAuth_accounts_id_fk; public static final org.jooq.ForeignKey FK_ACT_ACCOUNTS_ID = ForeignKeys0.FK_ACT_ACCOUNTS_ID; public static final org.jooq.ForeignKey CUSTOMDATA_ACCOUNT = ForeignKeys0.CUSTOMDATA_ACCOUNT; @@ -316,6 +318,7 @@ public class Keys { } private static class UniqueKeys0 extends org.jooq.impl.AbstractKeys { + public static final org.jooq.UniqueKey KEY_accountAmplifierThank_PRIMARY = createUniqueKey(mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank, mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank.accountId, mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank.amplifierId); public static final org.jooq.UniqueKey KEY_accountAuth_PRIMARY = createUniqueKey(mineplex.database.tables.AccountAuth.accountAuth, mineplex.database.tables.AccountAuth.accountAuth.id); public static final org.jooq.UniqueKey KEY_accountClan_PRIMARY = createUniqueKey(mineplex.database.tables.AccountClan.accountClan, mineplex.database.tables.AccountClan.accountClan.id); public static final org.jooq.UniqueKey KEY_accountCoinTransactions_PRIMARY = createUniqueKey(mineplex.database.tables.AccountCoinTransactions.accountCoinTransactions, mineplex.database.tables.AccountCoinTransactions.accountCoinTransactions.id); @@ -430,6 +433,7 @@ public class Keys { } private static class ForeignKeys0 extends org.jooq.impl.AbstractKeys { + public static final org.jooq.ForeignKey accountAmplifierThank_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank, mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank.accountId); public static final org.jooq.ForeignKey accountAuth_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountAuth.accountAuth, mineplex.database.tables.AccountAuth.accountAuth.accountId); public static final org.jooq.ForeignKey FK_ACT_ACCOUNTS_ID = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountCoinTransactions.accountCoinTransactions, mineplex.database.tables.AccountCoinTransactions.accountCoinTransactions.accountId); public static final org.jooq.ForeignKey CUSTOMDATA_ACCOUNT = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountCustomData.accountCustomData, mineplex.database.tables.AccountCustomData.accountCustomData.accountId); diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Routines.java b/Plugins/Mineplex.Database/src/mineplex/database/Routines.java index 0b96d1e5a..e4d6ad2b1 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Routines.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Routines.java @@ -57,6 +57,18 @@ public class Routines { return p.getSuccess(); } + /** + * Call Account.checkAmplifierThank + */ + public static java.lang.Byte callCheckamplifierthank(org.jooq.Configuration configuration, java.lang.Integer inAccountId, java.lang.Integer inAmplifierId) { + mineplex.database.routines.CheckAmplifierThank p = new mineplex.database.routines.CheckAmplifierThank(); + p.setInAccountId(inAccountId); + p.setInAmplifierId(inAmplifierId); + + p.execute(configuration); + return p.getCanThank(); + } + /** * Call Account.check_daily */ diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Tables.java b/Plugins/Mineplex.Database/src/mineplex/database/Tables.java index 65d0986a3..c65a8a1c7 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Tables.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Tables.java @@ -16,6 +16,11 @@ package mineplex.database; @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Tables { + /** + * The table Account.accountAmplifierThank + */ + public static final mineplex.database.tables.AccountAmplifierThank accountAmplifierThank = mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank; + /** * The table Account.accountAuth */ diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/BoosterPodium.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/BoosterPodium.java index 8c6139b9f..11ee67957 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/BoosterPodium.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/BoosterPodium.java @@ -4,7 +4,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.boosters.Booster; import mineplex.core.boosters.event.BoosterActivateEvent; import mineplex.core.boosters.event.BoosterExpireEvent; -import mineplex.core.boosters.tips.BoosterTipManager; +import mineplex.core.boosters.tips.BoosterThankManager; import mineplex.core.common.util.*; import mineplex.core.disguise.DisguiseManager; import mineplex.core.hologram.Hologram; @@ -177,7 +177,7 @@ public class BoosterPodium extends MiniPlugin return new String[] { C.cGreen + "Amplified by " + C.cWhite + booster.getPlayerName(), C.cWhite + booster.getTimeRemainingString() + " Remaining", - C.cAqua + "Click to Thank. You get " + BoosterTipManager.TIP_FOR_TIPPER + " Treasure Shards" + C.cAqua + "Click to Thank. You get " + BoosterThankManager.TIP_FOR_TIPPER + " Treasure Shards" }; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java index ae823e9fa..2ad31943c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java @@ -4,7 +4,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.boosters.Booster; import mineplex.core.boosters.BoosterManager; import mineplex.core.boosters.event.BoosterActivateEvent; -import mineplex.core.boosters.tips.BoosterTipManager; +import mineplex.core.boosters.tips.BoosterThankManager; import mineplex.core.boosters.tips.TipAddResult; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.jsonchat.ClickEvent; @@ -62,8 +62,8 @@ public class GameBoosterManager extends MiniPlugin _boosterManager.getTipManager().addTip(player, active, result -> { if (result == TipAddResult.SUCCESS) { - UtilPlayer.message(player, F.main("Tip", "You thanked " + F.name(active.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_SPONSOR) + " and you got " - + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER)) + " in return!"); + UtilPlayer.message(player, F.main("Tip", "You thanked " + F.name(active.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_SPONSOR) + " and you got " + + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER)) + " in return!"); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); } else { @@ -87,7 +87,7 @@ public class GameBoosterManager extends MiniPlugin Bukkit.broadcastMessage(F.main("Amplifier", F.name(booster.getPlayerName()) + " has activated a Game Amplifier on " + F.elem(event.getBoosterGroup().replaceAll("_", " ")) + "!")); } - JsonMessage message = new JsonMessage(F.main("Amplifier", F.elem("Click here") + " to thank them and receive " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER) + "!")); + JsonMessage message = new JsonMessage(F.main("Amplifier", F.elem("Click here") + " to thank them and receive " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER) + "!")); message.click(ClickEvent.RUN_COMMAND, "/amplifier thank " + event.getBoosterGroup()); message.hover(HoverEvent.SHOW_TEXT, C.cGreen + "Click to Thank"); message.send(JsonMessage.MessageType.CHAT_BOX, UtilServer.getPlayers()); From ca13b8f29e3c43c7d8088c21f7f74d7bf5226fed Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Wed, 3 Aug 2016 14:18:26 -0500 Subject: [PATCH 35/89] Fix compile errors --- Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java | 2 +- Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java | 2 +- .../Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java | 2 +- .../src/nautilus/game/arcade/booster/GameBoosterManager.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java index bfbb8adf9..df03752b3 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -132,7 +132,7 @@ public class ClansHub extends JavaPlugin ConditionManager condition = new ConditionManager(this); ThankManager thankManager = new ThankManager(this, clientManager, donationManager); - BoosterManager boosterManager = new BoosterManager(this, "", clientManager, donationManager, inventoryManager); + BoosterManager boosterManager = new BoosterManager(this, "", clientManager, donationManager, inventoryManager, thankManager); HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager); HologramManager hologramManager = new HologramManager(this, packetHandler); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index d59fe6769..6422c454f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -150,7 +150,7 @@ public class Hub extends JavaPlugin implements IRelation PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager); String boosterGroup = serverConfiguration.getServerGroup().getBoosterGroup(); ThankManager thankManager = new ThankManager(this, clientManager, donationManager); - BoosterManager boosterManager = new BoosterManager(this, boosterGroup, clientManager, donationManager, inventoryManager); + BoosterManager boosterManager = new BoosterManager(this, boosterGroup, clientManager, donationManager, inventoryManager, thankManager); HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager); HologramManager hologramManager = new HologramManager(this, packetHandler); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index d055de995..e1a22a7bf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -161,7 +161,7 @@ public class Arcade extends JavaPlugin MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager); GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager); ThankManager thankManager = new ThankManager(this, _clientManager, _donationManager); - BoosterManager boosterManager = new BoosterManager(this, _serverConfiguration.getServerGroup().getBoosterGroup(), _clientManager, _donationManager, inventoryManager); + BoosterManager boosterManager = new BoosterManager(this, _serverConfiguration.getServerGroup().getBoosterGroup(), _clientManager, _donationManager, inventoryManager, thankManager); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager); cosmeticManager.setInterfaceSlot(6); cosmeticManager.disableTeamArmor(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java index 2ad31943c..8ce1d893a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java @@ -59,7 +59,7 @@ public class GameBoosterManager extends MiniPlugin return; } - _boosterManager.getTipManager().addTip(player, active, result -> { + _boosterManager.getBoosterThankManager().addTip(player, active, result -> { if (result == TipAddResult.SUCCESS) { UtilPlayer.message(player, F.main("Tip", "You thanked " + F.name(active.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_SPONSOR) + " and you got " From a61906acfab440a91d7fe91f7fb4a45d5fb89e96 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Wed, 3 Aug 2016 14:24:49 -0500 Subject: [PATCH 36/89] Ignore "Testing" boostergroup when announcing activation --- .../game/arcade/booster/GameBoosterManager.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java index 8ce1d893a..7dc0b5af1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java @@ -79,17 +79,24 @@ public class GameBoosterManager extends MiniPlugin public void onActivate(BoosterActivateEvent event) { Booster booster = event.getBooster(); + + boolean isTesting = event.getBoosterGroup().equalsIgnoreCase("Testing"); + if (event.getBoosterGroup().equals(_boosterGroup)) { Bukkit.broadcastMessage(F.main("Amplifier", F.name(booster.getPlayerName()) + " has activated a Game Amplifier for " + booster.getMultiplier() + "x Shards!")); - } else + } + else if (!isTesting) { Bukkit.broadcastMessage(F.main("Amplifier", F.name(booster.getPlayerName()) + " has activated a Game Amplifier on " + F.elem(event.getBoosterGroup().replaceAll("_", " ")) + "!")); } - JsonMessage message = new JsonMessage(F.main("Amplifier", F.elem("Click here") + " to thank them and receive " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER) + "!")); - message.click(ClickEvent.RUN_COMMAND, "/amplifier thank " + event.getBoosterGroup()); - message.hover(HoverEvent.SHOW_TEXT, C.cGreen + "Click to Thank"); - message.send(JsonMessage.MessageType.CHAT_BOX, UtilServer.getPlayers()); + if (event.getBoosterGroup().equals(_boosterGroup) || !isTesting) + { + JsonMessage message = new JsonMessage(F.main("Amplifier", F.elem("Click here") + " to thank them and receive " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER) + "!")); + message.click(ClickEvent.RUN_COMMAND, "/amplifier thank " + event.getBoosterGroup()); + message.hover(HoverEvent.SHOW_TEXT, C.cGreen + "Click to Thank"); + message.send(JsonMessage.MessageType.CHAT_BOX, UtilServer.getPlayers()); + } } } From 2e8083837671d99bfc78af308c2596c171f83bf3 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Wed, 3 Aug 2016 14:25:07 -0500 Subject: [PATCH 37/89] Update ClaimTips lore --- .../core/bonuses/gui/buttons/ClaimTipsButton.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java index 95430a8d4..9e28f29ab 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java @@ -73,7 +73,7 @@ public class ClaimTipsButton implements GuiItem, Listener new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Amplifier Thanks Collected"), "Thanks Collected", 6*9, 20*3, getGui()).openInventory(); } - UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(GlobalCurrency.TREASURE_SHARD, claimThankResult.getClaimed()) + " from " + F.elem(claimThankResult.getUniqueThanks()) + "players thanking you!")); + UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(GlobalCurrency.TREASURE_SHARD, claimThankResult.getClaimed()) + " from " + F.elem(claimThankResult.getUniqueThanks()) + " players!")); // Pending explosions are strange.. Not sure why we are using strings. Either way, lets display a rank reward effect _bonusManager.addPendingExplosion(getPlayer(), "RANK"); getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); @@ -119,7 +119,7 @@ public class ClaimTipsButton implements GuiItem, Listener if (isAvailable()) { material = Material.EMERALD; - itemName = C.cGreen + C.Bold + "Game Amplifiers"; + itemName = C.cGreen + C.Bold + "Thanks"; lore.add(" "); lore.add(C.cYellow + "Your Rewards"); lore.add(" " + C.cWhite + getTips() + " Treasure Shards"); @@ -129,10 +129,11 @@ public class ClaimTipsButton implements GuiItem, Listener else { material = Material.REDSTONE_BLOCK; - itemName = C.cRed + C.Bold + "Game Amplifiers"; + itemName = C.cRed + C.Bold + "Thanks"; lore.add(" "); - lore.add(C.cGray + "Use Amplifiers to earn rewards"); + lore.add(C.cGray + "Earn thank rewards from players using /thank"); + lore.add(C.cGray + "on you, or by enabling Game Amplifiers."); lore.add(" "); lore.add(C.cWhite + "Get Amplifiers at " + C.cGreen + "mineplex.com/shop"); } From ad6c1dd970315cc965bfaf5f3074154313f57c5a Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Wed, 3 Aug 2016 14:55:33 -0500 Subject: [PATCH 38/89] Adjust some text wording --- .../mineplex/core/thank/command/ThankCommand.java | 13 +++++++++++-- .../game/arcade/booster/GameBoosterManager.java | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java index ef950d3a6..0794b5566 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java @@ -2,11 +2,13 @@ package mineplex.core.thank.command; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.thank.ThankManager; import mineplex.core.thank.ThankResult; +import org.bukkit.Sound; import org.bukkit.entity.Player; /** @@ -40,13 +42,13 @@ public class ThankCommand extends CommandBase switch (result) { case SUCCESS: - message = "You thanked " + F.name(playerName) + "!"; + message = "You thanked " + F.name(playerName) + " and earned " + F.currency(GlobalCurrency.TREASURE_SHARD, ThankManager.DEFAULT_SENDER_REWARD) + "!"; break; case CANNOT_THANK_SELF: message = "You cannot thank yourself!"; break; case COOLDOWN_DATABASE: - message = "/thank is on cooldown. Try again later"; + message = "You can only /thank once per day!"; break; case COOLDOWN_RECHARGE: message = null; @@ -59,6 +61,13 @@ public class ThankCommand extends CommandBase { UtilPlayer.message(caller, F.main("Thank", message)); } + + if (result == ThankResult.SUCCESS && player.isOnline()) + { + UtilPlayer.message(player, F.main("Thank", F.name(caller.getName()) + " used " + F.elem("/thank") + " on you! +" + F.currency(GlobalCurrency.TREASURE_SHARD, ThankManager.DEFAULT_RECEIVER_REWARD) + "!")); + UtilPlayer.message(player, F.main("Thank", "You can claim your reward at " + F.name("Carl the Creeper"))); + player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1f, 1.2f); + } }); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java index 7dc0b5af1..90d0aad03 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java @@ -93,7 +93,7 @@ public class GameBoosterManager extends MiniPlugin if (event.getBoosterGroup().equals(_boosterGroup) || !isTesting) { - JsonMessage message = new JsonMessage(F.main("Amplifier", F.elem("Click here") + " to thank them and receive " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER) + "!")); + JsonMessage message = new JsonMessage(F.main("Amplifier", F.elem("Click here") + " to thank them and get " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER) + "!")); message.click(ClickEvent.RUN_COMMAND, "/amplifier thank " + event.getBoosterGroup()); message.hover(HoverEvent.SHOW_TEXT, C.cGreen + "Click to Thank"); message.send(JsonMessage.MessageType.CHAT_BOX, UtilServer.getPlayers()); From 6d93efc1a2fc43c38498830e17356ce381b37f75 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Wed, 3 Aug 2016 14:57:30 -0500 Subject: [PATCH 39/89] Adjust button text as well --- .../mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java index 9e28f29ab..e866c415b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java @@ -119,7 +119,7 @@ public class ClaimTipsButton implements GuiItem, Listener if (isAvailable()) { material = Material.EMERALD; - itemName = C.cGreen + C.Bold + "Thanks"; + itemName = C.cGreen + C.Bold + "Thank Rewards"; lore.add(" "); lore.add(C.cYellow + "Your Rewards"); lore.add(" " + C.cWhite + getTips() + " Treasure Shards"); @@ -129,10 +129,10 @@ public class ClaimTipsButton implements GuiItem, Listener else { material = Material.REDSTONE_BLOCK; - itemName = C.cRed + C.Bold + "Thanks"; + itemName = C.cRed + C.Bold + "Thank Rewards"; lore.add(" "); - lore.add(C.cGray + "Earn thank rewards from players using /thank"); + lore.add(C.cGray + "Earn Thank Rewards from players using /thank"); lore.add(C.cGray + "on you, or by enabling Game Amplifiers."); lore.add(" "); lore.add(C.cWhite + "Get Amplifiers at " + C.cGreen + "mineplex.com/shop"); From 72f078fe546c7930b40476ab65e8f391d33dffe6 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Wed, 3 Aug 2016 15:04:06 -0500 Subject: [PATCH 40/89] Fix using wrong name, add missing jooq files --- .../core/thank/command/ThankCommand.java | 2 +- .../routines/CheckAmplifierThank.java | 67 ++++++ .../tables/AccountAmplifierThank.java | 109 ++++++++++ .../records/AccountAmplifierThankRecord.java | 199 ++++++++++++++++++ 4 files changed, 376 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/routines/CheckAmplifierThank.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/AccountAmplifierThank.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountAmplifierThankRecord.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java index 0794b5566..ac26750e1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java @@ -42,7 +42,7 @@ public class ThankCommand extends CommandBase switch (result) { case SUCCESS: - message = "You thanked " + F.name(playerName) + " and earned " + F.currency(GlobalCurrency.TREASURE_SHARD, ThankManager.DEFAULT_SENDER_REWARD) + "!"; + message = "You thanked " + F.name(player.getName()) + " and earned " + F.currency(GlobalCurrency.TREASURE_SHARD, ThankManager.DEFAULT_SENDER_REWARD) + "!"; break; case CANNOT_THANK_SELF: message = "You cannot thank yourself!"; diff --git a/Plugins/Mineplex.Database/src/mineplex/database/routines/CheckAmplifierThank.java b/Plugins/Mineplex.Database/src/mineplex/database/routines/CheckAmplifierThank.java new file mode 100644 index 000000000..2fd338361 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/routines/CheckAmplifierThank.java @@ -0,0 +1,67 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.routines; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class CheckAmplifierThank extends org.jooq.impl.AbstractRoutine implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 522346006; + + /** + * The parameter Account.checkAmplifierThank.inAccountId. + */ + public static final org.jooq.Parameter inAccountId = createParameter("inAccountId", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.checkAmplifierThank.inAmplifierId. + */ + public static final org.jooq.Parameter inAmplifierId = createParameter("inAmplifierId", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.checkAmplifierThank.canThank. + */ + public static final org.jooq.Parameter canThank = createParameter("canThank", org.jooq.impl.SQLDataType.TINYINT, false); + + /** + * Create a new routine call instance + */ + public CheckAmplifierThank() { + super("checkAmplifierThank", mineplex.database.Account.Account); + + addInParameter(inAccountId); + addInParameter(inAmplifierId); + addOutParameter(canThank); + } + + /** + * Set the inAccountId parameter IN value to the routine + */ + public void setInAccountId(java.lang.Integer value) { + setValue(mineplex.database.routines.CheckAmplifierThank.inAccountId, value); + } + + /** + * Set the inAmplifierId parameter IN value to the routine + */ + public void setInAmplifierId(java.lang.Integer value) { + setValue(mineplex.database.routines.CheckAmplifierThank.inAmplifierId, value); + } + + /** + * Get the canThank parameter OUT value from the routine + */ + public java.lang.Byte getCanThank() { + return getValue(canThank); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountAmplifierThank.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountAmplifierThank.java new file mode 100644 index 000000000..5e3e7f0b5 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountAmplifierThank.java @@ -0,0 +1,109 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountAmplifierThank extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -810649551; + + /** + * The reference instance of Account.accountAmplifierThank + */ + public static final mineplex.database.tables.AccountAmplifierThank accountAmplifierThank = new mineplex.database.tables.AccountAmplifierThank(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.AccountAmplifierThankRecord.class; + } + + /** + * The column Account.accountAmplifierThank.accountId. + */ + public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountAmplifierThank.amplifierId. + */ + public final org.jooq.TableField amplifierId = createField("amplifierId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountAmplifierThank.time. + */ + public final org.jooq.TableField time = createField("time", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaulted(true), this, ""); + + /** + * Create a Account.accountAmplifierThank table reference + */ + public AccountAmplifierThank() { + this("accountAmplifierThank", null); + } + + /** + * Create an aliased Account.accountAmplifierThank table reference + */ + public AccountAmplifierThank(java.lang.String alias) { + this(alias, mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank); + } + + private AccountAmplifierThank(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private AccountAmplifierThank(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_accountAmplifierThank_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_accountAmplifierThank_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.accountAmplifierThank_accounts_id_fk); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.AccountAmplifierThank as(java.lang.String alias) { + return new mineplex.database.tables.AccountAmplifierThank(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.AccountAmplifierThank rename(java.lang.String name) { + return new mineplex.database.tables.AccountAmplifierThank(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountAmplifierThankRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountAmplifierThankRecord.java new file mode 100644 index 000000000..0e6af2e8e --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountAmplifierThankRecord.java @@ -0,0 +1,199 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountAmplifierThankRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { + + private static final long serialVersionUID = 1203692620; + + /** + * Setter for Account.accountAmplifierThank.accountId. + */ + public void setAccountId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.accountAmplifierThank.accountId. + */ + public java.lang.Integer getAccountId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.accountAmplifierThank.amplifierId. + */ + public void setAmplifierId(java.lang.Integer value) { + setValue(1, value); + } + + /** + * Getter for Account.accountAmplifierThank.amplifierId. + */ + public java.lang.Integer getAmplifierId() { + return (java.lang.Integer) getValue(1); + } + + /** + * Setter for Account.accountAmplifierThank.time. + */ + public void setTime(java.sql.Timestamp value) { + setValue(2, value); + } + + /** + * Getter for Account.accountAmplifierThank.time. + */ + public java.sql.Timestamp getTime() { + return (java.sql.Timestamp) getValue(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record2 key() { + return (org.jooq.Record2) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 fieldsRow() { + return (org.jooq.Row3) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 valuesRow() { + return (org.jooq.Row3) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank.accountId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank.amplifierId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank.time; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getAccountId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value2() { + return getAmplifierId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.sql.Timestamp value3() { + return getTime(); + } + + /** + * {@inheritDoc} + */ + @Override + public AccountAmplifierThankRecord value1(java.lang.Integer value) { + setAccountId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountAmplifierThankRecord value2(java.lang.Integer value) { + setAmplifierId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountAmplifierThankRecord value3(java.sql.Timestamp value) { + setTime(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountAmplifierThankRecord values(java.lang.Integer value1, java.lang.Integer value2, java.sql.Timestamp value3) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached AccountAmplifierThankRecord + */ + public AccountAmplifierThankRecord() { + super(mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank); + } + + /** + * Create a detached, initialised AccountAmplifierThankRecord + */ + public AccountAmplifierThankRecord(java.lang.Integer accountId, java.lang.Integer amplifierId, java.sql.Timestamp time) { + super(mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank); + + setValue(0, accountId); + setValue(1, amplifierId); + setValue(2, time); + } +} From e113bedea58db135893bca083905f8b63e1f4c05 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Wed, 3 Aug 2016 15:11:31 -0500 Subject: [PATCH 41/89] Fix accidentally refactoring "thanks" in strings --- .../src/mineplex/core/chat/Chat.java | 2 +- .../hub/modules/valentines/Courtship.java | 52 +++++++++---------- .../arcade/game/games/cards/CardFactory.java | 32 ++++++------ 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index e24ba15b2..effa0f484 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -287,7 +287,7 @@ public class Chat extends MiniPlugin if (response == null) { - System.out.println("[ERROR] Unable to filter chat message...thank a lot CleanSpeak."); + System.out.println("[ERROR] Unable to filter chat message...thanks a lot CleanSpeak."); return originalMessage; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java index aa72a2546..f76644b16 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java @@ -29,7 +29,7 @@ public class Courtship "Mmmmmm, that's delicious! But I still don't like you very much.", "For a moment there, I thought you were my friend... But you're not! Leave me alone!", "Just because I'm drinking your drink, doesn't mean we're friends!", - "Hmmm... I don't know. I think I have enough friends right now, thank.", + "Hmmm... I don't know. I think I have enough friends right now, thanks.", "Ugh why are you always trying to talk to me?", "Just because I eat grass sometimes, doesn't mean I'm desperate enough to be your friend." }; @@ -38,15 +38,15 @@ public class Courtship * Created by: Mysticate * Timestamp: February 6, 2016 */ - + private ValentinesManager _manager; private Player _player; private Sheep _sheep; private String _prefix; private final boolean _success; - + private int _tick = 0; - + public Courtship(ValentinesManager manager, Player player, Sheep sheep, String prefix, boolean success) { _manager = manager; @@ -55,14 +55,14 @@ public class Courtship _prefix = prefix; _success = success; } - + public boolean tick() { if (!_player.isOnline()) return true; - + _tick++; - + { Vector vec = UtilAlg.getTrajectory(_sheep, _player); UtilEnt.CreatureForceLook(_sheep, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec)); @@ -77,21 +77,21 @@ public class Courtship Entity bottom = player; while (bottom.getVehicle() != null) bottom = bottom.getVehicle(); - + UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(_sheep, bottom), .5, true, 0.8, 0, 10, true); player.playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f); - + UtilPlayer.message(player, F.main(_prefix, "I'm talking to someone else right now!")); } } } - + if (_tick == 20) { message("What do we have here?"); _sheep.getWorld().playSound(_sheep.getLocation(), Sound.NOTE_BASS, 1F, 1F); } - + if (_tick == 40) { if (_success) @@ -105,16 +105,16 @@ public class Courtship _sheep.getWorld().playSound(_sheep.getLocation(), Sound.NOTE_BASS, .5F, 1F); } } - + if (_tick > 40 && _tick < 80) { if (_tick % 2 == 0) { _sheep.getWorld().playSound(_sheep.getLocation(), Sound.DIG_GRASS, 1F, 1F); - + UtilParticle.PlayParticle(ParticleType.HEART, _sheep.getLocation().clone().add(0, 1, 0), new Vector(), 0F, 1, ViewDist.NORMAL, _player); UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, _sheep.getLocation(), 1F, 1F, 1F, 0F, 1, ViewDist.NORMAL, _player); - + _sheep.setColor(DyeColor.PINK); } else @@ -122,7 +122,7 @@ public class Courtship _sheep.setColor(DyeColor.WHITE); } } - + if (_tick == 80) { if (_success) @@ -134,10 +134,10 @@ public class Courtship { message(UtilMath.randomElement(FAIL_MESSAGES)); _sheep.getWorld().playSound(_sheep.getLocation(), Sound.ANVIL_BREAK, 1F, 1F); - _sheep.setColor(DyeColor.BLACK); + _sheep.setColor(DyeColor.BLACK); } } - + if (_tick > 80 && _tick < 120 && _success) { if (_tick % 2 == 0) @@ -149,31 +149,31 @@ public class Courtship _sheep.setColor(DyeColor.RED); } } - + if (_tick == 90 && _success) { message("I think..."); _sheep.getWorld().playSound(_sheep.getLocation(), Sound.FIZZ, 1F, 1F); } - + if (_tick == 100 && _success) { message("I think I'm in love!"); _sheep.getWorld().playSound(_sheep.getLocation(), Sound.LEVEL_UP, 1F, 1F); } - + if (_tick == 120 && _success) { message("Here, take this present as a token of my admiration."); - _sheep.getWorld().playSound(_sheep.getLocation(), Sound.LEVEL_UP, 1F, 1F); - + _sheep.getWorld().playSound(_sheep.getLocation(), Sound.LEVEL_UP, 1F, 1F); + _manager.giveReward(_player); - + _sheep.setColor(DyeColor.RED); - + UtilServer.broadcast(C.cYellowB + _player.getName() + C.cWhiteB + " tricked " + C.cGoldB + "Polly the Pink Sheep" + C.cWhiteB + " with a love potion!"); } - + if (_tick == 130) { _sheep.setColor(DyeColor.PINK); @@ -183,7 +183,7 @@ public class Courtship return false; } - + private void message(String message) { UtilPlayer.message(_player, " "); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java index bcbe5ae60..8f3ef9115 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java @@ -10,57 +10,57 @@ import mineplex.core.map.MapText; public class CardFactory { private MapText _mapText; - + public CardFactory() { _mapText = new MapText(); } - + private String[] _questions = new String[] { - "When I get home from school, I crave _____.", "I was playing One in the Quiver when I ran into ____.", "Ultra+ now get free _____ every month.", "Everything was fine until _____ joined.", "Help me! My mom is _______.", "_________ crashed the server again…", "_______ ate his pet rabbit when he saw __________.", "My mouse batteries died because I was using it for ______.", "______ is the #1 reason of deaths on the server.", "Ugh, I'm lagging thank to _____!", "I need to go to the doctor, I'm sick with _________!", "My best friend thinks he is _____.", "The cure for all diseases is partially made out of _____.", "When i was little i wanted to become a ______ and use _____ to save the world.", "I painted a beautiful painting of ____!", "When you grow up you will realize that ______ is all you need.", "_______ knew he had made the wrong choice when he realised he was _______.", "While falling asleep, I dreamt of ______ kissing ______.", "I went to a fancy restaurant, but the chef gave me _____!", "What am I supposed to do when I see _____ ______?", "There is absolutely nothing worse in this world than ___________.", "I get all excited and tingly when I see ________!", "I would rather be _________ than _________.", "I think my brother is a big fan of _______.", "Why can't I sleep at night?", "What's that smell?", "I got 99 problems but ________ ain't one.", "What's the next game coming out on Mineplex?", "What is the next trend on YouTube?", "It's a pity that kids these days are getting involved with ________.", "What's that sound?", "What should I look for in a girlfriend?", "I wish I could forget about _______.", "What don't you want to find in your treasure chest?", "I can't take you seriously when you are always _________.", "I'm sorry, but I couldn't finish my homework because of _________.", "What does Batman do in his spare time?", "What's a girl's best friend?", "___________. That's how I want to die.", "For my next trick, I will pull _______ out of ________.", "________ is a slippery slope that leads to ________.", "Instead of coal, Santa now gives the bad children ________.", "An exciting game of The Bridges would be incomplete without _________.", "War! What is it good for?", "While mining diamonds, I like to think about ________.", "What are my parents hiding from me?", "What will always make girls like you?", "What did I bring back from the Nether?", "What don't you want to find in your Mushroom Soup?", "Step 1: __________, Step 2: __________, Step 3: Profit!" ,"What makes you need to fart?", "What do old people smell like?", "What's your secret power?", "The class field trip was completely ruined by _______.", "I never understood _______, until I found ________.", "What does Justin Beiber enjoy in his spare time?", "Why is the Villager sticky?", "Scientists think that Creepers explode because of _________.", "Why do you hurt all over?", "When you are a billionaire, you will spend all of your money on ________.", "How do you cheer up a sad friend?", "What is the new diet everyone is trying?", "What is the secret ingredient in Mountain Dew?", "________ is one of the few things that makes me happy.", "The most important thing you need to build a house is ________.", "What is the best way to get unbanned from Mineplex?", "_________ is the secret to winning at Super Smash Mobs.", + "When I get home from school, I crave _____.", "I was playing One in the Quiver when I ran into ____.", "Ultra+ now get free _____ every month.", "Everything was fine until _____ joined.", "Help me! My mom is _______.", "_________ crashed the server again…", "_______ ate his pet rabbit when he saw __________.", "My mouse batteries died because I was using it for ______.", "______ is the #1 reason of deaths on the server.", "Ugh, I'm lagging thanks to _____!", "I need to go to the doctor, I'm sick with _________!", "My best friend thinks he is _____.", "The cure for all diseases is partially made out of _____.", "When i was little i wanted to become a ______ and use _____ to save the world.", "I painted a beautiful painting of ____!", "When you grow up you will realize that ______ is all you need.", "_______ knew he had made the wrong choice when he realised he was _______.", "While falling asleep, I dreamt of ______ kissing ______.", "I went to a fancy restaurant, but the chef gave me _____!", "What am I supposed to do when I see _____ ______?", "There is absolutely nothing worse in this world than ___________.", "I get all excited and tingly when I see ________!", "I would rather be _________ than _________.", "I think my brother is a big fan of _______.", "Why can't I sleep at night?", "What's that smell?", "I got 99 problems but ________ ain't one.", "What's the next game coming out on Mineplex?", "What is the next trend on YouTube?", "It's a pity that kids these days are getting involved with ________.", "What's that sound?", "What should I look for in a girlfriend?", "I wish I could forget about _______.", "What don't you want to find in your treasure chest?", "I can't take you seriously when you are always _________.", "I'm sorry, but I couldn't finish my homework because of _________.", "What does Batman do in his spare time?", "What's a girl's best friend?", "___________. That's how I want to die.", "For my next trick, I will pull _______ out of ________.", "________ is a slippery slope that leads to ________.", "Instead of coal, Santa now gives the bad children ________.", "An exciting game of The Bridges would be incomplete without _________.", "War! What is it good for?", "While mining diamonds, I like to think about ________.", "What are my parents hiding from me?", "What will always make girls like you?", "What did I bring back from the Nether?", "What don't you want to find in your Mushroom Soup?", "Step 1: __________, Step 2: __________, Step 3: Profit!" ,"What makes you need to fart?", "What do old people smell like?", "What's your secret power?", "The class field trip was completely ruined by _______.", "I never understood _______, until I found ________.", "What does Justin Beiber enjoy in his spare time?", "Why is the Villager sticky?", "Scientists think that Creepers explode because of _________.", "Why do you hurt all over?", "When you are a billionaire, you will spend all of your money on ________.", "How do you cheer up a sad friend?", "What is the new diet everyone is trying?", "What is the secret ingredient in Mountain Dew?", "________ is one of the few things that makes me happy.", "The most important thing you need to build a house is ________.", "What is the best way to get unbanned from Mineplex?", "_________ is the secret to winning at Super Smash Mobs.", }; - + private String[] _answers = new String[] { - "A Stinky Pig Butt", "Mouldy Raw Fish", "A sawed off 10-foot pole", "billions of diamonds", "A whiny forum post", "Sparkling Diamonds", "Sheep that don’t know when to stop", "Villager Legs", "Curdled cow milk", "That one popcorn piece stuck in your teeth.", "THE DIAMOND DANCE!", "an unstoppable addiction to fly hacks", "the biggest pile of poop you've ever seen!", "Bed time", "A bag of Doritos and a Mountain Dew.", "zombies chewing on my butt", "Jazz hands", "Brain surgery", "A disappointing birthday party.", "Overly friendly Iron Golems", "An Endermans favourite block", "Puppies!", "your friend who deleted you from Skype", "being on fire", "two cows stealing your wallet", "a lifetime of sadness", "a golden notch apple", "dragon eggs", "holding hands", "kissing", "wearing parents on your head", "soup that is too hot", "edible underpants", "people who are terrible at PvP", "obesity", "sheep eating potatoes", "my collection of spider eyes", "oversized fishing rods", "working as a team", "horse meat", "zombies screaming while on fire", "a ghast calling her dad to say happy birthday", "Microsoft releasing a good game", "bad childhood memories", "a bad haircut", "a steamy locker room", "armed robbery", "bankruptcy", "stacks of TNT", "a block of dirt", "cold pizza", "a pack of angry wolves", "eternal sadness", "the Nether", "a blaze having a barbeque", "Endermen robbing your house", "dental surgery", "religious villagers", "poor villagers", "flesh-eating bacteria", "the drive to win", "friends who take all your loot", "Morgan Freeman", "Darth Vader", "Villager #17", "Barrack Obama", "Lady Gaga", "That one hobo that lives down the street", "A Sad Creeper", "Parker Games", "A shaved sheep", "CaptainSparklez", "DanTDM", "SkyDoesMinecraft", "Mineplex", "A Mineplex Administrator", "Miley Cyrus", "Notch", "Mojang", "Pikachu", "BATMAN!!!", "The Hulk", "Justin Beiber", "Herobrine", "Pirates", "Vikings", "Ninjas", "Uncontrollably pooping", "Dancing until a helper warned me", "Making passive aggressive tweets", "complaining about balance on the forums", "Chopping down the mineplex lobby tree", "crashing servers", "falling off a cliff", "Realizing that you arent actually a ninja.", "Eating a hot pepper", "Digging straight down", "using xray hacks", "picking your nose", "Playing against a team in SSM", "Mining diamond with a stone pickaxe", "stepping on Legos", "Shaking it off", "Watching Parker games", "Accidentally hiding an egg as Easter bunny morph", "doing a poop and realizing there is no toilet paper", "Eating rotten flesh", "Understanding how magnets work", "watching videos on YouTube", "finding Legendary loot in a Treasure Chest", "Doing homework", "dividing by 0", "Finding out the meaning of life", "banning players for no reason", "dying", "so angry that he pooped himself.", "spending hours planting carrots", "doing the right thing", "sleeping in a cave", "getting drunk on potions", "trolling on the internet", "punching a tree", "leaving a stinky surprise", "doing math", "being devoured by zombie pigmen", "farting and walking away", "sneakily doing a poop", "blowing everything up with TNT", "peeing a little bit", "Tweeting about cats", "reading the instructions carefully", - "leaving some poop in the corner of the room", "eating a balanced breakfast", "puking", "shooting arrows at bats", "typing /kill", "watching Frozen repeatedly", "building a house out of dirt", "winking at chickens", "yelling at a toaster", "putting in 110% effort", "paying a lot of money", "bribing with candy", "throwing rocks at people", "crying until everything is better" + "A Stinky Pig Butt", "Mouldy Raw Fish", "A sawed off 10-foot pole", "billions of diamonds", "A whiny forum post", "Sparkling Diamonds", "Sheep that don’t know when to stop", "Villager Legs", "Curdled cow milk", "That one popcorn piece stuck in your teeth.", "THE DIAMOND DANCE!", "an unstoppable addiction to fly hacks", "the biggest pile of poop you've ever seen!", "Bed time", "A bag of Doritos and a Mountain Dew.", "zombies chewing on my butt", "Jazz hands", "Brain surgery", "A disappointing birthday party.", "Overly friendly Iron Golems", "An Endermans favourite block", "Puppies!", "your friend who deleted you from Skype", "being on fire", "two cows stealing your wallet", "a lifetime of sadness", "a golden notch apple", "dragon eggs", "holding hands", "kissing", "wearing parents on your head", "soup that is too hot", "edible underpants", "people who are terrible at PvP", "obesity", "sheep eating potatoes", "my collection of spider eyes", "oversized fishing rods", "working as a team", "horse meat", "zombies screaming while on fire", "a ghast calling her dad to say happy birthday", "Microsoft releasing a good game", "bad childhood memories", "a bad haircut", "a steamy locker room", "armed robbery", "bankruptcy", "stacks of TNT", "a block of dirt", "cold pizza", "a pack of angry wolves", "eternal sadness", "the Nether", "a blaze having a barbeque", "Endermen robbing your house", "dental surgery", "religious villagers", "poor villagers", "flesh-eating bacteria", "the drive to win", "friends who take all your loot", "Morgan Freeman", "Darth Vader", "Villager #17", "Barrack Obama", "Lady Gaga", "That one hobo that lives down the street", "A Sad Creeper", "Parker Games", "A shaved sheep", "CaptainSparklez", "DanTDM", "SkyDoesMinecraft", "Mineplex", "A Mineplex Administrator", "Miley Cyrus", "Notch", "Mojang", "Pikachu", "BATMAN!!!", "The Hulk", "Justin Beiber", "Herobrine", "Pirates", "Vikings", "Ninjas", "Uncontrollably pooping", "Dancing until a helper warned me", "Making passive aggressive tweets", "complaining about balance on the forums", "Chopping down the mineplex lobby tree", "crashing servers", "falling off a cliff", "Realizing that you arent actually a ninja.", "Eating a hot pepper", "Digging straight down", "using xray hacks", "picking your nose", "Playing against a team in SSM", "Mining diamond with a stone pickaxe", "stepping on Legos", "Shaking it off", "Watching Parker games", "Accidentally hiding an egg as Easter bunny morph", "doing a poop and realizing there is no toilet paper", "Eating rotten flesh", "Understanding how magnets work", "watching videos on YouTube", "finding Legendary loot in a Treasure Chest", "Doing homework", "dividing by 0", "Finding out the meaning of life", "banning players for no reason", "dying", "so angry that he pooped himself.", "spending hours planting carrots", "doing the right thing", "sleeping in a cave", "getting drunk on potions", "trolling on the internet", "punching a tree", "leaving a stinky surprise", "doing math", "being devoured by zombie pigmen", "farting and walking away", "sneakily doing a poop", "blowing everything up with TNT", "peeing a little bit", "Tweeting about cats", "reading the instructions carefully", + "leaving some poop in the corner of the room", "eating a balanced breakfast", "puking", "shooting arrows at bats", "typing /kill", "watching Frozen repeatedly", "building a house out of dirt", "winking at chickens", "yelling at a toaster", "putting in 110% effort", "paying a lot of money", "bribing with candy", "throwing rocks at people", "crying until everything is better" }; - + public String getQuestionCard() { return _questions[UtilMath.r(_questions.length)]; } - + public String getAnswerCard() { return _answers[UtilMath.r(_answers.length)]; } - public ItemStack getAnswerStack() + public ItemStack getAnswerStack() { String text = getAnswerCard(); - + ItemStack stack = _mapText.getMap(true, text); - + ItemMeta meta = stack.getItemMeta(); meta.setDisplayName(C.cGreen + text); stack.setItemMeta(meta); - + return stack; } - + public ItemStack getQuestionStack() { String text = getQuestionCard(); - + ItemStack stack = _mapText.getMap(true, text); - + ItemMeta meta = stack.getItemMeta(); meta.setDisplayName(C.cYellow + text); stack.setItemMeta(meta); - + return stack; } } From 85c4c181ec431253f6e4fe40a62f302c3af0e39a Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Wed, 3 Aug 2016 18:22:36 -0500 Subject: [PATCH 42/89] Reload ThankData when a player is /thank - Allows rewards to appear immediately at carl --- .../src/mineplex/core/thank/ThankData.java | 7 ++- .../src/mineplex/core/thank/ThankManager.java | 54 ++++++++++++++++++- .../mineplex/core/thank/ThankRepository.java | 41 +++++++++----- 3 files changed, 86 insertions(+), 16 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankData.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankData.java index 361fcc61d..2a25ead78 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankData.java @@ -5,7 +5,7 @@ package mineplex.core.thank; */ public class ThankData { - private final int _thankToClaim; + private int _thankToClaim; public ThankData(int thankToClaim) { @@ -16,4 +16,9 @@ public class ThankData { return _thankToClaim; } + + public void setThankToClaim(int thankToClaim) + { + _thankToClaim = thankToClaim; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java index 7b59a90a2..e258f82bb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java @@ -14,6 +14,9 @@ import org.bukkit.plugin.java.JavaPlugin; import java.sql.ResultSet; import java.sql.SQLException; +/** + * This class handles /thank and amplifier thanks, along with allowing players to claim the rewards they earn + */ public class ThankManager extends MiniDbClientPlugin { public static final int DEFAULT_RECEIVER_REWARD = 5; @@ -38,6 +41,18 @@ public class ThankManager extends MiniDbClientPlugin addCommand(new ThankCommand(this)); } + /** + * Attempt to thank a player. This can be used to distribute rewards to players, give players rewards for using + * amplifiers, and allow players to thank anyone inside a game. + * + * @param receiver The player who is being thanked + * @param sender The player thanking receiver + * @param receiverReward The Treasure Shard reward for the receiver + * @param senderReward The Treasure Shard reward for the sender + * @param reason The reason that player is being thanked + * @param ignoreCooldown Should we ignore all thank cooldowns + * @param callback Callback for processing the result + */ public void thankPlayer(Player receiver, Player sender, int receiverReward, int senderReward, String reason, boolean ignoreCooldown, Callback callback) { if (!Recharge.Instance.use(sender, "Thank Player", 1000 * 5, false, false)) @@ -49,9 +64,32 @@ public class ThankManager extends MiniDbClientPlugin int senderAccountId = ClientManager.getAccountId(sender); int receiverAccountId = ClientManager.getAccountId(receiver); - thankPlayer(receiver.getName(), receiverAccountId, sender.getName(), senderAccountId, receiverReward, senderReward, reason, ignoreCooldown, callback); + thankPlayer(receiver.getName(), receiverAccountId, sender.getName(), senderAccountId, receiverReward, senderReward, reason, ignoreCooldown, result -> + { + if (result == ThankResult.SUCCESS) + { + // Reload their thank data if the player is online! + runAsync(() -> { + try + { + Set(receiver, _thankRepository.getThankData(receiverAccountId)); + } catch (SQLException e) + { + e.printStackTrace(); + } + }); + } + + callback.run(result); + }); } + /** + * Called when a player wants to "claim" all pending rewards that they haven't claimed yet + * + * @param player The player claiming their thank rewards + * @param callback Callback with the result of the claim + */ public void claimThanks(Player player, Callback callback) { int accountId = ClientManager.getAccountId(player); @@ -79,6 +117,20 @@ public class ThankManager extends MiniDbClientPlugin }); } + /** + * Attempt to thank a player. This can be used to distribute rewards to players, give players rewards for using + * amplifiers, and allow players to thank anyone inside a game. + * + * @param receiverName Name of the player being thanked + * @param receiverAccountId Account id of the player being thanked + * @param senderName Name of the player sending the thanks + * @param senderAccountId Account id of the player sending the thanks + * @param receiverReward The Treasure Shard reward for the receiver + * @param senderReward The Treasure Shard reward for the sender + * @param reason The reason that player is being thanked + * @param ignoreCooldown Should we ignore all thank cooldowns + * @param callback Callback for processing the result + */ public void thankPlayer(String receiverName, int receiverAccountId, String senderName, int senderAccountId, int receiverReward, int senderReward, String reason, boolean ignoreCooldown, Callback callback) { // Break out on bad account id diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankRepository.java index fc8c4b594..d426009fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankRepository.java @@ -4,11 +4,18 @@ import mineplex.core.database.MinecraftRepository; import mineplex.database.routines.AddThank; import mineplex.database.routines.ClaimThank; import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnInt; import org.bukkit.plugin.java.JavaPlugin; import org.jooq.Configuration; +import java.sql.ResultSet; +import java.sql.SQLException; + public class ThankRepository extends MinecraftRepository { + private static final String GET_THANK_DATA = "SELECT SUM(thankAmount) FROM accountThankTransactions WHERE receiverId = ? AND claimed = FALSE"; + public ThankRepository(JavaPlugin plugin) { super(plugin, DBPool.getAccount()); @@ -25,15 +32,6 @@ public class ThankRepository extends MinecraftRepository } - /** - * - * @param receiverAccountId - * @param senderAccountId - * @param thankAmount - * @param reason - * @param ignoreCooldown - * @return - */ public boolean thank(int receiverAccountId, int senderAccountId, int thankAmount, String reason, boolean ignoreCooldown) { AddThank addThank = new AddThank(); @@ -47,11 +45,6 @@ public class ThankRepository extends MinecraftRepository return addThank.getSuccess() == 1; } - /** - * - * @param accountId - * @return - */ public ClaimThankResult claimThank(int accountId) { ClaimThank claimThank = new ClaimThank(); @@ -59,4 +52,24 @@ public class ThankRepository extends MinecraftRepository claimThank.execute(jooq().configuration()); return new ClaimThankResult(claimThank.getAmountClaimed(), claimThank.getUniqueThank()); } + + /** + * Get ThankData for an accountId. This is used to reload ThankData when a player is thanked on live servers + * @param accountId The account id of the player + * @return {@link ThankData} for that player + */ + public ThankData getThankData(int accountId) throws SQLException + { + ThankData thankData = new ThankData(0); + + executeQuery(GET_THANK_DATA, resultSet -> + { + if (resultSet != null && resultSet.next()) + { + thankData.setThankToClaim(resultSet.getInt(1)); + } + }, new ColumnInt("receiverId", accountId)); + + return thankData; + } } From 91cf3917241428c7402570f778a5821c17d55712 Mon Sep 17 00:00:00 2001 From: xXVevzZXx Date: Thu, 4 Aug 2016 06:24:24 +0200 Subject: [PATCH 43/89] some adjustments to UHC Survivalgames --- .../games/survivalgames/SurvivalGames.java | 2 +- .../survivalgames/modes/UHCSurvivalgames.java | 311 +++++++++++++++++- .../modes/kit/KitSurvivalist.java | 48 +++ 3 files changed, 357 insertions(+), 4 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitSurvivalist.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index d357ced98..ea5d5e663 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -1009,7 +1009,7 @@ public abstract class SurvivalGames extends Game handlePickup(event.getItem().getItemStack()); } - private void handlePickup(ItemStack stack) + public void handlePickup(ItemStack stack) { if (stack.getType() == Material.CARROT || stack.getType() == Material.POTATO diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java index e7d1a30f2..8c2ba3e65 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java @@ -1,21 +1,38 @@ package nautilus.game.arcade.game.games.survivalgames.modes; +import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Chest; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.loot.RandomItem; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.games.AbsorptionFix; import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; +import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent; +import nautilus.game.arcade.game.games.survivalgames.kit.KitLooter; +import nautilus.game.arcade.game.games.survivalgames.modes.kit.KitSurvivalist; +import nautilus.game.arcade.kit.Kit; /** * UHCSurvivalgames gamemode for Survivalgames @@ -25,14 +42,73 @@ import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; public class UHCSurvivalgames extends SoloSurvivalGames { + private long _peacePhase; + private boolean _peace; + public UHCSurvivalgames(ArcadeManager manager) { - super(manager, GameType.Brawl); + super(manager, new Kit[] + { + new KitSurvivalist(manager) + }, + GameType.Brawl); + _peacePhase = 45000; // 45 Seconds SoupEnabled = false; + DamagePvP = false; + + BlockBreak = true; + BlockPlace = true; + + BlockBreakDeny.add(Material.DIAMOND_BLOCK.getId()); + BlockBreakDeny.add(Material.IRON_BLOCK.getId()); + BlockBreakDeny.add(Material.GOLD_BLOCK.getId()); + BlockBreakDeny.add(Material.REDSTONE_ORE.getId()); + BlockBreakDeny.add(Material.REDSTONE_WIRE.getId()); + BlockBreakDeny.add(Material.REDSTONE.getId()); + BlockBreakDeny.add(Material.TNT.getId()); + BlockBreakDeny.add(Material.CHEST.getId()); + + BlockPlaceDeny.add(Material.REDSTONE.getId()); + BlockPlaceDeny.add(Material.REDSTONE_ORE.getId()); + BlockPlaceDeny.add(Material.REDSTONE_WIRE.getId()); + BlockPlaceDeny.add(Material.CHEST.getId()); + new AbsorptionFix(this); } + + @EventHandler + public void enableDamage(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + if (!IsLive()) + return; + + if (!UtilTime.elapsed(GetStateTime(), _peacePhase)) + return; + + if (!_peace) + return; + + _peace = false; + + Announce(F.main("Game", "The Peace Phase has ended! You can now fight each other!")); + DamagePvP = true; + } + + @EventHandler + public void informPeace(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + _peace = true; + + Announce(F.main("Game", "A Peace Phase of " + F.time((_peacePhase/1000) + "") + " seconds has started!")); + } @EventHandler public void registerObj(GameStateChangeEvent event) @@ -58,14 +134,243 @@ public class UHCSurvivalgames extends SoloSurvivalGames { if (event.getEntity() instanceof Player) { - event.getDrops().add(new ItemStack(Material.GOLDEN_APPLE)); + event.getDrops().add(new ItemStack(Material.GOLDEN_APPLE, 2)); } } + + @EventHandler(priority=EventPriority.LOWEST) + public void spawnBreak(BlockBreakEvent event) + { + if (UtilMath.offset(event.getBlock().getLocation(), getSpawn()) < 40) + event.setCancelled(true); + } + + @EventHandler(priority=EventPriority.LOWEST) + public void spawnPlace(BlockPlaceEvent event) + { + if (UtilMath.offset(event.getBlock().getLocation(), getSpawn()) < 40) + event.setCancelled(true); + } + public void setupLoot() + { + // Build material + getBaseLoot().addLoot(new RandomItem(Material.WOOD, 40, 7, 15)); + + // Food + getBaseLoot().addLoot(new RandomItem(Material.BAKED_POTATO, 40, 1, 3)); + getBaseLoot().addLoot(new RandomItem(Material.COOKED_BEEF, 40, 1, 2)); + getBaseLoot().addLoot(new RandomItem(Material.COOKED_CHICKEN, 40, 1, 2)); + getBaseLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 10, 1, 1)); + getBaseLoot().addLoot(new RandomItem(Material.PORK, 35, 1, 4)); + + // Weapons + getBaseLoot().addLoot(new RandomItem(Material.IRON_AXE, 80)); + getBaseLoot().addLoot(new RandomItem(Material.IRON_SWORD, 70)); + getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_AXE, 60)); + getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_SWORD, 30)); + + // Gold armor + getBaseLoot().addLoot(new RandomItem(Material.GOLD_BOOTS, 25)); + getBaseLoot().addLoot(new RandomItem(Material.GOLD_CHESTPLATE, 25)); + getBaseLoot().addLoot(new RandomItem(Material.GOLD_HELMET, 25)); + getBaseLoot().addLoot(new RandomItem(Material.GOLD_LEGGINGS, 25)); + + // Chain armor + getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_BOOTS, 20)); + getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_CHESTPLATE, 20)); + getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_HELMET, 20)); + getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_LEGGINGS, 20)); + + // Throwable + getBaseLoot().addLoot(new RandomItem(Material.FISHING_ROD, 30)); + getBaseLoot().addLoot(new RandomItem(Material.BOW, 20)); + getBaseLoot().addLoot(new RandomItem(Material.ARROW, 40, 2, 4)); + + // Misc + getBaseLoot().addLoot(new RandomItem(Material.EXP_BOTTLE, 40, 1, 2)); + getBaseLoot().addLoot(new RandomItem(Material.COMPASS, 20)); + getBaseLoot().addLoot(new RandomItem(Material.STICK, 30, 1, 2)); + getBaseLoot().addLoot(new RandomItem(Material.BOAT, 15)); + getBaseLoot().addLoot(new RandomItem(Material.GOLD_INGOT, 20)); + getBaseLoot().addLoot(new RandomItem(Material.GOLDEN_APPLE, 2)); + getBaseLoot().addLoot(new RandomItem(ItemStackFactory.Instance.CreateStack( + Material.TNT, (byte) 0, 1, F.item("Throwing TNT")), 15)); + getSpawnLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15)); + + getSpawnLoot().cloneLoot(getBaseLoot()); + + // Food + getSpawnLoot().addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 5)); + getSpawnLoot().addLoot(new RandomItem(Material.CAKE, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 30, 1, 1)); + getSpawnLoot().addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 3)); + getSpawnLoot().addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 3)); + getSpawnLoot().addLoot(new RandomItem(Material.COOKED_FISH, 30, 1, 6)); + getSpawnLoot().addLoot(new RandomItem(Material.GRILLED_PORK, 30, 1, 3)); + getSpawnLoot().addLoot(new RandomItem(Material.COOKIE, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.PUMPKIN_PIE, 30, 1, 3)); + getSpawnLoot().addLoot(new RandomItem(Material.APPLE, 30, 2, 6)); + + // Loot for chests in spawn + // Weaponry and ores + getSpawnLoot().addLoot(new RandomItem(Material.STONE_SWORD, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.IRON_AXE, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.IRON_INGOT, 40, 1, 2)); + getSpawnLoot().addLoot(new RandomItem(Material.DIAMOND, 30)); + + // Iron gear + getSpawnLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.IRON_HELMET, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 30)); + + // Supply crate loot + // Diamond gear + getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_HELMET, 10)); + getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_CHESTPLATE, 6)); + getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_LEGGINGS, 8)); + getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_BOOTS, 10)); + + // Iron gear + getCrateLoot().addLoot(new RandomItem(Material.IRON_HELMET, 30)); + getCrateLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 24)); + getCrateLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 27)); + getCrateLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 30)); + + // Weapons + getCrateLoot().addLoot(new RandomItem(Material.IRON_SWORD, 24)); + getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_SWORD, 8)); + getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_AXE, 16)); + + // Cooked furnace + getFurnace().addLoot(new RandomItem(Material.COOKED_BEEF, 3, 1, 2)); + getFurnace().addLoot(new RandomItem(Material.COOKED_CHICKEN, 3, 1, 2)); + getFurnace().addLoot(new RandomItem(Material.COOKED_FISH, 3, 1, 2)); + getFurnace().addLoot(new RandomItem(Material.GRILLED_PORK, 3, 1, 2)); + getFurnace().addLoot(new RandomItem(Material.BAKED_POTATO, 3, 1, 1)); + getFurnace().addLoot(new RandomItem(Material.PUMPKIN_PIE, 3, 1, 1)); + getFurnace().addLoot(new RandomItem(Material.IRON_INGOT, 1, 1, 1)); + + // Raw furnace + getRawFurnace().addLoot(new RandomItem(Material.RAW_BEEF, 1, 1, 3)); + getRawFurnace().addLoot(new RandomItem(Material.RAW_CHICKEN, 1, 1, 3)); + getRawFurnace().addLoot(new RandomItem(Material.RAW_FISH, 1, 1, 3)); + getRawFurnace().addLoot(new RandomItem(Material.PORK, 1, 1, 3)); + getRawFurnace().addLoot(new RandomItem(Material.POTATO_ITEM, 1, 1, 3)); + + // Deathmatch Loot + getDeathMatch().addLoot(new RandomItem(Material.PUMPKIN_PIE, 4)); + getDeathMatch().addLoot(new RandomItem(Material.BAKED_POTATO, 4)); + getDeathMatch().addLoot(new RandomItem(Material.CAKE, 4)); + getDeathMatch().addLoot(new RandomItem(Material.APPLE, 4)); + getDeathMatch().addLoot(new RandomItem(Material.WOOD_SWORD, 3)); + getDeathMatch().addLoot(new RandomItem(Material.WOOD_AXE, 3)); + getDeathMatch().addLoot(new RandomItem(Material.STONE_AXE, 3)); + getDeathMatch().addLoot(new RandomItem(Material.STONE_SWORD, 1)); + } + + public void fillChest(Player looter, Block block) + { + getLootedBlocks().add(block.getLocation()); + + Chest chest = (Chest) block.getState(); + + chest.getBlockInventory().clear(); + + int items = 2; + if (Math.random() > 0.50) + items++; + if (Math.random() > 0.65) + items++; + if (Math.random() > 0.80) + items++; + if (Math.random() > 0.95) + items++; + + boolean spawnChest = getChestRefillTime() > 0 + && UtilMath.offset(chest.getLocation(), getSpawn()) < 8; + + if (spawnChest) + items += 3; + + if (GetKit(looter) instanceof KitLooter) + { + items += UtilMath.r(3); + } + + if (getSupplyBlocks().contains(block)) + { + items = 2; + if (Math.random() > 0.75) + items++; + if (Math.random() > 0.95) + items++; + } + + for (int i = 0; i < items; i++) + { + ItemStack item; + + if (spawnChest) + { + item = getSpawnLoot().getLoot(); + } + else if (isDeathMatchTeleported()) + { + item = getDeathMatch().getLoot(); + } + else + { + boolean drop = getSupplyBlocks().contains(block); + item = GetChestItem(drop); + + // Golden apple spawn + if (drop && i == items) + item = new ItemStack(Material.GOLDEN_APPLE); + } + + if (item.getType() == Material.COMPASS) + { + item = buildCompass(5); + } + + handlePickup(item); + + chest.getBlockInventory().setItem(UtilMath.r(27), item); + } + + if (getSupplyBlocks().contains(block)) + { + Bukkit.getPluginManager().callEvent( + new SupplyChestOpenEvent(looter, block)); + } + + getSupplyBlocks().remove(block); + } + + @Override + @EventHandler + public void preventCrafting(PrepareItemCraftEvent event) + { + ItemStack result = event.getInventory().getResult(); + + if (result != null) + { + Material type = result.getType(); + + if (type == Material.BUCKET + || type == Material.FLINT_AND_STEEL) + { + event.getInventory().setResult(new ItemStack(Material.AIR)); + } + } + } + @Override public String GetMode() { - return "UHC Survivalagmes"; + return "UHC Survivalgames"; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitSurvivalist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitSurvivalist.java new file mode 100644 index 000000000..d2165eeea --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitSurvivalist.java @@ -0,0 +1,48 @@ +package nautilus.game.arcade.game.games.survivalgames.modes.kit; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +/** + * KitSurvivalist + * + * @author xXVevzZXx + */ +public class KitSurvivalist extends Kit +{ + public KitSurvivalist(ArcadeManager manager) + { + super(manager, "Survivalist", KitAvailability.Free, + new String[] + { + "You are a survival expert!", + }, + new Perk[] + { + + }, + EntityType.PLAYER, + new ItemStack(Material.AIR)); + + } + + @Override + public void GiveItems(Player player) + { + + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + + } +} From 0ca4fe2d38b73b6b6a2c091a5c5b93660c17e582 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 4 Aug 2016 12:41:59 -0400 Subject: [PATCH 44/89] Disable MAC kick for suspicious movement --- .../src/mineplex/core/antihack/AntiHack.java | 81 +++++-------------- 1 file changed, 18 insertions(+), 63 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 2bd3903b3..bf74a6d2e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -1,16 +1,22 @@ package mineplex.core.antihack; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map.Entry; - +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.antihack.types.Fly; +import mineplex.core.antihack.types.Idle; +import mineplex.core.antihack.types.Reach; +import mineplex.core.antihack.types.Speed; +import mineplex.core.common.Rank; +import mineplex.core.common.util.*; +import mineplex.core.portal.Portal; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.punish.Punish; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -21,26 +27,11 @@ import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.antihack.types.Fly; -import mineplex.core.antihack.types.Idle; -import mineplex.core.antihack.types.Reach; -import mineplex.core.antihack.types.Speed; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.portal.Portal; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.punish.Punish; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map.Entry; public class AntiHack extends MiniPlugin { @@ -351,42 +342,6 @@ public class AntiHack extends MiniPlugin } } - //Auto-Kick - if (!handled && - _clientManager.Get(player).GetRank() != Rank.YOUTUBE && - _clientManager.Get(player).GetRank() != Rank.YOUTUBE_SMALL && - _clientManager.Get(player).GetRank() != Rank.TWITCH) - { - player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 2f, 0.5f); - - if (_kick || _hubAttempted.remove(player)) - { - player.kickPlayer( - C.cGold + "Mineplex Anti-Cheat" + "\n" + - C.cWhite + "You were kicked for suspicious movement." + "\n" + - C.cWhite + "Cheating may result in a " + C.cRed + "Permanent Ban" + C.cWhite + "." + "\n" + - C.cWhite + "If you were not cheating, you will not be banned." - ); - } - else - { - _hubAttempted.add(player); - - UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------"); - UtilPlayer.message(player, ""); - UtilPlayer.message(player, C.cGold + "Mineplex Anti-Cheat"); - UtilPlayer.message(player, ""); - UtilPlayer.message(player, "You were kicked from the game for suspicious movement."); - UtilPlayer.message(player, "Cheating may result in a " + C.cRed + "Permanent Ban" + C.cWhite + "."); - UtilPlayer.message(player, "If you were not cheating, you will not be banned."); - UtilPlayer.message(player, ""); - UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------"); - Portal.sendPlayerToServer(player, "Lobby"); - } - - UtilServer.broadcast(F.main("MAC", player.getName() + " was kicked for suspicious movement.")); - } - //Record ServerListPingEvent event = new ServerListPingEvent(null, Bukkit.getServer().getMotd(), Bukkit.getServer().getOnlinePlayers().size(), Bukkit.getServer().getMaxPlayers()); getPluginManager().callEvent(event); From bf7065732b88872cc24f5722f44ea3318867ecbf Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 13:34:04 -0400 Subject: [PATCH 45/89] Fix jukeboxes not being removed from the world from cosmetics and scoreboards attempting to use data from indices they do not have --- .../mineplex/core/explosion/Explosion.java | 1 + .../core/gadget/gadgets/SongData.java | 10 ++++- .../core/gadget/types/MusicGadget.java | 41 ++++++++++++++----- .../core/scoreboard/PlayerScoreboard.java | 5 ++- 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java index b950fb05e..dedb8c37b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java @@ -17,6 +17,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/SongData.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/SongData.java index c8751e8c6..7c95f445b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/SongData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/SongData.java @@ -36,4 +36,12 @@ public class SongData return false; } -} + + /** + * Forces this song's jukebox to revert to air + */ + public void disable() + { + Block.setType(Material.AIR); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MusicGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MusicGadget.java index 7e103aa6c..708e5e5a6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MusicGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MusicGadget.java @@ -3,17 +3,6 @@ package mineplex.core.gadget.types; import java.util.ArrayList; import java.util.Iterator; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetAppliedEvent; -import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.event.GadgetBlockEvent; -import mineplex.core.gadget.gadgets.SongData; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Location; @@ -21,6 +10,19 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.world.ChunkUnloadEvent; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetAppliedEvent; +import mineplex.core.gadget.event.GadgetBlockEvent; +import mineplex.core.gadget.event.GadgetEnableEvent; +import mineplex.core.gadget.gadgets.SongData; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class MusicGadget extends Gadget { @@ -127,6 +129,23 @@ public class MusicGadget extends Gadget } } } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void chunkUnload(ChunkUnloadEvent event) + { + Iterator songIterator = _songs.iterator(); + + while (songIterator.hasNext()) + { + SongData song = songIterator.next(); + + if (song.Block.getChunk().equals(event.getChunk())) + { + song.disable(); + songIterator.remove(); + } + } + } public boolean canPlayAt(Location location) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java index 272f24733..274d92c2a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java @@ -136,7 +136,10 @@ public class PlayerScoreboard { for (int i=lines.size() ; i<_currentLines.size() ; i++) { - _scoreboard.resetScores(_teamNames[i]); + if (i < _teamNames.length) + { + _scoreboard.resetScores(_teamNames[i]); + } } } From 14f140143bb827b8a93c37ef7ebf20faaaae692e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 13:34:33 -0400 Subject: [PATCH 46/89] Re-enable music in hub gadgets --- Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index c983c9cbb..ab253345d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -1035,16 +1035,6 @@ public class HubManager extends MiniClientPlugin new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager, _personalServerManager).openInventory();; } - @EventHandler - public void disableMusicChristmas(GadgetEnableEvent event) - { - if (event.getGadget() != null && event.getGadget().getGadgetType() == GadgetType.MUSIC_DISC) - { - UtilPlayer.message(event.getPlayer(), F.main("Hub", "Music Discs are disabled right now!")); - event.setCancelled(true); - } - } - @EventHandler public void onSongFinish(SongFinishEvent event) { From 1ab5c8229ba08902683fa3689c669bcda4f988d3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 13:40:05 -0400 Subject: [PATCH 47/89] Make bosses clean up after themselves and be more error-resistant --- .../core/boss/broodmother/SpiderBoss.java | 22 ++------ .../core/boss/broodmother/SpiderCreature.java | 54 ++++++++++--------- .../attacks/SpiderCeilingCling.java | 4 +- .../broodmother/attacks/SpiderWebBarrage.java | 5 +- .../broodmother/attacks/SpiderWebStomp.java | 7 +-- .../core/boss/ironwizard/GolemCreature.java | 30 +++-------- .../ironwizard/abilities/GroundSpike.java | 24 +++++++-- .../boss/skeletonking/SkeletonCreature.java | 9 +++- 8 files changed, 77 insertions(+), 78 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java index 612113429..124a924aa 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java @@ -1,6 +1,7 @@ package mineplex.minecraft.game.core.boss.broodmother; import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.UtilMath; import mineplex.core.disguise.DisguiseManager; import mineplex.core.projectile.ProjectileManager; import mineplex.minecraft.game.core.boss.EventCreature; @@ -21,8 +22,7 @@ public class SpiderBoss extends WorldEvent { public SpiderBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { - super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation, - "schematic/Golem.schematic"); + super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation); } @EventHandler @@ -30,7 +30,7 @@ public class SpiderBoss extends WorldEvent { Block block = event.getBlock(); - if (!getEventMap().isInMap(block.getLocation())) + if (UtilMath.offset2d(event.getBlock().getLocation(), getCenterLocation()) > 40) { return; } @@ -44,22 +44,6 @@ public class SpiderBoss extends WorldEvent event.getBlock().setType(Material.AIR); } - @EventHandler - public void onString(ItemSpawnEvent event) - { - if (!getEventMap().isInMap(event.getLocation())) - { - return; - } - - if (event.getEntity().getItemStack().getType() != Material.STRING) - { - return; - } - - event.setCancelled(true); - } - @Override protected void customStart() { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderCreature.java index b17578cd7..a4b657260 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderCreature.java @@ -8,24 +8,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map.Entry; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.boss.BossAbility; -import mineplex.minecraft.game.core.boss.EventCreature; -import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderCocoon; -import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderEggScatter; -import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderEggplosm; -import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderPoisonBarrage; -import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderWebBarrage; -import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderWebStomp; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -40,6 +22,24 @@ import org.bukkit.util.Vector; import com.google.common.collect.Lists; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderCeilingCling; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderEggScatter; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderEggplosm; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderPoisonBarrage; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderWebBarrage; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderWebStomp; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + public class SpiderCreature extends EventCreature { private ArrayList _currentAbilities = new ArrayList(); @@ -50,7 +50,6 @@ public class SpiderCreature extends EventCreature private Vector _afkWalk = new Vector(); private HashMap _cooldowns = new HashMap(); private long _lastAttack; - public List Webs = Lists.newArrayList(); public SpiderCreature(SpiderBoss boss, Location location, double maxHealth) { @@ -68,10 +67,10 @@ public class SpiderCreature extends EventCreature @Override public void dieCustom() { - for (Block block : Webs) + /*for (Block block : Webs) { block.setType(Material.AIR); - } + }*/ } @EventHandler @@ -131,10 +130,10 @@ public class SpiderCreature extends EventCreature } } - { // Cocoon + { // Ceiling Cling if (getEvent().getCreatures().size() < 5) { - weight.put(SpiderCocoon.class, 2); + weight.put(SpiderCeilingCling.class, 2); } } @@ -242,7 +241,14 @@ public class SpiderCreature extends EventCreature for (BossAbility ability : _currentAbilities) { - ability.tick(); + try + { + ability.tick(); + } + catch (Exception e) + { + e.printStackTrace(); + } if (!ability.canMove()) { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCeilingCling.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCeilingCling.java index b041e1ecf..ec6d85ad3 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCeilingCling.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCeilingCling.java @@ -41,7 +41,7 @@ public class SpiderCeilingCling extends SpiderEggAbility for (int i = 0; i < 10; i++) { - Location loc = getBoss().getSpawnLocation().clone().add(0, -27, 0).add(UtilMath.rr(5, true), 12, UtilMath.rr(5, true)); + Location loc = getLocation().add(UtilMath.rr(10, true), 12, UtilMath.rr(10, true)); if (UtilAlg.HasSight(getLocation(), loc)) { @@ -215,4 +215,4 @@ public class SpiderCeilingCling extends SpiderEggAbility event.SetCancelled("Cancelled"); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebBarrage.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebBarrage.java index 7ec04a2e8..103f8258e 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebBarrage.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebBarrage.java @@ -11,6 +11,7 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.BossAbility; import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; @@ -127,8 +128,8 @@ public class SpiderWebBarrage extends BossAbility if (UtilBlock.airFoliage(block) || block.getType() == Material.WEB) { - block.setType(Material.WEB); - getBoss().Webs.add(block); + Bukkit.broadcastMessage("Setting Web"); + getBoss().getEvent().setBlock(block, Material.WEB); } // Expire diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebStomp.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebStomp.java index d209c671d..45a8359d7 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebStomp.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebStomp.java @@ -5,6 +5,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.minecraft.game.core.boss.BossAbility; import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; +import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; @@ -78,10 +79,10 @@ public class SpiderWebStomp extends BossAbility { continue; } - - block.setType(Material.WEB); + + Bukkit.broadcastMessage("Setting Web"); + getBoss().getEvent().setBlock(block, Material.WEB); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.WEB); - getBoss().Webs.add(block); } } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java index 6133a6426..be4e87f8c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java @@ -409,7 +409,14 @@ public class GolemCreature extends EventCreature for (BossAbility ability : _currentAbilities) { - ability.tick(); + try + { + ability.tick(); + } + catch (Exception e) + { + e.printStackTrace(); //Keeps the boss from getting stuck if one of the moves throws an error in progression + } if (!ability.canMove()) { @@ -618,25 +625,4 @@ public class GolemCreature extends EventCreature endAbility(); } } - - @EventHandler - public void onPlayerDamage(CustomDamageEvent event) - { - if (!(event.GetDamageeEntity() instanceof Player)) - { - return; - } - - if (event.GetCause() != DamageCause.FALL) - { - return; - } - - if (!getEvent().getEventMap().isInMap(event.GetDamageeEntity().getLocation())) - { - return; - } - - event.AddMod("Fall negation", 0.5); - } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GroundSpike.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GroundSpike.java index 8aedd94de..3cac28e69 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GroundSpike.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GroundSpike.java @@ -2,10 +2,12 @@ package mineplex.minecraft.game.core.boss.ironwizard.abilities; import java.util.LinkedList; -import mineplex.core.common.util.UtilTime; - import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; public class GroundSpike { @@ -29,13 +31,17 @@ public class GroundSpike _finished = false; } + @SuppressWarnings("deprecation") private void raise() { if ((_height + 1) < _max) { _lastTick = System.currentTimeMillis(); Block b = _initial.getRelative(0, _height, 0); - b.setType(_type); + for (Player player : UtilServer.getPlayers()) + { + player.sendBlockChange(b.getLocation(), _type, (byte)0); + } _blocks.add(b); _height++; } @@ -49,13 +55,17 @@ public class GroundSpike } } + @SuppressWarnings("deprecation") private void lower() { _height = Math.min(_blocks.size() - 1, _height); if ((_height - 1) >= 0) { _lastTick = System.currentTimeMillis(); - _blocks.get(_height).setType(Material.AIR); + for (Player player : UtilServer.getPlayers()) + { + player.sendBlockChange(_blocks.get(_height).getLocation(), Material.AIR, (byte)0); + } _blocks.remove(_height); _height--; } @@ -73,12 +83,16 @@ public class GroundSpike return _finished; } + @SuppressWarnings("deprecation") public void finish() { _finished = true; for (Block block : _blocks) { - block.setType(Material.AIR); + for (Player player : UtilServer.getPlayers()) + { + player.sendBlockChange(block.getLocation(), Material.AIR, (byte)0); + } } _blocks.clear(); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java index 885e1814a..45cae347e 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java @@ -315,7 +315,14 @@ public class SkeletonCreature extends EventCreature for (BossAbility ability : _currentAbilities) { - ability.tick(); + try + { + ability.tick(); + } + catch (Exception e) + { + e.printStackTrace(); + } } boolean canMove = true; From ee1f2a7ef9bd3b32f15c64af4c34a7fd4e9484d4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 14:22:17 -0400 Subject: [PATCH 48/89] Make trapped chests more resistant to being opened and allow all chest types to be opened by besiegers, as well as preventing recruits from using hoppers to get items out of chests (PC-611) --- .../mineplex/game/clans/clans/ClansGame.java | 157 +++++++++++++++--- 1 file changed, 133 insertions(+), 24 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index 8156714a2..dc270090b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -2,27 +2,6 @@ package mineplex.game.clans.clans; import java.sql.Timestamp; -import mineplex.core.MiniPlugin; -import mineplex.core.blockrestore.BlockRestoreData; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansUtility.ClanRelation; -import mineplex.game.clans.core.repository.ClanTerritory; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Effect; @@ -31,6 +10,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World.Environment; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -51,10 +31,35 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniPlugin; +import mineplex.core.blockrestore.BlockRestoreData; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansUtility.ClanRelation; +import mineplex.game.clans.clans.siege.weapon.projectile.event.CraterExplodeEvent; +import mineplex.game.clans.core.repository.ClanTerritory; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + public class ClansGame extends MiniPlugin { + private static final int CLICKS_TO_OPEN_TRAPPED = 10; private ClansManager _clans; public ClansGame(JavaPlugin plugin, ClansManager clans) @@ -121,8 +126,6 @@ public class ClansGame extends MiniPlugin { if (event.isCancelled()) return; - if (event.getBlock().getType() != Material.LADDER) return; - if (isDupedFromClassShop(event.getItemInHand())) { event.setCancelled(true); @@ -143,7 +146,24 @@ public class ClansGame extends MiniPlugin return; } - if (_clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF) return; + if (_clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF) + { + if (_clans.getClanUtility().getOwner(event.getBlock().getLocation()) != null) + { + if (event.getBlock().getType() == Material.HOPPER && (event.getBlock().getRelative(BlockFace.UP).getType() == Material.CHEST || event.getBlock().getRelative(BlockFace.UP).getType() == Material.TRAPPED_CHEST)) + { + if (_clans.getClanUtility().getRole(event.getPlayer()) == ClanRole.RECRUIT) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "Recruits cannot siphon items out of chests with a hopper!")); + event.setCancelled(true); + } + } + } + + return; + } + + if (event.getBlock().getType() != Material.LADDER) return; final Block block = event.getBlock(); @@ -275,6 +295,43 @@ public class ClansGame extends MiniPlugin return; } + if (_clans.getClan(event.getPlayer()) != null && _clans.getClanUtility().isClaimed(event.getBlock().getLocation())) + { + if (_clans.getWarManager().isBeingBesiegedBy(_clans.getClanUtility().getOwner(event.getBlock().getLocation()), _clans.getClan(event.getPlayer()))) + { + if (event.getBlock().getType() == Material.CHEST) + { + return; + } + if (event.getBlock().getType() == Material.TRAPPED_CHEST) + { + if (Recharge.Instance.use(event.getPlayer(), "Chest Crack", 1000, true, false)) + { + int clicksRemain = CLICKS_TO_OPEN_TRAPPED; + if (event.getBlock().hasMetadata("CLICKS - " + event.getPlayer().getName())) + { + clicksRemain = event.getBlock().getMetadata("CLICKS - " + event.getPlayer().getName()).get(0).asInt(); + event.getBlock().removeMetadata("CLICKS - " + event.getPlayer().getName(), _clans.getPlugin()); + } + + clicksRemain--; + if (clicksRemain > 0) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You must try to break that chest " + clicksRemain + " more times before it will yield!")); + event.getBlock().setMetadata("CLICKS - " + event.getPlayer().getName(), new FixedMetadataValue(_clans.getPlugin(), clicksRemain)); + } + else + { + return; + } + } + + event.setCancelled(true); + return; + } + } + } + // Disallow event.setCancelled(true); @@ -326,6 +383,43 @@ public class ClansGame extends MiniPlugin Location loc = event.getClickedBlock().getRelative(event.getBlockFace()).getLocation(); if (UtilBlock.usable(event.getClickedBlock())) loc = event.getClickedBlock().getLocation(); + if (_clans.getClan(player) != null && _clans.getClanUtility().isClaimed(loc)) + { + if (_clans.getWarManager().isBeingBesiegedBy(_clans.getClanUtility().getOwner(loc), _clans.getClan(player))) + { + if (loc.getBlock().getType() == Material.CHEST) + { + return; + } + if (loc.getBlock().getType() == Material.TRAPPED_CHEST) + { + if (Recharge.Instance.use(player, "Chest Crack", 1000, true, false)) + { + int clicksRemain = CLICKS_TO_OPEN_TRAPPED; + if (loc.getBlock().hasMetadata("CLICKS - " + player.getName())) + { + clicksRemain = loc.getBlock().getMetadata("CLICKS - " + player.getName()).get(0).asInt(); + loc.getBlock().removeMetadata("CLICKS - " + player.getName(), _clans.getPlugin()); + } + + clicksRemain--; + if (clicksRemain > 0) + { + UtilPlayer.message(player, F.main("Clans", "You must try to open that chest " + clicksRemain + " more times before it will yield!")); + loc.getBlock().setMetadata("CLICKS - " + player.getName(), new FixedMetadataValue(_clans.getPlugin(), clicksRemain)); + } + else + { + return; + } + } + + event.setCancelled(true); + return; + } + } + } + // Borderlands if (player.getGameMode() != GameMode.CREATIVE && player.getItemInHand() != null && _clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()) && _clans.getClanUtility().isBorderlands(event.getClickedBlock().getLocation())) { @@ -601,6 +695,21 @@ public class ClansGame extends MiniPlugin clan.inform(C.cRed + "Your Territory is under attack!", null); } + @EventHandler(priority = EventPriority.HIGHEST) + public void Explosion(CraterExplodeEvent event) + { + for (Block block : event.getBlocks()) + { + ClanInfo clan = _clans.getClanUtility().getOwner(block.getLocation()); + if (clan == null) + { + return; + } + + clan.inform(C.cRed + "Your Territory is under attack!", null); + } + } + @EventHandler public void onClanHomeInteract(PlayerInteractEvent event) { From e01b57ceac564bf8e87ba9b5e1e25c28a52adfb1 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 14:24:00 -0400 Subject: [PATCH 49/89] Implement auto restart system for clans servers in off-peak times --- .../game/clans/clans/ClansManager.java | 61 ++++----- .../game/clans/restart/RestartCommand.java | 23 ++++ .../game/clans/restart/RestartManager.java | 121 ++++++++++++++++++ 3 files changed, 176 insertions(+), 29 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java 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 7736952a9..9a4cd01fa 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 @@ -9,6 +9,35 @@ import java.util.Set; import java.util.TimeZone; import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.SignChangeEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.vehicle.VehicleEnterEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.io.ByteArrayDataOutput; +import com.google.common.io.ByteStreams; + import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -97,6 +126,7 @@ import mineplex.game.clans.gameplay.HiddenChestManager; import mineplex.game.clans.gameplay.safelog.SafeLog; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.items.GearManager; +import mineplex.game.clans.restart.RestartManager; import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.tutorial.TutorialManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -119,35 +149,6 @@ import mineplex.minecraft.game.core.fire.Fire; import mineplex.minecraft.game.core.mechanics.Weapon; import mineplex.serverdata.commands.ServerCommandManager; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.SignChangeEvent; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.FoodLevelChangeEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.vehicle.VehicleEnterEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; - -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; - public class ClansManager extends MiniClientPluginimplements IRelation { public static final int CLAIMABLE_RADIUS = 800; @@ -455,6 +456,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati _siegeManager = new SiegeManager(this); _netherManager = new NetherManager(this); _amplifierManager = new AmplifierManager(plugin); + + new RestartManager(plugin); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartCommand.java new file mode 100644 index 000000000..4a33d2f5f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartCommand.java @@ -0,0 +1,23 @@ +package mineplex.game.clans.restart; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class RestartCommand extends CommandBase +{ + public RestartCommand(RestartManager plugin) + { + super(plugin, Rank.ADMIN, "forceRestart"); + } + + @Override + public void Execute(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main("Clans", "Initiating server restart!")); + Plugin.restart(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java new file mode 100644 index 000000000..2800434cb --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java @@ -0,0 +1,121 @@ +package mineplex.game.clans.restart; + +import java.util.Calendar; +import java.util.LinkedList; + +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.portal.Portal; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; + +public class RestartManager extends MiniPlugin +{ + private static final int MAX_RESTART_TIME = 2; //Server won't auto restart after 2am + private final LinkedList _warnings = new LinkedList<>(); + private Long _restartUnlock; + private Long _restartTime = -1L; + private boolean _restarting; + + public RestartManager(JavaPlugin plugin) + { + super("Restart Manager", plugin); + + if (inRestartZone(Calendar.HOUR_OF_DAY)) + { + _restartUnlock = System.currentTimeMillis() + 1000 + UtilTime.convert(MAX_RESTART_TIME - Calendar.HOUR_OF_DAY, TimeUnit.HOURS, TimeUnit.MILLISECONDS); + } + else + { + _restartUnlock = System.currentTimeMillis(); + } + + _warnings.add(60000L); + _warnings.add(30000L); + _warnings.add(10000L); + _warnings.add(5000L); + addCommand(new RestartCommand(this)); + } + + private boolean inRestartZone(int hour) + { + return hour >= 0 && hour < MAX_RESTART_TIME; //12 am = 0 + } + + private boolean tryRestart() + { + if (!inRestartZone(Calendar.HOUR_OF_DAY) || System.currentTimeMillis() < _restartUnlock) + { + return false; + } + if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) + { + return false; + } + if (ClansManager.getInstance().getNetherManager().InNether.size() > 0) + { + return false; + } + if (ClansManager.getInstance().getWorldEvent().getEvents().size() > 0) + { + return false; + } + + return true; + } + + public void restart() + { + Bukkit.broadcastMessage(F.main("Clans", "This Clans server will be restarting in " + F.elem(UtilTime.MakeStr(120000)) + "!")); + UtilTextMiddle.display(C.cRed + "Server Restart", C.cGray + "This server will restart in " + F.elem(UtilTime.MakeStr(120000)) + "!"); + _restartTime = System.currentTimeMillis() + 120000; + } + + @EventHandler + public void checkRestart(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + if (_restarting) + { + return; + } + + if (_restartTime != -1) + { + if (!_warnings.isEmpty()) + { + if (_restartTime - System.currentTimeMillis() <= _warnings.getFirst()) + { + Long time = _warnings.removeFirst(); + Bukkit.broadcastMessage(F.main("Clans", "This Clans server will be restarting in " + F.elem(UtilTime.MakeStr(time)) + "!")); + } + } + if (System.currentTimeMillis() >= _restartTime) + { + _restarting = true; + Portal.getInstance().sendAllPlayers("ClansHub"); + runSyncLater(() -> {Bukkit.shutdown();}, 120L); + } + } + else + { + if (tryRestart()) + { + restart(); + } + } + } +} \ No newline at end of file From ce6a0b376c6f562c7d97f6bd5164cbd5fbcd0461 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 14:24:56 -0400 Subject: [PATCH 50/89] Prevent players using the gui to bypass join cooldowns --- .../src/mineplex/game/clans/clans/ClansUtility.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index ff6c1fc70..5b225e410 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -608,6 +608,12 @@ public class ClansUtility return; } + if (_clansManager.leftRecently(caller.getUniqueId(), 20 * 60 * 1000) != null) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.MakeStr(_clansManager.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + ".")); + return; + } + if (!_clansManager.Get(caller).canJoin()) { UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - _clansManager.Get(caller).getDelay(), 1, UtilTime.TimeUnit.FIT) + C.mBody + ".")); From 027b6b3fc44537732db99a47ef2b1397ccafdcba Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 14:25:47 -0400 Subject: [PATCH 51/89] Prevent players from using /c home after recently being in combat --- .../mineplex/game/clans/clans/commands/ClansCommand.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 fa710b71f..db1320461 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 @@ -931,6 +931,13 @@ public class ClansCommand extends CommandBase return; } + if (!UtilTime.elapsed(_clansManager.getCombatManager().Get(caller).GetLastCombatEngaged(), 15000)) + { + long remain = _clansManager.getCombatManager().Get(caller).GetLastCombatEngaged() + 15000 - System.currentTimeMillis(); + UtilPlayer.message(caller, F.main("Clans", "You are combat tagged for " + F.elem(UtilTime.MakeStr(remain)) + "!")); + return; + } + // Event ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "tphome"); UtilServer.getServer().getPluginManager().callEvent(event); From 6170f9df870f9070016f12dd3479b97c6e05f381 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 14:27:07 -0400 Subject: [PATCH 52/89] Actually enable create button by removing stray '!' --- .../mineplex/game/clans/clans/gui/button/ClanCreateButton.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java index 3b917b2e1..e6fa820b5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java @@ -20,7 +20,7 @@ public class ClanCreateButton implements IButton @Override public void onClick(Player player, ClickType clickType) { - if (!UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Create)).isCancelled()) + if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Create)).isCancelled()) { return; } From d73ced0e8795fc29a146ffa5034fa6e551031476 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 14:28:49 -0400 Subject: [PATCH 53/89] Stop portals from spawning in mid-air --- .../src/mineplex/game/clans/clans/nether/NetherManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 9f139f30e..a14a74b58 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -526,7 +526,7 @@ public class NetherManager extends MiniPlugin { if (event.getCreature() instanceof GolemCreature || event.getCreature() instanceof SkeletonCreature || event.getCreature() instanceof SpiderCreature) { - spawnBossPortal(event.getCreature().getSpawnLocation()); + spawnBossPortal(event.getCreature().getEvent().getCenterLocation().clone().subtract(0, 1, 0)); } } } \ No newline at end of file From 223fb0e526bf457c8ecf9efb9f1da670e297c839 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 14:30:00 -0400 Subject: [PATCH 54/89] Use custom explosion calculations as opposed to default mineplex explosion handling --- .../game/clans/clans/siege/weapon/Cannon.java | 4 +- .../clans/clans/siege/weapon/SiegeWeapon.java | 2 - .../clans/siege/weapon/TntProjectile.java | 5 +- .../clans/siege/weapon/projectile/Crater.java | 98 ++++++++++++++++--- .../weapon/projectile/WeaponProjectile.java | 6 ++ .../projectile/event/CraterExplodeEvent.java | 66 +++++++++++++ 6 files changed, 161 insertions(+), 20 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/event/CraterExplodeEvent.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java index fce9ea9d2..fab2296fb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java @@ -443,7 +443,7 @@ public class Cannon extends SiegeWeapon return new double[] { yAdd, hMult }; } - @EventHandler + /*@EventHandler public void explosionEffects(SiegeWeaponExplodeEvent event) { List blocks = Stream.generate(() -> UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 4 * getPowerLevel()).getBlock()) @@ -464,5 +464,5 @@ public class Cannon extends SiegeWeapon false, false ); - } + }*/ } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java index b7f2daefd..4f6602afa 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java @@ -808,8 +808,6 @@ public abstract class SiegeWeapon implements Listener return; } - System.out.println(event.getAction()); - if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { handleRightClick(event.getPlayer()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/TntProjectile.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/TntProjectile.java index e53e6abd4..bb61ae4ce 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/TntProjectile.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/TntProjectile.java @@ -20,7 +20,7 @@ public class TntProjectile extends WeaponProjectile super(weapon, origin, yawRot, yVel, xMulti); } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.LOWEST) public void onTntExplode(EntityExplodeEvent event) { if (event.getEntity().equals(_projectileEntity)) @@ -59,5 +59,4 @@ public class TntProjectile extends WeaponProjectile return tnt; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java index 7f35a1850..bfe80ca0d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java @@ -1,41 +1,113 @@ package mineplex.game.clans.clans.siege.weapon.projectile; +import java.util.HashMap; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import com.google.common.collect.Lists; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.siege.weapon.SiegeWeapon; +import mineplex.game.clans.clans.siege.weapon.projectile.event.CraterExplodeEvent; import mineplex.game.clans.core.repository.ClanTerritory; -import org.bukkit.Location; - public class Crater { private final SiegeWeapon _weapon; private final Location _origin; + private final Player _cause; public Crater(SiegeWeapon weapon, WeaponProjectile projectile, Location origin) { _weapon = weapon; _origin = origin; + _cause = projectile.getShooter(); createExplosion(); } + @SuppressWarnings("deprecation") private void createExplosion() { - ClanTerritory terr = _weapon.getClans().getClanUtility().getClaim(_origin); - - if (terr != null && !ClansManager.getInstance().getBlacklist().allowed(terr.Owner)) + List blocks = Lists.newArrayList(); + List noRepeats = Lists.newArrayList(); + for (Block block : UtilBlock.getExplosionBlocks(_origin, 2.6f, false)) { - return; - } - if (terr != null) - { - ClanInfo clan = ClansManager.getInstance().getClanUtility().getOwner(terr); - if (clan != null && !ClansManager.getInstance().getWarManager().isBeingBesiegedBy(clan, _weapon.getOwner())) + String locID = block.getLocation().getX() + " " + block.getLocation().getY() + " " + block.getLocation().getZ(); + if (noRepeats.contains(locID)) { - return; + continue; } + else + { + noRepeats.add(locID); + } + if (block.getType() == Material.AIR || block.isLiquid()) + { + continue; + } + ClanTerritory terr = _weapon.getClans().getClanUtility().getClaim(block.getLocation()); + + if (terr != null) + { + if (!ClansManager.getInstance().getBlacklist().allowed(terr.Owner)) + { + continue; + } + ClanInfo clan = ClansManager.getInstance().getClanUtility().getOwner(terr); + if (clan != null && !ClansManager.getInstance().getWarManager().isBeingBesiegedBy(clan, _weapon.getOwner())) + { + continue; + } + } + blocks.add(block); } - _origin.getWorld().createExplosion(_origin, 2.6f); + ClansManager.getInstance().runSyncLater(() -> + { + CraterExplodeEvent event = UtilServer.CallEvent(new CraterExplodeEvent(_weapon, _origin, blocks)); + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _origin, null, 0, 1, ViewDist.NORMAL); + for (Block block : event.getBlocks()) + { + if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE) + { + block.breakNaturally(); + } + else if (block.getType() == Material.SMOOTH_BRICK) + { + if (block.getData() != 2) + { + block.setTypeIdAndData(98, (byte)2, true); + } + else + { + block.breakNaturally(); + } + } + else + { + block.breakNaturally(); + } + } + }, 1L); + + HashMap hitMap = UtilEnt.getInRadius(_origin, 3.5); + for (LivingEntity hit : hitMap.keySet()) + { + ClansManager.getInstance().getDamageManager().NewDamageEvent(hit, _cause, null, DamageCause.ENTITY_EXPLOSION, 7 / hitMap.get(hit), true, true, false, _cause.getName(), "Siege Cannon"); + } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java index 6ba7ae951..a305dfd20 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java @@ -85,6 +85,12 @@ public abstract class WeaponProjectile implements Listener } die(); + return; + } + + if (_projectileEntity.getTicksLived() > (15 * 20)) + { + die(); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/event/CraterExplodeEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/event/CraterExplodeEvent.java new file mode 100644 index 000000000..e7c7fbeb1 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/event/CraterExplodeEvent.java @@ -0,0 +1,66 @@ +package mineplex.game.clans.clans.siege.weapon.projectile.event; + +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.game.clans.clans.siege.weapon.SiegeWeapon; + +/** + * Event called when a Crater explodes + */ +public class CraterExplodeEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private SiegeWeapon _weapon; + private Location _origin; + private List _blocks; + + public CraterExplodeEvent(SiegeWeapon weapon, Location explosionOrigin, List blocks) + { + _weapon = weapon; + _origin = explosionOrigin; + _blocks = blocks; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + /** + * Gets the Siege Weapon that shot the projectile which created this crater + * @return The Siege Weapon that shot the projectile which created this crater + */ + public SiegeWeapon getWeapon() + { + return _weapon; + } + + /** + * Gets the location where this explosion originated + * @return The origin point of this explosion + */ + public Location getExplosionOrigin() + { + return _origin; + } + + /** + * Gets a list of all blocks affected by this explosion + * @return A list of all blocks affected by this explosion + */ + public List getBlocks() + { + return _blocks; + } +} \ No newline at end of file From 4637bc8531271b677ad70f45c7a38fc6f340fe09 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 14:31:13 -0400 Subject: [PATCH 55/89] Prevent war times from displaying as negative --- .../src/mineplex/game/clans/clans/war/WarManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index 1892dae30..b8d681442 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -334,7 +334,7 @@ public class WarManager extends MiniPlugin implements ScoreboardElement element.add(" "); element.add(C.cPurpleB + "Besieging"); element.add(" " + siege.getBesiegedClan()); - element.add(" " + UtilTime.convertString(siege.getTimeLeft(), 1, UtilTime.TimeUnit.FIT)); + element.add(" " + UtilTime.convertString(Math.max(siege.getTimeLeft(), 0), 1, UtilTime.TimeUnit.FIT)); } } @@ -345,7 +345,7 @@ public class WarManager extends MiniPlugin implements ScoreboardElement element.add(" "); element.add(C.cRedB + "Besieged"); element.add(" " + siege.getBesiegingClan()); - element.add(" " + UtilTime.convertString(siege.getTimeLeft(), 1, UtilTime.TimeUnit.FIT)); + element.add(" " + UtilTime.convertString(Math.max(siege.getTimeLeft(), 0), 1, UtilTime.TimeUnit.FIT)); } } } From a56f72b6afcdc1f620faf777a068f77ed6f69a26 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 14:32:30 -0400 Subject: [PATCH 56/89] Unify standard for event spawn points --- .../game/clans/clans/worldevent/EventTerrainFinder.java | 6 +++--- .../game/clans/clans/worldevent/WorldEventType.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java index 54ffef2d8..378b50478 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java @@ -137,16 +137,16 @@ public class EventTerrainFinder { NORTH_1("world", -495, 73, -1028), NORTH_2("world", 197, 66, -1018), - NORTH_3("world", 948, 71, -959), + NORTH_3("world", 948, 72, -959), EAST_1("world", 1109, 66, -753), EAST_2("world", 1141, 68, 31), EAST_3("world", 1044, 71, 603), SOUTH_1("world", 690, 71, 895), SOUTH_2("world", 144, 66, 1012), - SOUTH_3("world", -1093, 71, 895), + SOUTH_3("world", -1093, 72, 895), WEST_1("world", -937, 71, 559), WEST_2("world", -1092, 67, -9), - WEST_3("world", -969, 71, -441); + WEST_3("world", -969, 72, -441); private String _world; private double _x, _y, _z; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index 75b0b5b6c..cb7d58236 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -2,13 +2,13 @@ package mineplex.game.clans.clans.worldevent; import java.lang.reflect.Constructor; +import org.bukkit.Location; + import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.core.boss.WorldEvent; import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; import mineplex.minecraft.game.core.boss.skeletonking.SkeletonBoss; -import org.bukkit.Location; - public enum WorldEventType { //SLIME_KING("Slime King", SlimeBoss.class, 30), From 599c47a8c21ea832ccf0cf4014414161ff19cc3b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 14:33:21 -0400 Subject: [PATCH 57/89] Prevent stacks of runes being consumed on one item --- .../mineplex/game/clans/items/runes/RuneManager.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java index 1fa2eeff7..3578d5779 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java @@ -4,6 +4,7 @@ import java.util.Arrays; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.items.CustomItem; @@ -248,8 +249,18 @@ public class RuneManager implements Listener } event.setCancelled(true); + ItemStack cursorAfter = null; + if (event.getCursor().getAmount() > 1) + { + cursorAfter = event.getCursor().clone(); + cursorAfter.setAmount(cursorAfter.getAmount() - 1); + } event.setCursor(new ItemStack(Material.AIR)); event.getClickedInventory().setItem(event.getSlot(), after); + if (cursorAfter != null) + { + UtilInv.insert(player, cursorAfter); + } player.playSound(player.getLocation(), Sound.ANVIL_USE, 1.5f, 5f); player.updateInventory(); From 5b03692c9702a7ae434b08da16a87942842e3932 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 14:33:59 -0400 Subject: [PATCH 58/89] Add in cooldowns for other clans shop buttons to stop autoclick exploits --- .../src/mineplex/game/clans/shop/bank/CashInButton.java | 6 ++++++ .../mineplex/game/clans/shop/bank/GemTransferButton.java | 6 ++++++ .../mineplex/game/clans/shop/bank/StoreGoldButton.java | 8 +++++++- .../mineplex/game/clans/shop/energy/EnergyShopButton.java | 6 ++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/CashInButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/CashInButton.java index 1589acf09..e2259fd51 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/CashInButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/CashInButton.java @@ -7,6 +7,7 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.Callback; import mineplex.core.donation.DonationManager; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; @@ -29,6 +30,11 @@ public class CashInButton implements IButton { if (clickType != ClickType.LEFT && clickType != ClickType.RIGHT) return; + if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false)) + { + return; + } + ItemStack item = player.getItemOnCursor(); CustomItem cursorItem = GearManager.parseItem(item); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/GemTransferButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/GemTransferButton.java index cd5a969b2..226fcfdec 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/GemTransferButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/GemTransferButton.java @@ -7,6 +7,7 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.Callback; import mineplex.core.donation.DonationManager; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; @@ -31,6 +32,11 @@ public class GemTransferButton implements IButton { if (clickType != ClickType.LEFT) return; + if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false)) + { + return; + } + if (GoldManager.getInstance().canTransferGems(player)) { GoldManager.getInstance().transferGemsToCoins(player, _gemAmount); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/StoreGoldButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/StoreGoldButton.java index d6dcd4ccb..66efc500b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/StoreGoldButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/StoreGoldButton.java @@ -4,6 +4,7 @@ import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; import mineplex.game.clans.economy.GoldManager; @@ -21,6 +22,11 @@ public class StoreGoldButton implements IButton { if (clickType != ClickType.LEFT) return; + if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false)) + { + return; + } + if (_page.hasEnoughGold()) { int cost = BankPage.TOKEN_VALUE; @@ -29,4 +35,4 @@ public class StoreGoldButton implements IButton } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java index b28c2558f..162be0a87 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java @@ -3,6 +3,7 @@ package mineplex.game.clans.shop.energy; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; import mineplex.game.clans.clans.ClanEnergyManager; @@ -37,6 +38,11 @@ public class EnergyShopButton implements IButton @Override public void onClick(final Player player, ClickType clickType) { + if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false)) + { + return; + } + if (UtilServer.CallEvent(new PreEnergyShopBuyEvent(player, _energyToPurchase, _cost)).isCancelled()) { return; From 8eb74de2e87f2d99251d3e4f13b1efd66bd7fd4b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 Aug 2016 21:34:31 -0400 Subject: [PATCH 59/89] Make outposts not try to block all right clicking everywhere -.- --- .../clans/clans/siege/outpost/Outpost.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index 6f2a19718..b3813ac82 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -266,24 +266,23 @@ public class Outpost implements Listener if (getLifetime() <= 2000) return; - - - if(_outpostManager.getClansManager().hasTimer(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost whilst protected from PvP.")); - return; - } - - if (!_ownerClan.equals(_ownerClan.Clans.getClanUtility().getClanByPlayer(event.getPlayer()))) - { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "This is not yours to activate!")); - return; - } if (event.getClickedBlock() != null && _origin.equals(event.getClickedBlock().getLocation())) { if (event.getClickedBlock().getType().equals(Material.BEACON)) { + if(_outpostManager.getClansManager().hasTimer(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost whilst protected from PvP.")); + return; + } + + if (!_ownerClan.equals(_ownerClan.Clans.getClanUtility().getClanByPlayer(event.getPlayer()))) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "This is not yours to activate!")); + return; + } + _origin.getBlock().setType(Material.AIR); beginConstruction(); } From c5d979e5dc685251d6d23e99e9c3d5d247c6dace Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 6 Aug 2016 03:08:29 -0400 Subject: [PATCH 60/89] Remove unnecessary while loop --- .../clans/clans/siege/outpost/Outpost.java | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index b3813ac82..9f0d47163 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -235,27 +235,24 @@ public class Outpost implements Listener { if (getState() == OutpostState.LIVE) { - do + if (event.getClickedBlock() == null) + return; + + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (!UtilItem.isDoor(event.getClickedBlock().getType())) + return; + + if (_ownerClan.isMember(event.getPlayer())) + return; + + if (UtilAlg.inBoundingBox(event.getClickedBlock().getLocation(), _startCorner.clone().subtract(.5, 0, .5), _endCorner)) { - if (event.getClickedBlock() == null) - break; - - if (event.getAction() != Action.RIGHT_CLICK_BLOCK) - break; - - if (!UtilItem.isDoor(event.getClickedBlock().getType())) - break; - - if (_ownerClan.isMember(event.getPlayer())) - break; - - if (UtilAlg.inBoundingBox(event.getClickedBlock().getLocation(), _startCorner.clone().subtract(.5, 0, .5), _endCorner)) - { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot open the doors of this Outpost.")); - event.setCancelled(true); - return; - } - } while(false); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot open the doors of this Outpost.")); + event.setCancelled(true); + return; + } } if (getState() != OutpostState.AWAITING) From 95302177f8ef9653f558d773224ddbd3d55574c4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 7 Aug 2016 14:47:14 -0400 Subject: [PATCH 61/89] Add cooldowns to all gui items tied to giving rewards to prevent some exploitation --- .../core/bonuses/gui/buttons/ClaimTipsButton.java | 6 ++++++ .../core/bonuses/gui/buttons/DailyBonusButton.java | 6 ++++++ .../mineplex/core/bonuses/gui/buttons/PollButton.java | 11 +++++++++++ .../core/bonuses/gui/buttons/RankBonusButton.java | 6 ++++++ .../core/bonuses/gui/buttons/YoutubeButton.java | 6 ++++++ .../mineplex/core/treasure/gui/BuyChestButton.java | 6 ++++++ .../core/treasure/gui/OpenTreasureButton.java | 6 ++++++ 7 files changed, 47 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java index e866c415b..9121b1bda 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java @@ -10,6 +10,7 @@ import mineplex.core.gui.ItemRefresher; import mineplex.core.gui.pages.LoadingWindow; import mineplex.core.gui.pages.TimedMessageWindow; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.ShopItem; import mineplex.core.thank.ThankManager; import org.bukkit.*; @@ -58,6 +59,11 @@ public class ClaimTipsButton implements GuiItem, Listener @Override public void click(ClickType clickType) { + if (!Recharge.Instance.use(_player, "Claim Tips Button", 1000, false, false)) + { + return; + } + if (isAvailable()) { _item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing..."); refreshItem(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java index ebc150b6c..f46ceca73 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java @@ -13,6 +13,7 @@ import mineplex.core.gui.ItemRefresher; import mineplex.core.gui.pages.LoadingWindow; import mineplex.core.gui.pages.TimedMessageWindow; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.ShopItem; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -69,6 +70,11 @@ public class DailyBonusButton implements GuiItem, Listener @Override public void click(ClickType clickType) { + if (!Recharge.Instance.use(_player, "Carl Daily Bonus", 1000, false, false)) + { + return; + } + if (isAvailable()) { _item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing..."); refreshItem(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java index dfb707a05..29054f2a6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java @@ -17,6 +17,7 @@ import mineplex.core.gui.pages.TimedMessageWindow; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.poll.Poll; import mineplex.core.poll.PollManager; +import mineplex.core.recharge.Recharge; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -109,6 +110,11 @@ public class PollButton extends SimpleGui implements GuiItem { @Override public void click(ClickType clickType) { + if (!Recharge.Instance.use(getPlayer(), "Poll Main Button", 1000, false, false)) + { + return; + } + if (_poll == null) { getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 1.6f); @@ -195,6 +201,11 @@ public class PollButton extends SimpleGui implements GuiItem { @Override public void click(ClickType clickType) { + if (!Recharge.Instance.use(getPlayer(), "Poll Answer Button", 1000, false, false)) + { + return; + } + _create = true; _pollManager.answerPoll(getPlayer(), _poll, num + 1); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java index 1f525f36b..31541dc59 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java @@ -13,6 +13,7 @@ import mineplex.core.gui.ItemRefresher; import mineplex.core.gui.pages.LoadingWindow; import mineplex.core.gui.pages.TimedMessageWindow; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.ShopItem; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -78,6 +79,11 @@ public class RankBonusButton implements GuiItem, Listener { @Override public void click(ClickType clickType) { + if (!Recharge.Instance.use(_player, "Claim Rank Bonus", 1000, false, false)) + { + return; + } + if (isAvailable() && _bonusManager.isPastAugust()) { _item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing..."); refreshItem(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java index dd741b450..4a7b1b10e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java @@ -5,6 +5,7 @@ import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.gui.GuiItem; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; import mineplex.core.youtube.YoutubeManager; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -59,6 +60,11 @@ public class YoutubeButton implements GuiItem @Override public void click(ClickType clickType) { + if (!Recharge.Instance.use(_player, "Use Youtube Button", 1000, false, false)) + { + return; + } + _player.closeInventory(); final String message; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index 2d7203f06..7c957138a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -4,6 +4,7 @@ import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.inventory.InventoryManager; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.SalesPackageBase; @@ -41,6 +42,11 @@ public class BuyChestButton implements IButton @Override public void onClick(final Player player, ClickType clickType) { + if (!Recharge.Instance.use(player, "Buy Treasure Chest", 1000, false, false)) + { + return; + } + if (_chestType == TreasureType.FREEDOM) { if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/OpenTreasureButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/OpenTreasureButton.java index 1914e2b8b..e280643e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/OpenTreasureButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/OpenTreasureButton.java @@ -3,6 +3,7 @@ package mineplex.core.treasure.gui; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; import mineplex.core.treasure.TreasureLocation; import mineplex.core.treasure.TreasureType; @@ -24,6 +25,11 @@ public class OpenTreasureButton implements IButton @Override public void onClick(Player player, ClickType clickType) { + if (!Recharge.Instance.use(player, "Open Treasure Chest", 1000, false, false)) + { + return; + } + _treasureLocation.attemptOpenTreasure(player, _treasureType); player.closeInventory(); } From 36aa1f93172cacf8f293b6f8f2613b1ec3682944 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 7 Aug 2016 15:02:23 -0400 Subject: [PATCH 62/89] Stop swords and bows from being sold in stacks --- .../src/mineplex/game/clans/shop/ShopItemButton.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java index 1737e68d3..844b2d23d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java @@ -100,7 +100,7 @@ public class ShopItemButton> implements IButton } else if (clickType == ClickType.SHIFT_LEFT || clickType == ClickType.LEFT) { - final int amount = !(UtilItem.isArmor(_item.getType()) || UtilItem.isTool(_item.getType())) && shiftClick ? 64 : 1; + final int amount = !(UtilItem.isArmor(_item.getType()) || UtilItem.isTool(_item.getType()) || UtilItem.isSword(_item.getType()) || _item.getType() == Material.BOW) && shiftClick ? 64 : 1; final int cost = amount * _buyPrice; int goldCount = GoldManager.getInstance().getGold(player); From 5985731909aa7bba32e7ef24bd2418f9603c9747 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 7 Aug 2016 17:55:38 -0400 Subject: [PATCH 63/89] Make block drop rate 30% like normal TNT --- .../game/clans/clans/siege/weapon/projectile/Crater.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java index bfe80ca0d..73a9d6d29 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java @@ -99,7 +99,14 @@ public class Crater } else { - block.breakNaturally(); + if (Math.random() <= .3) + { + block.breakNaturally(); + } + else + { + block.setType(Material.AIR); + } } } }, 1L); From e16d88e52b6c141033c78112a563afee91ed5900 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 7 Aug 2016 18:52:00 -0400 Subject: [PATCH 64/89] Add 'Safe' items replacing normal trapped chests and make craters not spam message when they explode --- .../mineplex/game/clans/clans/ClansGame.java | 63 ++++++++++++++++++- .../clans/siege/weapon/projectile/Crater.java | 2 +- .../projectile/event/CraterExplodeEvent.java | 14 ++++- 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index dc270090b..c7dbf9104 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -1,6 +1,7 @@ package mineplex.game.clans.clans; import java.sql.Timestamp; +import java.util.Iterator; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -12,6 +13,7 @@ import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -25,12 +27,16 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.enchantment.EnchantItemEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.ShapedRecipe; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.plugin.java.JavaPlugin; @@ -48,6 +54,7 @@ import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -67,6 +74,27 @@ public class ClansGame extends MiniPlugin super("Clans Game", plugin); _clans = clans; + setupSafes(); + } + + private void setupSafes() + { + Iterator it = Bukkit.getServer().recipeIterator(); + while (it.hasNext()) + { + Recipe recipe = it.next(); + if (recipe != null && recipe.getResult().getType() == Material.TRAPPED_CHEST) + { + it.remove(); + } + } + + ShapedRecipe safe = new ShapedRecipe(new ItemBuilder(Material.TRAPPED_CHEST).setAmount(1).setTitle(C.cDGray + "Safe").build()) + .shape(new String[] {"III", "ICI", "III"}) + .setIngredient('I', Material.IRON_INGOT) + .setIngredient('C', Material.CHEST); + + Bukkit.addRecipe(safe); } public static boolean isDupedFromClassShop(ItemStack item) @@ -626,7 +654,7 @@ public class ClansGame extends MiniPlugin { ClanTerritory claim = _clans.getClanUtility().getClaim(event.getBlockPlaced().getLocation()); - if (claim != null && (claim.Owner.equals("Spawn") || claim.Owner.equals("Shops"))) + if (claim != null && (claim.Owner.equals("Spawn") || claim.Owner.equals("Shops") || claim.Owner.equals("Fields") || _clans.getClanUtility().getAccess(event.getPlayer(), event.getBlockPlaced().getLocation()) != ClanRelation.SELF)) { event.setCancelled(true); } @@ -706,7 +734,10 @@ public class ClansGame extends MiniPlugin return; } - clan.inform(C.cRed + "Your Territory is under attack!", null); + if (Recharge.Instance.use(event.getShooter(), "TNT TERRITORY ALERT", 1000, false, false)) + { + clan.inform(C.cRed + "Your Territory is under attack!", null); + } } } @@ -907,4 +938,30 @@ public class ClansGame extends MiniPlugin } } } -} + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPickupSafe(PlayerPickupItemEvent event) + { + Item item = event.getItem(); + ItemStack stack = item.getItemStack(); + if (stack.getType() == Material.TRAPPED_CHEST) + { + event.setCancelled(true); + item.remove(); + UtilInv.insert(event.getPlayer(), new ItemBuilder(Material.TRAPPED_CHEST).setAmount(stack.getAmount()).setTitle(C.cDGray + "Safe").build()); + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPickupSafe(InventoryPickupItemEvent event) + { + Item item = event.getItem(); + ItemStack stack = item.getItemStack(); + if (stack.getType() == Material.TRAPPED_CHEST) + { + event.setCancelled(true); + item.remove(); + event.getInventory().addItem(new ItemBuilder(Material.TRAPPED_CHEST).setAmount(stack.getAmount()).setTitle(C.cDGray + "Safe").build()); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java index 73a9d6d29..d3c8049af 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java @@ -78,7 +78,7 @@ public class Crater ClansManager.getInstance().runSyncLater(() -> { - CraterExplodeEvent event = UtilServer.CallEvent(new CraterExplodeEvent(_weapon, _origin, blocks)); + CraterExplodeEvent event = UtilServer.CallEvent(new CraterExplodeEvent(_weapon, _cause, _origin, blocks)); UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _origin, null, 0, 1, ViewDist.NORMAL); for (Block block : event.getBlocks()) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/event/CraterExplodeEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/event/CraterExplodeEvent.java index e7c7fbeb1..b2a97834f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/event/CraterExplodeEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/event/CraterExplodeEvent.java @@ -4,6 +4,7 @@ import java.util.List; import org.bukkit.Location; import org.bukkit.block.Block; +import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -17,12 +18,14 @@ public class CraterExplodeEvent extends Event private static final HandlerList handlers = new HandlerList(); private SiegeWeapon _weapon; + private Player _shooter; private Location _origin; private List _blocks; - public CraterExplodeEvent(SiegeWeapon weapon, Location explosionOrigin, List blocks) + public CraterExplodeEvent(SiegeWeapon weapon, Player shooter, Location explosionOrigin, List blocks) { _weapon = weapon; + _shooter = shooter; _origin = explosionOrigin; _blocks = blocks; } @@ -46,6 +49,15 @@ public class CraterExplodeEvent extends Event return _weapon; } + /** + * Gets the player responsible for this crater + * @return The player responsible for this crater + */ + public Player getShooter() + { + return _shooter; + } + /** * Gets the location where this explosion originated * @return The origin point of this explosion From 36e6c7ce3316ab2b8875b5e149aab8bb1b99f5fd Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 7 Aug 2016 18:52:21 -0400 Subject: [PATCH 65/89] Fix slight error in amplifier end messages --- .../mineplex/game/clans/clans/amplifiers/AmplifierManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java index 6183a0dcb..00d0073cc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java @@ -87,7 +87,7 @@ public class AmplifierManager extends MiniPlugin } if (_active != null && _active.isEnded()) { - Bukkit.broadcastMessage(F.main(getName(), "The " + F.clansNether(AMPLIFIER_NAME) + " owned by " + F.elem(_active.getOwner()) + " has run out! You can purchase another at http://www.mineplex.com/shop!")); + Bukkit.broadcastMessage(F.main(getName(), "The " + F.clansNether(AMPLIFIER_NAME) + " owned by " + F.elem(_active.getOwner().getName()) + " has run out! You can purchase another at http://www.mineplex.com/shop!")); _active = null; } } From 4e8ed68efdd8f6f23edf41fcf0b711ad4b4298c6 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 7 Aug 2016 18:52:48 -0400 Subject: [PATCH 66/89] Stop bows from selling in stacks --- .../src/mineplex/game/clans/shop/PvpItem.java | 4 ++-- .../src/mineplex/game/clans/shop/ShopItemButton.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java index a62f2ad89..c87a00d32 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java @@ -31,8 +31,8 @@ public class PvpItem extends ShopItem LEFT_CLICK_BUY, C.cWhite + "Costs " + C.cGreen + (buyPrice == 0 ? "Free (Tutorial)" : buyPrice + "g"), C.cWhite + " ", - UtilItem.isArmor(type) || UtilItem.isTool(type) ? "" : C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, - UtilItem.isArmor(type) || UtilItem.isTool(type) ? "" : C.cWhite + "Costs " + C.cGreen + (buyPrice * bulkCount) + "g", C.cWhite + " ", + UtilItem.isArmor(type) || UtilItem.isTool(type) || type == Material.BOW ? "" : C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, + UtilItem.isArmor(type) || UtilItem.isTool(type) || type == Material.BOW ? "" : C.cWhite + "Costs " + C.cGreen + (buyPrice * bulkCount) + "g", C.cWhite + " ", RIGHT_CLICK_SELL, C.cWhite + "Earns " + C.cGreen + (sellPrice == 0 ? "Free" : sellPrice + ""), C.cWhite + " ", diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java index 844b2d23d..8a292032d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java @@ -100,7 +100,7 @@ public class ShopItemButton> implements IButton } else if (clickType == ClickType.SHIFT_LEFT || clickType == ClickType.LEFT) { - final int amount = !(UtilItem.isArmor(_item.getType()) || UtilItem.isTool(_item.getType()) || UtilItem.isSword(_item.getType()) || _item.getType() == Material.BOW) && shiftClick ? 64 : 1; + final int amount = !(UtilItem.isArmor(_item.getType()) || UtilItem.isTool(_item.getType()) || _item.getType() == Material.BOW) && shiftClick ? 64 : 1; final int cost = amount * _buyPrice; int goldCount = GoldManager.getInstance().getGold(player); From cce871b0e24f2e570329e9f63e1f24a6e240fead Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 7 Aug 2016 18:53:05 -0400 Subject: [PATCH 67/89] Stop runes being applied to stacks of items --- .../src/mineplex/game/clans/items/runes/RuneManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java index 3578d5779..eb3ba28fd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java @@ -236,6 +236,11 @@ public class RuneManager implements Listener { return; } + if (event.getCurrentItem().getAmount() > 1) + { + UtilPlayer.message(player, F.main(_managerName, "The rune cannot apply to all of those items!")); + return; + } if (!rune.canApplyTo(event.getCurrentItem().getType())) { UtilPlayer.message(player, F.main(_managerName, "The rune seems to reject that type of item!")); From 73cb42c7ab494a98571bc06c867d9efcc371ba14 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 7 Aug 2016 18:53:23 -0400 Subject: [PATCH 68/89] Make outposts actually end after they expire --- .../mineplex/game/clans/clans/siege/outpost/Outpost.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index 9f0d47163..09ed9dcbc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -460,6 +460,14 @@ public class Outpost implements Listener UtilParticle.PlayParticleToAll(ParticleType.MOB_SPELL, _core.clone().add(circleX + .5, 1.1d, circleZ + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 1.f, 0, ViewDist.NORMAL); } + + if (_state == OutpostState.LIVE) + { + if (UtilTime.elapsed(_timeSpawned, MAX_LIFETIME)) + { + kill(); + } + } } @EventHandler From 5a2871528f5cdbe2d94204ea627de6dece5e41b4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 7 Aug 2016 18:53:35 -0400 Subject: [PATCH 69/89] Small aesthetic change to ghasts --- .../clans/clans/nether/miniboss/bosses/GhastMiniboss.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java index 5c2f35532..45133db1c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java @@ -17,6 +17,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Ghast; +import org.bukkit.entity.LargeFireball; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.ProjectileLaunchEvent; @@ -108,6 +109,10 @@ public class GhastMiniboss extends NetherMiniBoss { if (event.getEntity().getShooter() != null && event.getEntity().getShooter().equals(getEntity())) { + if (!(event.getEntity() instanceof LargeFireball)) + { + event.setCancelled(true); + } ClansManager.getInstance().runSyncLater(() -> { if (event.getEntity() == null || event.getEntity().isDead() || !event.getEntity().isValid()) From 4180f03a522851c03a981e5acfeafec60db1f7c0 Mon Sep 17 00:00:00 2001 From: cnr Date: Sun, 7 Aug 2016 22:40:26 -0400 Subject: [PATCH 70/89] Use the correct SalesPackageBase for gadgets --- .../src/mineplex/core/cosmetic/ui/page/GadgetPage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index cd40f9b06..672b89097 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -372,7 +372,7 @@ public class GadgetPage extends ShopPageBase UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!")); return; } - getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(player, this, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, gadget, getDonationManager(), () -> + getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(player, this, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo() : gadget), getDonationManager(), () -> { getPlugin().getInventoryManager().addItemToInventory(getPlayer(), gadget.getName(), (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo().getQuantity() : gadget.getQuantity())); refresh(); From e5a96e8189a0c2e49247b98b96a933136a7b6f0c Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 Aug 2016 21:54:27 -0400 Subject: [PATCH 71/89] Fix incorrect casing in mapping outposts --- .../clans/clans/siege/outpost/OutpostManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java index c2f382bf4..559fc6b4b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java @@ -68,12 +68,12 @@ public class OutpostManager extends MiniPlugin public boolean spawnOutpost(Player player, Location location, OutpostType type) { -// if (_clansManager.getNetherManager().isInNether(player)) -// { -// _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + "."); -// -// return false; -// } + if (_clansManager.getNetherManager().isInNether(player)) + { + _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + "."); + + return false; + } if (!_clansManager.isInClan(player)) { @@ -228,7 +228,7 @@ public class OutpostManager extends MiniPlugin public Outpost Get(ClanInfo clan) { - return clan == null ? null : _outposts.get(clan.getName().toLowerCase()); + return clan == null ? null : _outposts.get(clan.getName()); } public void queueForRemoval(String name) From 5fca64b86b32259152b09aceebb1146e7a2b03b2 Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Tue, 9 Aug 2016 15:10:45 -0400 Subject: [PATCH 72/89] Remove safezone requirement for observer mode --- .../clans/clans/observer/ObserverManager.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java index 606c1ec68..50ad63fdf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java @@ -166,21 +166,6 @@ public class ObserverManager extends MiniPlugin public boolean canEnterObserverMode(Player player, boolean notify) { - if (_clansManager.getClientManager().hasRank(player, Rank.CMOD)) - { - return true; - } - - ClanTerritory territory = _clansManager.getClanUtility().getClaim(player.getLocation()); - - if (territory == null || !territory.isSafe(player.getLocation())) - { - if (notify) - UtilPlayer.message(player, F.main("Observer", "You must be in a Safe Zone to use observer mode!")); - - return false; - } - return true; } From 933861176db88fa2b319f6a3347f7e90715f654f Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 10 Aug 2016 21:45:27 +0100 Subject: [PATCH 73/89] PC-662 Castle Siege - Fixes the game not ending if the whole of one team left. --- .../game/arcade/game/games/castlesiege/CastleSiege.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index a2c6951ac..50e9b449c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -49,6 +49,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.gadget.set.SetCandyCane; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -589,7 +590,7 @@ public class CastleSiege extends TeamGame if (!IsLive()) return; - if (this.WorldTimeSet > 24100) + if (this.WorldTimeSet > 24100 || GetTeam(ChatColor.RED).GetSize() == 0) { SetCustomWinLine(_kingName + ChatColor.RESET + " has survived the siege!"); @@ -613,7 +614,7 @@ public class CastleSiege extends TeamGame SetState(GameState.End); } - if (!_king.isValid()) + if (!_king.isValid() || GetTeam(ChatColor.AQUA).GetSize() == 0) { if (_kingDamager != null) { From a02699d84a40f624a728dddad0ff6db252a09a75 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 10 Aug 2016 21:46:02 +0100 Subject: [PATCH 74/89] PC-898 SSM - Fixes an issue where kit armor would not appear correctly in your inventory. --- .../nautilus/game/arcade/game/games/smash/kits/KitPig.java | 2 +- .../arcade/game/games/smash/kits/KitWitherSkeleton.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitPig.java index 23efec302..228622660 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitPig.java @@ -76,8 +76,8 @@ public class KitPig extends SmashKit private static final ItemStack[] PLAYER_ARMOR = { ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), + ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), null, }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitherSkeleton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitherSkeleton.java index b59a1bd66..75739762e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitherSkeleton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitherSkeleton.java @@ -67,10 +67,10 @@ public class KitWitherSkeleton extends SmashKit private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), + ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS) + ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), + ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET) }; From df646b065943bc1253314e529f25fdfea6935481 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 10 Aug 2016 21:46:37 +0100 Subject: [PATCH 75/89] PC-897 SG - Spectators can no longer punch fireballs from the world border --- .../game/games/survivalgames/SurvivalGames.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index ea5d5e663..b46fb4cc6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -34,6 +34,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.hanging.HangingBreakEvent; @@ -1262,7 +1263,7 @@ public abstract class SurvivalGames extends Game if (!(event.getEntity() instanceof Fireball)) return; - + Collection blocks = UtilBlock.getInRadius( event.getEntity().getLocation(), 2.4).keySet(); @@ -1284,6 +1285,15 @@ public abstract class SurvivalGames extends Game return sides >= 3; } + + @EventHandler + public void borderSpecInteraction(EntityDamageByEntityEvent event) + { + if (event.getEntity() instanceof Fireball && UtilPlayer.isSpectator(event.getDamager())) + { + event.setCancelled(true); + } + } @EventHandler public void borderDamage(CustomDamageEvent event) From 82b2541e3481fe4a480e4b2a9cd0218ca4e0a393 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 10 Aug 2016 21:47:13 +0100 Subject: [PATCH 76/89] PC-827 Team SSM - Teammates can no longer cancel each other's Blaze Firefly --- .../game/arcade/kit/perks/PerkFirefly.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java index df7e17b2e..f16ef797c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java @@ -17,15 +17,17 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; import nautilus.game.arcade.kit.SmashPerk; import nautilus.game.arcade.kit.perks.data.FireflyData; @@ -170,6 +172,11 @@ public class PerkFirefly extends SmashPerk if (event.GetDamage() <= 4) return; + if (!(event.GetDamagerEntity(true) instanceof Player)) + { + return; + } + Iterator dataIterator = _data.iterator(); while (dataIterator.hasNext()) @@ -181,6 +188,17 @@ public class PerkFirefly extends SmashPerk if (!UtilTime.elapsed(data.Time, 1250) && !isSuperActive(data.Player))// && event.GetCause() == DamageCause.PROJECTILE) { + Game game = Manager.GetGame(); + + if (game instanceof TeamSuperSmash) + { + if (game.GetTeam(data.Player).equals(game.GetTeam(event.GetDamagerPlayer(true)))) + { + event.SetCancelled("Team Damage"); + return; + } + } + dataIterator.remove(); } else From 7de9da3d1cc8e6406dd0f0a5f085fab781f494cd Mon Sep 17 00:00:00 2001 From: samczsun Date: Tue, 7 Jun 2016 19:33:03 -0400 Subject: [PATCH 77/89] Complete rework of disguising and antihack hook This commit completely rewrites DisguiseManager, DisguisePlayer, and PlayerDisguiseManager. Changes to disguising means that much of the core was also changed, primarily having to do with mapping by UUID versus player names. Several new API classes were added, such as EntitySelector, Managers, UtilTasks, and a brand new scoreboard API which is much more optimized and allows for much longer lines The new anticheat is hooked as well, with implementation for guardians which follow the players around. Release two code is also included, but is currently disabled via a boolean. --- .../core/common/jsonchat/JsonMessage.java | 2 +- .../mineplex/core/common/skin/SkinData.java | 142 +- .../mineplex/core/common/util/UtilAlg.java | 69 +- .../mineplex/core/common/util/UtilEnt.java | 29 +- .../mineplex/core/common/util/UtilPlayer.java | 9 + .../mineplex/core/common/util/UtilServer.java | 7 +- .../mineplex/core/common/util/UtilTasks.java | 40 + .../mineplex/core/common/util/UtilWorld.java | 7 +- Plugins/Mineplex.Core/pom.xml | 5 + .../src/mineplex/core/CustomTagFix.java | 632 ++++---- .../src/mineplex/core/Managers.java | 92 ++ .../src/mineplex/core/MiniClientPlugin.java | 47 +- .../src/mineplex/core/MiniDbClientPlugin.java | 3 +- .../src/mineplex/core/MiniPlugin.java | 63 +- .../mineplex/core/PacketsInteractionFix.java | 18 +- .../src/mineplex/core/PlayerSelector.java | 161 ++ .../core/ReflectivelyCreateMiniPlugin.java | 15 + .../src/mineplex/core/account/CoreClient.java | 126 +- .../core/account/CoreClientManager.java | 426 ++--- .../core/account/ILoginProcessor.java | 3 +- .../core/account/event/ClientUnloadEvent.java | 63 +- .../account/repository/AccountRepository.java | 2 +- .../core/achievement/AchievementManager.java | 8 +- .../src/mineplex/core/antihack/AntiHack.java | 729 ++++++++- .../core/antihack/AntiHackGuardian.java | 395 +++++ .../core/antihack/MajorViolationCommand.java | 46 + .../core/antihack/actions/AntiHackAction.java | 52 + .../core/antihack/actions/BanwaveAction.java | 35 + .../antihack/actions/ImmediateBanAction.java | 26 + .../core/antihack/actions/MixedAction.java | 49 + .../core/antihack/actions/NoopAction.java | 17 + .../core/antihack/banwave/BanWaveInfo.java | 157 ++ .../core/antihack/banwave/BanWaveManager.java | 80 + .../antihack/banwave/BanWaveRepository.java | 90 ++ .../mineplex/core/benefit/BenefitManager.java | 7 +- .../mineplex/core/bonuses/BonusManager.java | 8 +- .../core/cosmetic/ui/page/GadgetPage.java | 6 +- .../mineplex/core/cosmetic/ui/page/Menu.java | 24 +- .../core/cosmetic/ui/page/MountPage.java | 6 +- .../core/cosmetic/ui/page/PetPage.java | 4 +- .../src/mineplex/core/creature/Creature.java | 10 + .../core/customdata/CustomDataManager.java | 9 +- .../repository/CustomDataRepository.java | 5 +- .../core/delayedtask/DelayedTask.java | 6 +- .../core/disguise/DisguiseFactory.java | 2 +- .../core/disguise/DisguiseManager.java | 1374 ++++++----------- .../core/disguise/DisguisePlayerBean.java | 34 - .../core/disguise/PlayerDisguiseManager.java | 71 - .../disguise/disguises/DisguiseAmbient.java | 6 +- .../disguises/DisguiseArmorStand.java | 5 +- .../core/disguise/disguises/DisguiseBase.java | 147 +- .../disguise/disguises/DisguiseBlock.java | 5 +- .../disguises/DisguiseCaveSpider.java | 1 - .../disguise/disguises/DisguiseCreature.java | 13 +- .../disguise/disguises/DisguiseHuman.java | 5 +- .../disguises/DisguiseInsentient.java | 5 +- .../disguise/disguises/DisguiseLiving.java | 7 +- .../disguise/disguises/DisguiseMagmaCube.java | 5 +- .../disguise/disguises/DisguisePlayer.java | 490 ++++-- .../disguise/disguises/DisguiseRabbit.java | 3 +- .../disguise/disguises/DisguiseSlime.java | 5 +- .../playerdisguise/DisguiseCommand.java | 33 + .../playerdisguise/DisguisePlayerBean.java | 137 ++ .../playerdisguise/PlayerDisguiseManager.java | 631 ++++++++ .../events/PlayerDisguisedEvent.java | 32 + .../events/PlayerPreDisguiseEvent.java | 54 + .../events/PlayerPreUndisguiseEvent.java | 47 + .../events/PlayerUndisguisedEvent.java} | 6 +- .../core/donation/DonationManager.java | 16 +- .../core/donation/command/ShardCommand.java | 15 +- .../src/mineplex/core/elo/EloManager.java | 7 +- .../src/mineplex/core/energy/Energy.java | 4 +- .../core/event/JoinMessageBroadcastEvent.java | 47 + .../core/facebook/FacebookManager.java | 7 +- .../mineplex/core/friend/FriendManager.java | 21 +- .../core/friend/data/FriendRepository.java | 20 +- .../core/gadget/commands/AmmoCommand.java | 20 +- .../gadget/commands/LockCosmeticsCommand.java | 4 +- .../arrowtrail/titan/ArrowTrailTitan.java | 2 +- .../gadgets/death/titan/DeathTitan.java | 2 +- .../doublejump/titan/DoubleJumpTitan.java | 2 +- .../core/gadget/gadgets/morph/MorphBat.java | 2 +- .../core/gadget/gadgets/morph/MorphBlaze.java | 4 +- .../core/gadget/gadgets/morph/MorphBunny.java | 6 +- .../gadget/gadgets/morph/MorphChicken.java | 2 +- .../core/gadget/gadgets/morph/MorphCow.java | 2 +- .../gadget/gadgets/morph/MorphCreeper.java | 4 +- .../gadget/gadgets/morph/MorphEnderman.java | 2 +- .../core/gadget/gadgets/morph/MorphPig.java | 4 +- .../gadgets/morph/MorphPumpkinKing.java | 2 +- .../core/gadget/gadgets/morph/MorphSlime.java | 2 +- .../gadget/gadgets/morph/MorphSnowman.java | 2 +- .../core/gadget/gadgets/morph/MorphTitan.java | 4 +- .../gadget/gadgets/morph/MorphUncleSam.java | 36 +- .../gadget/gadgets/morph/MorphVillager.java | 6 +- .../gadget/gadgets/morph/MorphWither.java | 4 +- .../outfit/ravesuit/OutfitRaveSuit.java | 23 +- .../gadgets/particle/ParticleKronos.java | 2 +- .../gadgets/particle/ParticleLegend.java | 2 +- .../gadgets/particle/titan/ParticleTitan.java | 2 +- .../wineffect/WinEffectBabyChicken.java | 4 +- .../gadgets/wineffect/WinEffectFireworks.java | 4 +- .../gadgets/wineffect/WinEffectFlames.java | 6 +- .../gadgets/wineffect/WinEffectLavaTrap.java | 6 +- .../wineffect/WinEffectMrPunchMan.java | 8 +- .../gadgets/wineffect/WinEffectPodium.java | 8 +- .../WinEffectRiseOfTheElderGuardian.java | 6 +- .../wineffect/WinEffectSnowTrails.java | 4 +- .../mineplex/core/gadget/types/Gadget.java | 4 +- .../mineplex/core/gadget/types/HatGadget.java | 1 - .../core/gadget/types/WinEffectGadget.java | 4 +- .../core/giveaway/GiveawayManager.java | 6 +- .../src/mineplex/core/hologram/Hologram.java | 19 +- .../mineplex/core/ignore/IgnoreManager.java | 7 +- .../core/incognito/IncognitoManager.java | 7 +- .../core/inventory/InventoryManager.java | 6 +- .../mineplex/core/message/MessageManager.java | 79 +- .../core/message/commands/AdminCommand.java | 4 +- .../message/commands/AdminMessageCommand.java | 47 - .../message/commands/MessageAdminCommand.java | 25 +- .../message/redis/AnnouncementHandler.java | 56 - .../core/message/redis/MessageHandler.java | 38 - .../src/mineplex/core/monitor/LagMeter.java | 14 +- .../core/mount/types/MountDragon.java | 2 +- .../mineplex/core/mount/types/MountTitan.java | 2 +- .../src/mineplex/core/movement/Movement.java | 4 +- .../core/packethandler/PacketHandler.java | 7 +- .../core/packethandler/PacketVerifier.java | 5 + .../src/mineplex/core/party/Party.java | 67 +- .../core/party/PartyEventListener.java | 6 +- .../src/mineplex/core/party/PartyManager.java | 11 +- .../party/manager/PartyInviteManager.java | 2 +- .../party/manager/PartyMethodManager.java | 19 +- .../core/party/manager/PartyRedisManager.java | 14 +- .../core/party/ui/menus/PartyOwnerMenu.java | 10 +- .../core/party/ui/menus/PartyViewMenu.java | 10 +- .../HostEventServerCommand.java | 2 +- .../personalServer/HostServerCommand.java | 2 +- .../src/mineplex/core/pet/PetClient.java | 9 +- .../src/mineplex/core/pet/PetManager.java | 19 +- .../src/mineplex/core/poll/PollManager.java | 6 +- .../mineplex/core/portal/TransferHandler.java | 1 - .../core/preferences/PreferencesManager.java | 64 +- .../ui/ExclusivePreferencesPage.java | 11 +- .../profileCache/ProfileCacheManager.java | 20 +- .../progression/KitProgressionManager.java | 4 +- .../core/punish/Command/PunishCommand.java | 44 +- .../src/mineplex/core/punish/Punish.java | 63 +- .../mineplex/core/punish/UI/PunishPage.java | 28 +- .../mineplex/core/report/ReportManager.java | 2 +- .../core/reward/rewards/PetReward.java | 2 +- .../reward/rewards/UnknownPackageReward.java | 4 +- .../core/scoreboard/MineplexScoreboard.java | 260 ++++ .../core/scoreboard/ScoreboardElement.java | 242 +++ .../core/scoreboard/ScoreboardLine.java | 5 + .../core/scoreboard/ScoreboardManager.java | 211 +-- .../WritableMineplexScoreboard.java | 144 ++ .../serverConfig/ServerConfiguration.java | 2 +- .../src/mineplex/core/stats/StatsManager.java | 14 +- .../core/stats/command/GiveStatCommand.java | 15 +- .../stats/command/MasterBuilderUnban.java | 24 +- .../src/mineplex/core/task/TaskManager.java | 12 +- .../src/mineplex/core/teleport/Teleport.java | 175 +-- .../core/teleport/redis/RedisLocate.java | 13 +- .../teleport/redis/RedisLocateCallback.java | 8 + .../teleport/redis/RedisLocateHandler.java | 42 - .../src/mineplex/core/thank/ThankManager.java | 7 +- .../PlayerScoreboard.java | 2 +- .../ScoreboardData.java | 11 +- .../ScoreboardManager.java | 180 +++ .../elements/ScoreboardElement.java | 4 +- .../elements/ScoreboardElementCoinCount.java | 4 +- .../elements/ScoreboardElementGemCount.java | 4 +- .../elements/ScoreboardElementRank.java | 14 +- .../elements/ScoreboardElementScores.java | 4 +- .../elements/ScoreboardElementText.java | 4 +- .../core/tournament/TournamentManager.java | 6 +- .../core/treasure/gui/BuyChestButton.java | 5 - .../mineplex/core/utils/UtilGameProfile.java | 177 +++ .../mineplex/core/youtube/YoutubeManager.java | 9 +- .../src/mineplex/enjinTranslator/Enjin.java | 65 +- Plugins/Mineplex.Game.Clans/plugin.yml | 3 +- .../src/mineplex/game/clans/Clans.java | 106 +- .../game/clans/clans/ClansManager.java | 17 +- .../clans/commands/ClansLoginManager.java | 3 +- .../clans/clans/murder/MurderManager.java | 3 +- .../game/clans/clans/playtime/Playtime.java | 8 +- .../scoreboard/ClansPlayerScoreboard.java | 4 +- .../scoreboard/ClansScoreboardManager.java | 6 +- .../elements/ScoreboardElementClan.java | 4 +- .../elements/ScoreboardElementPlayer.java | 4 +- .../ScoreboardElementPlayerCount.java | 4 +- .../game/clans/clans/war/WarManager.java | 4 +- .../clans/worldevent/WorldEventManager.java | 10 +- .../clans/worldevent/WorldEventType.java | 2 +- .../clans/worldevent/kinghill/KingHill.java | 2 +- .../game/clans/economy/GoldCommand.java | 15 +- .../game/clans/economy/GoldManager.java | 9 +- .../game/clans/economy/SetGoldCommand.java | 19 +- .../gameplay/safelog/npc/CombatLogNPC.java | 4 +- .../game/clans/legacytutorial/Tutorial.java | 4 +- .../game/clans/tutorial/TutorialManager.java | 4 +- .../src/mineplex/clanshub/ClansHub.java | 21 +- .../clanshub/ClansTransferManager.java | 7 +- .../src/mineplex/clanshub/HubManager.java | 20 +- Plugins/Mineplex.Hub/plugin.yml | 3 +- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 23 +- .../src/mineplex/hub/HubClient.java | 98 +- .../src/mineplex/hub/HubManager.java | 399 ++--- .../src/mineplex/hub/HubScoreboardLine.java | 22 + .../hub/commands/DisguiseCommand.java | 481 ------ .../src/mineplex/hub/mail/MailManager.java | 5 +- .../hub/modules/HubScoreboardManager.java | 74 - .../mineplex/hub/modules/StackerManager.java | 3 +- .../src/mineplex/hub/queue/ui/QueuePage.java | 2 +- .../mineplex/hub/server/ServerManager.java | 3 +- .../mineplex/hub/server/ui/ServerNpcPage.java | 6 +- .../server/ui/button/JoinServerButton.java | 2 +- .../game/classcombat/Class/ClassManager.java | 27 +- .../game/classcombat/Class/ClientClass.java | 2 +- .../classcombat/Skill/Assassin/Illusion.java | 7 +- .../game/classcombat/shop/page/SkillPage.java | 4 +- .../minecraft/game/core/boss/WorldEvent.java | 6 +- .../core/boss/broodmother/SpiderBoss.java | 4 +- .../game/core/boss/ironwizard/GolemBoss.java | 4 +- .../core/boss/skeletonking/SkeletonBoss.java | 4 +- .../game/core/boss/slimeking/SlimeBoss.java | 4 +- .../game/core/combat/CombatComponent.java | 24 +- .../game/core/combat/CombatManager.java | 21 +- .../game/core/damage/DamageManager.java | 4 +- .../serverdata/commands/CommandCallback.java | 4 +- .../commands/ServerCommandManager.java | 8 +- .../src/mineplex/staffServer/StaffServer.java | 12 +- .../customerSupport/CustomerSupport.java | 45 +- .../customerSupport/checkCommand.java | 25 +- .../salespackage/command/CoinCommand.java | 35 +- .../command/GemHunterCommand.java | 21 +- .../salespackage/command/ItemCommand.java | 50 +- Plugins/Nautilus.Game.Arcade/plugin.yml | 3 +- .../src/nautilus/game/arcade/Arcade.java | 21 +- .../nautilus/game/arcade/ArcadeManager.java | 378 ++++- .../game/arcade/ArcadeScoreboardLine.java | 22 + .../game/arcade/command/DisguiseCommand.java | 507 ------ .../src/nautilus/game/arcade/game/Game.java | 260 ++-- .../nautilus/game/arcade/game/GameTeam.java | 166 +- .../game/arcade/game/RankedTeamGame.java | 2 +- .../nautilus/game/arcade/game/SoloGame.java | 22 +- .../nautilus/game/arcade/game/TeamGame.java | 29 +- .../game/arcade/game/games/bridge/Bridge.java | 30 +- .../game/arcade/game/games/build/Build.java | 22 +- .../game/games/build/modes/TeamBuild.java | 22 +- .../game/arcade/game/games/cards/Cards.java | 36 +- .../game/games/castlesiege/CastleSiege.java | 29 +- .../game/games/christmas/Christmas.java | 58 +- .../game/games/common/CaptureTheFlag.java | 49 +- .../arcade/game/games/common/Domination.java | 31 +- .../game/games/common/TeamDeathmatch.java | 28 +- .../arcade/game/games/deathtag/DeathTag.java | 12 +- .../game/games/dragonescape/DragonEscape.java | 24 +- .../games/dragonescape/DragonEscapeTeams.java | 14 +- .../game/games/dragons/DragonsTeams.java | 13 +- .../game/arcade/game/games/draw/Draw.java | 82 +- .../arcade/game/games/event/EventGame.java | 12 +- .../arcade/game/games/event/EventModule.java | 6 +- .../game/games/evolution/Evolution.java | 18 +- .../game/games/evolution/mobs/KitGolem.java | 3 +- .../game/games/gladiators/Gladiators.java | 54 +- .../game/games/halloween/Halloween.java | 24 +- .../arcade/game/games/hideseek/HideSeek.java | 24 +- .../arcade/game/games/milkcow/MilkCow.java | 22 +- .../minecraftleague/MinecraftLeague.java | 60 +- .../wither/data/WitherSkeletonTimer.java | 8 +- .../game/games/minestrike/Minestrike.java | 33 +- .../game/games/mineware/BawkBawkBattles.java | 57 +- .../games/mineware/challenge/Challenge.java | 3 - .../type/ChallengeDogsVersusCats.java | 10 + .../challenge/type/ChallengeLavaRun.java | 9 + .../challenge/type/ChallengeMilkACow.java | 8 + .../type/ChallengeZombieInfection.java | 9 + .../games/mineware/effect/ChickenAttack.java | 2 +- .../arcade/game/games/monstermaze/Maze.java | 2 +- .../game/games/monstermaze/MonsterMaze.java | 28 +- .../game/games/oldmineware/OldMineWare.java | 2 - .../game/games/paintball/Paintball.java | 2 +- .../game/arcade/game/games/quiver/Quiver.java | 16 +- .../arcade/game/games/quiver/QuiverTeams.java | 16 +- .../searchanddestroy/SearchAndDestroy.java | 16 +- .../arcade/game/games/sheep/SheepGame.java | 31 +- .../game/games/skywars/SoloSkywars.java | 34 +- .../game/games/skywars/TeamSkywars.java | 52 +- .../game/games/skywars/modes/UHCSkywars.java | 3 +- .../game/games/smash/SoloSuperSmash.java | 29 +- .../game/games/smash/TeamSuperSmash.java | 26 +- .../sneakyassassins/SneakyAssassins.java | 39 +- .../game/games/snowfight/SnowFight.java | 36 +- .../games/speedbuilders/SpeedBuilders.java | 26 +- .../game/games/squidshooter/SquidShooter.java | 12 +- .../survivalgames/SoloSurvivalGames.java | 32 +- .../games/survivalgames/SurvivalGames.java | 293 ++-- .../survivalgames/TeamSurvivalGames.java | 46 +- .../survivalgames/modes/UHCSurvivalgames.java | 2 +- .../game/arcade/game/games/tug/Tug.java | 20 +- .../game/games/turfforts/TurfForts.java | 23 +- .../arcade/game/games/typewars/TypeWars.java | 32 +- .../game/arcade/game/games/uhc/UHC.java | 511 +++--- .../games/uhc/helpers/WorldGenThread.java | 14 - .../game/games/valentines/Valentines.java | 34 +- .../arcade/game/games/wither/WitherGame.java | 22 +- .../arcade/game/games/wizards/Wizards.java | 16 +- .../games/zombiesurvival/ZombieSurvival.java | 9 +- .../arcade/game/modules/AntiExpOrbModule.java | 100 ++ .../game/arcade/game/modules/TeamModule.java | 2 +- .../game/modules/antixray/AntiXrayModule.java | 34 + .../modules/antixray/AntiXrayService.java | 30 + .../modules/combatlog/CombatLogModule.java | 2 + .../src/nautilus/game/arcade/kit/Kit.java | 2 +- .../game/arcade/managers/GameFlagManager.java | 5 +- .../arcade/managers/GameLobbyManager.java | 738 ++++----- .../game/arcade/managers/GameManager.java | 21 +- .../arcade/managers/GamePlayerManager.java | 5 +- .../arcade/managers/GameRewardManager.java | 12 +- .../arcade/managers/GameSpectatorManager.java | 14 +- .../managers/GameTournamentManager.java | 4 +- .../arcade/managers/chat/GameChatManager.java | 33 +- .../arcade/scoreboard/GameScoreboard.java | 339 ++-- .../arcade/scoreboard/ScoreboardElement.java | 8 - .../scoreboard/ScoreboardElementScores.java | 65 - .../scoreboard/ScoreboardElementText.java | 24 - Plugins/app.xml | 1 + Plugins/plugin.xml | 1 + 330 files changed, 9665 insertions(+), 6728 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTasks.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/Managers.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/ReflectivelyCreateMiniPlugin.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackGuardian.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/MajorViolationCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/AntiHackAction.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/BanwaveAction.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/ImmediateBanAction.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/MixedAction.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/NoopAction.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveRepository.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguisePlayerBean.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerDisguisedEvent.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreDisguiseEvent.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreUndisguiseEvent.java rename Plugins/Mineplex.Core/src/mineplex/core/disguise/{PlayerUndisguiseEvent.java => playerdisguise/events/PlayerUndisguisedEvent.java} (73%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/event/JoinMessageBroadcastEvent.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/message/redis/AnnouncementHandler.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/message/redis/MessageHandler.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/scoreboard/MineplexScoreboard.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardElement.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardLine.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/scoreboard/WritableMineplexScoreboard.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateHandler.java rename Plugins/Mineplex.Core/src/mineplex/core/{scoreboard => thereallyoldscoreboardapiweshouldremove}/PlayerScoreboard.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/{scoreboard => thereallyoldscoreboardapiweshouldremove}/ScoreboardData.java (94%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardManager.java rename Plugins/Mineplex.Core/src/mineplex/core/{scoreboard => thereallyoldscoreboardapiweshouldremove}/elements/ScoreboardElement.java (55%) rename Plugins/Mineplex.Core/src/mineplex/core/{scoreboard => thereallyoldscoreboardapiweshouldremove}/elements/ScoreboardElementCoinCount.java (76%) rename Plugins/Mineplex.Core/src/mineplex/core/{scoreboard => thereallyoldscoreboardapiweshouldremove}/elements/ScoreboardElementGemCount.java (75%) rename Plugins/Mineplex.Core/src/mineplex/core/{scoreboard => thereallyoldscoreboardapiweshouldremove}/elements/ScoreboardElementRank.java (50%) rename Plugins/Mineplex.Core/src/mineplex/core/{scoreboard => thereallyoldscoreboardapiweshouldremove}/elements/ScoreboardElementScores.java (89%) rename Plugins/Mineplex.Core/src/mineplex/core/{scoreboard => thereallyoldscoreboardapiweshouldremove}/elements/ScoreboardElementText.java (75%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/utils/UtilGameProfile.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/HubScoreboardLine.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubScoreboardManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeScoreboardLine.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/AntiExpOrbModule.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElement.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementScores.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementText.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/JsonMessage.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/JsonMessage.java index f4ce9532e..c32abd4a8 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/JsonMessage.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/JsonMessage.java @@ -108,7 +108,7 @@ public class JsonMessage public void sendToPlayer(Player player) { - UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + player.getName() + " " + toString()); + ((CraftPlayer) player).getHandle().sendMessage(IChatBaseComponent.ChatSerializer.a(toString())); } /** diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index b89b34866..5494a5672 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -1,7 +1,22 @@ package mineplex.core.common.skin; +import java.lang.reflect.Field; +import java.util.Base64; +import java.util.Collection; import java.util.List; +import java.util.Map; +import java.util.UUID; +import com.google.common.collect.Maps; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.mojang.authlib.minecraft.InsecureTextureException; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository; +import mineplex.core.common.util.UtilPlayer; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.Player; @@ -16,20 +31,42 @@ import net.minecraft.server.v1_8_R3.MinecraftKey; import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.NBTTagList; import net.minecraft.server.v1_8_R3.NBTTagString; +import org.bukkit.inventory.meta.SkullMeta; public class SkinData { + private static final Field PROFILE_FIELD; + + static + { + try + { + PROFILE_FIELD = Class.forName("org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaSkull").getDeclaredField("profile"); + PROFILE_FIELD.setAccessible(true); + } + catch (ReflectiveOperationException ex) + { + throw new RuntimeException(ex); + } + } + private static long _nameCount = -99999999999999L; public final static SkinData FREEDOM_CHEST = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjY1NzA5NDAzODcsInByb2ZpbGVJZCI6IjQwZWQ5NzU1OWIzNTQ1M2Q4NjU1ZmMwMDM5OGRiNmI5IiwicHJvZmlsZU5hbWUiOiJTcG9vYm5jb29iciIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc4N2Q4OGNlYzNmOWI0M2RiNDg1YTU0Mjc2YTQ1MjQzNGFiZDI2ZDMzY2QzZmZhMTM2N2ZiMzVmOWUzODQifX19", "UgsQyW/HJ/jmDzfI1d7RWFbhKi8PeJAKBuAOk7ajS5dzH5od301KfcmiT2X3TU7cBbUswcKtDb2F/m7gNrg/t+pU7Bi9UKzyALEu9HRjd4s1uKbqGkBip1z5Qycp4fhkSyKvtvTnA2fhpP9oHtE5FxGXdMhZXyFkLrli4Hyxp1BI0N4h7pgbcMaISPS0ZYzDRNxkrSnl3y3KyKn5Rl5qH7utmQtAjoyx9aueMZxG3tg/igfYF7uAvvmuYKsSiTZWZOOuSh+U1dkP+ZE/cQANfryXkLJSJHa9YZPCMJHXe4mMoAyu0/quwZCW9NlW3P30XeCfZ87IxfKxISIP0dLgY8hUJyCuI2u5U7TEDrDggPKr6XTcIbX2kFKOsYSeovsAgjC+1UKFH4Ba0jTbRmqzPK49fk/jU8XqRP2Gl9UZDIVbc0dMEXNOeJ0e0wejDtSyX8flBk9sIKYwqeB9ns4cFqSyTI5tKnNin12BNTFRK/bDp8dN7nloyQvhDGlW88UlnJmOFhR6R0naP89VM04VCLaYCr6jyv/ZwV88uPvL2kjhx14qSFfgqJI5ORhFgYkuc+nhyQaD8+y2t3ZMs0HAfoujmq98lp2ECLWyI0ATUcXjUyNYadLj4valS/m0jl7U2fwzcmVMQqOC3ddu6mHbt871hIkG2X4v6kEcVAtKmkg="); + + public final static SkinData ALEX = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjY3Mzc4OTE4MTgsInByb2ZpbGVJZCI6IjZhYjQzMTc4ODlmZDQ5MDU5N2Y2MGY2N2Q5ZDc2ZmQ5IiwicHJvZmlsZU5hbWUiOiJNSEZfQWxleCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7Im1ldGFkYXRhIjp7Im1vZGVsIjoic2xpbSJ9LCJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzYzYjA5ODk2NzM0MGRhYWM1MjkyOTNjMjRlMDQ5MTA1MDliMjA4ZTdiOTQ1NjNjM2VmMzFkZWM3YjM3NTAifX19", "BCyo2Ycx5cxjS9eR8ejakJ0inXSaiOO/2Wb3GoOSBFeKmnLpigR2kbvnIv0j+R5wtGLAbcAmxCZzvI9VpkHC0Al7zyAzY+WypfXi5MAju+dpVdCmp8p3m3oznYscPaI1ADR8ecQBMLFeG8RWuWha5whUyyRNQU8pBPbKMcsIMOn2voCQkH3cjtrZRgDGebxF32CE7I10GEhiFv8UyBVhZ11t6Jbbsj345j0ZHoydTlGADFFpnx+bAQ6BQlkMgNOWAJoI7/3p6IjFQUVYQV70o3VvP9G+B0VwHSQPxhCYxgF/1PcmKsET/HN6cPR34qKJ5HiSt2oS5q/EqLPc9cK/pFAVb+/rq/Z/TSVL94SE/OcImT7NHvVOqurLPLNyj7SMbQvL3bZS3wNkeU7TIkQkGiza2jmeTfPOkBXwMUBl95b+BX3aM36EtyZ4jL1eTOJdqG4x5JG9uGVvcGHw5289ykXUW3L3+A/9J2uYT3mzH9dJ1YLGA3dmTmMqjWrJRxdA5OU46fREsMWMaELbpiHOkhAgqMW1Bofs4hdvkBZE3JIbjIivncvXVU0MGgnd//U4P5iteUMY8Dpc+uKJ3N8KMojCbhWiig0ElLMuNFbNG9PVsUNwwT/wYLJZ3PJ0VBcNERgAWnJ16DM4oA8SfAKosmSQBCW11+1Sxfkj55QoxH0="); + public final static SkinData STEVE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjY3MzgxOTAzNDYsInByb2ZpbGVJZCI6ImJiYjg3ZGJlNjkwZjQyMDViZGM1NzJmZmI4ZWJjMjlkIiwicHJvZmlsZU5hbWUiOiJkaXJld29sZjIwIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS82NmZlNTE3NjY1MTdmM2QwMWNmZGI3MjQyZWI1ZjM0YWVhOTYyOGExNjZlM2U0MGZhZjRjMTMyMTY5NiJ9fX0=", "xIDCRBS39ZhhROcYkYORDcWosWqR5xvrTTScNzpt8WtBq1cAoL1mXEi/PtBrEEvajcpR/nGhRlZV/IeavtmUx49ulY3bdX827Rex3504DnmolxVqnq8/p1W8ywxV9FBcMI4Cto3c5kmIXHTTAcLsUuCmsmprzuMS+/RvfJ//vjem+lUc+eQKBe3Hc3ocapfxf1dHqSrtzurW2fRTMZcJWEOr9eicRDzOOP2nbtfZGeCcwJPnYJMxJReBWLO/LiV6Bzm/8+ynRFzmJVw7zvXY9WCz/Yt95nK1lqpFZXR7djFYTsnLpLc71rUPhPwSZSVm0Ca+wZWI2RFnm3kbKRsIB89EqsVIxgw9SMKHJwGPc/GBMOZuO2J6HxGn5xXE5JnLTn8YzpBDft+3Hnb2EJTJ2OCPHaQtzMiYDG4+OkwP7ksxcwmMxRUWuE37dwXi/d4A94IKsLqrCxj+vGFPo13wc5L0DRRx7Plk2/nrC32UhKomkjGz2XbS1aJpKgLILbaM1nYnNGKx/VBLNNJdpwhwaoWgRPEB2MEFmxV+GQ/QgOJuaI7fj5KfLqCePX5V3tfdEUb5OmnC2rH1+ptE1RNOBvPPV/D04NzpvvT9QtCq3I6f1fqbcdWVaYkrRcyD/EjQv0Vod46GJPT4jEQ8f2K10dpDtaB/cWGpT16XCRNT0F8="); + + public final static SkinData MOOSHROOM = new SkinData("eyJ0aW1lc3RhbXAiOjE0NDk4NzI0OTU0MTcsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIxOWJlYTU0Y2FkN2Q1OGFiNWRhNDA2YjBhOTJhYjNhODI0MjI1MjY2Nzc3ZTUzNGI3ZGI2YzM3MmRkZmY3ZiJ9fX0=", "UoSif81+UyvkcaanU8KAMYBpw9mefAmWehE2liDUFvk+y0X/9NovsxTYVpIDCltTSpLW3sNgamvbj4Ybs+s6DbudPiEkvh0ER7Bv2v29UJw7RzIdr6/1g548X12zcnh5iPGz/P75uNRnSfTFQx0ed8P/GNkPIjWpDuJFxEj6KcPzrCAGMx+BVw1VwryBIYf9cCDHky8z0bxR89rjiIvPTBFI6MRhqI3vgpEBTySHDS+Ki0Hwl5oa3PwS6+jgYx/4RSfFsb+BawcvDk2Xpkt5UimvqZ5BceYLIfCt4KbShYipgLXLfYUZrntjPemd3SxthjxUuA07i44UxRdiC8uqy1twLT/HUS28gpk68lA/id9tKFwu1CUzshgcmvQPt3ghtNViNziR/2t7D/+5D31Vzmhf6n7Pnpdirt/5frMi2BKMMs7pLa0EF8CrrDU7QCwPav+EZVGFvVZbxSkCDq+n3IQ3PUWSCzy6KPxpdOlUjD0pAfLoiNj0P8u4+puQtID76r/St8ExchYl2dodUImu1ZETWeFUClF3ZGat62evx8uRQEI2W4dsVwj40VUfjaAuvyDzuouaKTrCzJXLQZZjR1B8URvuK61fGX0nhW607mEi6DE+nxP2ZoBrROEX4e37Ap6+TQn9Q8tKDPdcxtwSOpPO4Qkncjn/mGtP9lZU/DQ="); + public final static SkinData COMPANION_CUBE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMDk5NjI0NjEsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2MyMTVkYmRhNTY1ZjVjYjhlYjEyZjU1NWY1ZTNkYTBlYTVmNTUxOTg5MWNjNWM1ZDY3NmZkODJjNjIifX19", "vaAQbhnhnTOs64ToFWLg7o4JmqkIl07HWJ6l7xibfISaOcU4BvYBxsfGvmoxlVdsUeCunAJ8/05qVLl5zZYd8Dt+To6JSY0RlqV8piRaaj3FztYWV2ZvG3YZxPxiD3HRJTAQnDobSuxHyPa1e3khjAFp9xJo4q1oqQ28oI2WDuoT+IHqxwkKVbGzO7UD5lzz5chjQC46E8SxddNKp9aqwbbccrkHYT4gteoonOXu4MFxZniJN12LqUCb6+G15rU8MijlBkWx0xE5NMUloeTGuJZItbHun9fysLk/+HE5xJOKYtpZNMuWX+DB/O5ds9dXrOoSAg+Vn0QU4CZbwcxzLii5ILOfEEBtePuEAgzROri+iCKp59CqlEMBrCsd3Um0MCdbuOfvkXGBHBz+bqX7VJY1ujlSdMefmbJtHAkDANnsaaVb+eli9Dk6139041sptsLytD+EfJzaitX6crBwKZ2WDx2P6LHo8B+iSOzOJxjf/08zlXqFw1vsk62IN6lisuZ89QyZw23RvOx3obLAGYs1GxAlMl9qQdpXcmuE1+lPR3g8gZ0BfnTeYwflC2wbR1tuwGG98lyUGCvGLyqNKAQTN87XV4IFQWR81mi1c5CcasoWhKf9D9nAik9aK7A915fEE5IvpeuUdZseDxDVVN5dBIs5q2PIHFAS0rDsDBc="); - public final static SkinData THE_GRINCH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTYxNDMwMDQsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzg4ZWRlOTI3ZDQzOWVmMzliMzFhYzFkYzJhODM5NGZlNzlhY2U4NDMyNzBjYmUxMjg2ZGM3NTE3ZjMxYTk2In19fQ==","ELo594vTzPq9ZmPYOtVr4kim/k19gzmoxEIK1ehS87gwgag5HcgM+P1FMnHIyrmSvTVaMh0NxwXmNS+JETFL7OrmgRYNpkxkkO4VBA0pfSn3dA9ujnXpDnDiWEPxKdMgQspIOOI0Z3esNt3pj8qIj6dWPtGwtso48tjHl2o/kazfa82yvGORlFhGkeEJKQMno/Buc12C0foQw39XI8GjvlSkFN2eH4Fp16RLu8/hf7SqJQC3L1KacvzMW1d8BWEIgACCJDni29+YqxflSqSyYrV4Z+D66S0jYvUUL/vM4/q/p/YWX/vs/FtMtHQTj4PCpAmMNTgfkahuhb6rCvKHukbjA+WhUdwyxSqXU5YnpXCu1M2dzZgiXjIi+fnyn4CmXKindWCQtSwu+mCA2ILv/6vEHoYJgdlz+DXyRkFx+DH4Sl74HBCOXTOq5AGjq5h3LYfsre+UjCCUv8VgxbVprOyj35So7K0m+6faCFVSt35T3RgicDQfdiWUrW7kmHQVvJpvaq9Vu+63F/0X93cwqwaR0buMirxRx7qkFrRunSI4T+9fsN02t1fAieeu80lBSv83wr7BFneSsLsdVAND9xttTb6fClg7anr8/XVEVIkylB4B+ZcWQbH61XP1nn7oFP2VBg1h6XuuLp8FGSgYf/LW+54/KZci/MnanqQE6QQ="); + public final static SkinData THE_GRINCH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTYxNDMwMDQsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzg4ZWRlOTI3ZDQzOWVmMzliMzFhYzFkYzJhODM5NGZlNzlhY2U4NDMyNzBjYmUxMjg2ZGM3NTE3ZjMxYTk2In19fQ==", "ELo594vTzPq9ZmPYOtVr4kim/k19gzmoxEIK1ehS87gwgag5HcgM+P1FMnHIyrmSvTVaMh0NxwXmNS+JETFL7OrmgRYNpkxkkO4VBA0pfSn3dA9ujnXpDnDiWEPxKdMgQspIOOI0Z3esNt3pj8qIj6dWPtGwtso48tjHl2o/kazfa82yvGORlFhGkeEJKQMno/Buc12C0foQw39XI8GjvlSkFN2eH4Fp16RLu8/hf7SqJQC3L1KacvzMW1d8BWEIgACCJDni29+YqxflSqSyYrV4Z+D66S0jYvUUL/vM4/q/p/YWX/vs/FtMtHQTj4PCpAmMNTgfkahuhb6rCvKHukbjA+WhUdwyxSqXU5YnpXCu1M2dzZgiXjIi+fnyn4CmXKindWCQtSwu+mCA2ILv/6vEHoYJgdlz+DXyRkFx+DH4Sl74HBCOXTOq5AGjq5h3LYfsre+UjCCUv8VgxbVprOyj35So7K0m+6faCFVSt35T3RgicDQfdiWUrW7kmHQVvJpvaq9Vu+63F/0X93cwqwaR0buMirxRx7qkFrRunSI4T+9fsN02t1fAieeu80lBSv83wr7BFneSsLsdVAND9xttTb6fClg7anr8/XVEVIkylB4B+ZcWQbH61XP1nn7oFP2VBg1h6XuuLp8FGSgYf/LW+54/KZci/MnanqQE6QQ="); public final static SkinData LOVESTRUCK = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMTAyNDMyNjUsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzczMTY5YWQwZTUyYjM1N2NiZGYxZDU0NGVkNGNmOWJmOTI4YmI0ZWNlMDhlY2YyY2M0YmYyYTlmMjJhODI4MmQifX19", "LL4RiSKQoTZamRQ4QG6izpvhgFu5gAqW4eZxcWAihk7GkhyxifpJpBTOzKrj5hH9fCUfYkkijVWUYTEcVSVRWhocp2HXW59TbKfxOeMvHU5vTMwgpwm6PnUfwuTsRPSLC7WMnEreI3cjOxPVmXbTniOSd+o8j4oOIgwFS+VLPiYLh5Jl16i5I/9ekafl3/x41NISKWl62geqO2jPWehlk+r3soiRJsxaKw20T61GSNLu19iA96Rz2T2tUHB4opm8hbLgoiNL2g1affTjq3cZPLHH4JWF3vPhqLB5uw6xb55vFLM/PP0YiEMIi7YZOfRGeaPp7uXbXgHeew+7PG9UDVMfqbwANQY4ndECijZoei54+xX3MDXkMhQsc5S+FLnGH6e4d008v81eEOyzJUPkKbGxLCBgTUb1s4IHwomCr30twPlo1IuFBOY1qeVvZUfAfPJsREuj5q/oCAoYFgupmb3ClWECnwwaH/T4wdHjfSBHoZQdLzcgDOAl0b5EXxWmYBECqk/WA4TrYIDVGdwkqjI0RkPLUoxTj6135KO+F7P7PwhU9WBGeW8hHq918DBL0fjQVHjrzvolTqwmw6nySSePnPOxFX/iwtHWzpBa9V6kUNNN+V7OGTgRr0H/yUxB+oq1F8UBqyqT4YpqxXCSD36derF/Xt5IdpTbEbGBpm0="); - public final static SkinData PRESENT = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk3MDIxNjIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2U2YzRkZWQwNTdjMjhiMTU0NjVkYzQzNmFmODIyYTNkZTY4NzgyZTZjMzgyOGMzMmFhYWE4ZjRiOTIzOWVjIn19fQ==","rJNlxTqHHmOoWwbXdMQLcj0P9w/PIr/hWKXH0nbhm/S2CFo/zfefffZlnQmpKCgn1Y8tXvcRwLGQ4CLpm9m2ZrKprSWRhrnOtZWYabrhExQESEammS3TY81VoNt+4On0pAGBippz/bRfWLuDne2rDbhuljnqvxjROmxpky7gRCU06VMlm2WLFC5XYJkiAaOXBqzpiHMMRPNnCvtcbtpILKi/Luj302eyN8nRKjHHbbiDmttwvlshxZ8UxJHvALtM506IUHba10Q6QX2zCeDAU5/WYRKa6e19r8plROcgGbKYFSq8JW5cWuWT3/rveZM6FnU6ABn9DWsCyfQ5wr2jdBd+xaevGTAScRHA5J493GqL1bBZYKj9yhQFtxJHCAf0++raAVPCZgyPtwTth4TAQisn8gnhM5R+txnW6xK+oflLy0dwEN1YdPLN/h7yuDnyjSMDe9RZT2NKMjok2C6Kux4WBI0KFXKC5Gqwa3Htku4v3WEOWMaVoWOtchQ9BzpQ/etD0ylmzjALQLB+HtndEEm1Jd3tmob42X4hBE8hCce7C3EtGINB33dlx4CK1xBqyGTJEqi69DJRzVL99u98+7kJ1Db9+MaPOfI4B2RY3XbvnSYwecandY//A3bb19FGSdl299ZXbp4zpm8fivzeB1rUAhhmtaA3Iwu/nEQNMkU="); - public final static SkinData RUDOLPH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk1NjgxODIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2IzZjdlMjhiNTJkZjJjZjhlZWM2NDk2ZmM0NWFlMGQ2NTM0Njc5OGIxYWRjNzM3ZDcxYzBmOTRlNDIyMSJ9fX0=","uUBOTe63CL+qRvtsb2g4AjB2YzxE3N6AUqIsTv8n0jYyPsuXpuOmZPSMEdgDVONywEJ1L4XRx05sjnGu56A8vuXmGI/uHQWuMZzbOSjiFfT3DkEm8zEl5AWpH9dz/t8nZ1WYUIwy0pN5VrZqIr1DAkF6AMh/Qy+FGDw1GG9ReRr80eJ0JiRskpkCpCZIGGjrgwNKAM8JOuNZ4gCQOTRC3etrcfls3qmUMFcVlhuB4bydxSR01i2w0A4b5KpufsJjLKw4InWn2+m/druo8hl9sYuusTeItW0MQmZqCAqXCc9YBnRPQ0hDXFgnPxOh3RwGWiZvL4MnWUVmLwZWh/Fk9QmyVbd7zVao0lxS8YNsKtP8j5B+hs4l9qNohhf0A07bt4oPeTtd5fQeOU5N87fUGuUAcpC4gP9U5WpVY5FFPBvLvGbXdV5jpuAQz4lLSoo1grsP9baR2IBvdN/0awjQWoPJfGOttegubkBHwz3LNcVqvZLtX/M13IDHZa6zQZEX0wsnMX60LeWgBWfTON1l2cSgaPTerHFS2EifJ2LvTBife3s9/4XR6Zth3FLFqxI3MSlqT2hVFRPLke6rBqfqPoWOj2MCykQ70IAwb3oTHcJDJ86V2DdNaU2bZ8V4TjaP+nRobsLJOImoPYEPq23MP36X8gbXEIjmuu8S5xRlrrc="); - public final static SkinData SANTA = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk3OTM3NTgsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2MyNTM5ZGFkZDUxYmE5ZTg0YzFhOTE1OTY3NWUxZTJiYWM1NmFlNmFlNTMxNTQyZDI1YTlkM2Q1YzQ2ODZmNiJ9fX0=","gvLc0Vo6+1vl17vrFCbK1eNqa4/ix4xiwcWae7WOCvqiVIX4sdIPagOGUrKsDdEhuWCKkTWILGP1K3wYfC9v/0mXZvbu0sRln+APTOsswMkQmbKcA1zTFTMpwEI+nIMzYJSbIx5wjz28K5hDf/umtHH2GADTENdJGGUtU4CyEdeHTzcqIAEV3bcMLkfTKvwKUWqI5gZbbercqmDeGkmXVS9297a9paRX1NfEL9pFT0pjdH3tCjgvvKfAwGC6tYtvTFbfcJocqgI+PI2f5OFf62A4XjWwWFi4wxCHVYNpqs/XTbfF64K7KVE0d9gsLjJoB8DMZPxlNpMFA0R5OIW6Q7Qjyz9IKxUqEYRCQbuUKpHyNDcmVKcTJRwBpCHeqAbTbweZHd5tzrT/terWhLEMsK1+lH2KBfIRIRB9kd3epyShNjSEKoly6uRXVxU+IJtfcq0aFVZlwgG3c1Ds9jbsNJV158e1n6WCmvT00RLdvpcIekwUKODhi3zFeFkrVvV50tGYqXLRZenitLJvDzx4c0IGK4krALrUS0oybinBS7/GmW3Ktz3xbGKZSzzaDw0EKB7Y6XHdb4yqR1xS7lAWgv4cNDEIUSzUDJ7HpmDCIF2A5kPS4XVYFCclyR6qPGD5e+9apVhBMz4lfYlT1IfRAUQlucO4UpAlkXs7ho3pQXU="); + public final static SkinData PRESENT = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk3MDIxNjIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2U2YzRkZWQwNTdjMjhiMTU0NjVkYzQzNmFmODIyYTNkZTY4NzgyZTZjMzgyOGMzMmFhYWE4ZjRiOTIzOWVjIn19fQ==", "rJNlxTqHHmOoWwbXdMQLcj0P9w/PIr/hWKXH0nbhm/S2CFo/zfefffZlnQmpKCgn1Y8tXvcRwLGQ4CLpm9m2ZrKprSWRhrnOtZWYabrhExQESEammS3TY81VoNt+4On0pAGBippz/bRfWLuDne2rDbhuljnqvxjROmxpky7gRCU06VMlm2WLFC5XYJkiAaOXBqzpiHMMRPNnCvtcbtpILKi/Luj302eyN8nRKjHHbbiDmttwvlshxZ8UxJHvALtM506IUHba10Q6QX2zCeDAU5/WYRKa6e19r8plROcgGbKYFSq8JW5cWuWT3/rveZM6FnU6ABn9DWsCyfQ5wr2jdBd+xaevGTAScRHA5J493GqL1bBZYKj9yhQFtxJHCAf0++raAVPCZgyPtwTth4TAQisn8gnhM5R+txnW6xK+oflLy0dwEN1YdPLN/h7yuDnyjSMDe9RZT2NKMjok2C6Kux4WBI0KFXKC5Gqwa3Htku4v3WEOWMaVoWOtchQ9BzpQ/etD0ylmzjALQLB+HtndEEm1Jd3tmob42X4hBE8hCce7C3EtGINB33dlx4CK1xBqyGTJEqi69DJRzVL99u98+7kJ1Db9+MaPOfI4B2RY3XbvnSYwecandY//A3bb19FGSdl299ZXbp4zpm8fivzeB1rUAhhmtaA3Iwu/nEQNMkU="); + public final static SkinData RUDOLPH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk1NjgxODIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2IzZjdlMjhiNTJkZjJjZjhlZWM2NDk2ZmM0NWFlMGQ2NTM0Njc5OGIxYWRjNzM3ZDcxYzBmOTRlNDIyMSJ9fX0=", "uUBOTe63CL+qRvtsb2g4AjB2YzxE3N6AUqIsTv8n0jYyPsuXpuOmZPSMEdgDVONywEJ1L4XRx05sjnGu56A8vuXmGI/uHQWuMZzbOSjiFfT3DkEm8zEl5AWpH9dz/t8nZ1WYUIwy0pN5VrZqIr1DAkF6AMh/Qy+FGDw1GG9ReRr80eJ0JiRskpkCpCZIGGjrgwNKAM8JOuNZ4gCQOTRC3etrcfls3qmUMFcVlhuB4bydxSR01i2w0A4b5KpufsJjLKw4InWn2+m/druo8hl9sYuusTeItW0MQmZqCAqXCc9YBnRPQ0hDXFgnPxOh3RwGWiZvL4MnWUVmLwZWh/Fk9QmyVbd7zVao0lxS8YNsKtP8j5B+hs4l9qNohhf0A07bt4oPeTtd5fQeOU5N87fUGuUAcpC4gP9U5WpVY5FFPBvLvGbXdV5jpuAQz4lLSoo1grsP9baR2IBvdN/0awjQWoPJfGOttegubkBHwz3LNcVqvZLtX/M13IDHZa6zQZEX0wsnMX60LeWgBWfTON1l2cSgaPTerHFS2EifJ2LvTBife3s9/4XR6Zth3FLFqxI3MSlqT2hVFRPLke6rBqfqPoWOj2MCykQ70IAwb3oTHcJDJ86V2DdNaU2bZ8V4TjaP+nRobsLJOImoPYEPq23MP36X8gbXEIjmuu8S5xRlrrc="); + public final static SkinData SANTA = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk3OTM3NTgsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2MyNTM5ZGFkZDUxYmE5ZTg0YzFhOTE1OTY3NWUxZTJiYWM1NmFlNmFlNTMxNTQyZDI1YTlkM2Q1YzQ2ODZmNiJ9fX0=", "gvLc0Vo6+1vl17vrFCbK1eNqa4/ix4xiwcWae7WOCvqiVIX4sdIPagOGUrKsDdEhuWCKkTWILGP1K3wYfC9v/0mXZvbu0sRln+APTOsswMkQmbKcA1zTFTMpwEI+nIMzYJSbIx5wjz28K5hDf/umtHH2GADTENdJGGUtU4CyEdeHTzcqIAEV3bcMLkfTKvwKUWqI5gZbbercqmDeGkmXVS9297a9paRX1NfEL9pFT0pjdH3tCjgvvKfAwGC6tYtvTFbfcJocqgI+PI2f5OFf62A4XjWwWFi4wxCHVYNpqs/XTbfF64K7KVE0d9gsLjJoB8DMZPxlNpMFA0R5OIW6Q7Qjyz9IKxUqEYRCQbuUKpHyNDcmVKcTJRwBpCHeqAbTbweZHd5tzrT/terWhLEMsK1+lH2KBfIRIRB9kd3epyShNjSEKoly6uRXVxU+IJtfcq0aFVZlwgG3c1Ds9jbsNJV158e1n6WCmvT00RLdvpcIekwUKODhi3zFeFkrVvV50tGYqXLRZenitLJvDzx4c0IGK4krALrUS0oybinBS7/GmW3Ktz3xbGKZSzzaDw0EKB7Y6XHdb4yqR1xS7lAWgv4cNDEIUSzUDJ7HpmDCIF2A5kPS4XVYFCclyR6qPGD5e+9apVhBMz4lfYlT1IfRAUQlucO4UpAlkXs7ho3pQXU="); public final static SkinData SECRET_PACKAGE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMTAzNzE3OTIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2QyNWI5YTRjOWRhOThkZTliZmIwZDNjOWI1M2MzMjJhMjgxN2IyMTMxOTQzY2E1YWM2NTBjZThmMzEzZjdhIn19fQ==", "Wb5T0Zhp1RVt78V/i8dYrwZCNT0xZIRe3LvL0bngH498f8Jrl43KHgTi4f299zE9giVynkTogGhJ8inq/xqFCRctl7Nn9L3LVu78uQwt+fs+o+kw/Qc+lggFSjEIc+fc13AZndpec0Df46Kh/OGD7NXbtbLb6TE/0dU2RwQlvZrZ/QHYJb8OJ6aUcnHvAZim8NUtG/nlZtSClepHVSuKdNnfzoF9rFVFA/x4jTr6mZYPZ33YgQd2oTAPk+qE3iN+0InjZQNs2YLoKFmFrgzn+tGvNApC0siF0HEZGQCFIwJOtnBsasGoxujIrln/ZdOil+5ac4VWInXr8lKgY0Q3Ocy8/0cJl+E/XqB+ztG29zhB8B1zdHBfJr+MgeSIqBCPx4SCtY6r7gnMlQYG+uVx5NP3S5aJW/cEfDyXmpCykIcBPzeErnKC0SiAqXkCVNjWJpX6qRWvWMXqS69w6ht6qHvEY2GxlZUb5AP+JgFlsl3hJDms6EPvM4zNL0Ko4oWIBzwYRQXiemrP9TGgyo0aL1RcQ0JgBFO2hSo37PK0YL3tUPgteJXzm21wu0TiZLkLCWSgMUfYfvVnhTa+xzod0xvfujpN6Y1DUTdcf8WS8TRYw2JigSkWrRW0fXPBCtTtQN5jiwM5/HrTpNLzg03J6SpfZ+rr8Rhq0S/8beQOMas="); - public final static SkinData SNOWMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk4Nzk5NDIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzEzMTgxYWViODQzODk3NzM1ZDQwMmIyNDk2OTQxNmZkYjBjZTM0YTZiOTM3ODE2MjQzNzU2ZTlkYWU1OGUzIn19fQ==","NZvsNu+HQ5uvGWq6O8VNDGq9A145bmk2IkHiz916uRVPMRqqCI/zwhKWNLlFACE/feuLkhYAois29ec6sVVOtHIoNA+S5q1Mb/Vjc3TJQxzqmx2FZOhJiIttFwYuo9WomQKBqrPMSJ9tpQig4wzoqldeeTjWC3dLz7JeX+gkzinryVjG7NNN9L5hXK5/BBxRcrtwmXJfUlSANyrd8RZW7mEUgU8yxlzdqTu0w7bZLjQNd4vciwoF3NelXDorMIIqiHTkuQesG91Njtu25VCUDK3nXbqEnZw2ZtxB5fT5G2Omm/vkNSRXc0P7iqchVowdYQcMlQUsp65xpkBbFS4LwjzDkYIfLmF++hePb8z72Gz77FxhO5sRLGreSH227McyL/0CtWNKm9ZZIfQtZZjEZTj9+eiJMCloCMg3yWa1VBOiLHzz0wY6gGklccIImPyXEg7E0dIK8qYseJMhmmBNZ8pDOkbUDp3mRlrQ2iyClgQkbuR63j79IBUaCxmsa3NnrAtaJklzd9mzkHXfMBh2XT7Gl8AhJS6JK5kCvip1rBBI8yjrsjE/E+lyJFIbC4rXxyMDGZWkcdrd7U4ZFYKiLHbzdFRqX+11qs9xO2BvomGXkATCzYmOf2kQ86R6rNN0+JfE4QpKzj2WWt3C8ky2qpuXZz29p0816E3/qseYtgg="); + public final static SkinData SNOWMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk4Nzk5NDIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzEzMTgxYWViODQzODk3NzM1ZDQwMmIyNDk2OTQxNmZkYjBjZTM0YTZiOTM3ODE2MjQzNzU2ZTlkYWU1OGUzIn19fQ==", "NZvsNu+HQ5uvGWq6O8VNDGq9A145bmk2IkHiz916uRVPMRqqCI/zwhKWNLlFACE/feuLkhYAois29ec6sVVOtHIoNA+S5q1Mb/Vjc3TJQxzqmx2FZOhJiIttFwYuo9WomQKBqrPMSJ9tpQig4wzoqldeeTjWC3dLz7JeX+gkzinryVjG7NNN9L5hXK5/BBxRcrtwmXJfUlSANyrd8RZW7mEUgU8yxlzdqTu0w7bZLjQNd4vciwoF3NelXDorMIIqiHTkuQesG91Njtu25VCUDK3nXbqEnZw2ZtxB5fT5G2Omm/vkNSRXc0P7iqchVowdYQcMlQUsp65xpkBbFS4LwjzDkYIfLmF++hePb8z72Gz77FxhO5sRLGreSH227McyL/0CtWNKm9ZZIfQtZZjEZTj9+eiJMCloCMg3yWa1VBOiLHzz0wY6gGklccIImPyXEg7E0dIK8qYseJMhmmBNZ8pDOkbUDp3mRlrQ2iyClgQkbuR63j79IBUaCxmsa3NnrAtaJklzd9mzkHXfMBh2XT7Gl8AhJS6JK5kCvip1rBBI8yjrsjE/E+lyJFIbC4rXxyMDGZWkcdrd7U4ZFYKiLHbzdFRqX+11qs9xO2BvomGXkATCzYmOf2kQ86R6rNN0+JfE4QpKzj2WWt3C8ky2qpuXZz29p0816E3/qseYtgg="); public final static SkinData TEDDY_BEAR = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMDkzOTE4MjYsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzQ0OTU4ZDdjNjlhZTQ4NGM2NWYzMTM0N2NkY2M5MmM2OWY1NDA2ODA1YjUzNjUyYTc1YThlZDc5OWRmNyJ9fX0=", "sNTRV9jTjLszUmyaqyEG7N8d5RM1jbwMSXi34S2EkVmIjWsowfSMnHRQqqgZfxcyqBM5I7MljtB84IeQWu4rqhyFrM9blWvtowjijFIOgKCs97q2sswv9iauU6ohvgTpgN5B0Q16MJmMIgZU8d8TATtEaIzq2eg6Ve1AJlNnW4huGNsoNfm8WdVU1tZmsYAwtVP/ryvhyj7mHyVF27m0Sm4fZRf/lHH5gEJYB4JHSAoEhjPIQOdkgRMJRrWGOfhhiGs3kEWmsRGfIPFo2ZJfcu+TFV2rd4Q+A1LmY8kimnzdKX3InXeKbk8qzcgqGNro4XFnSiHo1d6/B+N0JeYOTITYRQ6u24rNSUh5ezbG01iikVFCfrgb7UR6utoLK15F4/fmhpex+BJpmyZoXAqk08tZws/5wsIWQ1okrGcbBKWEHhw2ekUc82US21/W53vd657UBg7FuqM4FhkAqmsYPvYLMpNYxxmDJaI8uJyU7cnGFYyBaFlqUxfJUfcFTwWo10JO3yp5FjqeCQa7rFvfpsqw3w2mBpJmlZ5HRjfS5pmhk0QiY0TRfwZfFemkuZYnNbO82qLUm+6zTm0fbC90Swt8nNr/42ajzEoUjnL6VsERIXS5/fPwjftbQAC60ujy8yo66Sp3sSAALNg5zjM+Uizkq2f9Axc+kind22hp10M="); public final static SkinData UNCLE_SAM = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjYxODA0NjY4NTcsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jYzM1YWRmZTQ3ODBjNmU2NTk4YTJlYzk2ZjdhZGQ5ZDc4NjljMjBlZjRmYjEyNjk2NmJhOGFlMDRlOWRhIn19fQ==", "NmJ+hXmvwQlYFYY7YVQWRr11yBbAfJP+jk11SQ91gUUtJJjb4v8RFbNu5UXNCKxYj3BPtldqshG1maNB0NWJRud7ZyAdHc0JMmR1vtHEge9Hhet4fLyyaZ9rZn4BvD9Guqgv9H/mZzUzrft9TIho0Qbu/U++lVsbZXC2GrJDDMyLnYr9C7f+FUnr0z4WvkNcg23SHBOYkOYT95NSdykIka3c3v+/HvSvuwOnMsfVxqLyCZLpo20vamBJ1uK1dmx2+TVGnUPlofFHRdOXOpJc+YmicJvrsQR6a9zlvnTbU4MYClMOKvjLe6aX5Af+n8Gw3oKcm0PuR8CPLyf9kjcmUF6XMiEXAWWJtCgvhCiFV5/mQQH3cQ1kqk4BDLUxMVhG5tzjKLoQQy39cFM32ee+QFjXlzy59meC8jgvPmOVU3GpJ32XWOtaXMCyeJrhz2QVKRLEr2KZgz8Pd8VrHARXVZsNYEasj8z0cHjgSJqTU9kD90CC+4YpvdyRBRqbNQig5KuGCqUHKgflsEsM7YrFRKP5As1LgqYQfqRAMmLSo47eW0onOwchC9wCqqisPlYSuDRt4Mun/KFGqYh1Sghn8/gzu49La8BpwlekjVEoPEcDaIIgnFzOvgmmgMANkoJ3PzhHoHMoXtObe3eSTi+eYp4qAQVzkTxfF3WXY2fui1M="); @@ -40,49 +77,39 @@ public class SkinData //public final static SkinData CHISS = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTk1NDI5NjgyNDEsInByb2ZpbGVJZCI6IjFkMmJmZTYxN2ViZDQ0NWRiYTdkODM1NGEwZmZkMWVhIiwicHJvZmlsZU5hbWUiOiJDaGlzcyIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTg3MmNkMzRjY2IzMTIxYjRjNmEzOGFjM2JmOGVkM2UwMzk3YmQ2YTg4NDI4YjdhZmM2ZTUyNTI4NTVhMzQzIiwibWV0YWRhdGEiOnsibW9kZWwiOiJzbGltIn19fX0=", "hNTLRA2acZYx2dM90lnJN8FMK/ceD3+AxKNdD5FrXzxGtYL4C1Jr/vbTE0UosmwFP3wScNEW/fuDOjeZRjZHMJdvgDZMlMK/5KDhOY6sj/RS9RckztsgummSyjH/hdDn7TWWfhZLMbiia/K0VReI9eq2yD6zGQpvMlz5hB/5SX5YHWXvCah3TL4UzYSlSVDlwY/Q3sVuIZUr8m/LIXJwniJKLGo6tUgtiJd9eseOsbBpVjzCUtLD8A9WBe2/eODgmLfqEvXESIoDRG8vL2nPSXWma/YolYHIl32/i+ZxVD7dRRaXQFYSiLI24EtzX1pPhMjyaTLazP9abH43J6J31w02pKM7N/xTa62020L/YfRRKGT5lygEDb1NMoSpAjszPxah+Ra2/L+yUWEI8cMES6I4mIJ00tclPjWK01xhIn3tqg+y2gqsGHwPhu/7vmF5NirNfKFw0qciKNBfbCAF7ae+mkUKjmAPuvBUBqQb7BOcpNVWsCo/XvzmiZZYsf5P4Uwz8LqUK4uH6V/5dg7lY2Xg3+IUylsrDqLGFDI8iy/NdjIQMbuRadh4IDO6DcmxBri2Ax4JNBPBTnRezge8uq37MZcft/IXQgFWKB9RtidVEACaTOkRj27k+Ojnkki+j44k0wZB47hiXFUHMCHl3a0SVdQe15ZbVsQj/HAvAS0="); //public final static SkinData DEFEK7 = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTk1NDI3ODkwNTksInByb2ZpbGVJZCI6Ijg5ZDQ2M2Y3MjNlYzQ3MGE4MjQ0NDU3ZjBjOGQ4NjFjIiwicHJvZmlsZU5hbWUiOiJkZWZlazciLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2JmYWNjOWM4ZjhlY2E1OWU0NTE4MTUxZmE4OGFiMDZjOTFmNjM3OTE2NzJmMTRlNGYzODY3YTI2OTVlN2NmYmYifSwiQ0FQRSI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIyYjljNWVhNzYzYzg2ZmM1Y2FlYTMzZDgyYjBmYTY1YTdjMjI4ZmQzMjFiYTU0NzY2ZWE5NWEzZDBiOTc5MyJ9fX0=", "jBoRvkhQXz+nap8yJJIZ+4HClMItWODumeSOYjXytP3WWKHK0UMq0xC/keXsnmvo89lMRdRbknPt2ZX5Flgyjgr4Rt0KtDvpL/hG4BUsTWryUZZMKxdd6DkZXYRtTogLUfHeDYIz+cZQ0aXGMtvX/ZYTXJfMi6FYbIHY/qEEDnWhDX5y+SPpaJaZByPsvzi+qbfcFGnJ6nqi9ccyZYnYpnI2IVBM/yO/VRXWHxfqvJ0VVvv5KsGmVbko2Jxo0SDCxUL2UTH2+eol53FxhkkC+m2geC14k1zsZQLHDF3BgAG9+kFJ4UEoYRKF2Gy1FxeDCJtjYNdrYR8fdaUKRMcpBgEs+ZGe2U9EVVS/ZcBCjB7S+1Ne2bPzPFzTQPuBoMgggo1xbxBmQ5NyhYo4gwgj/xjSLIhb+5h7ioN1URfSRcfYdVv6RRO9l/u9l09jEom8y/jGRviefpEr+/e9iAl5Dd/6nzQgosBQja3NSfqYZmyuet2eI9zu61CObDTpR6yaCbNgBe/lWofRfULdpJpgjb4UNTBom3q82FcCiOe02OekGPw4+YlilhICBhajF5JzN8FKAdqI1osDcX3KuJgikYIW3voNaOP5YN3GXgilJNdou20KFC8ICq68HglgX7/0rLrWKIEoswnINIM6HcJbQuXncVPwQhV6K34Hlt/Na60="); - + private Property _skinProperty; - + public SkinData(String value, String signature) { _skinProperty = new Property("textures", value, signature); } - - public SkinData(GameProfile profile) + + private SkinData(GameProfile profile) { _skinProperty = profile.getProperties().get("textures").iterator().next(); } - - public SkinData(Player player) - { - this(((CraftPlayer)player).getProfile()); - } - + public ItemStack getSkull() { - NBTTagCompound arrayElement = new NBTTagCompound(); - arrayElement.setString("Value", _skinProperty.getValue()); - arrayElement.setString("Signature", _skinProperty.getSignature()); - - NBTTagList textures = new NBTTagList(); - textures.add(arrayElement); - - NBTTagCompound properties = new NBTTagCompound(); - properties.set("textures", textures); - - NBTTagCompound skullOwner = new NBTTagCompound(); - skullOwner.set("Properties", properties); - skullOwner.set("Name", new NBTTagString(getUnusedSkullName())); - - NBTTagCompound tag = new NBTTagCompound(); - tag.set("SkullOwner", skullOwner); - - - net.minecraft.server.v1_8_R3.ItemStack nmsItem = new net.minecraft.server.v1_8_R3.ItemStack(Item.REGISTRY.get(new MinecraftKey("skull")), 1, 3); - nmsItem.setTag(tag); - - - return CraftItemStack.asBukkitCopy(nmsItem); + ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3); + SkullMeta meta = (SkullMeta) item.getItemMeta(); + + GameProfile data = new GameProfile(UUID.randomUUID(), getUnusedSkullName()); + data.getProperties().put("textures", getProperty()); + + try + { + PROFILE_FIELD.set(meta, data); + } + catch (ReflectiveOperationException t) + { + t.printStackTrace(); + } + + item.setItemMeta(meta); + + return item; } public ItemStack getSkull(String name, List lore) @@ -94,16 +121,51 @@ public class SkinData stack.setItemMeta(meta); return stack; } - + public Property getProperty() { return new Property(_skinProperty.getName(), _skinProperty.getValue(), _skinProperty.getSignature()); } - + public static String getUnusedSkullName() { _nameCount++; return "_" + _nameCount; } + + /* + * Creates a {@link SkinData} from a given {@link GameProfile}. + * Will return null if the GameProfile does not have any texture data + * + * @param input The GameProfile to get textures from + * @param requireSecure Whether the SkinData should be signed + * @param useDefaultSkins Whether to subsitute an Alex or Steve skin if no textures are present + * + * @return The SkinData, or null if no textures are present + */ + public static SkinData constructFromGameProfile(GameProfile input, boolean requireSecure, boolean useDefaultSkins) + { + final Map map = Maps.newHashMap(); + + try + { + map.putAll(MinecraftServer.getServer().aD().getTextures(input, requireSecure)); + } + catch (InsecureTextureException ignored) + { + } + + if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) + { + return new SkinData(input); + } + + if (useDefaultSkins) + { + return UtilPlayer.isSlimSkin(input.getId()) ? SkinData.ALEX : SkinData.STEVE; + } + + return null; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index 1945a0e1b..adcc05264 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -1,25 +1,23 @@ package mineplex.core.common.util; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedList; -import java.util.List; -import java.util.Random; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Stream; - +import net.minecraft.server.v1_8_R3.AxisAlignedBB; import org.bukkit.Location; import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.TrigMath; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.util.EulerAngle; import org.bukkit.util.Vector; -import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Random; +import java.util.Set; +import java.util.TreeSet; public class UtilAlg { @@ -56,6 +54,17 @@ public class UtilAlg { return to.clone().subtract(from).normalize(); } + + public static double[] getTrajectory(double srcx, double srcy, double srcz, double dstx, double dsty, double dstz) + { + double dx = dstx - srcx; + double dy = dsty - srcy; + double dz = dstz - srcz; + + double len = Math.sqrt(dx * dx + dy * dy + dz * dz); + + return new double[] { dx / len, dy / len, dz / len}; + } public static Vector getTrajectory2d(Entity from, Entity to) { @@ -98,28 +107,42 @@ public class UtilAlg public static float GetPitch(Vector vec) { - double x = vec.getX(); - double y = vec.getY(); - double z = vec.getZ(); + return GetPitch(vec.getX(), vec.getY(), vec.getZ()); + } + + public static float GetPitch(double[] vec) + { + return GetPitch(vec[0], vec[1], vec[2]); + } + + public static float GetPitch(double x, double y, double z) + { double xz = Math.sqrt((x*x) + (z*z)); - double pitch = Math.toDegrees(Math.atan(xz/y)); + double pitch = Math.toDegrees(TrigMath.atan(xz/y)); if (y <= 0) pitch += 90; else pitch -= 90; - - //Fix for two vectors at same Y giving 180 + + //Fix for two vectors at same Y giving 180 if (pitch == 180) pitch = 0; - + return (float) pitch; } public static float GetYaw(Vector vec) { - double x = vec.getX(); - double z = vec.getZ(); - - double yaw = Math.toDegrees(Math.atan((-x)/z)); + return GetYaw(vec.getX(), vec.getY(), vec.getZ()); + } + + public static float GetYaw(double[] vec) + { + return GetYaw(vec[0], vec[1], vec[2]); + } + + public static float GetYaw(double x, double y, double z) + { + double yaw = Math.toDegrees(TrigMath.atan((-x)/z)); if (z < 0) yaw += 180; return (float) yaw; diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 786f816a2..0e78782db 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -12,6 +12,7 @@ import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.TrigMath; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; @@ -295,7 +296,7 @@ public class UtilEnt Vector dir = entity.getEyeLocation().toVector().subtract(location.toVector()).normalize(); Location loc = entity.getEyeLocation().clone(); - loc.setYaw(180 - (float) Math.toDegrees(Math.atan2(dir.getX(), dir.getZ()))); + loc.setYaw(180 - (float) Math.toDegrees(TrigMath.atan2(dir.getX(), dir.getZ()))); loc.setPitch(90 - (float) Math.toDegrees(Math.acos(dir.getY()))); Rotate(entity, loc.getYaw(), loc.getPitch()); @@ -700,6 +701,13 @@ public class UtilEnt return CreatureLook(ent, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec)); } + public static boolean CreatureLook(Entity ent, double srcx, double srcy, double srcz, double dstx, double dsty, double dstz) + { + double[] vec = UtilAlg.getTrajectory(srcx, srcy, srcz, dstx, dsty, dstz); + + return CreatureLook(ent, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec)); + } + public static boolean CreatureLook(Entity ent, Vector target) { return CreatureLook(ent, UtilAlg.GetPitch(target), UtilAlg.GetYaw(target)); @@ -737,16 +745,19 @@ public class UtilEnt EntityTrackerEntry entry = (EntityTrackerEntry) ((WorldServer) ec.getWorld()).tracker.trackedEntities.get(ec.getId()); - byte ya = (byte) (yaw * 256.0F / 360.0F); - byte pi = (byte) (pitch * 256.0F / 360.0F); + if (entry != null) + { + byte ya = (byte) (yaw * 256.0F / 360.0F); + byte pi = (byte) (pitch * 256.0F / 360.0F); - entry.yRot = ya; - entry.xRot = pi; - entry.i = ya; + entry.yRot = ya; + entry.xRot = pi; + entry.i = ya; - // Looks like both packets need to be sent. EntityLook packet for body yaw and head pitch. Head rotation for head yaw. - entry.broadcast(new PacketPlayOutEntity.PacketPlayOutEntityLook(ent.getEntityId(), ya, pi, ec.onGround)); - entry.broadcast(new PacketPlayOutEntityHeadRotation(ec, ya)); + // Looks like both packets need to be sent. EntityLook packet for body yaw and head pitch. Head rotation for head yaw. + entry.broadcast(new PacketPlayOutEntity.PacketPlayOutEntityLook(ent.getEntityId(), ya, pi, ec.onGround)); + entry.broadcast(new PacketPlayOutEntityHeadRotation(ec, ya)); + } return true; } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 9f5f14739..366c6fc35 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -938,9 +938,18 @@ public class UtilPlayer return true; } + public static void removeAllowedCommands(Player player) { if (ALLOWED_COMMANDS.containsKey(player.getUniqueId())) ALLOWED_COMMANDS.remove(player.getUniqueId()); } + + /* + * Returns whether the UUID belongs to a slim skin + */ + public static boolean isSlimSkin(UUID playerUUID) + { + return (playerUUID.hashCode() & 1) == 1; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java index 886d8e26d..b0ccc63ef 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java @@ -111,7 +111,7 @@ public class UtilServer HandlerList.unregisterAll(listener); } - public static Plugin getPlugin() + public static JavaPlugin getPlugin() { return JavaPlugin.getProvidingPlugin(UtilServer.class); } @@ -193,6 +193,11 @@ public class UtilServer return _serverName; } + public static String getServerNameFromConfig() + { + return getPlugin().getConfig().getString("serverstatus.name"); + } + public static Collection GetPlayers() { return Lists.newArrayList(getPlayers()); diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTasks.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTasks.java new file mode 100644 index 000000000..6e71d4002 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTasks.java @@ -0,0 +1,40 @@ +package mineplex.core.common.util; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitScheduler; + +import java.util.function.Consumer; + +public class UtilTasks +{ + private static final JavaPlugin LOADING_PLUGIN = JavaPlugin.getProvidingPlugin(UtilTasks.class); + + private static final BukkitScheduler SCHEDULER = Bukkit.getScheduler(); + + public static Runnable onMainThread(Runnable original) + { + return () -> + { + if (Bukkit.isPrimaryThread()) + { + original.run(); + } + else + { + SCHEDULER.runTask(LOADING_PLUGIN, original); + } + }; + } + + public static Consumer onMainThread(Consumer original) + { + return t -> + { + onMainThread(() -> + { + original.accept(t); + }); + }; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java index 99979144b..86c6083f2 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java @@ -24,7 +24,12 @@ public class UtilWorld { return UtilServer.getServer().getWorld(world); } - + + public static boolean areChunksEqual(Location first, Location second) + { + return first.getBlockX() >> 4 == second.getBlockX() >> 4 && first.getBlockZ() >> 4 == second.getBlockZ() >> 4; + } + public static String chunkToStr(Chunk chunk) { if (chunk == null) diff --git a/Plugins/Mineplex.Core/pom.xml b/Plugins/Mineplex.Core/pom.xml index 2a88ca1ca..6ab588198 100644 --- a/Plugins/Mineplex.Core/pom.xml +++ b/Plugins/Mineplex.Core/pom.xml @@ -44,6 +44,11 @@ org.apache.httpcomponents httpclient + + com.mineplex + anticheat + 1.0 + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index 7a32a4aa3..fbbe9c561 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -1,9 +1,12 @@ package mineplex.core; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.UUID; import mineplex.core.common.DummyEntity; @@ -53,15 +56,15 @@ import fr.neatmonster.nocheatplus.hooks.NCPHookManager; public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { - private NautHashMap> _entityMap = new NautHashMap>(); - private NautHashMap> _entityNameMap = new NautHashMap>(); - private NautHashMap> _entityRiding = new NautHashMap>(); + private Map> _entityMap = new HashMap<>(); + private Map> _entityNameMap = new HashMap<>(); + private Map> _entityRiding = new HashMap<>(); - private HashSet _loggedIn = new HashSet(); - private HashSet _ignoreIds = new HashSet(); + private Set _loggedIn = new HashSet<>(); + private Set _ignoreIds = new HashSet<>(); - private NautHashMap _exemptTimeMap = new NautHashMap(); - private NautHashMap> _doubleStrike = new NautHashMap>(); + private Map _exemptTimeMap = new HashMap<>(); + private Map> _doubleStrike = new HashMap<>(); public CustomTagFix(JavaPlugin plugin, PacketHandler packetHandler) { @@ -79,10 +82,10 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook @EventHandler public void playerQuit(PlayerQuitEvent event) { - _entityMap.remove(event.getPlayer().getName()); - _entityNameMap.remove(event.getPlayer().getName()); - _entityRiding.remove(event.getPlayer().getName()); - _loggedIn.remove(event.getPlayer().getName()); + _entityMap.remove(event.getPlayer().getUniqueId()); + _entityNameMap.remove(event.getPlayer().getUniqueId()); + _entityRiding.remove(event.getPlayer().getUniqueId()); + _loggedIn.remove(event.getPlayer().getUniqueId()); } @EventHandler(priority = EventPriority.LOW) @@ -122,7 +125,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook public void ncpExemptVelocity(final PlayerVelocityEvent event) { long ignoreTime = System.currentTimeMillis() + (long) (event.getVelocity().length() * 1500); - + if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId())) { _exemptTimeMap.put(event.getPlayer().getUniqueId(), @@ -139,7 +142,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook if (event.getType() != UpdateType.TICK) return; - for (Iterator> iterator = _exemptTimeMap.entrySet().iterator(); iterator.hasNext();) + for (Iterator> iterator = _exemptTimeMap.entrySet().iterator(); iterator.hasNext(); ) { final Entry entry = iterator.next(); @@ -150,12 +153,12 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook } for (Iterator>> iterator = _doubleStrike.entrySet().iterator(); iterator - .hasNext();) + .hasNext(); ) { Entry> entry = iterator.next(); for (Iterator> innerIterator = entry.getValue().entrySet().iterator(); innerIterator - .hasNext();) + .hasNext(); ) { final Entry entry2 = innerIterator.next(); @@ -176,11 +179,11 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook if (event.getType() != UpdateType.SEC) return; - for (Iterator iterator = _loggedIn.iterator(); iterator.hasNext();) + for (Iterator iterator = _loggedIn.iterator(); iterator.hasNext(); ) { - String player = iterator.next(); + UUID player = iterator.next(); - if (Bukkit.getPlayerExact(player) == null) + if (Bukkit.getPlayer(player) == null) { iterator.remove(); _entityMap.remove(player); @@ -195,7 +198,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook } } - @SuppressWarnings("unchecked") + public void handle(PacketInfo packetInfo) { if (packetInfo.isCancelled()) @@ -205,311 +208,84 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook Player owner = packetInfo.getPlayer(); PacketVerifier verifier = packetInfo.getVerifier(); - if (owner.isOnline()) + if (!owner.isOnline()) + // wat + return; + + if (!_entityMap.containsKey(owner.getUniqueId())) { - if (owner.isOnline() && !_entityMap.containsKey(owner.getName())) + _entityMap.put(owner.getUniqueId(), new HashMap<>()); + _entityNameMap.put(owner.getUniqueId(), new HashMap<>()); + _loggedIn.add(owner.getUniqueId()); + } + + if (packet instanceof PacketPlayOutSpawnEntityLiving) + { + PacketPlayOutSpawnEntityLiving spawnPacket = (PacketPlayOutSpawnEntityLiving) packet; + + // Ignore Armor stand packets + if (spawnPacket.b == EntityType.ARMOR_STAND.getTypeId() || spawnPacket.l == null || spawnPacket.l.c() == null) { - _entityMap.put(owner.getName(), new NautHashMap()); - _entityNameMap.put(owner.getName(), new NautHashMap()); - _loggedIn.add(owner.getName()); - } - - if (packet instanceof PacketPlayOutSpawnEntityLiving) - { - PacketPlayOutSpawnEntityLiving spawnPacket = (PacketPlayOutSpawnEntityLiving) packet; - - // Ignore Armor stand packets - if (spawnPacket.b == EntityType.ARMOR_STAND.getTypeId() || spawnPacket.l == null || spawnPacket.l.c() == null) - { - if (spawnPacket.b == EntityType.ARMOR_STAND.getTypeId()) - { - _ignoreIds.add(spawnPacket.a); - } - - return; - } - - for (WatchableObject watchable : (List) spawnPacket.l.c()) - { - if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1) - { - if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a)) - { - Integer[] ids = _entityMap.get(owner.getName()).get(spawnPacket.a); - int[] newIds = new int[ids.length]; - - for (int a = 0; a < ids.length; a++) - { - newIds[a] = ids[a]; - } - - UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); - - _entityNameMap.get(owner.getName()).remove(spawnPacket.a); - _entityMap.get(owner.getName()).remove(spawnPacket.a); - } - - final String entityName = spawnPacket.l.getString(2); - - if (entityName.isEmpty()) - { - return; - } - - Integer[] ids = new Integer[] - { - UtilEnt.getNewEntityId(), - UtilEnt.getNewEntityId() - }; - - _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); - _entityMap.get(owner.getName()).put(spawnPacket.a, ids); - - sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids); - break; - } - } - } - else if (packet instanceof PacketPlayOutNamedEntitySpawn) - { - PacketPlayOutNamedEntitySpawn spawnPacket = (PacketPlayOutNamedEntitySpawn) packet; - - for (WatchableObject watchable : (List) spawnPacket.i.c()) - { - if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1) - { - if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a)) - { - Integer[] ids = _entityMap.get(owner.getName()).get(spawnPacket.a); - - int[] newIds = new int[ids.length]; - - for (int a = 0; a < ids.length; a++) - { - newIds[a] = ids[a]; - } - - UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); - - _entityNameMap.get(owner.getName()).remove(spawnPacket.a); - _entityMap.get(owner.getName()).remove(spawnPacket.a); - } - - final String entityName = spawnPacket.i.getString(2); - - if (entityName.isEmpty()) - { - return; - } - - Integer[] ids = new Integer[] - { - UtilEnt.getNewEntityId(), - UtilEnt.getNewEntityId() - }; - - _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); - _entityMap.get(owner.getName()).put(spawnPacket.a, ids); - - sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids); - break; - } - } - } - else if (packet instanceof PacketPlayOutEntityMetadata) - { - PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata) packet; - - if (metaPacket.a != 777777 && !_ignoreIds.contains(metaPacket.a) && metaPacket.a != owner.getEntityId()) - { - boolean isDisplaying = _entityMap.get(owner.getName()).containsKey(metaPacket.a); - String currentName = _entityNameMap.get(owner.getName()).get(metaPacket.a); - - if (currentName == null) - { - currentName = ""; - } - - String newName = currentName; - boolean displayName = isDisplaying; - - for (WatchableObject watchable : (List) metaPacket.b) - { - if (watchable.a() == 3 && watchable.b() instanceof Byte) - { - displayName = ((Byte) watchable.b()) == 1; - } - - if (watchable.a() == 2 && watchable.b() instanceof String) - { - newName = (String) watchable.b(); - } - } - - // If the name has changed and the name should be showing, or the name display status has changed. - if ((!newName.equals(currentName) && displayName) || displayName != isDisplaying) - { - // If name is still being displayed - if (displayName) - { - Integer[] newId; - - if (isDisplaying) // Sending metadata - { - newId = _entityMap.get(owner.getName()).get(metaPacket.a); - } - else - // Spawning new entity - { - newId = new Integer[] - { - UtilEnt.getNewEntityId(), - UtilEnt.getNewEntityId() - }; - - _entityMap.get(owner.getName()).put(metaPacket.a, newId); - } - - _entityNameMap.get(owner.getName()).put(metaPacket.a, newName); - sendProtocolPackets(owner, metaPacket.a, newName, verifier, !isDisplaying, newId); - } - else - { // Lets delete it - Integer[] ids = _entityMap.get(owner.getName()).get(metaPacket.a); - int[] newIds = new int[ids.length]; - - for (int a = 0; a < ids.length; a++) - { - newIds[a] = ids[a]; - } - - verifier.bypassProcess(new PacketPlayOutEntityDestroy(newIds)); - - _entityMap.get(owner.getName()).remove(metaPacket.a); - _entityNameMap.get(owner.getName()).remove(metaPacket.a); - } - } - } - } - else if (packet instanceof PacketPlayOutEntityDestroy) - { - try - { - for (int id : ((PacketPlayOutEntityDestroy) packet).a) - { - if (_entityMap.get(owner.getName()).containsKey(id)) - { - Integer[] ids = _entityMap.get(owner.getName()).get(id); - int[] newIds = new int[ids.length]; - - for (int a = 0; a < ids.length; a++) - { - newIds[a] = ids[a]; - } - - UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); - _entityMap.get(owner.getName()).remove(id); - _entityNameMap.get(owner.getName()).remove(id); - } - } - } - catch (Exception exception) - { - exception.printStackTrace(); - } - } - else if (packet instanceof PacketPlayOutSpawnEntity) - { - PacketPlayOutSpawnEntity spawnPacket = (PacketPlayOutSpawnEntity) packet; - if (spawnPacket.j == 78) // Armor Stand Object ID + if (spawnPacket.b == EntityType.ARMOR_STAND.getTypeId()) { _ignoreIds.add(spawnPacket.a); } + + return; } - else if (packet instanceof PacketPlayInUseEntity) + + for (WatchableObject watchable : (List) spawnPacket.l.c()) { - PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet; - - loop: - - for (Entry entry : _entityMap.get(owner.getName()).entrySet()) + if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1) { - for (int id : entry.getValue()) + if (_entityMap.get(owner.getUniqueId()).containsKey(spawnPacket.a)) { - if (id == usePacket.a) + Integer[] ids = _entityMap.get(owner.getUniqueId()).get(spawnPacket.a); + int[] newIds = new int[ids.length]; + + for (int a = 0; a < ids.length; a++) { - PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity(); - newPacket.a = entry.getKey(); - newPacket.action = usePacket.action; - newPacket.c = usePacket.c; - - { - ((CraftPlayer) owner).getHandle().playerConnection.a(newPacket); - } - - break loop; + newIds[a] = ids[a]; } + + UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); + + _entityNameMap.get(owner.getUniqueId()).remove(spawnPacket.a); + _entityMap.get(owner.getUniqueId()).remove(spawnPacket.a); } + + final String entityName = spawnPacket.l.getString(2); + + if (entityName.isEmpty()) + { + return; + } + + Integer[] ids = new Integer[] + { + UtilEnt.getNewEntityId(), + UtilEnt.getNewEntityId() + }; + + _entityNameMap.get(owner.getUniqueId()).put(spawnPacket.a, entityName); + _entityMap.get(owner.getUniqueId()).put(spawnPacket.a, ids); + + sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids); + break; } } - else if (packet instanceof PacketPlayOutAttachEntity || packet instanceof PacketPlayOutNewAttachEntity) + } + else if (packet instanceof PacketPlayOutNamedEntitySpawn) + { + PacketPlayOutNamedEntitySpawn spawnPacket = (PacketPlayOutNamedEntitySpawn) packet; + + for (WatchableObject watchable : (List) spawnPacket.i.c()) { - int vech = -1; - int rider = -1; - - if (packet instanceof PacketPlayOutAttachEntity) + if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1) { - PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet; - vech = attachPacket.b; - rider = attachPacket.c; - } - else if (packet instanceof PacketPlayOutNewAttachEntity) - { - PacketPlayOutNewAttachEntity attachPacket = (PacketPlayOutNewAttachEntity) packet; - vech = attachPacket.a; - - if (attachPacket.b.length > 0) - rider = attachPacket.b[0]; - } - - // c = rider, b = ridden - // When detaching, c is sent, b is -1 - - // If this attach packet is for a player that has the fix - // If the attach packet isn't ordained by me - if (!_entityMap.containsKey(owner.getName())) - { - return; - } - - if (!_entityRiding.containsKey(owner.getName())) - { - _entityRiding.put(owner.getName(), new NautHashMap()); - } - - int vehicleId = -1; - - if (_entityRiding.get(owner.getName()).containsKey(vech)) - { - vehicleId = _entityRiding.get(owner.getName()).get(vech); - } - - if (rider == -1 && _entityMap.get(owner.getName()).containsKey(vehicleId)) - { - Integer[] ids = _entityMap.get(owner.getName()).get(vehicleId); - - _entityRiding.get(owner.getName()).remove(vech); - - sendProtocolPackets(owner, vehicleId, _entityNameMap.get(owner.getName()).get(vehicleId), verifier, true, - ids); - } - else - { - Integer[] ids = _entityMap.get(owner.getName()).get(rider); - - if (ids != null && ids[1] != vech) + if (_entityMap.get(owner.getUniqueId()).containsKey(spawnPacket.a)) { - _entityRiding.get(owner.getName()).put(vech, rider); + Integer[] ids = _entityMap.get(owner.getUniqueId()).get(spawnPacket.a); int[] newIds = new int[ids.length]; @@ -519,14 +295,242 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook } UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); + + _entityNameMap.get(owner.getUniqueId()).remove(spawnPacket.a); + _entityMap.get(owner.getUniqueId()).remove(spawnPacket.a); } + + final String entityName = spawnPacket.i.getString(2); + + if (entityName.isEmpty()) + { + return; + } + + Integer[] ids = new Integer[] + { + UtilEnt.getNewEntityId(), + UtilEnt.getNewEntityId() + }; + + _entityNameMap.get(owner.getUniqueId()).put(spawnPacket.a, entityName); + _entityMap.get(owner.getUniqueId()).put(spawnPacket.a, ids); + + sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids); + break; + } + } + } + else if (packet instanceof PacketPlayOutEntityMetadata) + { + PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata) packet; + + if (metaPacket.a != 777777 && !_ignoreIds.contains(metaPacket.a) && metaPacket.a != owner.getEntityId()) + { + boolean isDisplaying = _entityMap.get(owner.getUniqueId()).containsKey(metaPacket.a); + String currentName = _entityNameMap.get(owner.getUniqueId()).get(metaPacket.a); + + if (currentName == null) + { + currentName = ""; + } + + String newName = currentName; + boolean displayName = isDisplaying; + + for (WatchableObject watchable : (List) metaPacket.b) + { + if (watchable.a() == 3 && watchable.b() instanceof Byte) + { + displayName = ((Byte) watchable.b()) == 1; + } + + if (watchable.a() == 2 && watchable.b() instanceof String) + { + newName = (String) watchable.b(); + } + } + + // If the name has changed and the name should be showing, or the name display status has changed. + if ((!newName.equals(currentName) && displayName) || displayName != isDisplaying) + { + // If name is still being displayed + if (displayName) + { + Integer[] newId; + + if (isDisplaying) // Sending metadata + { + newId = _entityMap.get(owner.getUniqueId()).get(metaPacket.a); + } + else + // Spawning new entity + { + newId = new Integer[] + { + UtilEnt.getNewEntityId(), + UtilEnt.getNewEntityId() + }; + + _entityMap.get(owner.getUniqueId()).put(metaPacket.a, newId); + } + + _entityNameMap.get(owner.getUniqueId()).put(metaPacket.a, newName); + sendProtocolPackets(owner, metaPacket.a, newName, verifier, !isDisplaying, newId); + } + else + { // Lets delete it + Integer[] ids = _entityMap.get(owner.getUniqueId()).get(metaPacket.a); + int[] newIds = new int[ids.length]; + + for (int a = 0; a < ids.length; a++) + { + newIds[a] = ids[a]; + } + + verifier.bypassProcess(new PacketPlayOutEntityDestroy(newIds)); + + _entityMap.get(owner.getUniqueId()).remove(metaPacket.a); + _entityNameMap.get(owner.getUniqueId()).remove(metaPacket.a); + } + } + } + } + else if (packet instanceof PacketPlayOutEntityDestroy) + { + try + { + for (int id : ((PacketPlayOutEntityDestroy) packet).a) + { + if (_entityMap.get(owner.getUniqueId()).containsKey(id)) + { + Integer[] ids = _entityMap.get(owner.getUniqueId()).get(id); + int[] newIds = new int[ids.length]; + + for (int a = 0; a < ids.length; a++) + { + newIds[a] = ids[a]; + } + + UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); + _entityMap.get(owner.getUniqueId()).remove(id); + _entityNameMap.get(owner.getUniqueId()).remove(id); + } + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + else if (packet instanceof PacketPlayOutSpawnEntity) + { + PacketPlayOutSpawnEntity spawnPacket = (PacketPlayOutSpawnEntity) packet; + if (spawnPacket.j == 78) // Armor Stand Object ID + { + _ignoreIds.add(spawnPacket.a); + } + } + else if (packet instanceof PacketPlayInUseEntity) + { + PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet; + + loop: + + for (Entry entry : _entityMap.get(owner.getUniqueId()).entrySet()) + { + for (int id : entry.getValue()) + { + if (id == usePacket.a) + { + PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity(); + newPacket.a = entry.getKey(); + newPacket.action = usePacket.action; + newPacket.c = usePacket.c; + + { + ((CraftPlayer) owner).getHandle().playerConnection.a(newPacket); + } + + break loop; + } + } + } + } + else if (packet instanceof PacketPlayOutAttachEntity || packet instanceof PacketPlayOutNewAttachEntity) + { + int vech = -1; + int rider = -1; + + if (packet instanceof PacketPlayOutAttachEntity) + { + PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet; + vech = attachPacket.b; + rider = attachPacket.c; + } + else if (packet instanceof PacketPlayOutNewAttachEntity) + { + PacketPlayOutNewAttachEntity attachPacket = (PacketPlayOutNewAttachEntity) packet; + vech = attachPacket.a; + + if (attachPacket.b.length > 0) + rider = attachPacket.b[0]; + } + + // c = rider, b = ridden + // When detaching, c is sent, b is -1 + + // If this attach packet is for a player that has the fix + // If the attach packet isn't ordained by me + if (!_entityMap.containsKey(owner.getUniqueId())) + { + return; + } + + if (!_entityRiding.containsKey(owner.getUniqueId())) + { + _entityRiding.put(owner.getUniqueId(), new HashMap()); + } + + int vehicleId = -1; + + if (_entityRiding.get(owner.getUniqueId()).containsKey(vech)) + { + vehicleId = _entityRiding.get(owner.getUniqueId()).get(vech); + } + + if (rider == -1 && _entityMap.get(owner.getUniqueId()).containsKey(vehicleId)) + { + Integer[] ids = _entityMap.get(owner.getUniqueId()).get(vehicleId); + + _entityRiding.get(owner.getUniqueId()).remove(vech); + + sendProtocolPackets(owner, vehicleId, _entityNameMap.get(owner.getUniqueId()).get(vehicleId), verifier, true, + ids); + } + else + { + Integer[] ids = _entityMap.get(owner.getUniqueId()).get(rider); + + if (ids != null && ids[1] != vech) + { + _entityRiding.get(owner.getUniqueId()).put(vech, rider); + + int[] newIds = new int[ids.length]; + + for (int a = 0; a < ids.length; a++) + { + newIds[a] = ids[a]; + } + + UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); } } } } private void sendProtocolPackets(final Player owner, final int entityId, String entityName, final PacketVerifier packetList, - final boolean newPacket, final Integer[] entityIds) + final boolean newPacket, final Integer[] entityIds) { CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName); _plugin.getServer().getPluginManager().callEvent(event); @@ -565,9 +569,9 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook if (UtilPlayer.is1_9(owner)) { UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityId, new int[] - { - entityIds[1] - })); + { + entityIds[1] + })); } else { @@ -595,9 +599,9 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook if (UtilPlayer.is1_9(owner)) { UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityIds[1], new int[] - { - entityIds[0] - })); + { + entityIds[0] + })); } else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/Managers.java b/Plugins/Mineplex.Core/src/mineplex/core/Managers.java new file mode 100644 index 000000000..f37bfc810 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/Managers.java @@ -0,0 +1,92 @@ +package mineplex.core; + +import mineplex.core.common.util.UtilServer; + +import java.lang.reflect.Constructor; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * This class will manage all the MiniPlugin instances. It's not the best way to do it, but it works given how + * we use MiniPlugins right now, so let's not fret about that + */ +public class Managers +{ + private static final Map, Object> MANAGER_MAP = Collections.synchronizedMap(new HashMap<>()); + + /** + * Gets a Manager ({@link MiniPlugin}) based on its class + * + * @param clazz The class of the MiniPlugin to return + * @return The mapped MiniPlugin, or null if not found + */ + public static T get(Class clazz) + { + Object result = MANAGER_MAP.get(clazz); + return clazz.cast(result); + } + + /** + * Gets the given module, and initializes if necessary + * @param clazz + * @param + * @return + */ + public static T require(Class clazz) + { + if (MANAGER_MAP.containsKey(clazz)) + { + return get(clazz); + } + try + { + ReflectivelyCreateMiniPlugin annotation = clazz.getAnnotation(ReflectivelyCreateMiniPlugin.class); + if (annotation != null) + { + Constructor defaultConstructor = clazz.getDeclaredConstructor(); + defaultConstructor.setAccessible(true); + return defaultConstructor.newInstance(); + } + } + catch (ReflectiveOperationException ex) + { + ex.printStackTrace(System.out); + } + return null; + } + + public static void put(MiniPlugin manager) + { + if (manager == null) throw new NullPointerException("Manager cannot be null"); + if (MANAGER_MAP.containsKey(manager.getClass())) + { + if (!UtilServer.isTestServer()) + { + System.out.println("============== WARNING =============="); + System.out.println(" "); + System.out.println(" "); + System.out.println(" "); + System.out.println("Attempted to register " + manager.getClass().getName() + ", but it was already registered"); + new Exception("Stack trace").printStackTrace(System.out); + System.out.println(" "); + System.out.println(" "); + System.out.println(" "); + System.out.println("============== WARNING =============="); + } + else + { + throw new IllegalArgumentException("Manager " + manager.getClass().getName() + " is already registered"); + } + } + MANAGER_MAP.put(manager.getClass(), manager); + } + + public static void put(MiniPlugin manager, Class type) + { + if (manager == null) throw new NullPointerException("Manager cannot be null"); + if (!type.isAssignableFrom(manager.getClass())) throw new IllegalArgumentException(manager.getClass().getName() + " is not a subclass of " + type.getName()); + if (MANAGER_MAP.containsKey(type)) throw new IllegalArgumentException("Manager " + type.getName() + " is already registered"); + MANAGER_MAP.put(type, manager); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java index d90d08fe5..c5f2119e1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java @@ -1,19 +1,21 @@ package mineplex.core; -import java.util.Collection; - +import mineplex.core.account.event.ClientUnloadEvent; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.account.event.ClientUnloadEvent; -import mineplex.core.common.util.NautHashMap; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; public abstract class MiniClientPlugin extends MiniPlugin { - private static Object _clientDataLock = new Object(); + private static final Object _clientDataLock = new Object(); - private NautHashMap _clientData = new NautHashMap(); + private Map _clientData = new HashMap<>(); public MiniClientPlugin(String moduleName, JavaPlugin plugin) { @@ -26,18 +28,27 @@ public abstract class MiniClientPlugin extends MiniPlug synchronized (_clientDataLock) { saveData(event.GetName(), event.getAccountId()); - _clientData.remove(event.GetName()); + _clientData.remove(event.getUniqueId()); } } - + + @Deprecated public DataType Get(String name) + { + Player player = Bukkit.getPlayerExact(name); + if (player == null) + return null; + return Get(player); + } + + public DataType Get(UUID uuid) { synchronized (_clientDataLock) { - if (!_clientData.containsKey(name)) - _clientData.put(name, addPlayer(name)); - - return _clientData.get(name); + if (!_clientData.containsKey(uuid)) + _clientData.put(uuid, addPlayer(uuid)); + + return _clientData.get(uuid); } } @@ -45,7 +56,7 @@ public abstract class MiniClientPlugin extends MiniPlug public DataType Get(Player player) { - return Get(player.getName()); + return Get(player.getUniqueId()); } protected Collection GetValues() @@ -55,16 +66,16 @@ public abstract class MiniClientPlugin extends MiniPlug protected void Set(Player player, DataType data) { - Set(player.getName(), data); + Set(player.getUniqueId(), data); } - - protected void Set(String name, DataType data) + + protected void Set(UUID uuid, DataType data) { synchronized (_clientDataLock) { - _clientData.put(name, data); + _clientData.put(uuid, data); } } - protected abstract DataType addPlayer(String player); + protected abstract DataType addPlayer(UUID uuid); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/MiniDbClientPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/MiniDbClientPlugin.java index 2f479adeb..52805cdc5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/MiniDbClientPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/MiniDbClientPlugin.java @@ -2,6 +2,7 @@ package mineplex.core; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; import org.bukkit.plugin.java.JavaPlugin; @@ -21,7 +22,7 @@ public abstract class MiniDbClientPlugin extends MiniCl clientManager.addStoredProcedureLoginProcessor(this); } - public abstract void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException; + public abstract void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException; public CoreClientManager getClientManager() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java index 435f4dcff..80c128715 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java @@ -1,20 +1,30 @@ package mineplex.core; +import mineplex.core.command.CommandCenter; +import mineplex.core.command.ICommand; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.thread.ThreadPool; import org.bukkit.Bukkit; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; +import org.bukkit.scheduler.BukkitTask; -import mineplex.core.command.CommandCenter; -import mineplex.core.command.ICommand; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.thread.ThreadPool; - +/** + * In the future, all implementations of MiniPlugin should only have one constructor: + * + * private MiniPlugin() + * + * MiniPlugins should also not depend on load order. + * + * This way, we can reflectively create them during {@link #require} when they do not exist, leading to much cleaner code + */ public abstract class MiniPlugin implements Listener { protected String _moduleName = "Default"; @@ -23,6 +33,11 @@ public abstract class MiniPlugin implements Listener protected long _initializedTime; + public MiniPlugin(String moduleName) + { + this(moduleName, UtilServer.getPlugin()); + } + public MiniPlugin(String moduleName, JavaPlugin plugin) { _moduleName = moduleName; @@ -30,11 +45,13 @@ public abstract class MiniPlugin implements Listener _initializedTime = System.currentTimeMillis(); - _commands = new NautHashMap(); + _commands = new NautHashMap<>(); onEnable(); registerEvents(this); + + Managers.put(this); } public PluginManager getPluginManager() @@ -111,22 +128,36 @@ public abstract class MiniPlugin implements Listener public void runAsync(Runnable runnable) { - // Instead of using ThreadPool.ASYNC.execute(runnable); } - public void runAsync(Runnable runnable, long time) + public BukkitTask runAsync(Runnable runnable, long time) { - _plugin.getServer().getScheduler().runTaskLaterAsynchronously(_plugin, runnable, time); + return _plugin.getServer().getScheduler().runTaskLaterAsynchronously(_plugin, runnable, time); } - public void runSync(Runnable runnable) + public BukkitTask runAsyncTimer(Runnable runnable, long time, long period) { - _plugin.getServer().getScheduler().runTask(_plugin, runnable); + return _plugin.getServer().getScheduler().runTaskTimerAsynchronously(_plugin, runnable, time, period); } - public void runSyncLater(Runnable runnable, long delay) + public BukkitTask runSync(Runnable runnable) { - _plugin.getServer().getScheduler().runTaskLater(_plugin, runnable, delay); + return _plugin.getServer().getScheduler().runTask(_plugin, runnable); + } + + public BukkitTask runSyncLater(Runnable runnable, long delay) + { + return _plugin.getServer().getScheduler().runTaskLater(_plugin, runnable, delay); + } + + public BukkitTask runSyncTimer(Runnable runnable, long delay, long period) + { + return _plugin.getServer().getScheduler().runTaskTimer(_plugin, runnable, delay, period); + } + + protected T require(Class clazz) + { + return Managers.require(clazz); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/PacketsInteractionFix.java b/Plugins/Mineplex.Core/src/mineplex/core/PacketsInteractionFix.java index 227cba9bb..19d74a4b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/PacketsInteractionFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/PacketsInteractionFix.java @@ -4,6 +4,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; +import java.util.UUID; import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.MathHelper; @@ -33,7 +35,7 @@ import mineplex.core.updater.event.UpdateEvent; public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler { - private HashMap> _armorStands = new HashMap>(); + private Map> _armorStands = new HashMap<>(); public PacketsInteractionFix(JavaPlugin plugin, PacketHandler packetHandler) { @@ -46,7 +48,7 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler @EventHandler public void onQuit(PlayerQuitEvent event) { - _armorStands.remove(event.getPlayer().getName()); + _armorStands.remove(event.getPlayer().getUniqueId()); } @EventHandler @@ -57,13 +59,13 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler return; } - Iterator itel = _armorStands.keySet().iterator(); + Iterator itel = _armorStands.keySet().iterator(); while (itel.hasNext()) { - String name = itel.next(); + UUID id = itel.next(); - Player player = Bukkit.getPlayerExact(name); + Player player = Bukkit.getPlayer(id); if (player != null) { @@ -89,12 +91,12 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler return; } - if (!_armorStands.containsKey(player.getName())) + if (!_armorStands.containsKey(player.getUniqueId())) { - _armorStands.put(player.getName(), new HashSet()); + _armorStands.put(player.getUniqueId(), new HashSet()); } - HashSet list = _armorStands.get(player.getName()); + HashSet list = _armorStands.get(player.getUniqueId()); if (packetInfo.getPacket() instanceof PacketPlayOutSpawnEntityLiving) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java new file mode 100644 index 000000000..b280def94 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java @@ -0,0 +1,161 @@ +package mineplex.core; + +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.incognito.IncognitoManager; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.OfflinePlayer; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +/** + * A helper for selecting arbitrary players given a set of conditions + */ +public class PlayerSelector +{ + /** + * Select a random player from all the online players + * + * @return A random player, or null if none matched + */ + public static Player selectPlayer() + { + return selectPlayer(player -> true); + } + + /** + * Select a random player who match the given criterion + * + * @param selector The condition that the players must match against + * @return A random player, or null if none matched + */ + public static Player selectPlayer(Predicate selector) + { + List selected = selectPlayers(selector); + return selected.get(ThreadLocalRandom.current().nextInt(selected.size())); + } + + /** + * Select all the players who match the given criterion + * @param selector The condition that the players must match against + * @return All the players who match + */ + public static List selectPlayers(Predicate selector) + { + return Bukkit.getOnlinePlayers().stream().filter(selector).collect(Collectors.toList()); + } + + /** + * This condition will return true if the player is not vanished, and false if they are. + * + * If the {@link IncognitoManager} is not loaded, then this will return true + */ + public static final Predicate NOT_VANISHED = player -> + { + IncognitoManager manager = Managers.get(IncognitoManager.class); + if (manager == null) + { + return true; + } + return !manager.Get(player).Status; + }; + + /** + * This condition will return true if the player is not spectating, and false if they are + */ + public static final Predicate NOT_SPECTATING = player -> player.getGameMode() != GameMode.SPECTATOR; + + /** + * This condition will return true if the player has one of the given ranks + * + * @param useDisguisedRank Whether to use the disguised rank of the player should they be disguised + * @param ranks The ranks to check + * @return The resulting criterion + */ + public static Predicate hasAnyRank(boolean useDisguisedRank, Rank... ranks) + { + return player -> + { + CoreClientManager coreClientManager = Managers.get(CoreClientManager.class); + if (coreClientManager == null) + { + return true; + } + CoreClient client = coreClientManager.Get(player); + Rank rank = useDisguisedRank ? client.getRealOrDisguisedRank() : client.GetRank(); + + for (Rank requiredRank : ranks) + { + if (rank == requiredRank) + { + return true; + } + } + + return false; + }; + } + + + /** + * This condition will return true if the entity is in the world specified + * @param world The world that the entity must be in + * @return The resulting criterion + */ + public static Predicate inWorld(World world) + { + return entity -> world == null || entity.getWorld().equals(world); + } + + /** + * This will return a {@link Predicate} which will return true if and only if all of the supplied Predicates + * return true + * @param predicates The Predicates to test against + * @return The resulting criterion + */ + @SafeVarargs + public static Predicate and(Predicate... predicates) + { + return t -> + { + for (Predicate predicate : predicates) + { + if (!predicate.test(t)) + { + return false; + } + } + return true; + }; + } + + /** + * This will return a {@link Predicate} which will return true if and only if one of the the supplied Predicates + * return true + * @param predicates The Predicates to test against + * @return The resulting criterion + */ + @SafeVarargs + public static Predicate or(Predicate... predicates) + { + return t -> + { + for (Predicate predicate : predicates) + { + if (predicate.test(t)) + { + return true; + } + } + return false; + }; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ReflectivelyCreateMiniPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/ReflectivelyCreateMiniPlugin.java new file mode 100644 index 000000000..18c11d4cf --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/ReflectivelyCreateMiniPlugin.java @@ -0,0 +1,15 @@ +package mineplex.core; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Simply represents that this {@link MiniPlugin} can be reflectively instantiated with no harm + */ +@Target(value = ElementType.TYPE) +@Retention(value = RetentionPolicy.RUNTIME) +public @interface ReflectivelyCreateMiniPlugin +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java index 61ccdc618..603281907 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java @@ -9,51 +9,66 @@ import mineplex.serverdata.Utility; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -public class CoreClient +import java.util.UUID; + +public class CoreClient { - private int _accountId = -1; - private long _networkSessionLoginTime; + private int _accountId = -1; + private long _networkSessionLoginTime; private String _name; - private String _disguisedAs; + private UUID _uuid; private Player _player; private Rank _rank, _lastRank; - private Rank _disguisedRank; private Rank _tempRank, _lastTemp; - private boolean _disguised; - + + /* + * Disguise info + */ + private String _disguisedName; + private String _disguisedSkin; + private UUID _disguisedUUID; + private Rank _disguisedRank; + public CoreClient(Player player) { _player = player; + _uuid = player.getUniqueId(); _name = player.getName(); _networkSessionLoginTime = Utility.currentTimeMillis(); } - - public CoreClient(String name) + + public CoreClient(String name, UUID uuid) { _name = name; + _uuid = uuid; } - public String GetPlayerName() + public UUID getUniqueId() + { + return this._uuid; + } + + public String getName() { return _name; } - + public Player GetPlayer() { return _player; } - - public void SetPlayer(Player player) - { - _player = player; - } - - public int getAccountId() - { - return _accountId; - } - public void Delete() + public void SetPlayer(Player player) + { + _player = player; + } + + public int getAccountId() + { + return _accountId; + } + + public void Delete() { _name = null; _player = null; @@ -63,7 +78,7 @@ public class CoreClient { _accountId = accountId; } - + public Rank GetRank() { return GetRank(false); @@ -73,13 +88,13 @@ public class CoreClient { if (_rank == null) _rank = Rank.ALL; - + if (bypass || _tempRank == null) return _rank; else return _tempRank; } - + public Rank GetLastRank(boolean temp) { if (temp) @@ -100,7 +115,7 @@ public class CoreClient return _lastRank; } } - + public void SetRank(Rank rank, boolean temp) { if (temp) @@ -117,47 +132,70 @@ public class CoreClient _rank = rank; } } - + public long getNetworkSessionLoginTime() { return _networkSessionLoginTime; } - public String getDisguisedAs() + public void undisguise() { - return _disguisedAs; + this._disguisedName = null; + this._disguisedSkin = null; + this._disguisedRank = null; + this._disguisedUUID = null; } - public void setDisguisedAs(String originalName) + public String getDisguisedAs() { - this._disguisedAs = originalName; + return this._disguisedName; } - /** - * Only use this method if the client is actually disguised! - * @return - */ - public Rank getDisguisedRank() { + public String getDisguisedSkin() + { + return this._disguisedSkin; + } + + public Rank getDisguisedRank() + { return _disguisedRank; } - public void setDisguisedRank(Rank disguisedRank) { - this._disguisedRank = disguisedRank; + public UUID getDisguisedAsUUID() + { + return this._disguisedUUID; } - public boolean isDisguised() { - return _disguised; + public boolean isDisguised() + { + if (this._disguisedName == null) + { + return false; + } + return !this._name.equalsIgnoreCase(this._disguisedName); } - public void setDisguised(boolean disguised) { - this._disguised = disguised; + public void disguise(String name, UUID uuid, Rank rank) + { + this._disguisedName = name; + this._disguisedUUID = uuid; + this._disguisedRank = rank; } - public void setNetworkSessionLoginTime(long loginTime) + public Rank getRealOrDisguisedRank() + { + if (this._disguisedRank != null) + { + return this._disguisedRank; + } + return this.GetRank(); + } + + public void setNetworkSessionLoginTime(long loginTime) { _networkSessionLoginTime = loginTime; } - + public void resetTemp() { if (_tempRank != null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index e025133f9..dc68fca79 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -2,12 +2,17 @@ package mineplex.core.account; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; import com.google.gson.Gson; @@ -22,13 +27,14 @@ import mineplex.core.account.repository.AccountRepository; import mineplex.core.account.repository.token.ClientToken; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; -import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTasks; import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -43,43 +49,41 @@ import org.bukkit.plugin.java.JavaPlugin; public class CoreClientManager extends MiniPlugin { - private static NautHashMap _clientLoginLock = new NautHashMap(); - + private static final Map CLIENT_LOGIN_LOCKS = new ConcurrentHashMap<>(); + private JavaPlugin _plugin; private AccountRepository _repository; - private NautHashMap _clientList; - private HashSet _duplicateLoginGlitchPreventionList; + private Map _clientList = new HashMap<>(); + private HashSet _duplicateLoginGlitchPreventionList = new HashSet<>(); private List _loginProcessors = new ArrayList<>(); - private Object _clientLock = new Object(); - + private final Object _clientLock = new Object(); + private static AtomicInteger _clientsConnecting = new AtomicInteger(0); private static AtomicInteger _clientsProcessing = new AtomicInteger(0); - + private final Rank WHITELIST_BYPASS; - + public CoreClientManager(JavaPlugin plugin, String webServer) { this(plugin, webServer, Rank.MODERATOR); } - + public CoreClientManager(JavaPlugin plugin, String webServer, Rank whitelistBypass) { super("Client Manager", plugin); - + _plugin = plugin; _repository = new AccountRepository(plugin, webServer); - _clientList = new NautHashMap(); - _duplicateLoginGlitchPreventionList = new HashSet(); - WHITELIST_BYPASS = whitelistBypass; + WHITELIST_BYPASS = whitelistBypass; } - + public AccountRepository getRepository() { return _repository; } - + @Override public void addCommands() { @@ -87,72 +91,71 @@ public class CoreClientManager extends MiniPlugin addCommand(new TestRank(this)); } - public CoreClient Add(String name) + public CoreClient Add(String name, UUID uuid) { - CoreClient newClient = null; - - if (newClient == null) + CoreClient newClient = new CoreClient(name, uuid); + + CoreClient oldClient; + + synchronized (_clientLock) { - newClient = new CoreClient(name); + oldClient = _clientList.put(uuid, newClient); } - - CoreClient oldClient = null; - - synchronized(_clientLock) + + if (oldClient != null) { - oldClient = _clientList.put(name, newClient); + oldClient.Delete(); } - - if (oldClient != null) - { - oldClient.Delete(); - } return newClient; } - public void Del(String name, int accountId) + public void Del(String name, UUID uuid, int accountId) { - synchronized(_clientLock) + synchronized (_clientLock) { - _clientList.remove(name); + _clientList.remove(uuid); } // rawr added account id for custom data - william - _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name, accountId)); + _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name, uuid, accountId)); } + @Deprecated public CoreClient Get(String name) { - synchronized(_clientLock) + Player p = Bukkit.getPlayerExact(name); + return Get(p.getUniqueId()); + } + + public CoreClient Get(UUID uuid) + { + synchronized (_clientLock) { - for(CoreClient client : _clientList.values()) - { - if(client.getDisguisedAs() != null) - if(client.getDisguisedAs().equalsIgnoreCase(name)) - return client; - } - CoreClient client = _clientList.get(name); - + CoreClient client = _clientList.get(uuid); + if (client == null) { - client = new CoreClient(name); + Player player = Bukkit.getPlayer(uuid); + if (player != null) + { + client = new CoreClient(player.getName(), uuid); + } + else + { + client = new CoreClient(null, uuid); + } } - + return client; } } - - public boolean Contains(String name) - { - return _clientList.containsKey(name); - } - + public CoreClient Get(Player player) { - return Get(player.getName()); + return Get(player.getUniqueId()); } - + public int getPlayerCountIncludingConnecting() { return Bukkit.getOnlinePlayers().size() + Math.max(0, _clientsConnecting.get()); @@ -160,6 +163,7 @@ public class CoreClientManager extends MiniPlugin /** * Get the databse account id for a player. Requires the player is online + * * @param player * @return */ @@ -185,12 +189,12 @@ public class CoreClientManager extends MiniPlugin e.printStackTrace(); } } - + try { _clientsProcessing.incrementAndGet(); - - if (!LoadClient(Add(event.getName()), event.getUniqueId(), event.getAddress().getHostAddress())) + + if (!LoadClient(Add(event.getName(), event.getUniqueId()), event.getUniqueId(), event.getAddress().getHostAddress())) event.disallow(Result.KICK_OTHER, "There was a problem logging you in."); } catch (Exception exception) @@ -202,8 +206,8 @@ public class CoreClientManager extends MiniPlugin { _clientsProcessing.decrementAndGet(); } - - if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().has(WHITELIST_BYPASS)) + + if (Bukkit.hasWhitelist() && !Get(event.getUniqueId()).GetRank().has(WHITELIST_BYPASS)) { for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) { @@ -212,7 +216,7 @@ public class CoreClientManager extends MiniPlugin return; } } - + event.disallow(Result.KICK_WHITELIST, "You are not whitelisted my friend."); } } @@ -226,93 +230,84 @@ public class CoreClientManager extends MiniPlugin { _repository.getAccountId(uuid, callback); } - + public void loadClientByName(final String playerName, final Runnable runnable) { - Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() + loadClientByName(playerName, client -> runnable.run()); + } + + public void loadClientByName(String playerName, Consumer loadedClient) + { + runAsync(() -> { - public void run() + AtomicReference loaded = new AtomicReference<>(); + try { - try + ClientToken token = null; + Gson gson = new Gson(); + + // Fails if not in DB and if duplicate. + UUID uuid = loadUUIDFromDB(playerName); + + if (uuid == null) { - ClientToken token = null; - Gson gson = new Gson(); - - // Fails if not in DB and if duplicate. - UUID uuid = loadUUIDFromDB(playerName); - - if (uuid == null) + uuid = UtilGameProfile.getProfileByName(playerName, false, profile -> {}).get().getId(); + } + + String response = ""; + + if (uuid == null) + { + response = _repository.getClientByName(playerName); + } + else + { + response = _repository.getClientByUUID(uuid); + } + + token = gson.fromJson(response, ClientToken.class); + + CoreClient client = Add(playerName, uuid); + client.SetRank(Rank.valueOf(token.Rank), false); + client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName())); + + // JSON sql response + Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); + + if (client.getAccountId() > 0) + { + PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); + + if (playerInfo != null) { - try - { - uuid = UUIDFetcher.getUUIDOf(playerName); - } - catch (Exception exception) - { - System.out.println("Error fetching uuid from mojang : " + exception.getMessage()); - } - } - - String response = ""; - - if (uuid == null) - { - response = _repository.getClientByName(playerName); - } - else - { - response = _repository.getClientByUUID(uuid); - } - - token = gson.fromJson(response, ClientToken.class); - - CoreClient client = Add(playerName); - client.SetRank(Rank.valueOf(token.Rank), false); - client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName())); - - // JSON sql response - Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); - - if (client.getAccountId() > 0) - { - PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); - - if (playerInfo != null) - { - playerInfo.setAccountId(client.getAccountId()); - PlayerCache.getInstance().addPlayer(playerInfo); - } + playerInfo.setAccountId(client.getAccountId()); + PlayerCache.getInstance().addPlayer(playerInfo); } } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() - { - public void run() - { - if (runnable != null) - runnable.run(); - } - }); - } + + loaded.set(client); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + finally + { + UtilTasks.onMainThread(() -> loadedClient.accept(loaded.get())).run(); } }); } - + public void loadClientByNameSync(final String playerName, final Runnable runnable) { try { ClientToken token = null; Gson gson = new Gson(); - + // Fails if not in DB and if duplicate. UUID uuid = loadUUIDFromDB(playerName); - + if (uuid == null) { try @@ -324,9 +319,9 @@ public class CoreClientManager extends MiniPlugin System.out.println("Error fetching uuid from mojang : " + exception.getMessage()); } } - + String response = ""; - + if (uuid == null) { response = _repository.getClientByName(playerName); @@ -335,20 +330,20 @@ public class CoreClientManager extends MiniPlugin { response = _repository.getClientByUUID(uuid); } - - token = gson.fromJson(response, ClientToken.class); - CoreClient client = Add(playerName); - client.SetRank(Rank.valueOf(token.Rank), false); - client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName())); - + token = gson.fromJson(response, ClientToken.class); + + CoreClient client = Add(playerName, uuid); + client.SetRank(Rank.valueOf(token.Rank), false); + client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName())); + // JSON sql response Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); - + if (client.getAccountId() > 0) { PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); - + if (playerInfo != null) { playerInfo.setAccountId(client.getAccountId()); @@ -358,7 +353,7 @@ public class CoreClientManager extends MiniPlugin } catch (Exception exception) { - exception.printStackTrace(); + exception.printStackTrace(); } finally { @@ -372,13 +367,13 @@ public class CoreClientManager extends MiniPlugin }); } } - + public boolean LoadClient(final CoreClient client, final UUID uuid, String ipAddress) { - TimingManager.start(client.GetPlayerName() + " LoadClient Total."); + TimingManager.start(client.getName() + " LoadClient Total."); long timeStart = System.currentTimeMillis(); - _clientLoginLock.put(client.GetPlayerName(), new Object()); + CLIENT_LOGIN_LOCKS.put(client.getName(), new Object()); ClientToken token = null; Gson gson = new Gson(); @@ -387,33 +382,36 @@ public class CoreClientManager extends MiniPlugin @Override public void run() { - try { - client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName())); - } catch (SQLException e) { + try + { + client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName())); + } + catch (SQLException e) + { // TODO Auto-generated catch block e.printStackTrace(); } - _clientLoginLock.remove(client.GetPlayerName()); + CLIENT_LOGIN_LOCKS.remove(client.getName()); } }); - - TimingManager.start(client.GetPlayerName() + " GetClient."); - String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress); - TimingManager.stop(client.GetPlayerName() + " GetClient."); - TimingManager.start(client.GetPlayerName() + " Event."); - token = gson.fromJson(response, ClientToken.class); - + TimingManager.start(client.getName() + " GetClient."); + String response = _repository.GetClient(client.getName(), uuid, ipAddress); + TimingManager.stop(client.getName() + " GetClient."); + + TimingManager.start(client.getName() + " Event."); + token = gson.fromJson(response, ClientToken.class); + client.SetRank(Rank.valueOf(token.Rank), false); - + // _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString()); - + // JSON sql response Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); - TimingManager.stop(client.GetPlayerName() + " Event."); + TimingManager.stop(client.getName() + " Event."); - TimingManager.start(client.GetPlayerName() + " While Loop."); - while (_clientLoginLock.containsKey(client.GetPlayerName()) && System.currentTimeMillis() - timeStart < 15000) + TimingManager.start(client.getName() + " While Loop."); + while (CLIENT_LOGIN_LOCKS.containsKey(client.getName()) && System.currentTimeMillis() - timeStart < 15000) { try { @@ -424,19 +422,19 @@ public class CoreClientManager extends MiniPlugin e.printStackTrace(); } } - TimingManager.stop(client.GetPlayerName() + " While Loop."); - - if (_clientLoginLock.containsKey(client.GetPlayerName())) + TimingManager.stop(client.getName() + " While Loop."); + + if (CLIENT_LOGIN_LOCKS.containsKey(client.getName())) { System.out.println("MYSQL TOO LONG TO LOGIN...."); } - - TimingManager.stop(client.GetPlayerName() + " LoadClient Total."); - + + TimingManager.stop(client.getName() + " LoadClient Total."); + if (client.getAccountId() > 0) { PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); - + if (playerInfo != null) { client.setNetworkSessionLoginTime(playerInfo.getLoginTime()); @@ -444,32 +442,32 @@ public class CoreClientManager extends MiniPlugin PlayerCache.getInstance().addPlayer(playerInfo); } } - - return !_clientLoginLock.containsKey(client.GetPlayerName()); + + return !CLIENT_LOGIN_LOCKS.containsKey(client.getName()); } @EventHandler(priority = EventPriority.LOWEST) public void Login(PlayerLoginEvent event) { - synchronized(_clientLock) + synchronized (_clientLock) { - if (!_clientList.containsKey(event.getPlayer().getName())) + if (!_clientList.containsKey(event.getPlayer().getUniqueId())) { - _clientList.put(event.getPlayer().getName(), new CoreClient(event.getPlayer().getName())); + _clientList.put(event.getPlayer().getUniqueId(), new CoreClient(event.getPlayer().getName(), event.getPlayer().getUniqueId())); } } - CoreClient client = Get(event.getPlayer().getName()); - - if (client == null || client.GetRank() == null) - { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconnect."); - return; - } - - client.SetPlayer(event.getPlayer()); - - // Reserved Slot Check + CoreClient client = Get(event.getPlayer().getUniqueId()); + + if (client == null || client.GetRank() == null) + { + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconnect."); + return; + } + + client.SetPlayer(event.getPlayer()); + + // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers()) { if (client.GetRank().has(event.getPlayer(), Rank.ULTRA, false)) @@ -478,27 +476,29 @@ public class CoreClientManager extends MiniPlugin event.setResult(PlayerLoginEvent.Result.ALLOWED); return; } - + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This server is full and no longer accepts players."); } } - + @EventHandler public void Kick(PlayerKickEvent event) { if (event.getReason().contains("You logged in from another location")) { - _duplicateLoginGlitchPreventionList.add(event.getPlayer().getName()); - Bukkit.getScheduler().runTask(_plugin, new Runnable() { - public void run() { - if(!_clientList.containsKey(event.getPlayer().getName())) return; - Player p = _clientList.get(event.getPlayer().getName()).GetPlayer(); - p.kickPlayer("You're already logged in."); - } + _duplicateLoginGlitchPreventionList.add(event.getPlayer().getUniqueId()); + Bukkit.getScheduler().runTask(_plugin, new Runnable() + { + public void run() + { + if (!_clientList.containsKey(event.getPlayer().getUniqueId())) return; + Player p = _clientList.get(event.getPlayer().getUniqueId()).GetPlayer(); + p.kickPlayer("You're already logged in."); + } }); } } - + @EventHandler(priority = EventPriority.MONITOR) public void Quit(PlayerQuitEvent event) { @@ -509,11 +509,11 @@ public class CoreClientManager extends MiniPlugin // PlayerKick -> old // PlayerQuit -> old // Then it glitches because it added new, but then removed old afterwards since its based on name as key. - - if (!_duplicateLoginGlitchPreventionList.contains(event.getPlayer().getName())) + + if (!_duplicateLoginGlitchPreventionList.contains(event.getPlayer().getUniqueId())) { - Del(event.getPlayer().getName(), _clientList.get(event.getPlayer().getName()).getAccountId()); - _duplicateLoginGlitchPreventionList.remove(event.getPlayer().getName()); + Del(event.getPlayer().getName(), event.getPlayer().getUniqueId(), _clientList.get(event.getPlayer().getUniqueId()).getAccountId()); + _duplicateLoginGlitchPreventionList.remove(event.getPlayer().getUniqueId()); } } @@ -525,14 +525,14 @@ public class CoreClientManager extends MiniPlugin { if (_plugin.getServer().getPlayer(name) != null) { - CoreClient client = Get(name); + CoreClient client = Get(name); client.SetRank(newRank, false); } } }, name, uuid, rank, perm); } - + public void SaveRank(final Callback callback, final String name, final UUID uuid, Rank rank, boolean perm) { _repository.saveRank(new Callback() @@ -541,17 +541,17 @@ public class CoreClientManager extends MiniPlugin { if (_plugin.getServer().getPlayer(name) != null) { - CoreClient client = Get(name); + CoreClient client = Get(name); client.SetRank(newRank, false); } - + if (callback != null) callback.run(newRank); } }, name, uuid, rank, perm); } - + public void checkPlayerNameExact(final Callback callback, final String playerName) { _repository.matchPlayerName(new Callback>() @@ -570,7 +570,7 @@ public class CoreClientManager extends MiniPlugin } }, playerName); } - + public void checkPlayerName(final Player caller, final String playerName, final Callback callback) { _repository.matchPlayerName(new Callback>() @@ -617,51 +617,51 @@ public class CoreClientManager extends MiniPlugin } }, playerName); } - + // DONT USE THIS IN PRODUCTION...its for enjin listener -someone you despise but definitely not me (defek7) public UUID loadUUIDFromDB(String name) { return _repository.getClientUUID(name); } - + @EventHandler public void cleanGlitchedClients(UpdateEvent event) { if (event.getType() != UpdateType.SLOW) return; - - synchronized(_clientLock) + + synchronized (_clientLock) { - for (Iterator> clientIterator = _clientList.entrySet().iterator(); clientIterator.hasNext();) + for (Iterator> clientIterator = _clientList.entrySet().iterator(); clientIterator.hasNext(); ) { CoreClient client = clientIterator.next().getValue(); // rawr, needed this for custom data - william Player clientPlayer = client.GetPlayer(); - + if (clientPlayer != null && !clientPlayer.isOnline()) { clientIterator.remove(); - + if (clientPlayer != null) { - _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName(), client.getAccountId())); + _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName(), clientPlayer.getUniqueId(), client.getAccountId())); } } } } } - + @EventHandler public void debug(UpdateEvent event) { if (event.getType() != UpdateType.SLOWER) return; - + // System.out.println("====="); // System.out.println("Connecting : " + _clientsConnecting.get()); // System.out.println("Processing : " + _clientsProcessing.get()); // System.out.println("====="); } - + public void addStoredProcedureLoginProcessor(ILoginProcessor processor) { _loginProcessors.add(processor); @@ -672,7 +672,7 @@ public class CoreClientManager extends MiniPlugin CoreClient client = Get(player); if (client == null) return false; - + return client.GetRank().has(rank); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java index 7c7db7911..6aa25a27b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java @@ -2,12 +2,13 @@ package mineplex.core.account; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; public interface ILoginProcessor { String getName(); - void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException; + void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException; String getQuery(int accountId, String uuid, String name); } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java index d0d2d467a..47325e2c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java @@ -3,36 +3,45 @@ package mineplex.core.account.event; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import java.util.UUID; + public class ClientUnloadEvent extends Event { - private static final HandlerList handlers = new HandlerList(); - - private String _name; - private int _accountId; + private static final HandlerList handlers = new HandlerList(); - public ClientUnloadEvent(String name, int accountId) - { - _name = name; - _accountId = accountId; - } - - public String GetName() - { - return _name; - } + private String _name; + private UUID _uuid; + private int _accountId; - public int getAccountId() - { - return _accountId; - } + public ClientUnloadEvent(String name, UUID uuid, int accountId) + { + _name = name; + _accountId = accountId; + this._uuid = uuid; + } - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { - return handlers; - } + public String GetName() + { + return _name; + } + + public UUID getUniqueId() + { + return this._uuid; + } + + public int getAccountId() + { + return _accountId; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java index e00cd1b21..daea474e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -113,7 +113,7 @@ public class AccountRepository extends MinecraftRepository for (ILoginProcessor loginProcessor : loginProcessors) { - loginProcessor.processLoginResultSet(name, finalId, statement.getResultSet()); + loginProcessor.processLoginResultSet(name, uuid, finalId, statement.getResultSet()); statement.getMoreResults(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java index 5cdc68527..dbd63549c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java @@ -18,6 +18,8 @@ import mineplex.core.incognito.IncognitoManager; import mineplex.core.stats.StatsManager; import mineplex.core.stats.event.StatChangeEvent; +import java.util.UUID; + public class AchievementManager extends MiniPlugin { private IncognitoManager _incognitoManager; @@ -44,16 +46,16 @@ public class AchievementManager extends MiniPlugin public AchievementData get(Player player, Achievement type) { - return get(player.getName(), type); + return get(player.getUniqueId(), type); } - public AchievementData get(String playerName, Achievement type) + public AchievementData get(UUID playerUUID, Achievement type) { int exp = 0; for (String stat : type.getStats()) { - exp += _statsManager.Get(playerName).getStat(stat); + exp += _statsManager.Get(playerUUID).getStat(stat); } return type.getLevelData(exp); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index bf74a6d2e..0a032f529 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -1,50 +1,129 @@ package mineplex.core.antihack; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.util.concurrent.AtomicDouble; +import com.mineplex.anticheat.api.GameEndEvent; +import com.mineplex.anticheat.api.GameStartEvent; +import com.mineplex.anticheat.api.MineplexLink; +import com.mineplex.anticheat.api.PlayerViolationEvent; +import mineplex.core.PlayerSelector; import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.antihack.actions.AntiHackAction; +import mineplex.core.antihack.banwave.BanWaveManager; import mineplex.core.antihack.types.Fly; import mineplex.core.antihack.types.Idle; import mineplex.core.antihack.types.Reach; import mineplex.core.antihack.types.Speed; +import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; +import mineplex.core.punish.Category; import mineplex.core.punish.Punish; +import mineplex.core.punish.PunishClient; +import mineplex.core.punish.Punishment; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.serverdata.commands.ServerCommandManager; +import net.minecraft.server.v1_8_R3.ChatClickable; +import net.minecraft.server.v1_8_R3.ChatComponentText; +import net.minecraft.server.v1_8_R3.ChatHoverable; +import net.minecraft.server.v1_8_R3.ChatModifier; +import net.minecraft.server.v1_8_R3.EnumChatFormat; +import net.minecraft.server.v1_8_R3.IChatBaseComponent; +import net.minecraft.server.v1_8_R3.MathHelper; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.server.ServerListPingEvent; -import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.ServicePriority; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitTask; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; +import java.util.function.Predicate; +@ReflectivelyCreateMiniPlugin public class AntiHack extends MiniPlugin { - public static AntiHack Instance; + public static final boolean IS_PHASE_TWO = false; + public static final String NAME = "Chiss"; + public static final String USER_HAS_BEEN_BANNED = F.main("GWEN", "%s has been banned. I am always watching"); + public static final String USER_HAS_BEEN_BANNED_BANWAVE = USER_HAS_BEEN_BANNED; + + private static final int VL_DIFF_BEFORE_RENOTIFY = 999999; + private static final int MAX_STALKED_PLAYERS = 3; + private static final int STALK_COOLDOWN_TIME_SECONDS = 5; + private static final int MIN_STALK_TIME = 10 * 20; + private static final int MAX_STALK_TIME = 20 * 20; + private static final int MAX_MIN_DIFF = MAX_STALK_TIME - MIN_STALK_TIME; + private static final Function STALK_END_PROBABILITY_EQUATION = x -> + { + return 1.0/ MAX_MIN_DIFF * x; // linear equation with points (0, 0) and (diff, 1) + }; + + private final Cache _cooldown = CacheBuilder.newBuilder() + .concurrencyLevel(1) + .expireAfterWrite(30, TimeUnit.SECONDS) + .build(); + + private final Cache _stalkingCooldown = CacheBuilder.newBuilder() + .concurrencyLevel(1) + .expireAfterWrite(STALK_COOLDOWN_TIME_SECONDS, TimeUnit.SECONDS) + .build(); + private final List _stalking = new ArrayList<>(); + + private final String _thisServer; private boolean _enabled = true; private boolean _strict = false; private boolean _kick = true; - public Punish Punish; - public Portal Portal; - private PreferencesManager _preferences; - private CoreClientManager _clientManager; + public Portal Portal = require(Portal.class); + private PreferencesManager _preferences = require(PreferencesManager.class); + private CoreClientManager _clientManager = require(CoreClientManager.class); //Record Offenses private HashMap>> _offense = new HashMap>>(); @@ -54,16 +133,16 @@ public class AntiHack extends MiniPlugin //Player Info private HashSet _velocityEvent = new HashSet(); - private HashMap _lastMoveEvent = new HashMap(); - + private HashMap _lastMoveEvent = new HashMap(); + private HashSet _hubAttempted = new HashSet(); //Hack Requirements - public int FloatHackTicks = 10; - public int HoverHackTicks = 4; + public int FloatHackTicks = 10; + public int HoverHackTicks = 4; public int RiseHackTicks = 6; public int SpeedHackTicks = 6; - public int IdleTime = 20000; + public int IdleTime = 20000; public int KeepOffensesFor = 30000; @@ -72,19 +151,25 @@ public class AntiHack extends MiniPlugin public ArrayList _movementDetectors; public ArrayList _combatDetectors; - + private AntiHackRepository _repository; - protected AntiHack(JavaPlugin plugin, Punish punish, Portal portal, PreferencesManager preferences, CoreClientManager clientManager) + private List _guardians = new ArrayList<>(); + + private Predicate _filter = player -> true; + + private Set _pendingBan = new HashSet<>(); + + @SuppressWarnings("Convert2streamapi") + private AntiHack() { - super("AntiHack", plugin); + super("AntiHack"); - Punish = punish; - Portal = portal; - _preferences = preferences; - _clientManager = clientManager; + DisguiseManager disguiseManager = require(DisguiseManager.class); - _repository = new AntiHackRepository(plugin.getConfig().getString("serverstatus.name")); + this._thisServer = UtilServer.getServerNameFromConfig(); + + _repository = new AntiHackRepository(this._thisServer); _repository.initialize(); _movementDetectors = new ArrayList(); @@ -93,13 +178,519 @@ public class AntiHack extends MiniPlugin _movementDetectors.add(new Fly(this)); _movementDetectors.add(new Idle(this)); _movementDetectors.add(new Speed(this)); - + _combatDetectors.add(new Reach(this)); + + Bukkit.getServicesManager().register(MineplexLink.class, new MineplexLink() + { + @Override + public EntityType getActiveDisguise(Player player) + { + DisguiseBase disguise = disguiseManager.getActiveDisguise(player); + return disguise != null ? disguise.getDisguiseType() : null; + } + }, this._plugin, ServicePriority.Normal); + + ServerCommandManager.getInstance().registerCommandType(MajorViolationCommand.class, violation -> + { + if (!violation.getOriginatingServer().equals(this._thisServer)) + { + IChatBaseComponent component = new ChatComponentText("") + .addSibling( + new ChatComponentText("A") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.AQUA) + .setRandom(true) + ) + ) + .addSibling( + new ChatComponentText(" GWEN > ") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.RED) + .setBold(true) + ) + ) + .addSibling( + new ChatComponentText(violation.getPlayerName()) + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.GOLD) + ) + ) + .addSibling( + new ChatComponentText(" failed " + violation.getHackType() + " VL" + violation.getViolations() + " in server ") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + ) + ) + .addSibling( + new ChatComponentText( + violation.getOriginatingServer() + ) + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + .setChatClickable( + new ChatClickable( + ChatClickable.EnumClickAction.RUN_COMMAND, + "/server " + violation.getOriginatingServer() + ) + ) + .setChatHoverable( + new ChatHoverable( + ChatHoverable.EnumHoverAction.SHOW_TEXT, + new ChatComponentText("Teleport to " + violation.getOriginatingServer()) + ) + ) + ) + ) + .addSibling( + new ChatComponentText(": " + violation.getMessage() + ". Please investigate") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + ) + ); + + for (Player player : Bukkit.getOnlinePlayers()) + { + if (_clientManager.Get(player).GetRank().has(Rank.HELPER)) + { + ((CraftPlayer) player).getHandle().sendMessage(component); + } + } + } + }); + + this._plugin.getServer().getScheduler().runTaskTimer(this._plugin, () -> + { + for (AntiHackGuardian guardian : this._guardians) + { + if (guardian.getTarget() != null && !guardian.getTarget().isOnline()) + { + this._stalking.remove(guardian.getTarget().getUniqueId()); + guardian.stopTargeting(); + } + else if (guardian.getTargetingTime() > MIN_STALK_TIME) + { + double threshold = STALK_END_PROBABILITY_EQUATION.apply(guardian.getTargetingTime() - MIN_STALK_TIME); + if (Math.random() <= threshold) + { + this._stalking.remove(guardian.getTarget().getUniqueId()); + _stalkingCooldown.put(guardian.getTarget().getUniqueId(), true); + guardian.stopTargeting(); + } + } + guardian.tick(); + } + }, 0L, 1L); + + this._plugin.getServer().getScheduler().runTaskTimer(this._plugin, () -> + { + if (_stalking.size() >= MAX_STALKED_PLAYERS) + { + return; + } + + if (_guardians.size() == 0) + { + return; + } + + List targets = PlayerSelector.selectPlayers(PlayerSelector.and( + PlayerSelector.NOT_VANISHED, + PlayerSelector.hasAnyRank(false, + Rank.ALL, + Rank.ULTRA, + Rank.HERO, + Rank.LEGEND, + Rank.TITAN, + Rank.TWITCH, + Rank.YOUTUBE_SMALL, + Rank.YOUTUBE, + Rank.MEDIA, + Rank.ADMIN, + Rank.DEVELOPER, + Rank.OWNER, + Rank.LT + ), + player -> !_stalking.contains(player.getUniqueId()), + player -> _stalkingCooldown.getIfPresent(player.getUniqueId()) == null, + _filter + )); + + while (_stalking.size() < MAX_STALKED_PLAYERS && targets.size() > 0) + { + Player target = targets.remove(ThreadLocalRandom.current().nextInt(targets.size())); + + int start = ThreadLocalRandom.current().nextInt(_guardians.size()); + + for (int i = start, j = 0; j < _guardians.size(); i++, j++) + { + if (i >= _guardians.size()) + { + i -= _guardians.size(); + } + AntiHackGuardian guardian = _guardians.get(i); + if (!guardian.isTargeting()) + { + guardian.target(target); + _stalking.add(target.getUniqueId()); + break; + } + } + } + }, 0L, 20L); + + require(BanWaveManager.class); } - public static void Initialize(JavaPlugin plugin, Punish punish, Portal portal, PreferencesManager preferences, CoreClientManager clientManager) + public void registerFilter(Predicate filter) { - Instance = new AntiHack(plugin, punish, portal, preferences, clientManager); + if (filter == null) + { + this._filter = player -> true; + } + else + { + this._filter = filter; + } + } + + public void registerGuardian(AntiHackGuardian guardian) + { + this._guardians.add(guardian); + } + + public void clearGuardians() + { + this._guardians.forEach(AntiHackGuardian::remove); + this._guardians.clear(); + this._stalking.clear(); + this._stalkingCooldown.cleanUp(); + } + + public void runBanAnimation(Player player, Runnable after) + { + if (!IS_PHASE_TWO) + return; + + if (_pendingBan.add(player)) + { + float oldWalkSpeed = player.getWalkSpeed(); + player.setWalkSpeed(0); + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10)); + + double radius = 4; + double heightAdj = 8; + + double baseDeg = 18; + + Location center = player.getLocation().add(0, heightAdj, 0); + AntiHackGuardian north = new AntiHackGuardian(center.clone().add(0, 0, -radius), 0, 0, 0, 0, 0, 0); + AntiHackGuardian east = new AntiHackGuardian(center.clone().add(radius, 0, 0), 0, 0, 0, 0, 0, 0); + AntiHackGuardian south = new AntiHackGuardian(center.clone().add(0, 0, radius), 0, 0, 0, 0, 0, 0); + AntiHackGuardian west = new AntiHackGuardian(center.clone().add(-radius, 0, 0), 0, 0, 0, 0, 0, 0); + + UtilEnt.CreatureLook(east.getEntity(), player); + UtilEnt.CreatureLook(west.getEntity(), player); + UtilEnt.CreatureLook(south.getEntity(), player); + UtilEnt.CreatureLook(north.getEntity(), player); + + Function magic = seconds -> + { + return Math.pow(2, seconds - 5); + }; + + runSyncLater(() -> + { + north.shoot(player); + east.shoot(player); + south.shoot(player); + west.shoot(player); + + // We get 5 seconds, or 100 ticks + AtomicInteger timer = new AtomicInteger(5); + AtomicReference task = new AtomicReference<>(); + + AtomicDouble cNorth = new AtomicDouble(270); + AtomicDouble cEast = new AtomicDouble(0); + AtomicDouble cSouth = new AtomicDouble(90); + AtomicDouble cWest = new AtomicDouble(180); + + task.set(runSyncTimer(() -> + { + timer.getAndIncrement(); + if (timer.get() > 100) + { + task.get().cancel(); + + player.removePotionEffect(PotionEffectType.JUMP); + player.setWalkSpeed(oldWalkSpeed); + Location location = player.getLocation(); + + UtilParticle.PlayParticle(UtilParticle.ParticleType.HUGE_EXPLOSION, player.getLocation(), 3f, 3f, 3f, 0, 32, UtilParticle.ViewDist.MAX, UtilServer.getPlayers()); + + after.run(); + + _pendingBan.remove(player); + + north.shoot(null); + south.shoot(null); + east.shoot(null); + west.shoot(null); + UtilEnt.CreatureLook(north.getEntity(), location); + UtilEnt.CreatureLook(south.getEntity(), location); + UtilEnt.CreatureLook(east.getEntity(), location); + UtilEnt.CreatureLook(west.getEntity(), location); + runSyncLater(() -> + { + north.remove(); + south.remove(); + east.remove(); + west.remove(); + }, 40L); + return; + } + + double seconds = timer.get() / 20.0; + + double rate = magic.apply(seconds) * 3 * baseDeg; + + player.getLocation(center); + center.add(0, heightAdj, 0); + + { + cNorth.addAndGet(rate); + north.move(center.getX() + radius * MathHelper.cos((float) Math.toRadians(cNorth.get())), center.getY(), center.getZ() + radius * MathHelper.sin((float) Math.toRadians(cNorth.get()))); + } + { + cSouth.addAndGet(rate); + south.move(center.getX() + radius * MathHelper.cos((float) Math.toRadians(cSouth.get())), center.getY(), center.getZ() + radius * MathHelper.sin((float) Math.toRadians(cSouth.get()))); + } + { + cEast.addAndGet(rate); + east.move(center.getX() + radius * MathHelper.cos((float) Math.toRadians(cEast.get())), center.getY(), center.getZ() + radius * MathHelper.sin((float) Math.toRadians(cEast.get()))); + } + { + cWest.addAndGet(rate); + west.move(center.getX() + radius * MathHelper.cos((float) Math.toRadians(cWest.get())), center.getY(), center.getZ() + radius * MathHelper.sin((float) Math.toRadians(cWest.get()))); + } + }, 5, 1)); + }, 20); + } + } + + public void doBan(Player player, String message) + { + runSync(() -> + { + int totalPunishments = getPunishments(player); + int daysBanned = getDaysBanned(player); + CoreClient coreClient = _clientManager.Get(player); + + if (coreClient.GetRank().has(Rank.TWITCH)) + { + require(Punish.class).AddPunishment(coreClient.getName(), Category.Hacking, message, AntiHack.NAME, totalPunishments + 1, true, daysBanned == -1 ? -1 : TimeUnit.DAYS.toHours(daysBanned), true); + } + else + { + runBanAnimation(player, () -> + { + require(Punish.class).AddPunishment(coreClient.getName(), Category.Hacking, message, AntiHack.NAME, totalPunishments + 1, true, daysBanned == -1 ? -1 : TimeUnit.DAYS.toHours(daysBanned), true); + announceBan(player); + }); + } + }); + } + + public void doBanWave(Player player, String message) + { + runSync(() -> + { + int totalPunishments = getPunishments(player); + int daysBanned = getDaysBanned(player); + CoreClient coreClient = _clientManager.Get(player); + if (coreClient.GetRank().has(Rank.TWITCH)) + { + require(Punish.class).AddPunishment(coreClient.getName(), Category.Hacking, message, AntiHack.NAME, totalPunishments + 1, true, daysBanned == -1 ? -1 : TimeUnit.DAYS.toHours(daysBanned), true); + } + else + { + runBanAnimation(player, () -> + { + require(Punish.class).AddPunishment(coreClient.getName(), Category.Hacking, message, AntiHack.NAME, totalPunishments + 1, true, daysBanned == -1 ? -1 : TimeUnit.DAYS.toHours(daysBanned), true); + announceBanwave(player); + }); + } + }); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void on(PlayerMoveEvent event) + { + if (_pendingBan.contains(event.getPlayer()) && UtilMath.offset2d(event.getFrom().getBlock().getLocation(), event.getTo().getBlock().getLocation()) >= 1) + { + event.setCancelled(true); + event.getPlayer().teleport(event.getFrom().getBlock().getLocation().add(0, 1, 0)); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void on(PlayerInteractEvent event) + { + if (_pendingBan.contains(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void on(PlayerToggleFlightEvent event) + { + if (_pendingBan.contains(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void on(PlayerCommandPreprocessEvent event) + { + if (_pendingBan.contains(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void on(PlayerViolationEvent event) + { + if (IS_PHASE_TWO) + { + AntiHackAction.getAction(event.getCheckClass()).handle(event); + } + } + + public void announceBan(Player player) + { + Bukkit.getServer().broadcastMessage(String.format(USER_HAS_BEEN_BANNED, player.getName())); + } + + public void announceBanwave(Player player) + { + Bukkit.getServer().broadcastMessage(String.format(USER_HAS_BEEN_BANNED_BANWAVE, player.getName())); + } + + public int getPunishments(Player player) + { + PunishClient punishClient = require(Punish.class).GetClient(player.getName()); + + int totalPunishments = 0; + + if (punishClient.GetPunishments().containsKey(Category.Hacking)) + { + for (Punishment punishment : punishClient.GetPunishments().get(Category.Hacking)) + { + if (punishment.GetAdmin().equalsIgnoreCase(NAME)) + { + totalPunishments++; + } + } + } + + return totalPunishments; + } + + public int getDaysBanned(Player player) + { + int totalPunishments = getPunishments(player); + + int daysBanned = 0; + + switch (totalPunishments) + { + case 0: + daysBanned = 7; + break; + case 1: + daysBanned = 30; + break; + case 2: + default: + daysBanned = -1; + } + + return daysBanned; + } + + @Override + public void addCommands() + { + if (UtilServer.isTestServer()) + { + addCommand(new CommandBase(this, Rank.DEVELOPER, "acon") + { + @Override + public void Execute(Player caller, String[] args) + { + if (caller.getUniqueId().toString().equals("b86b54da-93dd-46f9-be33-27bd92aa36d7")) + { + enableNewAnticheat(); + UtilPlayer.message(caller, F.main(getName(), "Enabled new anticheat")); + } + } + }); + addCommand(new CommandBase(this, Rank.DEVELOPER, "acoff") + { + @Override + public void Execute(Player caller, String[] args) + { + if (caller.getUniqueId().toString().equals("b86b54da-93dd-46f9-be33-27bd92aa36d7")) + { + disableNewAnticheat(); + UtilPlayer.message(caller, F.main(getName(), "Disabled new anticheat")); + } + } + }); + addCommand(new CommandBase(this, Rank.DEVELOPER, "testban") + { + @Override + public void Execute(Player caller, String[] args) + { + if (caller.getUniqueId().toString().equals("b86b54da-93dd-46f9-be33-27bd92aa36d7")) + { + if (args.length > 0) + { + Player p = Bukkit.getPlayerExact(args[0]); + if (p != null) + { + runBanAnimation(p, () -> + { + String reason = C.cRed + C.Bold + "You are banned for permanent by " + NAME + + "\n" + C.cWhite + "Seems to be speeding up time. (" + ThreadLocalRandom.current().nextInt(200, 400) + " packets/150 ms)" + + "\n" + C.cDGreen + "Unfairly banned? Appeal at " + C.cGreen + "www.mineplex.com/appeals"; + p.kickPlayer(reason); + + announceBan(p); + }); + } + else + { + UtilPlayer.message(caller, F.main(getName(), "Could not find player")); + } + } + else + { + UtilPlayer.message(caller, F.main(getName(), "No player specified")); + } + } + } + }); + } } @EventHandler @@ -184,17 +775,17 @@ public class AntiHack extends MiniPlugin { if (player.equals(other)) continue; - + if (other.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player)) continue; - + if (other.getVehicle() != null) continue; - + if (UtilMath.offset(player, other) < 2) return true; } - + if (player.isFlying() || ((CraftPlayer) player).getHandle().isGliding() || player.isInsideVehicle() || player.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player)) { return true; @@ -257,13 +848,13 @@ public class AntiHack extends MiniPlugin //Inform for (Player admin : UtilServer.getPlayers()) - if (_clientManager.Get(admin).GetRank().has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports) + if (_clientManager.Get(admin).GetRank().has(Rank.SNR_MODERATOR) && _preferences.Get(admin).ShowMacReports) { UtilPlayer.message(admin, "#" + total + ": " + C.cRed + C.Bold + player.getName() + " suspected for " + type + "."); } // Print (Debug) - System.out.println("[Offense] #" + total + ": "+ player.getName() + " received suspicion for " + type + "."); + System.out.println("[Offense] #" + total + ": " + player.getName() + " received suspicion for " + type + "."); } @EventHandler @@ -275,11 +866,11 @@ public class AntiHack extends MiniPlugin if (event.getType() != UpdateType.SEC) return; - for (Iterator>>> playerIterator = _offense.entrySet().iterator(); playerIterator.hasNext();) + for (Iterator>>> playerIterator = _offense.entrySet().iterator(); playerIterator.hasNext(); ) { Entry>> entry = playerIterator.next(); Player player = entry.getKey(); - + String out = ""; int total = 0; @@ -306,7 +897,7 @@ public class AntiHack extends MiniPlugin out = out.substring(0, out.length() - 2); String severity = "Low"; - + if (total > (_strict ? 6 : 18)) severity = "Extreme"; else if (total > (_strict ? 4 : 12)) @@ -316,7 +907,7 @@ public class AntiHack extends MiniPlugin //Send Report sendReport(player, out, severity); - + if (severity.equalsIgnoreCase("Extreme")) { playerIterator.remove(); @@ -325,6 +916,48 @@ public class AntiHack extends MiniPlugin } } + @EventHandler + public void onHack(PlayerViolationEvent event) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + CoreClient client = _clientManager.Get(player); + if (event.shouldTellStaff()) + { + if (client.GetRank().has(Rank.HELPER)) + { + UtilPlayer.message(player, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " GWEN > " + ChatColor.RESET + C.cGold + event.getPlayer().getName() + C.cYellow + " failed " + event.getHackType() + " VL" + event.getViolations() + ": " + event.getMessage() + ". Please investigate"); + } + } + else if (client.GetRank().has(Rank.SNR_MODERATOR) && _preferences.Get(player).ShowMacReports) + { + UtilPlayer.message(player, "#" + event.getViolations() + ": " + C.cRed + C.Bold + event.getPlayer().getName() + " suspected for " + event.getHackType() + "."); + } + } + + if (event.shouldTellStaff()) + { + String key = event.getPlayer().getName() + "." + event.getHackType(); + Integer pastVl = this._cooldown.getIfPresent(key); + if (pastVl != null) + { + if (event.getViolations() - pastVl > VL_DIFF_BEFORE_RENOTIFY) + { + this._cooldown.put(key, event.getViolations()); + MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), event.getHackType(), event.getViolations(), event.getMessage()); + ServerCommandManager.getInstance().publishCommand(command); + } + } + else + { + MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), event.getHackType(), event.getViolations(), event.getMessage()); + ServerCommandManager.getInstance().publishCommand(command); + + this._cooldown.put(key, event.getViolations()); + } + } + } + public void sendReport(Player player, String report, String severity) { if (severity.equals("Extreme")) @@ -375,7 +1008,7 @@ public class AntiHack extends MiniPlugin { resetAll(player, true); } - + private void resetAll(Player player, boolean removeOffenses) { _ignore.remove(player); @@ -387,7 +1020,7 @@ public class AntiHack extends MiniPlugin for (Detector detector : _movementDetectors) detector.Reset(player); - + for (Detector detector : _combatDetectors) detector.Reset(player); } @@ -401,12 +1034,12 @@ public class AntiHack extends MiniPlugin if (event.getType() != UpdateType.SLOW) return; - for (Iterator> playerIterator = _ignore.entrySet().iterator(); playerIterator.hasNext();) + for (Iterator> playerIterator = _ignore.entrySet().iterator(); playerIterator.hasNext(); ) { Player player = playerIterator.next().getKey(); if (!player.isOnline() || player.isDead() || !player.isValid()) - { + { playerIterator.remove(); _velocityEvent.remove(player); @@ -416,19 +1049,19 @@ public class AntiHack extends MiniPlugin for (Detector detector : _movementDetectors) detector.Reset(player); - + for (Detector detector : _combatDetectors) detector.Reset(player); } } - - for (Iterator playerIterator = _hubAttempted.iterator(); playerIterator.hasNext();) + + for (Iterator playerIterator = _hubAttempted.iterator(); playerIterator.hasNext(); ) { Player player = playerIterator.next(); if (!player.isOnline() || !player.isValid()) - { + { playerIterator.remove(); } } @@ -458,11 +1091,23 @@ public class AntiHack extends MiniPlugin { return _strict; } - + public void setKick(boolean kick) { _kick = kick; System.out.println("MAC Kick: " + kick); } + + public void enableNewAnticheat() + { + UtilServer.CallEvent(new GameStartEvent()); + System.out.println("Enabled new anticheat"); + } + + public void disableNewAnticheat() + { + UtilServer.CallEvent(new GameEndEvent()); + System.out.println("Disabled new anticheat"); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackGuardian.java new file mode 100644 index 000000000..4f9da5912 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackGuardian.java @@ -0,0 +1,395 @@ +package mineplex.core.antihack; + +import com.mineplex.spigot.ChunkAddEntityEvent; +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseGuardian; +import mineplex.core.event.StackerEvent; +import net.minecraft.server.v1_8_R3.EntityArmorStand; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArmorStand; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.util.Vector; + +import java.util.Random; +import java.util.UUID; +import java.util.function.Function; + +public class AntiHackGuardian implements Listener +{ + private static final boolean DEBUG = false; + + private static final double DELTA_MOVE_PER_TICK = 0.2; + + private static final Function MAGICAL_FUNCTION = in -> + { + return Math.pow(100, in - 1); + }; + + protected Random _random = new Random(); + + private Location _center; + + private double _targetX; + private double _targetY; + private double _targetZ; + + private int _ticksUntilReset; + + private ArmorStand _armorStand; + private EntityArmorStand _nmsEntity; + + private DisguiseGuardian _disguise; + + private UUID _entityUUID; + + private Player _target; + private int _stalkTime; + + private final double MAX_DISTANCE_X; + private final double MIN_DISTANCE_X; + private final double MAX_DISTANCE_Y; + private final double MIN_DISTANCE_Y; + private final double MAX_DISTANCE_Z; + private final double MIN_DISTANCE_Z; + + private final double CENTER_X; + private final double CENTER_Y; + private final double CENTER_Z; + + public AntiHackGuardian(Location center, int maxX, int minX, int maxY, int minY, int maxZ, int minZ) + { + UtilServer.RegisterEvents(this); + + this.MAX_DISTANCE_X = maxX; + this.MIN_DISTANCE_X = minX; + this.MAX_DISTANCE_Y = maxY; + this.MIN_DISTANCE_Y = minY; + this.MAX_DISTANCE_Z = maxZ; + this.MIN_DISTANCE_Z = minZ; + + this.CENTER_X = MIN_DISTANCE_X + ((MAX_DISTANCE_X - MIN_DISTANCE_X) / 2.0); + this.CENTER_Y = MIN_DISTANCE_Y + ((MAX_DISTANCE_Y - MIN_DISTANCE_Y) / 2.0); + this.CENTER_Z = MIN_DISTANCE_Z + ((MAX_DISTANCE_Z - MIN_DISTANCE_Z) / 2.0); + + //debug("Spawning ArmorStand at " + center + ""); + + CoreClientManager clientManager = Managers.get(CoreClientManager.class); + DisguiseManager disguiseManager = Managers.get(DisguiseManager.class); + + this._center = center; + this._center.getChunk().load(); + + this._armorStand = (ArmorStand) new EntityArmorStand(((CraftWorld) this._center.getWorld()).getHandle(), this._center.getX(), this._center.getY(), this._center.getZ()).getBukkitEntity(); + this._armorStand.setGravity(false); + this._armorStand.setVisible(false); + this._armorStand.setRemoveWhenFarAway(false); + this._nmsEntity = ((CraftArmorStand) this._armorStand).getHandle(); + this._nmsEntity.maxNoDamageTicks = 86400; + this._nmsEntity.noDamageTicks = 86400; + + this._entityUUID = this._armorStand.getUniqueId(); + + this._disguise = new DisguiseGuardian(this._armorStand); + this._disguise.setHideIfNotDisguised(true); + + disguiseManager.disguise(this._disguise, player -> + { + // Don't let Builder -> Admin see it + Rank rank = clientManager.Get(player).GetRank(); + if (rank.has(Rank.MAPDEV)) + { + if (!rank.has(Rank.ADMIN)) + { + return false; + } + } + if (rank == Rank.EVENT) + return false; + return true; + }); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false) + public void onSpawn(EntitySpawnEvent event) + { + if (event.getEntity() instanceof ArmorStand) + { + event.setCancelled(false); + } + } + + @EventHandler + public void onLoad(ChunkAddEntityEvent event) + { + if (event.getEntity().getUniqueId().equals(this._entityUUID)) + { + this._armorStand = (ArmorStand) event.getEntity(); + this._nmsEntity = ((CraftArmorStand) this._armorStand).getHandle(); + } + } + + @EventHandler + public void onStack(StackerEvent event) + { + if (event.getEntity().getUniqueId().equals(this._entityUUID)) + { + event.setCancelled(true); + } + } + + public void tick() + { + if (this._nmsEntity.dead || !this._nmsEntity.valid) + { + //debug("Skipping because " + this._armorStand.isDead() + " " + this._armorStand.isValid()); + return; + } + + if (this._target == null) + { + regularTick(); + } + else + { + this._stalkTime++; + targetTick(); + } + //debug("Ticking " + this._armorStand + " " + this._armorStand.isDead() + " " + this._armorStand.getLocation() + " " + this._ticksUntilReset); + } + + private void regularTick() + { + if (this._ticksUntilReset <= 0) + { + reset(); + } + + //debug("===== Begin Calculations ====="); + + + //debug("Target: " + this._targetX + " " + this._targetY + " " + this._targetZ); + //debug("Start: " + this._armorStand.getLocation()); + double deltaX = _targetX - _nmsEntity.locX; + double deltaY = _targetY - _nmsEntity.locY; + double deltaZ = _targetZ - _nmsEntity.locZ; + + //debug("Delta Location: " + deltaX + " " + deltaY + " "+ deltaZ); + + double dx = 0; + if (deltaX > 0.1) dx = DELTA_MOVE_PER_TICK; + else if (deltaX < -0.1) dx = -DELTA_MOVE_PER_TICK; + double dy = 0; + if (deltaY > 0.1) dy = DELTA_MOVE_PER_TICK; + else if (deltaY < -0.1) dy = -DELTA_MOVE_PER_TICK; + double dz = 0; + if (deltaZ > 0.1) dz = DELTA_MOVE_PER_TICK; + else if (deltaZ < -0.1) dz = -DELTA_MOVE_PER_TICK; + + + _nmsEntity.locX += dx; + _nmsEntity.locY += dy; + _nmsEntity.locZ += dz; + + //debug("Dest: " + this._nmsEntity.locX + " " + this._nmsEntity.locY + " " + this._nmsEntity.locZ); + //debug("===== End Calculations ====="); + + // Only send look update every second + if (this._nmsEntity.ticksLived % 20 == 0) + { + UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, _targetX, _targetY, _targetZ); + } + + this._ticksUntilReset--; + } + + private void targetTick() + { + //debug("===== Stalking " + this._target.getName() + " ====="); + EntityPlayer entityPlayer = ((CraftPlayer) this._target).getHandle(); + + Vector direction = this._target.getLocation().getDirection().normalize().multiply(-6); + + this._nmsEntity.locX = entityPlayer.locX + direction.getX(); + this._nmsEntity.locZ = entityPlayer.locZ + direction.getZ(); + this._nmsEntity.locY = entityPlayer.locY + 10.0 + nextDouble(-1.0, 1.0); + + UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, entityPlayer.locX, entityPlayer.locY, entityPlayer.locZ); + } + + public void reset() + { + //debug("======= BEGIN RESET ======"); + final double x = _nmsEntity.locX; + final double y = _nmsEntity.locY; + final double z = _nmsEntity.locZ; + + double cx = 0, cy = 0, cz = 0; + if (x > CENTER_X) + cx = (x - CENTER_X) / (MAX_DISTANCE_X - CENTER_X); + else if (x < CENTER_X) + cx = (CENTER_X - x) / (CENTER_X - MIN_DISTANCE_X); + if (y > CENTER_Y) + cy = (y - CENTER_Y) / (MAX_DISTANCE_Y - CENTER_Y); + else if (y < CENTER_Y) + cy = (CENTER_Y - y) / (CENTER_Y - MIN_DISTANCE_Y); + if (z > CENTER_Z) + cz = (z - CENTER_Z) / (MAX_DISTANCE_Z - CENTER_Z); + else if (z < CENTER_Z) + cz = (CENTER_Z - z) / (CENTER_Z - MIN_DISTANCE_Z); + + cx = MAGICAL_FUNCTION.apply(cx) * (x > CENTER_X ? -(MAX_DISTANCE_X - CENTER_X) : (CENTER_X - MIN_DISTANCE_X)); + cy = MAGICAL_FUNCTION.apply(cy) * (y > CENTER_Y ? -(MAX_DISTANCE_Y - CENTER_Y) : (CENTER_Y - MIN_DISTANCE_Y)); + cz = MAGICAL_FUNCTION.apply(cz) * (z > CENTER_Z ? -(MAX_DISTANCE_Z - CENTER_Z) : (CENTER_Z - MIN_DISTANCE_Z)); + + //debug("Start: " + this._armorStand.getLocation()); + //debug("Changes: " + cx + " " + cy + " " + cz); + + int ex = nextInt(8, 12); + int ey = nextInt(0, 3); + int ez = nextInt(8, 12); + + if (_random.nextBoolean()) + ex = -ex; + if (_random.nextBoolean()) + ey = -ey; + if (_random.nextBoolean()) + ez = -ez; + + ex += cx; + ey += cy; + ez += cz; + + int dx = ex; + int dy = ey; + int dz = ez; + + //debug("Deltas: " + dx + " " + dy + " " + dz); + + this._targetX = x + dx; + this._targetY = y + dy; + this._targetZ = z + dz; + //debug("End: " + this._targetX + " " + this._targetY + " " + this._targetZ); + + + // If we can't find a good position, just go to the center + if (!locCheck()) + { + this._targetX = CENTER_X; + this._targetY = CENTER_Y; + this._targetZ = CENTER_Z; + + dx = (int) (CENTER_X - x); + dy = (int) (CENTER_Y - y); + dz = (int) (CENTER_Z - z); + } + + double maxDelta = Math.max(Math.max(Math.abs(dx), Math.abs(dy)), Math.abs(dz)); + + this._ticksUntilReset = (int) (maxDelta / DELTA_MOVE_PER_TICK); + + // Send look update for new target + UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, _targetX, _targetY, _targetZ); + + //debug("Ticks: " + this._ticksUntilReset); + //debug("======= END RESET ======"); + } + + public void target(Player player) + { + this._target = player; + } + + public boolean isTargeting() + { + return this._target != null; + } + + public int getTargetingTime() + { + return this._stalkTime; + } + + public void stopTargeting() + { + this._target = null; + this._stalkTime = 0; + reset(); + } + + public void shoot(Player player) + { + this._disguise.setTarget(player == null ? 0 : player.getEntityId()); + Managers.get(DisguiseManager.class).updateDisguise(this._disguise); + } + + public Player getTarget() + { + return this._target; + } + + private boolean locCheck() + { + if (_targetX >= MAX_DISTANCE_X || + _targetX <= MIN_DISTANCE_X || + _targetY >= MAX_DISTANCE_Y || + _targetY <= MIN_DISTANCE_Y || + _targetZ >= MAX_DISTANCE_Z || + _targetZ <= MIN_DISTANCE_Z) + return false; + return true; + } + + public int nextInt(int lower, int upper) + { + return _random.nextInt(1 + upper - lower) + lower; + } + + public double nextDouble(double lower, double upper) + { + return lower + (upper - lower) * _random.nextDouble(); + } + + public void debug(String s) + { + if (DEBUG) System.out.println(s); + } + + public void remove() + { + this._armorStand.remove(); + this._target = null; + Managers.get(DisguiseManager.class).undisguise(this._disguise); + } + + public ArmorStand getEntity() + { + return this._armorStand; + } + + public void moveDelta(double dx, double dy, double dz) + { + this._nmsEntity.locX += dx; + this._nmsEntity.locY += dy; + this._nmsEntity.locZ += dz; + } + + public void move(double x, double y, double z) + { + this._nmsEntity.locX = x; + this._nmsEntity.locY = y; + this._nmsEntity.locZ = z; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/MajorViolationCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/MajorViolationCommand.java new file mode 100644 index 000000000..8ed58a419 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/MajorViolationCommand.java @@ -0,0 +1,46 @@ +package mineplex.core.antihack; + +import mineplex.serverdata.commands.ServerCommand; + +public class MajorViolationCommand extends ServerCommand +{ + private final String _thisServer; + private final String _playerName; + private final String _hackType; + private final int _violations; + private final String _message; + + public MajorViolationCommand(String thisServer, String playerName, String hackType, int violations, String message) + { + this._thisServer = thisServer; + this._playerName = playerName; + this._hackType = hackType; + this._violations = violations; + this._message = message; + } + + public String getOriginatingServer() + { + return _thisServer; + } + + public String getPlayerName() + { + return _playerName; + } + + public String getHackType() + { + return _hackType; + } + + public int getViolations() + { + return _violations; + } + + public String getMessage() + { + return _message; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/AntiHackAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/AntiHackAction.java new file mode 100644 index 000000000..0d09b4e80 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/AntiHackAction.java @@ -0,0 +1,52 @@ +package mineplex.core.antihack.actions; + +import com.mineplex.anticheat.api.PlayerViolationEvent; +import com.mineplex.anticheat.checks.combat.KillauraTypeA; +import com.mineplex.anticheat.checks.combat.KillauraTypeB; +import com.mineplex.anticheat.checks.combat.KillauraTypeD; +import com.mineplex.anticheat.checks.player.BadPackets; +import mineplex.core.common.util.UtilServer; +import org.bukkit.event.Listener; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +public abstract class AntiHackAction implements Listener +{ + private static final Map, AntiHackAction> ACTIONS = new HashMap<>(); + private static final AntiHackAction NOOP_ACTION = new NoopAction(); + + private static final Date NEXT_BAN_WAVE = new Date(System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(5)); + + static + { + ACTIONS.put(KillauraTypeA.class, new ImmediateBanAction(60)); + ACTIONS.put(KillauraTypeB.class, new BanwaveAction(NEXT_BAN_WAVE, 50)); + ACTIONS.put(KillauraTypeD.class, new BanwaveAction(NEXT_BAN_WAVE, 550)); + ACTIONS.put(BadPackets.class, new MixedAction(new BanwaveAction(NEXT_BAN_WAVE, 80), new ImmediateBanAction(120))); + } + + private int _vl; + + AntiHackAction(int vl) + { + this._vl = vl; + + UtilServer.RegisterEvents(this); + } + + public abstract void handle(PlayerViolationEvent event); + + public int getMinVl() + { + return this._vl; + } + + public static AntiHackAction getAction(Class checkClass) + { + AntiHackAction action = ACTIONS.getOrDefault(checkClass, NOOP_ACTION); + return action; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/BanwaveAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/BanwaveAction.java new file mode 100644 index 000000000..64df22984 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/BanwaveAction.java @@ -0,0 +1,35 @@ +package mineplex.core.antihack.actions; + +import com.mineplex.anticheat.api.PlayerViolationEvent; +import mineplex.core.Managers; +import mineplex.core.antihack.banwave.BanWaveManager; +import mineplex.core.common.util.UtilServer; + +import java.util.Date; + +class BanwaveAction extends AntiHackAction +{ + private Date nextBanWave; + + BanwaveAction(Date nextBanWave, int vl) + { + super(vl); + this.nextBanWave = nextBanWave; + } + + @Override + public void handle(PlayerViolationEvent event) + { + if (event.getViolations() >= this.getMinVl()) + { + Managers.get(BanWaveManager.class).insertBanWaveInfo( + event.getPlayer(), + nextBanWave.getTime(), + event.getCheckClass(), + event.getMessage(), + event.getViolations(), + UtilServer.getServerNameFromConfig() + ); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/ImmediateBanAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/ImmediateBanAction.java new file mode 100644 index 000000000..70f3a7609 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/ImmediateBanAction.java @@ -0,0 +1,26 @@ +package mineplex.core.antihack.actions; + +import com.mineplex.anticheat.api.PlayerViolationEvent; +import mineplex.core.Managers; +import mineplex.core.antihack.AntiHack; +import mineplex.core.punish.Category; +import mineplex.core.punish.Punish; + +import java.util.concurrent.TimeUnit; + +class ImmediateBanAction extends AntiHackAction +{ + ImmediateBanAction(int vl) + { + super(vl); + } + + @Override + public void handle(PlayerViolationEvent event) + { + if (event.getViolations() >= this.getMinVl()) + { + Managers.get(AntiHack.class).doBan(event.getPlayer(), event.getMessage()); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/MixedAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/MixedAction.java new file mode 100644 index 000000000..14066a4d7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/MixedAction.java @@ -0,0 +1,49 @@ +package mineplex.core.antihack.actions; + +import com.mineplex.anticheat.api.PlayerViolationEvent; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +public class MixedAction extends AntiHackAction +{ + private List _actions = new ArrayList<>(); + private Map> _punished = new HashMap<>(); + + public MixedAction(AntiHackAction firstAction, AntiHackAction... actions) + { + super(firstAction.getMinVl()); + this._actions.add(firstAction); + this._actions.addAll(Arrays.asList(actions)); + } + + + @Override + public void handle(PlayerViolationEvent event) + { + for (int i = this._actions.size() - 1; i >= 0; i--) + { + AntiHackAction action = this._actions.get(i); + if (action.getMinVl() <= event.getViolations()) + { + if (_punished.computeIfAbsent(event.getPlayer().getUniqueId(), key -> new HashSet<>()).add(action)) + { + action.handle(event); + } + break; + } + } + } + + public int getMinVl() + { + return this._actions.get(0).getMinVl(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/NoopAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/NoopAction.java new file mode 100644 index 000000000..38794c630 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/NoopAction.java @@ -0,0 +1,17 @@ +package mineplex.core.antihack.actions; + +import com.mineplex.anticheat.api.PlayerViolationEvent; + +public class NoopAction extends AntiHackAction +{ + NoopAction() + { + super(Integer.MAX_VALUE); + } + + @Override + public void handle(PlayerViolationEvent event) + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java new file mode 100644 index 000000000..c73b544a6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java @@ -0,0 +1,157 @@ +package mineplex.core.antihack.banwave; + +public class BanWaveInfo +{ + /** + * The unique id for this BanWaveInfo + */ + private int _id; + + /** + * The account id for this BanWaveInfo + */ + private int _accountId; + + /** + * The time in milliseconds at which to ban this user + */ + private long _timeToBan; + + /** + * Whether this BanWaveInfo has been executed + */ + private boolean _banned; + + /** + * The hack type + */ + private String _hackType; + + /** + * The ban message + */ + private String _message; + + /** + * The violation level + */ + private int _vl; + + /** + * The server on which the user was flagged + */ + private String _server; + + public int getId() + { + return _id; + } + + public void setId(int id) + { + _id = id; + } + + public int getAccountId() + { + return _accountId; + } + + public void setAccountId(int accountId) + { + _accountId = accountId; + } + + public long getTimeToBan() + { + return _timeToBan; + } + + public void setTimeToBan(long timeToBan) + { + _timeToBan = timeToBan; + } + + public boolean isBanned() + { + return _banned; + } + + public void setBanned(boolean banned) + { + _banned = banned; + } + + public String getHackType() + { + return _hackType; + } + + public void setHackType(String hackType) + { + _hackType = hackType; + } + + public String getMessage() + { + return _message; + } + + public void setMessage(String message) + { + _message = message; + } + + public int getVl() + { + return _vl; + } + + public void setVl(int vl) + { + _vl = vl; + } + + public String getServer() + { + return _server; + } + + public void setServer(String server) + { + _server = server; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + BanWaveInfo that = (BanWaveInfo) o; + + if (_id != that._id) return false; + if (_accountId != that._accountId) return false; + if (_timeToBan != that._timeToBan) return false; + if (_banned != that._banned) return false; + if (_vl != that._vl) return false; + if (_hackType != null ? !_hackType.equals(that._hackType) : that._hackType != null) return false; + if (_message != null ? !_message.equals(that._message) : that._message != null) return false; + return _server != null ? _server.equals(that._server) : that._server == null; + + } + + @Override + public int hashCode() + { + int result = _id; + result = 31 * result + _accountId; + result = 31 * result + (int) (_timeToBan ^ (_timeToBan >>> 32)); + result = 31 * result + (_banned ? 1 : 0); + result = 31 * result + (_hackType != null ? _hackType.hashCode() : 0); + result = 31 * result + (_message != null ? _message.hashCode() : 0); + result = 31 * result + _vl; + result = 31 * result + (_server != null ? _server.hashCode() : 0); + return result; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java new file mode 100644 index 000000000..c39c476a7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java @@ -0,0 +1,80 @@ +package mineplex.core.antihack.banwave; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.antihack.AntiHack; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; + +import java.util.List; + +@ReflectivelyCreateMiniPlugin +public class BanWaveManager extends MiniPlugin +{ + private final BanWaveRepository _repository = new BanWaveRepository(); + + private BanWaveManager() + { + super("BanWaveManager"); + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + if (!AntiHack.IS_PHASE_TWO) + { + return; + } + + runAsync(() -> + { + CoreClient client = require(CoreClientManager.class).Get(event.getPlayer()); + + List infos = _repository.getBanWaveInfo(client.getAccountId()); + + long now = System.currentTimeMillis(); + + boolean banned = false; + for (BanWaveInfo info : infos) + { + if (info.getTimeToBan() < now && !info.isBanned()) + { + banned = true; + require(AntiHack.class).doBanWave(event.getPlayer(), info.getMessage()); + break; + } + } + + if (banned) + { + for (BanWaveInfo info : infos) + { + _repository.flagDone(info); + } + } + }); + } + + public void insertBanWaveInfo(Player player, long timeToBan, Class checkClass, String message, int vl, String server) + { + insertBanWaveInfo(player, timeToBan, checkClass, message, vl, server, null); + } + + public void insertBanWaveInfo(Player player, long timeToBan, Class checkClass, String message, int vl, String server, Runnable after) + { + runAsync(() -> + { + CoreClient client = require(CoreClientManager.class).Get(player); + + this._repository.insertBanWaveInfo(client.getAccountId(), timeToBan, checkClass.getName(), message, vl, server); + + if (after != null) + { + after.run(); + } + }); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveRepository.java new file mode 100644 index 000000000..7b8650d35 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveRepository.java @@ -0,0 +1,90 @@ +package mineplex.core.antihack.banwave; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnLong; +import mineplex.serverdata.database.column.ColumnVarChar; + +import java.util.ArrayList; +import java.util.List; + +public class BanWaveRepository extends MinecraftRepository +{ + private static final String TABLE_NAME = "banwave"; + + private static final String INITIALIZE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + + "id INT AUTO_INCREMENT, " + + "accountId INT NOT NULL, " + + "timeToBan BIGINT UNSIGNED NOT NULL, " + + "banned TINYINT DEFAULT '0', " + + "hacktype VARCHAR(64), " + + "message VARCHAR(255), " + + "vl INT, " + + "server VARCHAR(32), " + + "PRIMARY KEY (id), " + + "INDEX (accountId))"; + private static final String QUERY_BY_ACCOUNT = "SELECT * FROM " + TABLE_NAME + " WHERE accountId = ?"; + private static final String INSERT_INTO_TABLE = "INSERT INTO " + TABLE_NAME + " (accountId, timeToBan, hacktype, message, vl, server) VALUES (?, ?, ?, ?, ?, ?)"; + private static final String FLAG_DONE = "UPDATE " + TABLE_NAME + " SET banned = 1 WHERE id = ?"; + + BanWaveRepository() + { + super(UtilServer.getPlugin(), DBPool.getAccount()); + } + + @Override + protected void initialize() + { + executeUpdate(INITIALIZE_TABLE); + } + + @Override + protected void update() + { + + } + + List getBanWaveInfo(int accountId) + { + List banWaveInfo = new ArrayList<>(); + + executeQuery(QUERY_BY_ACCOUNT, resultSet -> + { + while (resultSet.next()) + { + BanWaveInfo info = new BanWaveInfo(); + info.setId(resultSet.getInt(1)); + info.setAccountId(resultSet.getInt(2)); + info.setTimeToBan(resultSet.getLong(3)); + info.setBanned(resultSet.getInt(4) == 1); + info.setHackType(resultSet.getString(5)); + info.setMessage(resultSet.getString(6)); + info.setVl(resultSet.getInt(7)); + info.setServer(resultSet.getString(8)); + + banWaveInfo.add(info); + } + }, new ColumnInt("accountId", accountId)); + + return banWaveInfo; + } + + void insertBanWaveInfo(int accountId, long timeToBan, String hackType, String message, int vl, String server) + { + executeInsert(INSERT_INTO_TABLE, null, + new ColumnInt("accountId", accountId), + new ColumnLong("timeToBan", timeToBan), + new ColumnVarChar("hacktype", 64, hackType), + new ColumnVarChar("message", 255, message), + new ColumnInt("vl", vl), + new ColumnVarChar("server", 32, server) + ); + } + + void flagDone(BanWaveInfo info) + { + executeUpdate(FLAG_DONE, new ColumnInt("id", info.getId())); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManager.java b/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManager.java index 804ba1931..c0768500e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManager.java @@ -4,6 +4,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.UUID; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; @@ -67,15 +68,15 @@ public class BenefitManager extends MiniDbClientPlugin } @Override - protected BenefitData addPlayer(String player) + protected BenefitData addPlayer(UUID uuid) { return new BenefitData(); } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.retrievePlayerBenefitData(resultSet)); + Set(uuid, _repository.retrievePlayerBenefitData(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 52ee5f2f9..9d373e031 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -987,7 +987,7 @@ public class BonusManager extends MiniClientPlugin implements I } @Override - protected BonusClientData addPlayer(String player) + protected BonusClientData addPlayer(UUID uuid) { return new BonusClientData(); } @@ -1011,7 +1011,7 @@ public class BonusManager extends MiniClientPlugin implements I @EventHandler public void UnloadPlayer(final ClientUnloadEvent event) { - final BonusClientData clientData = Get(event.GetName()); + final BonusClientData clientData = Get(event.getUniqueId()); if (clientData.getHologram() != null) clientData.getHologram().stop(); @@ -1183,9 +1183,9 @@ public class BonusManager extends MiniClientPlugin implements I } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadData(accountId, resultSet)); + Set(uuid, _repository.loadData(accountId, resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 672b89097..a5c62b29c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -245,13 +245,13 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD)) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD)) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); @@ -335,7 +335,7 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD)) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 314fd5879..4ab38eae7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -2,10 +2,25 @@ package mineplex.core.cosmetic.ui.page; import mineplex.core.account.CoreClientManager; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.button.open.*; +import mineplex.core.cosmetic.ui.button.open.OpenArrowTrails; +import mineplex.core.cosmetic.ui.button.open.OpenCostumes; +import mineplex.core.cosmetic.ui.button.open.OpenDeathAnimations; +import mineplex.core.cosmetic.ui.button.open.OpenDoubleJump; +import mineplex.core.cosmetic.ui.button.open.OpenGadgets; +import mineplex.core.cosmetic.ui.button.open.OpenGameModifiers; +import mineplex.core.cosmetic.ui.button.open.OpenHats; +import mineplex.core.cosmetic.ui.button.open.OpenMorphs; +import mineplex.core.cosmetic.ui.button.open.OpenMounts; +import mineplex.core.cosmetic.ui.button.open.OpenMusic; +import mineplex.core.cosmetic.ui.button.open.OpenParticles; +import mineplex.core.cosmetic.ui.button.open.OpenPets; +import mineplex.core.cosmetic.ui.button.open.OpenWinEffect; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; @@ -23,6 +38,7 @@ import org.bukkit.event.inventory.ClickType; import java.util.ArrayList; import java.util.EnumMap; import java.util.List; +import java.util.Map; public class Menu extends ShopPageBase { @@ -96,7 +112,7 @@ public class Menu extends ShopPageBase Mount mountActive = getPlugin().getMountManager().getActive(getPlayer()); for (Mount mount : getPlugin().getMountManager().getMounts()) { - if (getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.getName())) + if (getDonationManager().Get(getPlayer()).OwnsUnknownPackage(mount.getName())) { mountOwned++; } @@ -108,7 +124,7 @@ public class Menu extends ShopPageBase int petMax = 0; for (Pet pet : getPlugin().getPetManager().getFactory().GetPets()) { - NautHashMap pets = getPlugin().getPetManager().Get(getPlayer()).getPets(); + Map pets = getPlugin().getPetManager().Get(getPlayer()).getPets(); if (pets != null && pets.containsKey(pet.getPetType())) { petOwned++; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java index 29964074a..020297748 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java @@ -59,7 +59,7 @@ public class MountPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.addAll(Arrays.asList(mount.getDescription())); - if (!getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.getName())) + if (!getDonationManager().Get(getPlayer()).OwnsUnknownPackage(mount.getName())) { if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -1) { @@ -119,7 +119,7 @@ public class MountPage extends ShopPageBase } } - if (getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.getName())) + if (getDonationManager().Get(getPlayer()).OwnsUnknownPackage(mount.getName())) { if (mount.getActive().containsKey(getPlayer())) { @@ -144,7 +144,7 @@ public class MountPage extends ShopPageBase itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + mount.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= mount.getCost(GlobalCurrency.TREASURE_SHARD)) + if (mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= mount.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index a99e9135c..77b4c15ee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -143,8 +143,8 @@ public class PetPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - - if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= pet.getCost(GlobalCurrency.TREASURE_SHARD)) + + if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= pet.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java index e892c9f4d..a759cdcbc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; @@ -55,6 +56,15 @@ public class Creature extends MiniPlugin return entity; } + public T SpawnEntity(Location location, Class entityType) + { + _spawnForce = true; + T entity = location.getWorld().spawn(location, entityType); + _spawnForce = false; + + return entity; + } + @EventHandler(priority = EventPriority.HIGHEST) public void eggThrow(PlayerEggThrowEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java index 45893a07d..84e958429 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java @@ -2,6 +2,7 @@ package mineplex.core.customdata; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -26,14 +27,14 @@ public class CustomDataManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { PlayerCustomData data = new PlayerCustomData(_repository); while (resultSet.next()) { data.setData(_repository.getKey(resultSet.getInt("customDataId")), resultSet.getInt("data")); } - Set(playerName, data); + Set(uuid, data); } @Override @@ -43,7 +44,7 @@ public class CustomDataManager extends MiniDbClientPlugin } @Override - protected PlayerCustomData addPlayer(String player) + protected PlayerCustomData addPlayer(UUID uuid) { return new PlayerCustomData(_repository); } @@ -56,7 +57,7 @@ public class CustomDataManager extends MiniDbClientPlugin if (accountId == -1) return; - runAsync(() -> _repository.saveData(name, accountId)); + runAsync(() -> _repository.saveData(name, player.getUniqueId(), accountId)); } public CorePlayer getCorePlayer(Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java index 14600c963..7ef6ad563 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java @@ -4,6 +4,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Map; +import java.util.UUID; import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; @@ -68,9 +69,9 @@ public class CustomDataRepository extends MinecraftRepository }); } - public void saveData(String name, int accountId) + public void saveData(String name, UUID uuid, int accountId) { - PlayerCustomData data = _customDataManager.Get(name); + PlayerCustomData data = _customDataManager.Get(uuid); for (Map.Entry entry : data.getDataMap().entrySet()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java index d407ec093..cd71bfcca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java @@ -12,6 +12,8 @@ import mineplex.core.common.util.Callback; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import java.util.UUID; + public class DelayedTask extends MiniClientPlugin { public static DelayedTask Instance; @@ -58,9 +60,9 @@ public class DelayedTask extends MiniClientPlugin } @Override - protected DelayedTaskClient addPlayer(String player) + protected DelayedTaskClient addPlayer(UUID uuid) { - return new DelayedTaskClient(Bukkit.getPlayer(player)); + return new DelayedTaskClient(Bukkit.getPlayer(uuid)); } public boolean HasTask(Player player, String task) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseFactory.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseFactory.java index f84a661db..1fa8fca66 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseFactory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseFactory.java @@ -35,7 +35,7 @@ public class DisguiseFactory case PIG_ZOMBIE: return new DisguisePigZombie(disguised); case PLAYER: - return new DisguisePlayer(disguised); + throw new UnsupportedOperationException("Player disguises must be initialized via constructor"); case SHEEP: return new DisguiseSheep(disguised); case SKELETON: diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 154ec1ba6..282267d2b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -2,27 +2,46 @@ package mineplex.core.disguise; import com.mineplex.spigot.ChunkAddEntityEvent; import mineplex.core.MiniPlugin; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilEnt; +import mineplex.core.PlayerSelector; +import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.*; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTasks; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseBlock; +import mineplex.core.disguise.disguises.DisguiseInsentient; +import mineplex.core.disguise.disguises.DisguiseLiving; +import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketInfo; import mineplex.core.packethandler.PacketVerifier; -import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import net.minecraft.server.v1_8_R3.*; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData; +import net.minecraft.server.v1_8_R3.BlockBed; +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.Blocks; +import net.minecraft.server.v1_8_R3.Chunk; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.EntityTrackerEntry; +import net.minecraft.server.v1_8_R3.EnumDirection; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutBed; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; +import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk; +import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateAttributes; +import net.minecraft.server.v1_8_R3.WorldServer; +import net.minecraft.server.v1_8_R3.WorldSettings; import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; +import org.bukkit.OfflinePlayer; import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Entity; @@ -30,447 +49,285 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.player.*; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.ChunkUnloadEvent; -import org.bukkit.plugin.java.JavaPlugin; -import java.lang.reflect.Field; -import java.util.*; -import java.util.Map.Entry; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.function.Predicate; +/* + * notes: rabbit jump has been removed (PacketPlayOutEntityStatus) because it didn't work for 1.9+ anyways + * + * contact samczsun before you make any major changes + */ +@ReflectivelyCreateMiniPlugin public class DisguiseManager extends MiniPlugin implements IPacketHandler { - public static DisguiseManager INSTANCE; + // A map of entityids which are disguised to their respective disguises + private Map> _spawnPacketMap = new HashMap<>(); - private NautHashMap _spawnPacketMap = new NautHashMap(); - private NautHashMap _movePacketMap = new NautHashMap(); - private NautHashMap _moveTempMap = new NautHashMap(); - private HashSet _goingUp = new HashSet(); - private NautHashMap _entityDisguiseMap = new NautHashMap(); - private NautHashMap> _disguisePlayerMap = new NautHashMap>(); - private HashSet _blockedNames = new HashSet(); - private NautHashMap> _futureDisguises = new NautHashMap>(); - private NautHashMap> _lastRabbitHop = new NautHashMap>(); + // The map which stores entity UUIDs once they have been unloaded + private Map> _entityDisguiseMap = new HashMap<>(); + + // The map of which players should a disguise be shown to + private Map> _disguisePlayerMap = new HashMap<>(); + + private HashSet _blockedNames = new HashSet<>(); private boolean _handlingPacket = false; - private Field _xChunk; - private Field _zChunk; - - private Chunk _bedChunk; - private boolean _bedPackets; - - - public DisguiseManager(JavaPlugin plugin, PacketHandler packetHandler) + private DisguiseManager() { - super("Disguise Manager", plugin); + super("Disguise Manager"); - packetHandler.addPacketHandler(this, PacketPlayOutAnimation.class, PacketPlayOutBed.class, - PacketPlayOutEntityStatus.class, PacketPlayOutMapChunk.class, PacketPlayOutMapChunkBulk.class, - PacketPlayOutNamedEntitySpawn.class, PacketPlayOutPlayerInfo.class, - PacketPlayOutEntity.PacketPlayOutRelEntityMove.class, PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook.class, - PacketPlayOutSpawnEntity.class, PacketPlayOutEntityVelocity.class, PacketPlayOutEntityDestroy.class, - PacketPlayOutEntityTeleport.class, PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntityLiving.class, - PacketPlayOutUpdateAttributes.class, PacketPlayOutEntityEquipment.class, PacketPlayOutNamedSoundEffect.class); + require(PacketHandler.class) + .addPacketHandler(this, + PacketPlayOutNamedEntitySpawn.class, + PacketPlayOutPlayerInfo.class, + PacketPlayOutSpawnEntity.class, + PacketPlayOutEntityMetadata.class, + PacketPlayOutSpawnEntityLiving.class, + PacketPlayOutUpdateAttributes.class, + PacketPlayOutEntityEquipment.class + ); - INSTANCE = this; - - try - { - _bedChunk = new Chunk(((CraftWorld) Bukkit.getWorlds().get(0)).getHandle(), 0, 0); - Field cSection = Chunk.class.getDeclaredField("sections"); - cSection.setAccessible(true); - - ChunkSection chunkSection = new ChunkSection(0, true); - Block block = Block.getById(Material.BED_BLOCK.getId()); - - // block = ((Object[]) ReflectionManager.getNmsField(ReflectionManager.getNmsClass("Block"),"byId") - // .get(null))[Material.BED_BLOCK.getId()]; - - for (BlockFace face : new BlockFace[] - { - BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH - }) - { - int x = 1 + face.getModX(); - int z = 1 + face.getModZ(); - - chunkSection.setType(x, 0, z, block.fromLegacyData(face.ordinal())); - chunkSection.a(x, 0, z, 0); - chunkSection.b(x, 0, z, 0); - } - - ChunkSection[] chunkSections = new ChunkSection[16]; - chunkSections[0] = chunkSection; - cSection.set(_bedChunk, chunkSections); - - // TODO -// _bedChunk.world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle(); - - _xChunk = Chunk.class.getField("locX"); - _xChunk.setAccessible(true); - - _zChunk = Chunk.class.getField("locZ"); - _zChunk.setAccessible(true); - } - catch (IllegalArgumentException e) - { - e.printStackTrace(); - } - catch (NoSuchFieldException e) - { - e.printStackTrace(); - } - catch (SecurityException e) - { - e.printStackTrace(); - } - catch (IllegalAccessException e) - { - e.printStackTrace(); - } - } - - public void addFutureDisguise(DisguiseBase disguise, Player... players) - { - final int entityId = UtilEnt.getNewEntityId(false); - - _futureDisguises.put(entityId, new HashMap.SimpleEntry(disguise, players)); - - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() - { - public void run() - { - if (_futureDisguises.containsKey(entityId)) - { - Entry entry = _futureDisguises.remove(entityId); - - Entity entity = UtilEnt.getEntityById(entityId); - - if (entity != null) - { - entry.getKey().setEntity(entity); - - disguise(entry.getKey(), entry.getValue()); - } - } - } - }, 4); - } - - public void addViewerToDisguise(DisguiseBase disguise, Player player, boolean reapply) - { - _disguisePlayerMap.get(disguise).add(player); - - if (reapply) - refreshTrackers(disguise.GetEntity().getBukkitEntity(), new Player[] - { - player - }); + createBedChunk(); } + // We want to re-register entities that were reloaded by chunk loading @EventHandler - public void ChunkAddEntity(ChunkAddEntityEvent event) + public void onEntityAdd(ChunkAddEntityEvent event) { - DisguiseBase disguise = _entityDisguiseMap.get(event.getEntity().getUniqueId().toString()); + LinkedList disguises = _entityDisguiseMap.remove(event.getEntity().getUniqueId()); - if (disguise != null) + if (disguises != null) { - disguise.setEntity(event.getEntity()); - _spawnPacketMap.put(event.getEntity().getEntityId(), disguise); - _entityDisguiseMap.remove(event.getEntity().getUniqueId().toString()); - - if (disguise instanceof DisguiseRabbit) - { - _lastRabbitHop.put(disguise.GetEntityId(), new NautHashMap()); - } - } - } - - @EventHandler - public void chunkJoin(PlayerJoinEvent event) - { - if (!_bedPackets) - return; - - chunkMove(event.getPlayer(), event.getPlayer().getLocation(), null); - } - - private void chunkMove(Player player, Location newLoc, Location oldLoc) - { - for (Packet packet : getChunkMovePackets(player, newLoc, oldLoc)) - { - UtilPlayer.sendPacket(player, packet); + disguises.forEach(disguise -> disguise.setEntity(event.getEntity())); + _spawnPacketMap.put(event.getEntity().getEntityId(), disguises); } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void chunkMove(PlayerMoveEvent event) - { - if (!_bedPackets) - return; - - Location to = event.getTo(); - Location from = event.getFrom(); - - int x1 = getChunk(to.getX()); - int z1 = getChunk(to.getZ()); - int x2 = getChunk(from.getX()); - int z2 = getChunk(from.getZ()); - - if (x1 != x2 || z1 != z2) - { - chunkMove(event.getPlayer(), to, from); - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void chunkTeleport(PlayerTeleportEvent event) - { - if (!_bedPackets) - return; - - Location to = event.getTo(); - Location from = event.getFrom(); - - if (to.getWorld() == from.getWorld()) - { - int x1 = getChunk(to.getX()); - int z1 = getChunk(to.getZ()); - - int x2 = getChunk(from.getX()); - int z2 = getChunk(from.getZ()); - - if (x1 != x2 || z1 != z2) - { - final Player player = event.getPlayer(); - final Location prev = new Location(to.getWorld(), x1, 0, z1); - - chunkMove(player, null, from); - - Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() - { - public void run() - { - if (!player.isOnline()) - { - return; - } - - Location loc = player.getLocation(); - - if (player.getWorld() != loc.getWorld()) - { - return; - } - - int x2 = getChunk(loc.getX()); - int z2 = getChunk(loc.getZ()); - - if (prev.getBlockX() == x2 && prev.getBlockZ() == z2 && loc.getWorld() == prev.getWorld()) - { - chunkMove(player, loc, null); - } - - refreshBedTrackers(player); - } - }); - } - } - } - - @EventHandler - public void ChunkUnload(ChunkUnloadEvent event) + public void onEntityRemove(ChunkUnloadEvent event) { + Set careAbout = new HashSet<>(); for (Entity entity : event.getChunk().getEntities()) { if (_spawnPacketMap.containsKey(entity.getEntityId())) { - _entityDisguiseMap.put(entity.getUniqueId().toString(), _spawnPacketMap.get(entity.getEntityId())); - _spawnPacketMap.remove(entity.getEntityId()); - _lastRabbitHop.remove(entity.getEntityId()); + careAbout.add(entity); } } - } - public void clearDisguises() - { - _spawnPacketMap.clear(); - _movePacketMap.clear(); - _moveTempMap.clear(); - _goingUp.clear(); - _entityDisguiseMap.clear(); - _disguisePlayerMap.clear(); - - if (_bedPackets) + // Run it a tick later so that if someone else happened to cancel the event, we won't fall for it + runSync(() -> { - unregisterBedChunk(); - } - } - - private boolean containsSpawnDisguise(Player owner, int entityId) - { - return _spawnPacketMap.containsKey(entityId) - && (_spawnPacketMap.get(entityId).Global || (_disguisePlayerMap.containsKey(_spawnPacketMap.get(entityId)) && _disguisePlayerMap - .get(_spawnPacketMap.get(entityId)).contains(owner))); - } - - public void disguise(DisguiseBase disguise, boolean refreshTrackers, Player... players) - { - if (!disguise.GetEntity().isAlive()) - return; - - if (!_bedPackets && disguise instanceof DisguisePlayer && ((DisguisePlayer) disguise).getSleepingDirection() != null) - { - _bedPackets = true; - - for (Player player : Bukkit.getOnlinePlayers()) + for (Entity entity : careAbout) { - UtilPlayer.sendPacket(player, getBedChunkLoadPackets(player, player.getLocation())); - } - } - - if (players.length != 0) - { - disguise.Global = false; - } - - _spawnPacketMap.put(disguise.GetEntityId(), disguise); - _disguisePlayerMap.put(disguise, new HashSet()); - - if (disguise instanceof DisguiseRabbit) - { - _lastRabbitHop.put(disguise.GetEntityId(), new NautHashMap()); - } - - for (Player player : players) - addViewerToDisguise(disguise, player, false); - - if (disguise.GetEntity() instanceof EntityPlayer && disguise instanceof DisguisePlayer) - { - if (!(disguise.GetEntity()).getName().equalsIgnoreCase(((DisguisePlayer) disguise).getName())) - { - _blockedNames.add((disguise.GetEntity()).getName()); - } - } - - if (refreshTrackers) - { - refreshTrackers(disguise.GetEntity().getBukkitEntity(), - disguise.Global ? Bukkit.getOnlinePlayers().toArray(new Player[0]) : players); - } - } - - public void disguise(DisguiseBase disguise, Player... players) - { - disguise(disguise, true, players); - } - - public PacketPlayOutMapChunk[] getBedChunkLoadPackets(Player player, Location newLoc) - { - prepareChunk(newLoc); - - PacketPlayOutMapChunk[] packets = new PacketPlayOutMapChunk[2]; - - // Make unload - packets[0] = new PacketPlayOutMapChunk(_bedChunk, true, 0); - - // Make load - packets[1] = new PacketPlayOutMapChunk(_bedChunk, true, '\uffff'); - - return packets; - } - - public Packet getBedChunkUnloadPacket(Player player, Location oldLoc) - { - prepareChunk(oldLoc); - - return new PacketPlayOutMapChunk(_bedChunk, true, 0); - } - - private Packet[] getBedPackets(Location recieving, DisguisePlayer playerDisguise) - { - try - { - PacketPlayOutBed bedPacket = new PacketPlayOutBed(); - - bedPacket.a = playerDisguise.GetEntityId(); - - int chunkX = getChunk(recieving.getX()); - int chunkZ = getChunk(recieving.getZ()); - - bedPacket.b = new BlockPosition((chunkX * 16) + 1 + playerDisguise.getSleepingDirection().getModX(), 0, (chunkZ * 16) - + 1 + playerDisguise.getSleepingDirection().getModZ()); - - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(playerDisguise.GetEntity()); - - teleportPacket.c += (int) (0.35D * 32); - - return new Packet[] + if (!entity.isValid()) { - bedPacket, teleportPacket - }; - } - catch (Exception ex) - { - ex.printStackTrace(); - } - - return null; + _entityDisguiseMap.put(entity.getUniqueId(), _spawnPacketMap.remove(entity.getEntityId())); + } + } + }); } - private int getChunk(double block) + private boolean containsSpawnDisguise(Player owner, DisguiseBase disguise) { - int chunk = (int) Math.floor(block / 16D) - 17; - chunk -= chunk % 8; - return chunk; + return disguise != null && (_disguisePlayerMap.containsKey(disguise) && _disguisePlayerMap.get(disguise).test(owner)); } - private ArrayList getChunkMovePackets(Player player, Location newLoc, Location oldLoc) + public void disguise(DisguiseBase disguise, Runnable after) { - ArrayList packets = new ArrayList(); + disguise(disguise, after, player -> true); + } - if (newLoc != null) + public void disguise(DisguiseBase disguise, Predicate accept) + { + disguise(disguise, null, accept); + } + + public void disguise(DisguiseBase disguise) + { + disguise(disguise, null, t -> true); + } + + public void disguise(DisguiseBase disguise, Runnable after, Predicate accept) + { + UtilTasks.onMainThread(() -> { - packets.addAll(Arrays.asList(getBedChunkLoadPackets(player, newLoc))); + // First, add everything to handle future disguises + DisguiseBase before = null; - EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle(); + LinkedList disguises = _spawnPacketMap.computeIfAbsent(disguise.getEntityId(), key -> new LinkedList<>()); - for (Entry> entry : _disguisePlayerMap.entrySet()) + before = disguises.peekFirst(); + + disguises.addFirst(disguise); + + _disguisePlayerMap.put(disguise, accept); + + // If the entity hasn't been spawned in yet, try to spawn it in and if that fails, remove everything + + boolean spawnedIn = false; + + if (!disguise.getEntity().valid) { - if (entry.getKey().Global || entry.getValue().contains(player)) + disguise.attemptToSpawn(); + if (!disguise.getEntity().valid) { - EntityTrackerEntry tracker = getEntityTracker(entry.getKey().GetEntity()); + disguises.remove(disguise); + _disguisePlayerMap.remove(disguise); + return; + } + spawnedIn = true; + } - if (tracker != null && tracker.trackedPlayers.contains(nmsPlayer)) + if (before != null) + { + before.onTransfer(disguise); + } + + // todo figure out what this does + if (disguise.getEntity() instanceof EntityPlayer && disguise instanceof DisguisePlayer) + { + if (!(disguise.getEntity()).getName().equalsIgnoreCase(((DisguisePlayer) disguise).getName())) + { + _blockedNames.add(disguise.getEntity().getName()); + } + } + + if (!spawnedIn) + { + refreshTrackers(disguise.getEntity().getBukkitEntity()); + } + + disguise.onDisguise(true); + + if (after != null) + { + after.run(); + } + }).run(); + } + + public boolean undisguise(DisguiseBase originalDisguise) + { + return undisguise(originalDisguise, UndisguiseReason.EXPLICIT); + } + + public boolean undisguise(DisguiseBase originalDisguise, UndisguiseReason reason) + { + if (originalDisguise == null) return false; + if (originalDisguise.getEntity() == null) return false; + + net.minecraft.server.v1_8_R3.Entity entity = originalDisguise.getEntity(); + + LinkedList activeDisguises = this._spawnPacketMap.get(originalDisguise.getEntityId()); + + if (activeDisguises == null) return false; + + if (!activeDisguises.contains(originalDisguise)) return false; + + if (entity.getBukkitEntity() instanceof Player) + { + _blockedNames.remove(entity.getName()); + } + + Predicate test = _disguisePlayerMap.remove(originalDisguise); + + if (originalDisguise instanceof DisguisePlayer) + { + for (Player player : UtilServer.getPlayersCollection()) + { + if (test.test(player)) + { + EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + entityPlayer.playerConnection.networkManager.handle(((DisguisePlayer) originalDisguise).getUndisguiseInfoPackets(true)); + if (reason != UndisguiseReason.QUIT) { - if (entry.getKey() instanceof DisguisePlayer - && ((DisguisePlayer) entry.getKey()).getSleepingDirection() != null) - { - - packets.addAll(Arrays.asList(getBedPackets(newLoc, (DisguisePlayer) entry.getKey()))); - } + entityPlayer.playerConnection.networkManager.handle(((DisguisePlayer) originalDisguise).getUndisguiseInfoPackets(false)); } } } } - if (oldLoc != null) + int index = activeDisguises.indexOf(originalDisguise); + + activeDisguises.remove(originalDisguise); + + if (activeDisguises.size() == 0) + _spawnPacketMap.remove(originalDisguise.getEntityId()); + + if (index == 0) { - packets.add(getBedChunkUnloadPacket(player, oldLoc)); + originalDisguise.onUndisguise(true); + if (activeDisguises.size() > 0) + { + activeDisguises.getFirst().onReturn(originalDisguise); + } + + if (reason != UndisguiseReason.QUIT) + { + refreshTrackers(entity.getBukkitEntity()); + } + } + else + { + originalDisguise.onUndisguise(false); } - return packets; + return true; } + @Deprecated + public void undisguise(Entity entity) + { + undisguise(getActiveDisguise(entity), UndisguiseReason.EXPLICIT); + } + + @Deprecated + /* + * @Deprecated Use getActiveDisguise instead + */ public DisguiseBase getDisguise(LivingEntity entity) + { + return getActiveDisguise(entity); + } + + public DisguiseBase getActiveDisguise(Entity entity) + { + return getActiveDisguise(entity.getEntityId()); + } + + public DisguiseBase getActiveDisguise(int entityId) + { + LinkedList list = _spawnPacketMap.get(entityId); + if (list != null && list.size() > 0) + { + return list.getFirst(); + } + return null; + } + + public LinkedList getAllDisguises(Entity entity) { return _spawnPacketMap.get(entity.getEntityId()); } private EntityTrackerEntry getEntityTracker(net.minecraft.server.v1_8_R3.Entity entity) { - return (EntityTrackerEntry) ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); + return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); } public void handle(PacketInfo packetInfo) @@ -482,69 +339,27 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler final Player owner = packetInfo.getPlayer(); final PacketVerifier packetVerifier = packetInfo.getVerifier(); - if (packet instanceof PacketPlayOutRelEntityMoveLook || packet instanceof PacketPlayOutRelEntityMove) - { - int entityId = -1; - - if (packet instanceof PacketPlayOutRelEntityMoveLook) - { - entityId = ((PacketPlayOutRelEntityMoveLook) packet).a; - }/* - else if (packet instanceof PacketPlayOutEntityLook) - { - entityId = ((PacketPlayOutEntityLook) packet).a; - }*/ - else if (packet instanceof PacketPlayOutRelEntityMove) - { - PacketPlayOutRelEntityMove rPacket = (PacketPlayOutRelEntityMove) packet; - - if (rPacket.b != 0 || rPacket.c != 0 || rPacket.d != 0) - { - entityId = rPacket.a; - } - } - /*else if (packet instanceof PacketPlayOutEntityTeleport) - { - entityId = ((PacketPlayOutEntityTeleport) packet).a; - }*/ - - if (_lastRabbitHop.containsKey(entityId)) - { - NautHashMap rabbitHops = _lastRabbitHop.get(entityId); - - if (rabbitHops != null) - { - long last = rabbitHops.containsKey(owner.getEntityId()) ? System.currentTimeMillis() - - rabbitHops.get(owner.getEntityId()) : 1000; - - if (last > 500 || last < 100) - { - rabbitHops.put(owner.getEntityId(), System.currentTimeMillis()); - - PacketPlayOutEntityStatus entityStatus = new PacketPlayOutEntityStatus(); - - entityStatus.a = entityId; - entityStatus.b = (byte) 1; - - handlePacket(entityStatus, packetVerifier); - } - } - } - } - if (packet instanceof PacketPlayOutPlayerInfo) { - for (PlayerInfoData info : ((PacketPlayOutPlayerInfo) packet).b) + PacketPlayOutPlayerInfo packetPlayOutPlayerInfo = ((PacketPlayOutPlayerInfo) packet); + Iterator iterator = packetPlayOutPlayerInfo.b.iterator(); + while (iterator.hasNext()) { - if (_blockedNames.contains(info.a().getName())) + PacketPlayOutPlayerInfo.PlayerInfoData next = iterator.next(); + if (_blockedNames.contains(next.a().getName())) { - packetInfo.setCancelled(true); - break; + iterator.remove(); } } + + if (packetPlayOutPlayerInfo.b.size() == 0) + { + packetInfo.setCancelled(true); + } } - else if (packet instanceof PacketPlayOutSpawnEntity || packet instanceof PacketPlayOutSpawnEntityLiving - || packet instanceof PacketPlayOutNamedEntitySpawn) + else if (packet instanceof PacketPlayOutSpawnEntity || + packet instanceof PacketPlayOutSpawnEntityLiving || + packet instanceof PacketPlayOutNamedEntitySpawn) { int entityId = -1; @@ -561,271 +376,128 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler entityId = ((PacketPlayOutNamedEntitySpawn) packet).a; } - if (_futureDisguises.containsKey(entityId)) + DisguiseBase latestDisguise = getActiveDisguise(entityId); + + if (latestDisguise != null) { - Entry entry = _futureDisguises.remove(entityId); - - Entity entity = UtilEnt.getEntityById(entityId); - - if (entity != null) + if (containsSpawnDisguise(owner, latestDisguise)) { - entry.getKey().setEntity(entity); + packetInfo.setCancelled(true); - boolean cancel = entry.getValue().length == 0; - - for (Player player : entry.getValue()) - { - if (player == owner) - { - cancel = true; - break; - } - } - - if (cancel) - { - packetInfo.setCancelled(true); - } - - disguise(entry.getKey(), false, entry.getValue()); + handleSpawnPackets(packetInfo.getVerifier(), latestDisguise); + } + else if (latestDisguise.isHideIfNotDisguised()) + { + packetInfo.setCancelled(true); } - } - - if (_spawnPacketMap.containsKey(entityId) - && (_spawnPacketMap.get(entityId).Global || _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains( - owner))) - { - packetInfo.setCancelled(true); - - handleSpawnPackets(packetInfo, _spawnPacketMap.get(entityId)); } } else if (packet instanceof PacketPlayOutUpdateAttributes) { int entityId = ((PacketPlayOutUpdateAttributes) packet).a; - if (_spawnPacketMap.containsKey(entityId) - && owner.getEntityId() != entityId - && (_spawnPacketMap.get(entityId).Global || _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains( - owner))) + DisguiseBase latestDisguise = getActiveDisguise(entityId); + + if (latestDisguise != null && containsSpawnDisguise(owner, latestDisguise)) { // Crash clients with meta to a block id. - if (_spawnPacketMap.get(entityId) instanceof DisguiseBlock) + if (latestDisguise instanceof DisguiseBlock) packetInfo.setCancelled(true); } } - /* - * Why is this here??? - else if (packet instanceof PacketPlayOutAnimation) - { - int entityId = ((PacketPlayOutAnimation) packet).a; - - if (containsSpawnDisguise(owner, entityId) && owner.getEntityId() != entityId) - { - packetInfo.setCancelled(true); - } - } - */ else if (packet instanceof PacketPlayOutEntityMetadata) { int entityId = ((PacketPlayOutEntityMetadata) packet).a; - if (containsSpawnDisguise(owner, entityId) && owner.getEntityId() != entityId) + DisguiseBase latestDisguise = getActiveDisguise(entityId); + + if (latestDisguise != null && containsSpawnDisguise(owner, latestDisguise) && owner.getEntityId() != entityId) { - handlePacket(_spawnPacketMap.get(entityId).GetMetaDataPacket(), packetVerifier); packetInfo.setCancelled(true); + handlePacket(latestDisguise.getMetadataPacket(), packetVerifier); } } else if (packet instanceof PacketPlayOutEntityEquipment) { int entityId = ((PacketPlayOutEntityEquipment) packet).a; - if (containsSpawnDisguise(owner, entityId) && _spawnPacketMap.get(entityId) instanceof DisguiseInsentient) + DisguiseBase latestDisguise = getActiveDisguise(entityId); + + if (latestDisguise != null && containsSpawnDisguise(owner, latestDisguise) && latestDisguise instanceof DisguiseInsentient) { - if (!((DisguiseInsentient) _spawnPacketMap.get(entityId)).armorVisible() - && ((PacketPlayOutEntityEquipment) packet).b != 0) + if (!((DisguiseInsentient) latestDisguise).armorVisible() && ((PacketPlayOutEntityEquipment) packet).b != 0) { packetInfo.setCancelled(true); } } } - else if (packet instanceof PacketPlayOutEntityVelocity) - { - PacketPlayOutEntityVelocity velocityPacket = (PacketPlayOutEntityVelocity) packet; - - // Only for viewers - if (velocityPacket.a == owner.getEntityId()) - { - if (velocityPacket.c > 0) - _goingUp.add(velocityPacket.a); - } - else if (velocityPacket.b == 0 && velocityPacket.c == 0 && velocityPacket.d == 0) - { - return; - } - else if (_spawnPacketMap.containsKey(velocityPacket.a)) - { - packetInfo.setCancelled(true); - } - } - else if (packet instanceof PacketPlayOutRelEntityMove) - { - final PacketPlayOutRelEntityMove movePacket = (PacketPlayOutRelEntityMove) packet; - - // Only for viewers - if (movePacket.a == owner.getEntityId()) - return; - - if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c < 20) - { - _goingUp.remove(movePacket.a); - _movePacketMap.remove(movePacket.a); - } - - if (!containsSpawnDisguise(owner, movePacket.a)) - return; - - final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity(); - velocityPacket.a = movePacket.a; - velocityPacket.b = movePacket.b * 100; - velocityPacket.c = movePacket.c * 100; - velocityPacket.d = movePacket.d * 100; - - if (_movePacketMap.containsKey(movePacket.a)) - { - PacketPlayOutEntityVelocity lastVelocityPacket = _movePacketMap.get(movePacket.a); - - velocityPacket.b = (int) (.8 * lastVelocityPacket.b); - velocityPacket.c = (int) (.8 * lastVelocityPacket.c); - velocityPacket.d = (int) (.8 * lastVelocityPacket.d); - } - - _movePacketMap.put(movePacket.a, velocityPacket); - - packetVerifier.bypassProcess(velocityPacket); - - if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20) - { - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() - { - public void run() - { - packetVerifier.bypassProcess(velocityPacket); - } - }); - } - - if (_spawnPacketMap.get(movePacket.a) instanceof DisguiseBlock) - { - - } - } - else if (packet instanceof PacketPlayOutRelEntityMoveLook) - { - final PacketPlayOutRelEntityMoveLook movePacket = (PacketPlayOutRelEntityMoveLook) packet; - - // Only for viewers - if (movePacket.a == owner.getEntityId()) - return; - - if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c <= 20) - { - _goingUp.remove(movePacket.a); - _movePacketMap.remove(movePacket.a); - } - - if (!containsSpawnDisguise(owner, movePacket.a)) - return; - - final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity(); - velocityPacket.a = movePacket.a; - velocityPacket.b = movePacket.b * 100; - velocityPacket.c = movePacket.c * 100; - velocityPacket.d = movePacket.d * 100; - - if (_movePacketMap.containsKey(movePacket.a)) - { - PacketPlayOutEntityVelocity lastVelocityPacket = _movePacketMap.get(movePacket.a); - - velocityPacket.b = (int) (.8 * lastVelocityPacket.b); - velocityPacket.c = (int) (.8 * lastVelocityPacket.c); - velocityPacket.d = (int) (.8 * lastVelocityPacket.d); - } - - _movePacketMap.put(movePacket.a, velocityPacket); - - packetVerifier.bypassProcess(velocityPacket); - - if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20) - { - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() - { - public void run() - { - packetVerifier.bypassProcess(velocityPacket); - } - }); - } - } } private void handlePacket(Packet packet, PacketVerifier verifier) { + if (packet == null) return; _handlingPacket = true; verifier.process(packet); _handlingPacket = false; } - private void handleSpawnPackets(PacketInfo packetInfo, DisguiseBase disguise) + private void handleSpawnPackets(PacketVerifier packetVerifier, DisguiseBase disguise) { - final Player player = packetInfo.getPlayer(); - - final PacketVerifier packetVerifier = packetInfo.getVerifier(); - if (disguise instanceof DisguisePlayer) { - final DisguisePlayer pDisguise = (DisguisePlayer) disguise; - handlePacket(pDisguise.getNewInfoPacket(true), packetVerifier); - - PacketPlayOutNamedEntitySpawn namePacket = pDisguise.spawnBeforePlayer(player.getLocation()); - - namePacket.i.watch(0, (byte) 32, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 32); - - handlePacket(namePacket, packetVerifier); - - if (pDisguise.getSleepingDirection() != null) + Packet infoPacket = pDisguise.getDisguiseInfoPackets(false); + if (infoPacket != null) { - for (Packet packet : getBedPackets(player.getLocation(), pDisguise)) - { - handlePacket(packet, packetVerifier); - } + handlePacket(infoPacket, packetVerifier); + } - } - else + infoPacket = pDisguise.getDisguiseInfoPackets(true); + if (infoPacket != null) { - handlePacket(new PacketPlayOutEntityTeleport(pDisguise.GetEntity()), packetVerifier); + handlePacket(infoPacket, packetVerifier); } + handlePacket(pDisguise.getSpawnPacket(), packetVerifier); + for (Packet packet : pDisguise.getEquipmentPackets()) { handlePacket(packet, packetVerifier); } - handlePacket(pDisguise.GetMetaDataPacket(), packetVerifier); + handlePacket(pDisguise.getMetadataPacket(), packetVerifier); - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() + if (pDisguise.getSleepingDirection() != null) { - public void run() + for (Packet packet : getBedPackets(pDisguise)) { - handlePacket(pDisguise.getNewInfoPacket(false), packetVerifier); + handlePacket(packet, packetVerifier); } - }, 6); + } + + if (!pDisguise.showInTabList()) + { + Runnable r = () -> + { + PacketPlayOutPlayerInfo playerInfoPacketRemove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData dataRemove = playerInfoPacketRemove.new PlayerInfoData(pDisguise.getProfile(), 0, WorldSettings.EnumGamemode.SURVIVAL, null); + playerInfoPacketRemove.b.add(dataRemove); + handlePacket(playerInfoPacketRemove, packetVerifier); + }; + if (pDisguise.getShowInTabListDelay() == 0) + { + r.run(); + } + else + { + Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), r, pDisguise.getShowInTabListDelay()); + } + } } else { - handlePacket(disguise.GetSpawnPacket(), packetVerifier); + handlePacket(disguise.getSpawnPacket(), packetVerifier); if (disguise instanceof DisguiseLiving) { @@ -844,233 +516,80 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler return _spawnPacketMap.containsKey(entity.getEntityId()); } - @EventHandler + @EventHandler(priority = EventPriority.MONITOR) public void PlayerQuit(PlayerQuitEvent event) { - for (DisguiseBase disguise : _disguisePlayerMap.keySet()) - { - _disguisePlayerMap.get(disguise).remove(event.getPlayer()); - } - - for (Integer disguise : _lastRabbitHop.keySet()) - { - _lastRabbitHop.get(disguise).remove(event.getPlayer().getEntityId()); - } - - undisguise(event.getPlayer()); + while (getActiveDisguise(event.getPlayer()) != null) + undisguise(getActiveDisguise(event.getPlayer()), UndisguiseReason.QUIT); } - private void prepareChunk(Location loc) + private void refreshTrackers(Entity entity) { - int chunkX = getChunk(loc.getX()); - int chunkZ = getChunk(loc.getZ()); + DisguiseBase activeDisguise = getActiveDisguise(entity); + Predicate tester = _disguisePlayerMap.getOrDefault(activeDisguise, test -> true); - try - { - _xChunk.set(_bedChunk, chunkX); - _zChunk.set(_bedChunk, chunkZ); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - private void refreshBedTrackers(final Player player) - { - for (final DisguiseBase disguise : this._disguisePlayerMap.keySet()) - { - if (!(disguise instanceof DisguisePlayer) || ((DisguisePlayer) disguise).getSleepingDirection() == null) - { - continue; - } - - final EntityTrackerEntry entityTracker = getEntityTracker(disguise.GetEntity()); - - if (entityTracker != null) - { - if (!entityTracker.trackedPlayers.contains(((CraftPlayer) player).getHandle())) - { - continue; - } - - Packet destroyPacket = new PacketPlayOutEntityDestroy(new int[] - { - disguise.GetEntityId() - }); - - entityTracker.clear(((CraftPlayer) player).getHandle()); - - UtilPlayer.sendPacket(player, destroyPacket); - - final World world = disguise.GetEntity().getBukkitEntity().getWorld(); - - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() - { - public void run() - { - try - { - Entity entity = disguise.GetEntity().getBukkitEntity(); - - if (entity.getWorld() == world && entity.isValid()) - { - if (player.isOnline() && player.getWorld() == entity.getWorld()) - { - entityTracker.updatePlayer(((CraftPlayer) player).getHandle()); - } - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - }, 5); - } - } - } - - private void refreshTrackers(final Entity entity, final Player[] players) - { final EntityTrackerEntry entityTracker = getEntityTracker(((CraftEntity) entity).getHandle()); if (entityTracker != null) { - Packet destroyPacket = new PacketPlayOutEntityDestroy(new int[] - { - entity.getEntityId() - }); - - for (Player player : players) + if (entity.isValid()) { - entityTracker.clear(((CraftPlayer) player).getHandle()); - - UtilPlayer.sendPacket(player, destroyPacket); - } - - final World world = entity.getWorld(); - - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() - { - public void run() + for (Player player : PlayerSelector.selectPlayers( + PlayerSelector.and( + PlayerSelector.inWorld(entity.getWorld()), + OfflinePlayer::isOnline, + tester + ) + ) + ) { - try + EntityPlayer handle = ((CraftPlayer) player).getHandle(); + entityTracker.clear(handle); + runSyncLater(() -> { - if (entity.getWorld() == world && entity.isValid()) - { - for (Player player : players) - { - if (player.isOnline() && player.getWorld() == entity.getWorld()) - { - entityTracker.updatePlayer(((CraftPlayer) player).getHandle()); - } - } - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - }, 5); - } - } - - public void removeViewerToDisguise(DisguiseBase disguise, Player player) - { - _disguisePlayerMap.get(disguise).remove(player); - - refreshTrackers(disguise.GetEntity().getBukkitEntity(), new Player[] - { - player - }); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void switchedWorld(PlayerChangedWorldEvent event) - { - if (!_bedPackets) - return; - - chunkMove(event.getPlayer(), event.getPlayer().getLocation(), null); - } - - @EventHandler - public void TeleportDisguises(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - TimingManager.startTotal("Teleport Disguises"); - for (Player player : Bukkit.getOnlinePlayers()) - { - for (Player otherPlayer : Bukkit.getOnlinePlayers()) - { - if (player == otherPlayer) - continue; - - if (otherPlayer.getLocation().subtract(0, .5, 0).getBlock().getTypeId() != 0) - UtilPlayer.sendPacket(player, new PacketPlayOutEntityTeleport( - ((CraftPlayer) otherPlayer).getHandle())); - } - } - TimingManager.stopTotal("Teleport Disguises"); - } - - public void undisguise(LivingEntity entity) - { - if (!_spawnPacketMap.containsKey(entity.getEntityId())) - return; - - _lastRabbitHop.remove(entity.getEntityId()); - DisguiseBase disguise = _spawnPacketMap.remove(entity.getEntityId()); - Collection players = (disguise.Global ? Bukkit.getOnlinePlayers() : _disguisePlayerMap.remove(disguise)); - - _movePacketMap.remove(entity.getEntityId()); - _moveTempMap.remove(entity.getEntityId()); - - if (entity instanceof Player) - { - _blockedNames.remove(((Player) entity).getName()); - } - - refreshTrackers(entity, players.toArray(new Player[0])); - - if (_bedPackets && disguise instanceof DisguisePlayer && ((DisguisePlayer) disguise).getSleepingDirection() != null) - { - for (DisguiseBase dis : _disguisePlayerMap.keySet()) - { - if (dis instanceof DisguisePlayer && ((DisguisePlayer) dis).getSleepingDirection() != null) - { - return; + /* + * This is like, the hackiest shit ever. + * + * Basically, we need to delay by an arbitrary amount of ticks (in this case, 5) because of the client. + * + * In the client, the renderer renders batches of 16x16x16, and entites are stored in ChunkSections. + * However, the data structure used is a HashMultimap, and the hashCode() method for Entity simply returns its entity id + * + * Now, due to an unfortunate coincidence, sending a PacketPlayOutEntityDestroy does not immediately remove an entity from the client. + * Instead, it queues it for removal on the next tick (why tf). This means that if we send a destroy and spawn packet one after the other, + * the process looks something like this + * + * Received PacketPlayOutEntityDestroy + * Queue removal of original entity + * Received PacketPlayOutSpawnLivingEntity + * Register entity in ChunkSection (based on entity id) + * --- next tick --- + * Removal of original entity from ChunkSection (which is now the new disguised entity + * + * So, what can we do? + * + * We could do this, where we delay an arbitrary amount of time and hope that the client processes the tick. + * However, a better long term solution would be to rewrite entity ids properly + */ + entityTracker.updatePlayer(((CraftPlayer) player).getHandle()); + }, 5L); } } - - unregisterBedChunk(); - } - } - - private void unregisterBedChunk() - { - _bedPackets = false; - - for (Player player : Bukkit.getOnlinePlayers()) - { - chunkMove(player, null, player.getLocation()); } } public void updateDisguise(DisguiseBase disguise) { - Collection players = (disguise.Global ? Bukkit.getOnlinePlayers() : _disguisePlayerMap.get(disguise)); - - for (Player player : players) + Predicate tester = _disguisePlayerMap.get(disguise); + for (Player player : Bukkit.getOnlinePlayers()) { - if (disguise.GetEntity() == ((CraftPlayer) player).getHandle()) - continue; + if (tester.test(player)) + { + if (disguise.getEntity() == ((CraftPlayer) player).getHandle()) + continue; - UtilPlayer.sendPacket(player, disguise.GetMetaDataPacket()); + UtilPlayer.sendPacket(player, disguise.getMetadataPacket()); + } } } @@ -1080,27 +599,154 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler if (event.getType() != UpdateType.SLOWER || _disguisePlayerMap.isEmpty()) return; - for (Iterator disguiseIterator = _disguisePlayerMap.keySet().iterator(); disguiseIterator.hasNext();) + for (Iterator disguiseIterator = _disguisePlayerMap.keySet().iterator(); disguiseIterator.hasNext(); ) { DisguiseBase disguise = disguiseIterator.next(); - if (!(disguise.GetEntity() instanceof EntityPlayer)) + if (!(disguise.getEntity() instanceof EntityPlayer)) continue; - EntityPlayer disguisedPlayer = (EntityPlayer) disguise.GetEntity(); + EntityPlayer disguisedPlayer = (EntityPlayer) disguise.getEntity(); if (Bukkit.getPlayerExact(disguisedPlayer.getName()) == null || !disguisedPlayer.isAlive() || !disguisedPlayer.valid) disguiseIterator.remove(); - else - { - for (Iterator playerIterator = _disguisePlayerMap.get(disguise).iterator(); playerIterator.hasNext();) - { - Player player = playerIterator.next(); - - if (!player.isOnline() || !player.isValid()) - playerIterator.remove(); - } - } } } + + public enum UndisguiseReason + { + EXPLICIT, + QUIT + } + + /* + * ================================= + * HERE BEGINS STUFF SOLELY TO DEAL + * WITH MAKING PLAYERS LOOK LIKE + * THEY'RE ON BEDS + * + * DON'T TOUCH UNLESS YOU KNOW + * EXACTLY WHAT YOU'RE DOING + * ================================= + */ + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void switchedWorld(PlayerChangedWorldEvent event) + { + chunkMove(event.getPlayer()); + } + + @EventHandler + public void chunkJoin(PlayerJoinEvent event) + { + chunkMove(event.getPlayer()); + } + + private void chunkMove(Player player) + { + List packets = new ArrayList<>(); + + PacketPlayOutMapChunk chunk = new PacketPlayOutMapChunk(_bedChunk, true, '\uffff'); + chunk.a = BED_POS_NORTH[0] >> 4; + chunk.b = BED_POS_NORTH[2] >> 4; + + packets.add(chunk); + + EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle(); + + _spawnPacketMap.entrySet().stream() + .filter(entry -> entry.getValue().size() > 0 && entry.getValue().getFirst() instanceof DisguisePlayer && ((DisguisePlayer) entry.getValue().getFirst()).getSleepingDirection() != null) + .filter(entry -> this.containsSpawnDisguise(player, entry.getValue().getFirst())) + .forEach(entry -> + { + EntityTrackerEntry tracker = getEntityTracker(entry.getValue().getFirst().getEntity()); + + if (tracker != null && tracker.trackedPlayers.contains(nmsPlayer)) + { + packets.addAll(getBedPackets((DisguisePlayer) entry.getValue().getFirst())); + } + }); + + for (Packet packet : packets) + { + UtilPlayer.sendPacket(player, packet); + } + } + + /* + * Create the packets needed to make this DisguisePlayer appear as though laying on a bed + * + * fixme can we make this better at all?!?!?! + */ + private List getBedPackets(DisguisePlayer playerDisguise) + { + int[] coords = getCoordsFor(playerDisguise); + + List packets = new ArrayList<>(); + PacketPlayOutBed bedPacket = new PacketPlayOutBed(); + bedPacket.a = playerDisguise.getEntityId(); + bedPacket.b = new BlockPosition(coords[0], coords[1], coords[2]); + packets.add(bedPacket); + + int partitions = 3; + double posX = coords[0], posY = coords[1], posZ = coords[2]; + double targetX = playerDisguise.getEntity().locX, targetY = playerDisguise.getEntity().locY, targetZ = playerDisguise.getEntity().locZ; + + while (partitions > 1) + { + double d0 = posX + (targetX - posX) / (double) partitions; + double d1 = posY + (targetY - posY) / (double) partitions; + double d2 = posZ + (targetZ - posZ) / (double) partitions; + + + PacketPlayOutMapChunk chunk = new PacketPlayOutMapChunk(_bedChunk, true, '\uffff'); + chunk.a = (int) Math.floor(d0) >> 4; + chunk.b = (int) Math.floor(d2) >> 4; + packets.add(chunk); + partitions--; + + posX = d0; + posY = d1; + posZ = d2; + } + + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(playerDisguise.getEntity()); + packets.add(teleportPacket); + + return packets; + } + + + private static final int[] BED_POS_NORTH = {-29999999, 0, -29999999}; + private static final int[] BED_POS_SOUTH = {-29999999, 0, -29999998}; + private static final int[] BED_POS_EAST = {-29999999, 0, -29999997}; + private static final int[] BED_POS_WEST = {-29999999, 0, -29999996}; + + private Chunk _bedChunk; + + private void createBedChunk() + { + this._bedChunk = new Chunk(MinecraftServer.getServer().getWorld(), 0, 0); + this._bedChunk.a(new BlockPosition(BED_POS_NORTH[0], BED_POS_NORTH[1], BED_POS_NORTH[2]), Blocks.BED.getBlockData().set(BlockBed.FACING, EnumDirection.NORTH)); + this._bedChunk.a(new BlockPosition(BED_POS_SOUTH[0], BED_POS_SOUTH[1], BED_POS_SOUTH[2]), Blocks.BED.getBlockData().set(BlockBed.FACING, EnumDirection.SOUTH)); + this._bedChunk.a(new BlockPosition(BED_POS_EAST[0], BED_POS_EAST[1], BED_POS_EAST[2]), Blocks.BED.getBlockData().set(BlockBed.FACING, EnumDirection.EAST)); + this._bedChunk.a(new BlockPosition(BED_POS_WEST[0], BED_POS_WEST[1], BED_POS_WEST[2]), Blocks.BED.getBlockData().set(BlockBed.FACING, EnumDirection.WEST)); + } + + private int[] getCoordsFor(DisguisePlayer player) + { + BlockFace facing = player.getSleepingDirection(); + switch (facing) + { + case NORTH: + return BED_POS_SOUTH; + case SOUTH: + return BED_POS_NORTH; + case EAST: + return BED_POS_WEST; + case WEST: + return BED_POS_EAST; + } + throw new IllegalArgumentException("Unsupported blockface " + facing); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java deleted file mode 100644 index 3403768bb..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java +++ /dev/null @@ -1,34 +0,0 @@ -package mineplex.core.disguise; - -import mineplex.serverdata.data.Data; - -public class DisguisePlayerBean implements Data -{ - private int _accountID; - private String _disguisedPlayer; - private String _playerName; - public DisguisePlayerBean(int playerAccountID, String playerName, String disguiseAs) - { - this._accountID = playerAccountID; - this._disguisedPlayer = disguiseAs; - this._playerName = playerName; - - } - public int getAccountID() - { - return _accountID; - } - public String getDisguisedPlayer() - { - return _disguisedPlayer; - } - public String getPlayerName() - { - return _playerName; - } - @Override - public String getDataId() - { - return _accountID+_playerName; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java deleted file mode 100644 index 82e27bb5f..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java +++ /dev/null @@ -1,71 +0,0 @@ -package mineplex.core.disguise; - -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClient; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.serverdata.Region; -import mineplex.serverdata.redis.RedisDataRepository; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; - -public class PlayerDisguiseManager extends MiniPlugin -{ - private CoreClientManager _clients; - private RedisDataRepository _redis; - public PlayerDisguiseManager(JavaPlugin plugin, CoreClientManager clients) - { - super("Player Disguise Manager", plugin); - this._clients = clients; - - _redis = new RedisDataRepository(Region.ALL, DisguisePlayerBean.class, "disguisedPlayer"); - } - - @EventHandler - public void onDisguisedPlayerQuit(PlayerQuitEvent event) - { - CoreClient client = _clients.Get(event.getPlayer()); - if(client.isDisguised()) - { - _redis.addElement(new DisguisePlayerBean(client.getAccountId(), client.GetPlayerName(), client.getDisguisedAs()), 60*60*12); // 12 hours - } - } - - @EventHandler - public void onDisguisedPlayerJoin(PlayerJoinEvent event) - { - new BukkitRunnable() - { - @Override - public void run() - { - CoreClient client = _clients.Get(event.getPlayer()); - - if(!client.GetRank().has(Rank.JNR_DEV) && client.GetRank() != Rank.YOUTUBE_SMALL && client.GetRank() != Rank.TWITCH && client.GetRank() != Rank.YOUTUBE) - return; - - if(_redis.elementExists(client.getAccountId()+client.GetPlayerName())) - { - DisguisePlayerBean bean = _redis.getElement(client.getAccountId()+client.GetPlayerName()); - Bukkit.getPluginManager().callEvent(new PlayerCommandPreprocessEvent(event.getPlayer(), "/Disguise " + bean.getDisguisedPlayer())); - event.setJoinMessage(""); - } - } - }.runTaskLater(getPlugin(), 7); - } - - @EventHandler - public void onPlayerUndisguise(PlayerUndisguiseEvent event) - { - CoreClient client = _clients.Get(event.getPlayer()); - _redis.removeElement(client.getAccountId()+client.GetPlayerName()); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java index 547787e0d..d72e9aafb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java @@ -1,9 +1,11 @@ package mineplex.core.disguise.disguises; +import org.bukkit.entity.EntityType; + public abstract class DisguiseAmbient extends DisguiseInsentient { - public DisguiseAmbient(org.bukkit.entity.Entity entity) + public DisguiseAmbient(EntityType entityType, org.bukkit.entity.Entity entity) { - super(entity); + super(entityType, entity); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java index 520ef6ff2..ed3cade7d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java @@ -1,5 +1,6 @@ package mineplex.core.disguise.disguises; +import org.bukkit.entity.EntityType; import org.bukkit.util.Vector; import net.minecraft.server.v1_8_R3.EntityArmorStand; @@ -12,7 +13,7 @@ public class DisguiseArmorStand extends DisguiseInsentient { public DisguiseArmorStand(org.bukkit.entity.Entity entity) { - super(entity); + super(EntityType.ARMOR_STAND, entity); DataWatcher.a(10, (byte) 0, EntityArmorStand.META_ARMOR_OPTION, (byte) 0); @@ -47,7 +48,7 @@ public class DisguiseArmorStand extends DisguiseInsentient } @Override - public Packet GetSpawnPacket() + public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); packet.a = Entity.getId(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java index 5b325b952..7c742b3c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java @@ -1,12 +1,5 @@ package mineplex.core.disguise.disguises; -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.entity.Player; - import mineplex.core.common.DummyEntity; import mineplex.core.common.util.UtilPlayer; import net.minecraft.server.v1_8_R3.DataWatcher; @@ -14,48 +7,72 @@ import net.minecraft.server.v1_8_R3.Entity; import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.EntityTrackerEntry; import net.minecraft.server.v1_8_R3.IntHashMap; +import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; import net.minecraft.server.v1_8_R3.WorldServer; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.CreatureSpawnEvent; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public abstract class DisguiseBase { protected Entity Entity; protected DataWatcher DataWatcher; - + private DisguiseBase _soundDisguise; - - public boolean Global = true; - - public DisguiseBase(org.bukkit.entity.Entity entity) - { - if (entity != null) + + private EntityType _disguiseType; + + /** + * Whether the disguised entity should be entirely hidden from a player if that player does not receive the disguise + */ + private boolean _hideIfNotDisguised = false; + + public DisguiseBase(EntityType entityType, org.bukkit.entity.Entity entity) + { + if (entity == null) { - setEntity(entity); + throw new NullPointerException("Entity cannot be null (did you mean to pass in an unspawned entity?)"); } + this._disguiseType = entityType; + + setEntity(entity); + DataWatcher = new DataWatcher(new DummyEntity(null)); - DataWatcher.a(0, Byte.valueOf((byte) 0), Entity.META_ENTITYDATA, (byte) 0); - DataWatcher.a(1, Short.valueOf((short) 300), Entity.META_AIR, 300); + DataWatcher.a(0, (byte) 0, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0); + DataWatcher.a(1, (short) 300, net.minecraft.server.v1_8_R3.Entity.META_AIR, 300); _soundDisguise = this; } + public void attemptToSpawn() + { + this.Entity.world.addEntity(this.Entity, CreatureSpawnEvent.SpawnReason.CUSTOM); + } + public void setEntity(org.bukkit.entity.Entity entity) { Entity = ((CraftEntity) entity).getHandle(); } - + public void UpdateDataWatcher() { - DataWatcher.watch(0, Entity.getDataWatcher().getByte(0), Entity.META_ENTITYDATA, Entity.getDataWatcher().getByte(0)); - DataWatcher.watch(1, Entity.getDataWatcher().getShort(1), Entity.META_AIR, (int) Entity.getDataWatcher().getShort(1)); + DataWatcher.watch(0, Entity.getDataWatcher().getByte(0), net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, Entity.getDataWatcher().getByte(0)); + DataWatcher.watch(1, Entity.getDataWatcher().getShort(1), net.minecraft.server.v1_8_R3.Entity.META_AIR, (int) Entity.getDataWatcher().getShort(1)); } - - public abstract Packet GetSpawnPacket(); - public Packet GetMetaDataPacket() + public abstract Packet getSpawnPacket(); + + public Packet getMetadataPacket() { UpdateDataWatcher(); return new PacketPlayOutEntityMetadata(Entity.getId(), DataWatcher, true); @@ -71,7 +88,7 @@ public abstract class DisguiseBase if (tracker.get(Entity.getId()) == null) return; - Packet packet = GetMetaDataPacket(); + Packet packet = getMetadataPacket(); for (EntityPlayer player : tracker.get(Entity.getId()).trackedPlayers) { @@ -82,53 +99,99 @@ public abstract class DisguiseBase public void setSoundDisguise(DisguiseBase soundDisguise) { _soundDisguise = soundDisguise; - + if (_soundDisguise == null) _soundDisguise = this; } - + public void playHurtSound() { Entity.world.makeSound(Entity, _soundDisguise.getHurtSound(), _soundDisguise.getVolume(), _soundDisguise.getPitch()); } - - public void playHurtSound(Location location) - { - Entity.world.makeSound(location.getX(), location.getY(), location.getZ(), _soundDisguise.getHurtSound(), _soundDisguise.getVolume(), _soundDisguise.getPitch()); - } - public Entity GetEntity() + public Entity getEntity() { return Entity; } - public int GetEntityId() + public int getEntityId() { return Entity.getId(); } - + protected abstract String getHurtSound(); - + protected abstract float getVolume(); - + protected abstract float getPitch(); - + public List getTrackedPlayers() { List players = new ArrayList<>(); IntHashMap tracker = ((WorldServer) Entity.world).tracker.trackedEntities; - for(EntityPlayer ep : tracker.get(Entity.getId()).trackedPlayers) + if (tracker.get(Entity.getId()) == null) + { + System.out.println("Tracker did not contain " + Entity.getId() + " " + Entity.getCustomName() + " " + Entity.dead + " " + Entity.locX + " " + Entity.locY + " " + Entity.locZ); + return Collections.emptyList(); + } + for (EntityPlayer ep : tracker.get(Entity.getId()).trackedPlayers) { players.add(ep.getBukkitEntity()); } return players; } - + public void sendPacket(Packet... packet) { - for(Player p : getTrackedPlayers()) { - UtilPlayer.sendPacket(p, packet); + List trackedPlayers = getTrackedPlayers(); + for (Packet p : packet) + { + if (p instanceof PacketPlayOutPlayerInfo) + { + MinecraftServer.getServer().getPlayerList().sendAll(p); + } + else + { + for (Player player : trackedPlayers) + { + UtilPlayer.sendPacket(player, p); + } + } } } - + + public void onDisguise(boolean isActive) + { + + } + + public void onUndisguise(boolean wasActive) + { + + } + + public void onTransfer(DisguiseBase other) + { + + } + + public void onReturn(DisguiseBase other) + { + + } + + public void setHideIfNotDisguised(boolean hideIfNotDisguised) + { + this._hideIfNotDisguised = hideIfNotDisguised; + } + + public boolean isHideIfNotDisguised() + { + return this._hideIfNotDisguised; + } + + public EntityType getDisguiseType() + { + return this._disguiseType; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java index f0406a88e..735ae8914 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java @@ -5,6 +5,7 @@ import java.util.Random; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; +import org.bukkit.entity.EntityType; public class DisguiseBlock extends DisguiseBase { @@ -15,7 +16,7 @@ public class DisguiseBlock extends DisguiseBase public DisguiseBlock(org.bukkit.entity.Entity entity, int blockId, int blockData) { - super(entity); + super(EntityType.FALLING_BLOCK, entity); _blockId = blockId; _blockData = blockData; @@ -32,7 +33,7 @@ public class DisguiseBlock extends DisguiseBase } @Override - public Packet GetSpawnPacket() + public Packet getSpawnPacket() { PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity(); packet.a = Entity.getId(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java index 530f69a5c..09b3d076a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java @@ -35,5 +35,4 @@ public class DisguiseCaveSpider extends DisguiseMonster { return "mob.spider.say"; } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java index a1db97615..2e00319f0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java @@ -7,22 +7,13 @@ import org.bukkit.entity.*; public abstract class DisguiseCreature extends DisguiseInsentient { - private final EntityType _disguiseType; - public DisguiseCreature(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(entity); - - _disguiseType = disguiseType; - } - - public EntityType getDisguiseType() - { - return _disguiseType; + super(disguiseType, entity); } @SuppressWarnings("deprecation") - public Packet GetSpawnPacket() + public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); packet.a = Entity.getId(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java index 5a42eb867..344af0254 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java @@ -1,12 +1,13 @@ package mineplex.core.disguise.disguises; import net.minecraft.server.v1_8_R3.EntityHuman; +import org.bukkit.entity.EntityType; public abstract class DisguiseHuman extends DisguiseLiving { - public DisguiseHuman(org.bukkit.entity.Entity entity) + public DisguiseHuman(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(entity); + super(disguiseType, entity); byte skin = 0; skin |= (1 << 0); //Enable Cape diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java index 349073a17..843af0c09 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java @@ -4,14 +4,15 @@ import mineplex.core.common.*; import net.minecraft.server.v1_8_R3.EntityInsentient; import org.bukkit.*; +import org.bukkit.entity.EntityType; public abstract class DisguiseInsentient extends DisguiseLiving { private boolean _showArmor; - public DisguiseInsentient(org.bukkit.entity.Entity entity) + public DisguiseInsentient(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(entity); + super(disguiseType, entity); DataWatcher.a(3, Byte.valueOf((byte) 0), EntityInsentient.META_CUSTOMNAME_VISIBLE, false); DataWatcher.a(2, "", EntityInsentient.META_CUSTOMNAME, ""); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java index 0f426bf2d..2a1dd6ea2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java @@ -5,6 +5,7 @@ import java.util.Random; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; import net.minecraft.server.v1_8_R3.EntityLiving; @@ -17,9 +18,9 @@ public abstract class DisguiseLiving extends DisguiseBase private boolean _invisible; private ItemStack[] _equipment = new ItemStack[5]; - public DisguiseLiving(org.bukkit.entity.Entity entity) + public DisguiseLiving(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(entity); + super(disguiseType, entity); DataWatcher.a(6, Float.valueOf(1.0F), EntityLiving.META_HEALTH, 1F); DataWatcher.a(7, Integer.valueOf(0), EntityLiving.META_POTION_COLOR, 0); @@ -88,7 +89,7 @@ public abstract class DisguiseLiving extends DisguiseBase { PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(); - packet.a = GetEntityId(); + packet.a = getEntityId(); packet.b = nmsSlot; packet.c = CraftItemStack.asNMSCopy(itemstack); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java index 3bbd587b7..e39715d04 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java @@ -4,12 +4,13 @@ import net.minecraft.server.v1_8_R3.EntitySlime; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import org.bukkit.entity.EntityType; public class DisguiseMagmaCube extends DisguiseInsentient { public DisguiseMagmaCube(org.bukkit.entity.Entity entity) { - super(entity); + super(EntityType.MAGMA_CUBE, entity); DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1); } @@ -24,7 +25,7 @@ public class DisguiseMagmaCube extends DisguiseInsentient return DataWatcher.getByte(16); } - public Packet GetSpawnPacket() + public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); packet.a = Entity.getId(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java index 3e114c350..a97cd2921 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java @@ -1,80 +1,180 @@ package mineplex.core.disguise.disguises; -import java.util.UUID; - -import org.bukkit.Location; -import org.bukkit.block.BlockFace; - import com.mojang.authlib.GameProfile; - +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; import mineplex.core.common.skin.SkinData; -import mineplex.core.common.util.UtilPlayer; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.EntityTrackerEntry; -import net.minecraft.server.v1_8_R3.IntHashMap; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager; +import mineplex.core.thread.ThreadPool; +import mineplex.core.utils.UtilGameProfile; +import net.minecraft.server.v1_8_R3.AttributeInstance; +import net.minecraft.server.v1_8_R3.AttributeMapServer; import net.minecraft.server.v1_8_R3.EntityHuman; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.IInventory; +import net.minecraft.server.v1_8_R3.ITileEntityContainer; import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MobEffect; import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutAbilities; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEffect; +import net.minecraft.server.v1_8_R3.PacketPlayOutExperience; +import net.minecraft.server.v1_8_R3.PacketPlayOutHeldItemSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow; import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.WorldServer; import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; +import net.minecraft.server.v1_8_R3.PacketPlayOutPosition; +import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateAttributes; +import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateHealth; import net.minecraft.server.v1_8_R3.WorldSettings; +import org.bukkit.Bukkit; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerChangedWorldEvent; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.Callable; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Future; +import java.util.function.Supplier; public class DisguisePlayer extends DisguiseHuman { - private Entity _entity; - private GameProfile _profile; - private boolean _sneaking; - private BlockFace _sleeping; - private boolean _sendSkinToSelf; + private String _requestedUsername; - public DisguisePlayer(org.bukkit.entity.Entity entity) + // If _requestedSkinData is not null, that will be used + private SkinData _requestedSkinData; + private String _requestedSkin; + + private GameProfile _originalProfile; + private GameProfile _profile; + + private BlockFace _sleeping; + + private boolean _sendSkinToSelf = true; + private boolean _showInTabList = false; + private int _showInTabListDelay = 30; + + private DisguisePlayer(Entity entity) { - super(entity); - _entity = entity; + super(EntityType.PLAYER, entity); + this._originalProfile = entity instanceof Player ? UtilGameProfile.getGameProfile((Player) entity) : null; } - public DisguisePlayer(org.bukkit.entity.Entity entity, GameProfile profile) + /** + * Using this constructor, this DisguisePlayer will be given the same GameProfile as provided + */ + public DisguisePlayer(Entity entity, GameProfile gameProfile) { this(entity); - setProfile(profile); + this._profile = UtilGameProfile.clone(gameProfile); } - public void setProfile(GameProfile profile) + /** + * @param username The username to disguise this player as, AND the username of the player whose skin will be used + */ + public DisguisePlayer(Entity entity, String username) { - GameProfile newProfile = new GameProfile(UUID.randomUUID(), profile.getName()); - - newProfile.getProperties().putAll(profile.getProperties()); - - _profile = newProfile; + this(entity, username, username); + } + + /** + * @param username The username to disguise this entity as + * @param skin The username of the player whose skin will be used + */ + public DisguisePlayer(Entity entity, String username, String skin) + { + this(entity); + + this._requestedUsername = username; + this._requestedSkin = skin; + } + + public DisguisePlayer(Entity entity, String username, SkinData skinData) + { + this(entity); + + this._requestedUsername = username; + this._requestedSkinData = skinData; + } + + /** + * If this DisguisePlayer has been initialized with a requested username and requested skin, it must be initialized + * + * @param onComplete The Runnable which will be run once initialized. Can be null. It will be run on a separate thread if initialization took place, and the current thread if not + * + * @returns A Future which, upon completion, implies the task is done + */ + public Future initialize(Runnable onComplete) + { + if (this._profile != null && this._profile.isComplete()) + { + onComplete.run(); + return CompletableFuture.completedFuture(null); + } + + return ThreadPool.ASYNC.submit(() -> + { + try + { + GameProfile profileOfUsername = UtilGameProfile.getProfileByName(_requestedUsername, true, null).get(); + + if (_requestedSkinData == null) + { + GameProfile profileOfSkin = UtilGameProfile.getProfileByName(_requestedSkin, true, null).get(); + _requestedSkinData = SkinData.constructFromGameProfile(profileOfSkin, true, true); + } + + this._profile = new GameProfile(profileOfUsername.getId(), profileOfUsername.getName()); + this._profile.getProperties().put("textures", _requestedSkinData.getProperty()); + } + catch (Exception e) + { + // fixme handle + e.printStackTrace(); + } + finally + { + onComplete.run(); + } + }, null); + } + + public GameProfile getProfile() + { + return _profile; + } + + public void setSendSkinDataToSelf(boolean sendToSelf) + { + _sendSkinToSelf = sendToSelf; + } + + public boolean getSendSkinDataToSelf() + { + return _sendSkinToSelf; + } + + public void showInTabList(boolean show, int delay) + { + this._showInTabList = show; + this._showInTabListDelay = delay; } - - public GameProfile getProfile() - { - return _profile; - } - - public void setSkinData(SkinData skin) - { - _profile.getProperties().put("textures", skin.getProperty()); - } - - /** - * Currently not working. - */ - public void setSendSkinDataToSelf(boolean sendToSelf) - { - _sendSkinToSelf = sendToSelf; - } - - public boolean getSendSkinDataToSelf() - { - return _sendSkinToSelf; - } public BlockFace getSleepingDirection() { @@ -82,31 +182,44 @@ public class DisguisePlayer extends DisguiseHuman } /** - * Don't use this if the disguise is already on as it will not work the way you want it to. Contact libraryaddict if you need + * Don't use this if the disguise is already on as it will not work the way you want it to. Contact samczsun if you need * that added. + *

+ * BlockFace.NORTH = feet pointing north + * BlockFace.SOUTH = feet pointing south + * etc etc */ public void setSleeping(BlockFace sleeping) { _sleeping = sleeping; } - public void setSneaking(boolean sneaking) + public PacketPlayOutPlayerInfo getDisguiseInfoPackets(boolean add) { - _sneaking = sneaking; - } + if (!add && _originalProfile == null) + return null; - public boolean getSneaking() - { - return _sneaking; - } - - public Packet getNewInfoPacket(boolean add) - { PacketPlayOutPlayerInfo newDisguiseInfo = new PacketPlayOutPlayerInfo(); newDisguiseInfo.a = add ? EnumPlayerInfoAction.ADD_PLAYER : EnumPlayerInfoAction.REMOVE_PLAYER; - PacketPlayOutPlayerInfo.PlayerInfoData info = newDisguiseInfo.new PlayerInfoData(_profile, 90, - WorldSettings.EnumGamemode.SURVIVAL, null); + PacketPlayOutPlayerInfo.PlayerInfoData info = newDisguiseInfo.new PlayerInfoData(add ? _profile : _originalProfile, UtilMath.r(120), + getAppropriateGamemode(), null); + + newDisguiseInfo.b.add(info); + + return newDisguiseInfo; + } + + public Packet getUndisguiseInfoPackets(boolean remove) + { + if (!remove && _originalProfile == null) + return null; + + PacketPlayOutPlayerInfo newDisguiseInfo = new PacketPlayOutPlayerInfo(); + newDisguiseInfo.a = remove ? EnumPlayerInfoAction.REMOVE_PLAYER : EnumPlayerInfoAction.ADD_PLAYER; + + PacketPlayOutPlayerInfo.PlayerInfoData info = newDisguiseInfo.new PlayerInfoData(remove ? _profile : _originalProfile, UtilMath.r(120), + getAppropriateGamemode(), null); newDisguiseInfo.b.add(info); @@ -120,32 +233,26 @@ public class DisguisePlayer extends DisguiseHuman byte b0 = DataWatcher.getByte(0); - if (_sneaking) + if (Entity.isSneaking()) + { DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1)), EntityHuman.META_ENTITYDATA, (byte) (b0 | 1 << 1)); + } else + { DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1))), EntityHuman.META_ENTITYDATA, (byte) (b0 & ~(1 << 1))); - } + } - public PacketPlayOutNamedEntitySpawn spawnBeforePlayer(Location spawnLocation) - { - Location loc = spawnLocation.add(spawnLocation.getDirection().normalize().multiply(30)); - loc.setY(Math.max(loc.getY(), 0)); + if (Entity instanceof EntityPlayer) + { + EntityPlayer entityPlayer = (EntityPlayer) Entity; - PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); - packet.a = Entity.getId(); - packet.b = _profile.getId(); - packet.c = MathHelper.floor(loc.getX() * 32.0D); - packet.d = MathHelper.floor(loc.getY() * 32.0D); - packet.e = MathHelper.floor(loc.getZ() * 32.0D); - packet.f = (byte) ((int) (loc.getYaw() * 256.0F / 360.0F)); - packet.g = (byte) ((int) (loc.getPitch() * 256.0F / 360.0F)); - packet.i = DataWatcher; - - return packet; + DataWatcher.watch(10, entityPlayer.getDataWatcher().getByte(10), EntityPlayer.META_SKIN, entityPlayer.getDataWatcher().getByte(10)); + DataWatcher.watch(16, (byte) 0, EntityPlayer.META_CAPE, (byte) 1); + } } @Override - public PacketPlayOutNamedEntitySpawn GetSpawnPacket() + public PacketPlayOutNamedEntitySpawn getSpawnPacket() { PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); packet.a = Entity.getId(); @@ -153,8 +260,8 @@ public class DisguisePlayer extends DisguiseHuman packet.c = MathHelper.floor(Entity.locX * 32.0D); packet.d = MathHelper.floor(Entity.locY * 32.0D); packet.e = MathHelper.floor(Entity.locZ * 32.0D); - packet.f = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.g = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); + packet.f = (byte) ((int) ((Entity.isFakeHead() ? Entity.fakePitch : Entity.pitch) * 256.0F / 360.0F)); + packet.g = (byte) ((int) ((Entity.isFakeHead() ? Entity.fakePitch : Entity.pitch) * 256.0F / 360.0F)); packet.i = DataWatcher; return packet; @@ -164,18 +271,213 @@ public class DisguisePlayer extends DisguiseHuman { return _profile.getName(); } - - public void sendHit() - { - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = GetEntityId(); - packet.b = 0; - - sendPacket(packet); - } - public org.bukkit.entity.Entity getEntity() + public void sendHit() { - return _entity; + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = getEntityId(); + packet.b = 0; + + sendPacket(packet); + } + + @Override + public void onDisguise(boolean isActive) + { + if (this.Entity instanceof EntityPlayer) + { + if (_sendSkinToSelf) + { + EntityPlayer entityPlayer = ((EntityPlayer) this.Entity); + + // First construct the packet which will remove the previous disguise from the tab list + PacketPlayOutPlayerInfo playerInfoPacketRemove = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData dataRemove = playerInfoPacketRemove.new PlayerInfoData(_originalProfile, entityPlayer.ping, getAppropriateGamemode(), null); + playerInfoPacketRemove.b.add(dataRemove); + + // This packet will add the new disguised name into the tab list + // We have to create a new profile with the original ID because when we respawn the caller, their UUID stays the same + PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData data = playerInfoPacket.new PlayerInfoData(getSelfProfile(), entityPlayer.ping, getAppropriateGamemode(), null); + playerInfoPacket.b.add(data); + + // This packet does the magic. It forces a new player to be created client-side which causes the skin to reload + PacketPlayOutRespawn respawnPacket = new PacketPlayOutRespawn(entityPlayer.world.getWorld().getEnvironment().getId(), entityPlayer.getWorld().getDifficulty(), entityPlayer.getWorld().worldData.getType(), getAppropriateGamemode()); + + entityPlayer.playerConnection.networkManager.handle(playerInfoPacketRemove); + entityPlayer.playerConnection.networkManager.handle(playerInfoPacket); + entityPlayer.playerConnection.networkManager.handle(respawnPacket); + + update(entityPlayer); + } + } + } + + @Override + public void onUndisguise(boolean wasActive) + { + if (this.Entity instanceof EntityPlayer) + { + if (_sendSkinToSelf) + { + EntityPlayer entityPlayer = ((EntityPlayer) this.Entity); + + // First construct the packet which will remove the previous disguise from the tab list + PacketPlayOutPlayerInfo playerInfoPacketRemove = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData dataRemove = playerInfoPacketRemove.new PlayerInfoData(getSelfProfile(), entityPlayer.ping, getAppropriateGamemode(), null); + playerInfoPacketRemove.b.add(dataRemove); + + // This packet will add the new disguised name into the tab list + // We have to create a new profile with the original ID because when we respawn the caller, their UUID stays the same + + PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData data = playerInfoPacket.new PlayerInfoData(_originalProfile, entityPlayer.ping, entityPlayer.playerInteractManager.getGameMode(), null); + playerInfoPacket.b.add(data); + + // This packet does the magic. It forces a new player to be created client-side which causes the skin to reload + PacketPlayOutRespawn respawnPacket = new PacketPlayOutRespawn(entityPlayer.world.getWorld().getEnvironment().getId(), entityPlayer.getWorld().getDifficulty(), entityPlayer.getWorld().worldData.getType(), getAppropriateGamemode()); + + entityPlayer.playerConnection.networkManager.handle(playerInfoPacketRemove); + entityPlayer.playerConnection.networkManager.handle(playerInfoPacket); + entityPlayer.playerConnection.networkManager.handle(respawnPacket); + + update(entityPlayer); + } + } + } + + @Override + public void onTransfer(DisguiseBase disguise) + { + if (disguise instanceof DisguisePlayer) + { + if (((DisguisePlayer) disguise).getSendSkinDataToSelf() && _sendSkinToSelf && this.Entity instanceof EntityPlayer) + { + EntityPlayer entityPlayer = ((EntityPlayer) this.Entity); + + PacketPlayOutPlayerInfo playerInfoRemove = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData data = playerInfoRemove.new PlayerInfoData(getSelfProfile(), entityPlayer.ping, getAppropriateGamemode(), null); + playerInfoRemove.b.add(data); + + entityPlayer.playerConnection.networkManager.handle(playerInfoRemove); + } + } + } + + @EventHandler + public void onReturn(DisguiseBase disguise) + { + if (disguise instanceof DisguisePlayer) + { + if (((DisguisePlayer) disguise).getSendSkinDataToSelf() && _sendSkinToSelf && this.Entity instanceof EntityPlayer) + { + EntityPlayer entityPlayer = ((EntityPlayer) this.Entity); + + PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData data = playerInfoPacket.new PlayerInfoData(((DisguisePlayer) disguise)._originalProfile, entityPlayer.ping, entityPlayer.playerInteractManager.getGameMode(), null); + playerInfoPacket.b.add(data); + + entityPlayer.playerConnection.networkManager.handle(playerInfoPacket); + + PacketPlayOutPlayerInfo playerInfoAdd = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData dataRemove = playerInfoAdd.new PlayerInfoData(getSelfProfile(), entityPlayer.ping, entityPlayer.playerInteractManager.getGameMode(), null); + playerInfoAdd.b.add(dataRemove); + + entityPlayer.playerConnection.networkManager.handle(playerInfoAdd); + } + } + } + + public GameProfile getOriginalProfile() + { + return UtilGameProfile.clone(_originalProfile); + } + + private void update(EntityPlayer entityPlayer) + { + // And then we teleport them back to where they were + PacketPlayOutPosition positionPacket = new PacketPlayOutPosition(entityPlayer.locX, entityPlayer.locY, entityPlayer.locZ, entityPlayer.yaw, entityPlayer.pitch, new HashSet<>()); + + // Allow them to fly again + PacketPlayOutAbilities packetPlayOutAbilities = new PacketPlayOutAbilities(entityPlayer.abilities); + + // Give them their exp again + PacketPlayOutExperience exp = new PacketPlayOutExperience(entityPlayer.exp, entityPlayer.expTotal, entityPlayer.expLevel); + + entityPlayer.playerConnection.networkManager.handle(positionPacket); + entityPlayer.playerConnection.networkManager.handle(packetPlayOutAbilities); + entityPlayer.playerConnection.networkManager.handle(exp); + if (entityPlayer.activeContainer != entityPlayer.defaultContainer) + { + IInventory inv = ((CraftInventory) entityPlayer.activeContainer.getBukkitView().getTopInventory()).getInventory(); + String name; + if (inv instanceof ITileEntityContainer) + { + name = ((ITileEntityContainer) inv).getContainerName(); + } + else + { + name = "minecraft:chest"; + } + + entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(entityPlayer.activeContainer.windowId, name, inv.getScoreboardDisplayName(), inv.getSize())); + } + entityPlayer.updateInventory(entityPlayer.activeContainer); + entityPlayer.playerConnection.networkManager.handle(new PacketPlayOutHeldItemSlot(entityPlayer.inventory.itemInHandIndex)); + + AttributeMapServer attributemapserver = (AttributeMapServer) entityPlayer.getAttributeMap(); + Set set = attributemapserver.getAttributes(); + + entityPlayer.getBukkitEntity().injectScaledMaxHealth(set, true); + + entityPlayer.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(entityPlayer.getBukkitEntity().getScaledHealth(), entityPlayer.getFoodData().getFoodLevel(), entityPlayer.getFoodData().getSaturationLevel())); + entityPlayer.playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(entityPlayer.getId(), set)); + + for (MobEffect mobEffect : entityPlayer.getEffects()) + { + if (entityPlayer.playerConnection.networkManager.getVersion() > 47 || mobEffect.getEffectId() != 25) + entityPlayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityPlayer.getId(), mobEffect)); + } + } + + public boolean showInTabList() + { + return this._showInTabList; + } + + public int getShowInTabListDelay() + { + return this._showInTabListDelay; + } + + private WorldSettings.EnumGamemode getAppropriateGamemode() + { + if (Entity instanceof EntityPlayer) + { + return ((EntityPlayer) Entity).playerInteractManager.getGameMode(); + } + return WorldSettings.EnumGamemode.SURVIVAL; + } + + private GameProfile getSelfProfile() + { + GameProfile selfProfile = new GameProfile(getOriginalUUID(), this._profile.getName()); + selfProfile.getProperties().putAll(this._profile.getProperties()); + return selfProfile; + } + + private UUID getOriginalUUID() + { + if (this._originalProfile.getProperties().containsKey(PlayerDisguiseManager.ORIGINAL_UUID_KEY)) + { + try + { + return UUID.fromString(this._originalProfile.getProperties().get(PlayerDisguiseManager.ORIGINAL_UUID_KEY).iterator().next().getValue()); + } + catch (IllegalArgumentException ignored) + { + } + } + return this._originalProfile.getId(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java index 426949661..1ebe31ae6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java @@ -18,7 +18,7 @@ public class DisguiseRabbit extends DisguiseAnimal } @Override - public Packet GetSpawnPacket() + public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); packet.a = Entity.getId(); @@ -75,5 +75,4 @@ public class DisguiseRabbit extends DisguiseAnimal return packet; } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java index 67e7547b0..a9f0b44f5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java @@ -4,12 +4,13 @@ import net.minecraft.server.v1_8_R3.EntitySlime; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import org.bukkit.entity.EntityType; public class DisguiseSlime extends DisguiseInsentient { public DisguiseSlime(org.bukkit.entity.Entity entity) { - super(entity); + super(EntityType.SLIME, entity); DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1); } @@ -24,7 +25,7 @@ public class DisguiseSlime extends DisguiseInsentient return DataWatcher.getByte(16); } - public Packet GetSpawnPacket() + public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); packet.a = Entity.getId(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java new file mode 100644 index 000000000..1974687a7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java @@ -0,0 +1,33 @@ +package mineplex.core.disguise.playerdisguise; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +public class DisguiseCommand extends CommandBase implements Listener +{ + DisguiseCommand(PlayerDisguiseManager plugin) + { + super(plugin, Rank.ADMIN, new Rank[]{Rank.YOUTUBE, Rank.TWITCH}, "disguise"); + } + + @Override + public void Execute(final Player caller, final String[] args) + { + if (args == null || args.length == 0) + { + Plugin.undisguise(caller); + return; + } + if (args.length > 2) + { + UtilPlayer.message(caller, F.help("/disguise [username of skin]", "Disguise yourself as 'username' with optional skin belonging to 'username of skin'", Rank.ADMIN)); + return; + } + + Plugin.disguise(caller, args[0], args.length > 1 ? args[1] : args[0]); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguisePlayerBean.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguisePlayerBean.java new file mode 100644 index 000000000..ab7878e08 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguisePlayerBean.java @@ -0,0 +1,137 @@ +package mineplex.core.disguise.playerdisguise; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.PropertyMap; +import com.mojang.util.UUIDTypeAdapter; +import mineplex.serverdata.data.Data; + +import java.lang.reflect.Type; +import java.util.UUID; + +public class DisguisePlayerBean implements Data +{ + private static final Gson GSON; + + static + { + GSON = new GsonBuilder() + .registerTypeAdapter(GameProfile.class, new GameProfileSerializer()) + .registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()) + .registerTypeAdapter(UUID.class, new UUIDTypeAdapter()) + .create(); + } + + private int _accountID; + private String _playerName; + + private String _disguisedPlayer; + private String _disguisedSkin; + + private String _serializedGameProfile; + + public DisguisePlayerBean(int playerAccountID, String playerName, String disguiseAs, String disguiseSkin, GameProfile targetProfile) + { + this._accountID = playerAccountID; + this._playerName = playerName; + + this._disguisedPlayer = disguiseAs; + this._disguisedSkin = disguiseSkin; + + this._serializedGameProfile = serialize(targetProfile); + } + + public int getAccountID() + { + return _accountID; + } + + public String getDisguisedPlayer() + { + return _disguisedPlayer; + } + + public String getDisguisedSkin() + { + return this._disguisedSkin; + } + + public String getPlayerName() + { + return _playerName; + } + + @Override + public String getDataId() + { + return _accountID + _playerName; + } + + public GameProfile getGameProfile() + { + return deserialize(this._serializedGameProfile); + } + + private String serialize(GameProfile gameProfile) + { + return GSON.toJson(gameProfile); + } + + private GameProfile deserialize(String in) + { + return GSON.fromJson(in, GameProfile.class); + } + + private static class GameProfileSerializer implements JsonSerializer, JsonDeserializer + { + private GameProfileSerializer() + { + } + + public GameProfile deserialize(JsonElement var1, Type var2, JsonDeserializationContext var3) throws JsonParseException + { + JsonObject var4 = (JsonObject) var1; + UUID var5 = var4.has("id") ? (UUID) var3.deserialize(var4.get("id"), UUID.class) : null; + String var6 = var4.has("name") ? var4.getAsJsonPrimitive("name").getAsString() : null; + GameProfile gameProfile = new GameProfile(var5, var6); + + if (var4.has("properties")) + { + PropertyMap propertyMap = var3.deserialize(var4.get("properties"), PropertyMap.class); + gameProfile.getProperties().putAll(propertyMap); + } + + return gameProfile; + } + + public JsonElement serialize(GameProfile var1, Type var2, JsonSerializationContext var3) + { + JsonObject var4 = new JsonObject(); + + if (var1.getId() != null) + { + var4.add("id", var3.serialize(var1.getId())); + } + + if (var1.getName() != null) + { + var4.addProperty("name", var1.getName()); + } + + if (var1.getProperties() != null) + { + var4.add("properties", var3.serialize(var1.getProperties())); + } + + return var4; + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java new file mode 100644 index 000000000..e7ff8c3d6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java @@ -0,0 +1,631 @@ +package mineplex.core.disguise.playerdisguise; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.disguise.playerdisguise.events.PlayerDisguisedEvent; +import mineplex.core.disguise.playerdisguise.events.PlayerPreDisguiseEvent; +import mineplex.core.disguise.playerdisguise.events.PlayerPreUndisguiseEvent; +import mineplex.core.disguise.playerdisguise.events.PlayerUndisguisedEvent; +import mineplex.core.event.JoinMessageBroadcastEvent; +import mineplex.core.friend.FriendManager; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.punish.Punish; +import mineplex.core.punish.PunishClient; +import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.utils.UtilGameProfile; +import mineplex.serverdata.Region; +import mineplex.serverdata.data.PlayerStatus; +import mineplex.serverdata.redis.RedisDataRepository; +import mineplex.serverdata.servers.ServerManager; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_8_R3.PlayerList; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.lang.reflect.Field; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.function.Consumer; + +@ReflectivelyCreateMiniPlugin +public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler +{ + public static final String ORIGINAL_UUID_KEY = "originalUUID"; + + private CoreClientManager _clients = require(CoreClientManager.class); + private DisguiseManager _disguise = require(DisguiseManager.class); + private Punish _punish = require(Punish.class); + private CosmeticManager _cosmetics = require(CosmeticManager.class); + private PreferencesManager _prefs = require(PreferencesManager.class); + + private RedisDataRepository _redis; + + // The list of usernames which cannot join because someone else is joining + private Set _cannotJoin = Collections.synchronizedSet(new HashSet<>()); + private Set _loggingIn = Collections.synchronizedSet(new HashSet<>()); + + private Set _pendingDisguise1 = new HashSet<>(); + + private PlayerDisguiseManager() + { + super("Player Disguise Manager"); + + _serverName = _plugin.getConfig().getString("serverstatus.name"); + + require(PacketHandler.class).addPacketHandler(this, PacketHandler.ListenerPriority.LOW, PacketPlayOutPlayerInfo.class, PacketPlayOutNamedEntitySpawn.class); + + _redis = new RedisDataRepository<>(Region.ALL, DisguisePlayerBean.class, "disguisedPlayer"); + } + + @Override + public void addCommands() + { + this.addCommand(new DisguiseCommand(this)); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void cleanup(PlayerQuitEvent event) + { + _cannotJoin.remove(event.getPlayer().getName().toLowerCase()); + _loggingIn.remove(event.getPlayer().getName().toLowerCase()); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onDisguiserJoin(PlayerLoginEvent event) + { + for (DisguisePlayer disguisePlayer : _disguises.values()) + { + if (disguisePlayer.getProfile().getName().equalsIgnoreCase(event.getPlayer().getName())) + { + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + event.setKickMessage("Failed to login: The authentication servers are currently down for maintainence"); + return; + } + } + + if (_cannotJoin.contains(event.getPlayer().getName().toLowerCase())) + { + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + event.setKickMessage("Failed to login: The authentication servers are currently down for maintainence"); + return; + } + + CoreClient client = _clients.Get(event.getPlayer().getUniqueId()); + + DisguisePlayerBean bean = _redis.getElement(client.getAccountId() + client.getName()); + + if (bean != null) + { + Player player = Bukkit.getPlayerExact(bean.getDisguisedPlayer()); + if (player != null) + { + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + event.setKickMessage("You cannot join this server because you are disguised and the user is online!"); + return; + } + + if (_loggingIn.contains(bean.getDisguisedPlayer())) + { + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + event.setKickMessage("You cannot join this server because you are disguised and the user is currently logging in!"); + return; + } + + _cannotJoin.add(bean.getDisguisedPlayer().toLowerCase()); + + runSyncLater(() -> + { + _cannotJoin.remove(bean.getDisguisedPlayer().toLowerCase()); + }, 800L); + } + else + { + _loggingIn.add(event.getPlayer().getName().toLowerCase()); + + runSyncLater(() -> _loggingIn.remove(event.getPlayer().getName().toLowerCase()), 800L); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void onDisguisedPlayerJoin(PlayerJoinEvent event) + { + CoreClient client = _clients.Get(event.getPlayer()); + + if (_redis.elementExists(client.getAccountId() + client.getName())) + { + DisguisePlayerBean bean = _redis.getElement(client.getAccountId() + client.getName()); + + if (bean.getGameProfile() != null) + { + _pendingDisguise1.add(event.getPlayer().getUniqueId()); + + runSyncLater(() -> + { + UtilPlayer.message(event.getPlayer(), F.main(getName(), "Attempting to disguise you as " + bean.getGameProfile().getName())); + disguise(event.getPlayer(), bean.getGameProfile()); + }, 1); + } + } + } + + @EventHandler + public void onJoinMessage(JoinMessageBroadcastEvent event) + { + if (_pendingDisguise1.contains(event.getPlayer().getUniqueId())) + { + CoreClient client = _clients.Get(event.getPlayer()); + DisguisePlayerBean bean = _redis.getElement(client.getAccountId() + client.getName()); + + event.setUsername(bean.getDisguisedPlayer()); + } + } + + public void storeDisguiseData(Player player, String disguisedName, GameProfile gameProfile) + { + CoreClient client = _clients.Get(player); + _redis.addElement(new DisguisePlayerBean(client.getAccountId(), client.getName(), disguisedName, null, gameProfile), 60 * 60 * 12); // 12 hours + System.out.println("+=+=+=+=+=+=+"); + System.out.println("ADDING DISGUISE INFO FOR " + player.getName()); + System.out.println("+=+=+=+=+=+=+"); + } + + public void removeDisguiseData(Player player) + { + CoreClient client = _clients.Get(player); + _redis.removeElement(client.getAccountId() + client.getName()); + System.out.println("+=+=+=+=+=+=+"); + System.out.println("REMOVING DISGUISE INFO FOR " + player.getName()); + System.out.println("+=+=+=+=+=+=+"); + } + + + /* + * Maps players (their UUID) with their disguises + */ + private final Map _disguises = new HashMap<>(); + + /* + * Mapping of old username to disguised username + */ + private final Map _mapping = new HashMap<>(); + + /* + * A set of usernames which are currently being disguised + * This is to prevent two people from running /disguise at the same time + */ + private Set _pendingDisguise = Collections.synchronizedSet(new HashSet<>()); + + private final String _serverName; + + private RedisDataRepository _repository = new RedisDataRepository<>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), + Region.currentRegion(), PlayerStatus.class, "playerStatus"); + + @EventHandler + public void onQuit(PlayerQuitEvent event) + { + _pendingDisguise1.remove(event.getPlayer().getUniqueId()); + _disguises.remove(event.getPlayer().getUniqueId()); + _mapping.remove(event.getPlayer().getName().toLowerCase()); + } + + private boolean isDisguised(Player player) + { + return _disguises.containsKey(player.getUniqueId()); + } + + public void allow(Player player) + { + _pendingDisguise1.remove(player.getUniqueId()); + } + + public DisguiseManager getDisguiseManager() + { + return this._disguise; + } + + public CoreClientManager getClientManager() + { + return this._clients; + } + + public Punish getPunishManager() + { + return this._punish; + } + + public CosmeticManager getCostmeticManager() + { + return this._cosmetics; + } + + public PreferencesManager getPreferencesManager() + { + return this._prefs; + } + + // DisguiseManager is too slow, we need to cancel it here first + @Override + public void handle(PacketInfo packetInfo) + { + if (packetInfo.getPacket() instanceof PacketPlayOutPlayerInfo) + { + PacketPlayOutPlayerInfo packet = (PacketPlayOutPlayerInfo) packetInfo.getPacket(); + Iterator iterator = packet.b.iterator(); + while (iterator.hasNext()) + { + PacketPlayOutPlayerInfo.PlayerInfoData data = iterator.next(); + if (_pendingDisguise1.contains(data.a().getId())) + { + iterator.remove(); + } + } + + if (packet.b.isEmpty()) + { + packetInfo.setCancelled(true); + } + else + { + if (packet.a != PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER && packet.a != PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER) + { + for (PacketPlayOutPlayerInfo.PlayerInfoData data : packet.b) + { + Player player = Bukkit.getPlayerExact(data.a().getName()); + + if (player != null) + { + if (isDisguised(player)) + { + PacketPlayOutPlayerInfo custom = new PacketPlayOutPlayerInfo(); + custom.a = packet.a; + + GameProfile originalProfile = _disguises.get(player.getUniqueId()).getOriginalProfile(); + custom.b.add(custom.new PlayerInfoData(originalProfile, data.b, data.c, data.d())); + + ((CraftPlayer) player).getHandle().playerConnection.networkManager.handle(custom); + } + } + else + { + System.out.println("Null player while sending PlayerInfoData: " + data.a().getName()); + } + } + } + } + } + else if (packetInfo.getPacket() instanceof PacketPlayOutNamedEntitySpawn) + { + PacketPlayOutNamedEntitySpawn spawn = (PacketPlayOutNamedEntitySpawn) packetInfo.getPacket(); + if (_pendingDisguise1.contains(spawn.b)) + { + packetInfo.setCancelled(true); + } + } + } + + public void undisguise(Player caller) + { + if (!isDisguised(caller)) + { + if (getDisguiseManager().isDisguised(caller)) + { + UtilPlayer.message(caller, F.main("Disguise", "You have been disguised by something else. Perhaps you are morphed?")); + } + else + { + UtilPlayer.message(caller, F.main("Disguise", "You are not disguised. You can disguise with /disguise [username of skin]")); + } + return; + } + + if (getDisguiseManager().getActiveDisguise(caller) != _disguises.get(caller.getUniqueId())) + { + UtilPlayer.message(caller, F.main("Disguise", "Could not undisguise as it is not your active disguise. Perhaps you are morphed?")); + return; + } + + PlayerPreUndisguiseEvent playerPreUndisguiseEvent = new PlayerPreUndisguiseEvent(caller); + UtilServer.CallEvent(playerPreUndisguiseEvent); + if (playerPreUndisguiseEvent.isCancelled()) + { + return; + } + + DisguisePlayer disguise = _disguises.remove(caller.getUniqueId()); + + GameProfile originalProfile = disguise.getOriginalProfile(); + GameProfile currentProfile = ((CraftPlayer) caller).getProfile(); + + require(ScoreboardManager.class).handlePlayerQuit(disguise.getName()); + try + { + UtilGameProfile.changeName(currentProfile, originalProfile.getName()); + UtilGameProfile.changeId(currentProfile, originalProfile.getId()); + currentProfile.getProperties().clear(); + currentProfile.getProperties().putAll(originalProfile.getProperties()); + + Field playersByName = PlayerList.class.getDeclaredField("playersByName"); + playersByName.setAccessible(true); + Map map = (Map) playersByName.get(MinecraftServer.getServer().getPlayerList()); + map.remove(disguise.getProfile().getName()); + map.put(disguise.getOriginalProfile().getName(), disguise.getEntity()); + } + catch (Exception ex) + { + UtilPlayer.message(caller, F.main("Disguise", "Could not undisguise because something went terribly wrong :(")); + ex.printStackTrace(); + return; + } + + getDisguiseManager().undisguise(caller); + + GameProfile disguisedProfile = disguise.getProfile(); + + CoreClient client = getClientManager().Get(caller); + client.undisguise(); + + require(FriendManager.class).updatePlayerStatus(disguisedProfile.getName(), null); + require(FriendManager.class).updatePlayerStatus(originalProfile.getName(), new PlayerStatus(originalProfile.getName(), _serverName)); + getPreferencesManager().handlePlayerJoin(caller, true); + + require(ScoreboardManager.class).handlePlayerJoin(disguise.getOriginalProfile().getName()); + + + _mapping.remove(disguise.getName().toLowerCase()); + + UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); + getPluginManager().callEvent(new PlayerUndisguisedEvent(caller)); + removeDisguiseData(caller); + } + + public void disguise(Player caller, GameProfile requestedProfile) + { + if (getDisguiseManager().isDisguised(caller)) + { + if (isDisguised(caller)) + { + UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); + } + else + { + UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Perhaps you are morphed?")); + } + return; + } + + if (isDisguised(caller)) + { + UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); + return; + } + + String requestedUsername = requestedProfile.getName(); + + if (!requestedUsername.equalsIgnoreCase(caller.getName())) + { + _cannotJoin.add(requestedUsername.toLowerCase()); + for (Player other : UtilServer.getPlayersCollection()) + { + if (other.getName().equalsIgnoreCase(requestedUsername)) + { + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "This name is already in use!")); + return; + } + } + } + + if (!_pendingDisguise.add(requestedUsername.toLowerCase())) + { + UtilPlayer.message(caller, F.main("Disguise", "Someone is already disguising as that user")); + return; + } + + PlayerPreDisguiseEvent playerPreDisguiseEvent = new PlayerPreDisguiseEvent(caller, requestedUsername); + UtilServer.CallEvent(playerPreDisguiseEvent); + if (playerPreDisguiseEvent.isCancelled()) + { + UtilPlayer.message(caller, F.main(getName(), "Your disguise was cancelled by something")); + _pendingDisguise.remove(requestedUsername.toLowerCase()); + return; + } + + CoreClient callerClient = getClientManager().Get(caller); + + if (!requestedUsername.equalsIgnoreCase(caller.getName())) + { + Rank otherRank = Rank.ALL; + CoreClient other = new CoreClient(requestedUsername, requestedProfile.getId()); + try + { + getClientManager().LoadClient(other, requestedProfile.getId(), caller.getAddress().getAddress().getHostAddress()); + otherRank = other.GetRank(); + } + catch (NullPointerException exception) + { + other = null; + } + + if (otherRank.has(Rank.TWITCH)) + { + UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, YouTubers or Twitchers!")); + return; + } + + if (other != null) + { + PunishClient pclient = getPunishManager().GetClient(requestedUsername); + if (pclient != null && (pclient.IsBanned() || pclient.IsMuted())) + { + UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as players who are banned/muted!")); + return; + } + } + + callerClient.disguise(requestedUsername, requestedProfile.getId(), otherRank); + + _mapping.put(callerClient.getDisguisedAs().toLowerCase(), callerClient.getName()); + + System.out.println("================="); + System.out.println("Disguising " + caller.getName() + " as:"); + System.out.println(requestedProfile.getName() + " id " + requestedProfile.getId()); + System.out.println("Properties:"); + for (Map.Entry p : requestedProfile.getProperties().entries()) + { + System.out.println("\t" + p.getKey() + " " + p.getValue().getName()); + System.out.println("\t" + p.getValue().getValue()); + System.out.println("\t" + p.getValue().getSignature()); + } + System.out.println("================="); + + DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); + disguisePlayer.showInTabList(true, 0); + allow(caller); + getDisguiseManager().disguise(disguisePlayer, () -> + { + GameProfile callerProfile = ((CraftPlayer) caller).getProfile(); + + require(ScoreboardManager.class).handlePlayerQuit(disguisePlayer.getOriginalProfile().getName()); + + try + { + UtilGameProfile.changeName(callerProfile, disguisePlayer.getProfile().getName()); + UtilGameProfile.changeId(callerProfile, disguisePlayer.getProfile().getId()); + + Field playersByName = PlayerList.class.getDeclaredField("playersByName"); + playersByName.setAccessible(true); + Map map = (Map) playersByName.get(MinecraftServer.getServer().getPlayerList()); + map.remove(disguisePlayer.getOriginalProfile().getName()); + map.put(disguisePlayer.getProfile().getName(), disguisePlayer.getEntity()); + } + catch (Throwable t) + { + t.printStackTrace(); + } + + require(ScoreboardManager.class).handlePlayerJoin(disguisePlayer.getName()); + + callerProfile.getProperties().clear(); + callerProfile.getProperties().putAll(disguisePlayer.getProfile().getProperties()); + + callerProfile.getProperties().removeAll(ORIGINAL_UUID_KEY); + callerProfile.getProperties().put(ORIGINAL_UUID_KEY, new Property(ORIGINAL_UUID_KEY, caller.getUniqueId().toString())); + + require(FriendManager.class).updatePlayerStatus(disguisePlayer.getOriginalProfile().getName(), null); + require(FriendManager.class).updatePlayerStatus(requestedUsername, new PlayerStatus(requestedUsername, _serverName)); + + getPreferencesManager().handlePlayerJoin(caller, true); + + _disguises.put(caller.getUniqueId(), disguisePlayer); + + UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + requestedUsername)); + + UtilServer.CallEvent(new PlayerDisguisedEvent(caller)); + + storeDisguiseData(caller, requestedUsername, requestedProfile); + + _pendingDisguise.remove(requestedUsername.toLowerCase()); + + _cannotJoin.remove(requestedUsername.toLowerCase()); + }); + } + else + { + DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); + disguisePlayer.showInTabList(true, 0); + allow(caller); + getDisguiseManager().disguise(disguisePlayer, () -> + { + ((CraftPlayer) caller).getProfile().getProperties().clear(); + ((CraftPlayer) caller).getProfile().getProperties().putAll(disguisePlayer.getProfile().getProperties()); + + storeDisguiseData(caller, caller.getName(), requestedProfile); + getPreferencesManager().handlePlayerJoin(caller, true); + + _disguises.put(caller.getUniqueId(), disguisePlayer); + + _pendingDisguise.remove(requestedUsername.toLowerCase()); + }); + } + } + + public void disguise(Player caller, String requestedUsername, String requestedSkin) + { + if (!validateUsername(caller, requestedUsername)) return; + if (!validateUsername(caller, requestedSkin)) return; + + UtilGameProfile.getProfileByName(requestedUsername, true, requestedProfile -> + { + Consumer skinConsumer = requestedProfileSkin -> + { + SkinData skinData = SkinData.constructFromGameProfile(requestedProfileSkin, true, true); + requestedProfile.getProperties().clear(); + requestedProfile.getProperties().put("textures", skinData.getProperty()); + + disguise(caller, requestedProfile); + }; + + if (!requestedUsername.equalsIgnoreCase(requestedSkin)) + { + UtilGameProfile.getProfileByName(requestedSkin, true, skinConsumer); + } + else + { + skinConsumer.accept(UtilGameProfile.clone(requestedProfile)); + } + }); + } + + private boolean validateUsername(Player caller, String username) + { + String replaced = UtilGameProfile.legalize(username); + if (!replaced.equals(username)) + { + UtilPlayer.message(caller, F.main(getName(), "The chosen username of '" + username + "' is not valid")); + return false; + } + + if (username.length() > 16) + { + UtilPlayer.message(caller, F.main("Disguise", "The chosen username of '" + username + "' is " + F.count(String.valueOf(username.length() - 16)) + " characters too long!")); + return false; + } + + if (username.length() <= 0) + { + UtilPlayer.message(caller, F.main("Disguise", "The chosen username of '" + username + "' must be longer than 0 characters")); + return false; + } + + return true; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerDisguisedEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerDisguisedEvent.java new file mode 100644 index 000000000..260cfe11e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerDisguisedEvent.java @@ -0,0 +1,32 @@ +package mineplex.core.disguise.playerdisguise.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerDisguisedEvent extends Event +{ + private static final HandlerList HANDLERS = new HandlerList(); + + private Player _player; + + public PlayerDisguisedEvent(Player disguisee) + { + this._player = disguisee; + } + + public Player getPlayer() + { + return _player; + } + + public HandlerList getHandlers() + { + return HANDLERS; + } + + public static HandlerList getHandlerList() + { + return HANDLERS; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreDisguiseEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreDisguiseEvent.java new file mode 100644 index 000000000..b0ccbd4f3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreDisguiseEvent.java @@ -0,0 +1,54 @@ +package mineplex.core.disguise.playerdisguise.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerPreDisguiseEvent extends Event implements Cancellable +{ + private static final HandlerList HANDLERS = new HandlerList(); + + private Player _player; + private String _requestedUsername; + private boolean _cancelled; + + public PlayerPreDisguiseEvent(Player disguisee, String requestedUsername) + { + this._player = disguisee; + this._requestedUsername = requestedUsername; + } + + public Player getPlayer() + { + return _player; + } + + public String getRequestedUsername() + { + return this._requestedUsername; + } + + @Override + public HandlerList getHandlers() + { + return HANDLERS; + } + + public static HandlerList getHandlerList() + { + return HANDLERS; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean b) + { + this._cancelled = b; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreUndisguiseEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreUndisguiseEvent.java new file mode 100644 index 000000000..a490b2f8b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreUndisguiseEvent.java @@ -0,0 +1,47 @@ +package mineplex.core.disguise.playerdisguise.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerPreUndisguiseEvent extends Event implements Cancellable +{ + private static final HandlerList HANDLERS = new HandlerList(); + + private Player _player; + private boolean _cancelled; + + public PlayerPreUndisguiseEvent(Player disguisee) + { + this._player = disguisee; + } + + public Player getPlayer() + { + return _player; + } + + @Override + public HandlerList getHandlers() + { + return HANDLERS; + } + + public static HandlerList getHandlerList() + { + return HANDLERS; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean b) + { + this._cancelled = b; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerUndisguisedEvent.java similarity index 73% rename from Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java rename to Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerUndisguisedEvent.java index ad8d9a9d0..4820ffeea 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerUndisguisedEvent.java @@ -1,14 +1,14 @@ -package mineplex.core.disguise; +package mineplex.core.disguise.playerdisguise.events; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -public class PlayerUndisguiseEvent extends Event +public class PlayerUndisguisedEvent extends Event { private static final HandlerList handlers = new HandlerList(); private Player _player; - public PlayerUndisguiseEvent(Player disguisee) + public PlayerUndisguisedEvent(Player disguisee) { this._player = disguisee; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 206d245be..260ce09cd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -69,7 +69,7 @@ public class DonationManager extends MiniClientPlugin private void LoadDonor(DonorTokenWrapper token, UUID uuid) { - Get(token.Name).loadToken(token.DonorToken); + Get(uuid).loadToken(token.DonorToken); //_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins()); } @@ -80,7 +80,7 @@ public class DonationManager extends MiniClientPlugin public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final GlobalCurrency currencyType, final int cost, boolean oneTimePurchase) { - final Donor donor = Bukkit.getPlayerExact(name) != null ? Get(name) : null; + final Donor donor = Bukkit.getPlayerExact(name) != null ? Get(Bukkit.getPlayerExact(name)) : null; if (donor != null) { @@ -120,7 +120,7 @@ public class DonationManager extends MiniClientPlugin { if (response == TransactionResponse.Success) { - Donor donor = Get(name); + Donor donor = Get(uuid); if (donor != null) { @@ -149,7 +149,7 @@ public class DonationManager extends MiniClientPlugin { if (updateTotal) { - Donor donor = Get(name); + Donor donor = Get(uuid); if (donor != null) { @@ -177,7 +177,7 @@ public class DonationManager extends MiniClientPlugin _gemQueue.get(player).put(caller, totalAmount); //Do Temp Change - Donor donor = Get(player.getName()); + Donor donor = Get(player.getUniqueId()); if (donor != null) donor.addBalance(GlobalCurrency.GEM, amount); @@ -264,7 +264,7 @@ public class DonationManager extends MiniClientPlugin _coinQueue.get(player).put(caller, totalAmount); //Do Temp Change - Donor donor = Get(player.getName()); + Donor donor = Get(player.getUniqueId()); if (donor != null) donor.addBalance(GlobalCurrency.TREASURE_SHARD, amount); @@ -333,7 +333,7 @@ public class DonationManager extends MiniClientPlugin { if (success) { - Donor donor = Get(data.getPlayerName()); + Donor donor = Get(data.getUuid()); if (donor != null) { @@ -373,7 +373,7 @@ public class DonationManager extends MiniClientPlugin } @Override - protected Donor addPlayer(String player) + protected Donor addPlayer(UUID uuid) { return new Donor(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java index cbe9dc269..f606a607c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java @@ -36,18 +36,13 @@ public class ShardCommand extends CommandBase } else if (target == null) { - Plugin.getClientManager().loadClientByName(targetName, new Runnable() + Plugin.getClientManager().loadClientByName(targetName, client -> { - public void run() + if (client != null) + rewardCoins(caller, null, targetName, client.getAccountId(), coinsString); + else { - CoreClient client = Plugin.getClientManager().Get(targetName); - - if (client != null) - rewardCoins(caller, null, targetName, client.getAccountId(), coinsString); - else - { - UtilPlayer.message(caller, F.main("Shards", "Could not find player " + F.name(targetName))); - } + UtilPlayer.message(caller, F.main("Shards", "Could not find player " + F.name(targetName))); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java index cbfec07b9..e46c10f59 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java @@ -2,6 +2,7 @@ package mineplex.core.elo; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; @@ -114,15 +115,15 @@ public class EloManager extends MiniDbClientPlugin } @Override - protected EloClientData addPlayer(String player) + protected EloClientData addPlayer(UUID uuid) { return new EloClientData(); } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadClientInformation(resultSet)); + Set(uuid, _repository.loadClientInformation(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/energy/Energy.java b/Plugins/Mineplex.Core/src/mineplex/core/energy/Energy.java index 51849c397..b1f180cdc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/energy/Energy.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/energy/Energy.java @@ -16,6 +16,8 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.energy.event.EnergyEvent; import mineplex.core.energy.event.EnergyEvent.EnergyChangeReason; +import java.util.UUID; + public class Energy extends MiniClientPlugin { private double _baseEnergy = 180; @@ -137,7 +139,7 @@ public class Energy extends MiniClientPlugin } @Override - protected ClientEnergy addPlayer(String player) + protected ClientEnergy addPlayer(UUID uuid) { return new ClientEnergy(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/event/JoinMessageBroadcastEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/event/JoinMessageBroadcastEvent.java new file mode 100644 index 000000000..be57e5da2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/event/JoinMessageBroadcastEvent.java @@ -0,0 +1,47 @@ +package mineplex.core.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/* + * This event is called when the join message is about to be sent + */ +public class JoinMessageBroadcastEvent extends Event +{ + private static final HandlerList HANDLERS = new HandlerList(); + + private Player _player; + private String _username; + + public JoinMessageBroadcastEvent(Player player) + { + this._player = player; + this._username = player.getName(); + } + + public Player getPlayer() + { + return this._player; + } + + public String getUsername() + { + return this._username; + } + + public void setUsername(String username) + { + this._username = username; + } + + public HandlerList getHandlers() + { + return HANDLERS; + } + + public static HandlerList getHandlerList() + { + return HANDLERS; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java index 4f1e56d17..83b402573 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java @@ -2,6 +2,7 @@ package mineplex.core.facebook; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -106,16 +107,16 @@ public class FacebookManager extends MiniDbClientPlugin } @Override - protected FacebookClient addPlayer(String player) + protected FacebookClient addPlayer(UUID uuid) { return new FacebookClient(false); } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { boolean hasRow = resultSet.next(); - Set(playerName, new FacebookClient(hasRow)); + Set(uuid, new FacebookClient(hasRow)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index 355aa3407..2b76462b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.UUID; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; @@ -28,6 +29,7 @@ import mineplex.core.preferences.PreferencesManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.serverdata.data.PlayerStatus; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -70,7 +72,7 @@ public class FriendManager extends MiniDbClientPlugin } @Override - protected FriendData addPlayer(String player) + protected FriendData addPlayer(UUID uuid) { return new FriendData(); } @@ -399,10 +401,21 @@ public class FriendManager extends MiniDbClientPlugin return false; } - @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + + public void updatePlayerStatus(String playerName, PlayerStatus status) { - Set(playerName, _repository.loadClientInformation(resultSet)); + _repository.updatePlayerStatus(playerName, status); + } + + public PlayerStatus getStatus(String playerName) + { + return _repository.getStatus(playerName); + } + + @Override + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException + { + Set(uuid, _repository.loadClientInformation(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java index e26721864..81cf0b4eb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -14,7 +14,6 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.common.util.NautHashMap; import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.ResultSetCallable; import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.core.friend.FriendStatusType; @@ -183,7 +182,7 @@ public class FriendRepository extends MinecraftRepository /** * @param playerName - the name of the player whose current server status is being fetched - * @return the {@link MinecraftServer} name that the player matching {@code playerName} + * @return the name that the player matching {@code playerName} * is currently online on, if they are online, null otherwise. */ public String fetchPlayerServer(String playerName) @@ -192,4 +191,21 @@ public class FriendRepository extends MinecraftRepository return (status == null) ? null : status.getServer(); } + + public void updatePlayerStatus(String playerName, PlayerStatus status) + { + if (status != null) + { + _repository.addElement(status, 60 * 60 * 8); + } + else + { + _repository.removeElement(playerName.toLowerCase()); + } + } + + public PlayerStatus getStatus(String playerName) + { + return _repository.getElement(playerName.toLowerCase()); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java index 9135d6f38..4f7a4df5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java @@ -54,21 +54,15 @@ public class AmmoCommand extends CommandBase { if (target == null) { - _plugin.getClientManager().loadClientByName(targetName, new Runnable() + _plugin.getClientManager().loadClientByName(targetName, loadedProfile -> { - @Override - public void run() + if (loadedProfile != null) { - CoreClient client = _plugin.getClientManager().Get(targetName); - - if (client != null) - { - addAmmo(caller, client.GetPlayer(), gadget, amount); - } - else - { - UtilPlayer.message(caller, F.main("Ammo", "Could not find player " + F.name(targetName))); - } + addAmmo(caller, loadedProfile.GetPlayer(), gadget, amount); + } + else + { + UtilPlayer.message(caller, F.main("Ammo", "Could not find player " + F.name(targetName))); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java index 1fc07c933..36bdfd764 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java @@ -89,7 +89,7 @@ public class LockCosmeticsCommand extends CommandBase Item clientItem = _plugin.getInventoryManager().getItem(gadget.getName()); if (clientItem == null) continue; - _plugin.getInventoryManager().Get(caller.getName()).removeItem(new ClientItem(clientItem, 1)); + _plugin.getInventoryManager().Get(caller).removeItem(new ClientItem(clientItem, 1)); removed++; } } @@ -108,7 +108,7 @@ public class LockCosmeticsCommand extends CommandBase Item clientItem = _plugin.getInventoryManager().getItem(mount.getName()); if (clientItem == null) continue; - _plugin.getInventoryManager().Get(caller.getName()).removeItem(new ClientItem(clientItem, 1)); + _plugin.getInventoryManager().Get(caller).removeItem(new ClientItem(clientItem, 1)); removed++; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java index 57938844b..6bada9d2d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java @@ -45,7 +45,7 @@ public class ArrowTrailTitan extends ArrowEffectGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java index 1d4fd7b3e..375384371 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java @@ -34,7 +34,7 @@ public class DeathTitan extends DeathEffectGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java index 2282001f2..9de6ce64f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java @@ -39,7 +39,7 @@ public class DoubleJumpTitan extends DoubleJumpEffectGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java index 5a3e85f68..29641ce98 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java @@ -59,7 +59,7 @@ public class MorphBat extends MorphGadget implements IThrown this.ApplyArmor(player, message); DisguiseBat disguise = new DisguiseBat(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java index 0708fe148..75dc613cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java @@ -42,7 +42,7 @@ public class MorphBlaze extends MorphGadget this.ApplyArmor(player, message); DisguiseBlaze disguise = new DisguiseBlaze(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } @@ -84,7 +84,7 @@ public class MorphBlaze extends MorphGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java index 55abae373..2c6be003f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java @@ -55,7 +55,7 @@ public class MorphBunny extends MorphGadget this.ApplyArmor(player, message); DisguiseRabbit disguise = new DisguiseRabbit(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); @@ -135,8 +135,8 @@ public class MorphBunny extends MorphGadget if (!UtilEvent.isAction(event, ActionType.L)) return; - - if (Manager.getDonationManager().Get(player.getName()).getBalance(GlobalCurrency.TREASURE_SHARD) < 500) + + if (Manager.getDonationManager().Get(player).getBalance(GlobalCurrency.TREASURE_SHARD) < 500) { UtilPlayer.message(player, F.main("Gadget", "You do not have enough Shards.")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java index 20c997d91..74faab8a5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java @@ -48,7 +48,7 @@ public class MorphChicken extends MorphGadget this.ApplyArmor(player, message); DisguiseChicken disguise = new DisguiseChicken(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java index 652c35330..734d8f0e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java @@ -36,7 +36,7 @@ public class MorphCow extends MorphGadget this.ApplyArmor(player, message); DisguiseCow disguise = new DisguiseCow(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java index 149c59a82..e0dd79087 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java @@ -50,7 +50,7 @@ public class MorphCreeper extends MorphGadget this.ApplyArmor(player, message); DisguiseCreeper disguise = new DisguiseCreeper(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } @@ -171,7 +171,7 @@ public class MorphCreeper extends MorphGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java index 59e7d9e2f..0c8bcc296 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java @@ -47,7 +47,7 @@ public class MorphEnderman extends MorphGadget this.ApplyArmor(player, message); DisguiseEnderman disguise = new DisguiseEnderman(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java index 5a0e4f4c2..dbf439dc0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java @@ -49,7 +49,7 @@ public class MorphPig extends MorphGadget this.ApplyArmor(player, message); DisguisePig disguise = new DisguisePig(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } @@ -84,7 +84,7 @@ public class MorphPig extends MorphGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.ULTRA)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java index ae4aa8913..1faab01c8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java @@ -34,7 +34,7 @@ public class MorphPumpkinKing extends MorphGadget DisguiseSkeleton disguise = new DisguiseSkeleton(player); disguise.showArmor(); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); disguise.SetSkeletonType(SkeletonType.WITHER); Manager.getDisguiseManager().disguise(disguise); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java index 7ea51f3f0..bd7400c2c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java @@ -48,7 +48,7 @@ public class MorphSlime extends MorphGadget this.ApplyArmor(player, message); DisguiseSlime disguise = new DisguiseSlime(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); int size = 1 + (_achievementManager.getMineplexLevelNumber(player, _clientManager.Get(player).GetRank())) / 8; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java index 3996d5626..c2a16a87f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java @@ -60,7 +60,7 @@ public class MorphSnowman extends MorphGadget this.ApplyArmor(player, message); DisguiseSnowman disguise = new DisguiseSnowman(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java index c2bcd1cc7..f2ef8d5d8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java @@ -63,7 +63,7 @@ public class MorphTitan extends MorphGadget this.ApplyArmor(player, message); DisguiseGuardian disguise = new DisguiseGuardian(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); disguise.setElder(true); Manager.getDisguiseManager().disguise(disguise); @@ -228,7 +228,7 @@ public class MorphTitan extends MorphGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java index 44cad0b25..e5fa3bca1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java @@ -1,22 +1,32 @@ package mineplex.core.gadget.gadgets.morph; -import java.util.UUID; - import com.mojang.authlib.GameProfile; import mineplex.core.common.skin.SkinData; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; +import mineplex.core.utils.UtilGameProfile; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.WeakHashMap; public class MorphUncleSam extends MorphGadget { + private Map _disguises = new HashMap<>(); public MorphUncleSam(GadgetManager manager) { @@ -37,12 +47,15 @@ public class MorphUncleSam extends MorphGadget { this.ApplyArmor(player, message); - DisguisePlayer disguisePlayer = new DisguisePlayer(player); - disguisePlayer.setProfile(new GameProfile(UUID.randomUUID(), C.cRed + "Uncle " + C.cBlue + "Sam")); - SkinData uncleSam = SkinData.UNCLE_SAM; - disguisePlayer.setSkinData(uncleSam); - disguisePlayer.setSendSkinDataToSelf(true); + GameProfile profile = UtilGameProfile.getGameProfile(player); + profile.getProperties().clear(); + profile.getProperties().put("textures", SkinData.UNCLE_SAM.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile); + disguisePlayer.showInTabList(true, 0); Manager.getDisguiseManager().disguise(disguisePlayer); + + this._disguises.put(player.getUniqueId(), disguisePlayer); } @Override @@ -50,7 +63,7 @@ public class MorphUncleSam extends MorphGadget { this.RemoveArmor(player); - Manager.getDisguiseManager().undisguise(player); + Manager.getDisguiseManager().undisguise(this._disguises.remove(player.getUniqueId())); } @EventHandler @@ -71,4 +84,9 @@ public class MorphUncleSam extends MorphGadget UtilFirework.playFreedomFirework(player.getLocation().clone().add(0, 2, 0)); } + @EventHandler + public void quit(PlayerQuitEvent event) + { + this._disguises.remove(event.getPlayer().getUniqueId()); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java index 794fba99d..e0f9edd70 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java @@ -51,7 +51,7 @@ public class MorphVillager extends MorphGadget implements IThrown this.ApplyArmor(player, message); DisguiseVillager disguise = new DisguiseVillager(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } @@ -73,8 +73,8 @@ public class MorphVillager extends MorphGadget implements IThrown if (!UtilEvent.isAction(event, ActionType.L)) return; - - if (Manager.getDonationManager().Get(player.getName()).getBalance(GlobalCurrency.GEM) < 20) + + if (Manager.getDonationManager().Get(player).getBalance(GlobalCurrency.GEM) < 20) { UtilPlayer.message(player, F.main("Gadget", "You do not have enough Gems.")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java index 505551d3b..682b79bd7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java @@ -64,7 +64,7 @@ public class MorphWither extends MorphGadget player.setHealth(300); DisguiseWither disguise = new DisguiseWither(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); //disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); @@ -184,7 +184,7 @@ public class MorphWither extends MorphGadget // TODO HARDCODED Wither Morph Database Item Id - 550 if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) { - Manager.getInventoryManager().Get(event.getPlayer().getName()).addItem(new ClientItem(new Item(550, getName()), 1)); + Manager.getInventoryManager().Get(event.getPlayer()).addItem(new ClientItem(new Item(550, getName()), 1)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/ravesuit/OutfitRaveSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/ravesuit/OutfitRaveSuit.java index adfef82bc..2c851cced 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/ravesuit/OutfitRaveSuit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/ravesuit/OutfitRaveSuit.java @@ -1,6 +1,8 @@ package mineplex.core.gadget.gadgets.outfit.ravesuit; import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import org.bukkit.Color; import org.bukkit.Material; @@ -24,8 +26,7 @@ import mineplex.core.updater.event.UpdateEvent; public class OutfitRaveSuit extends OutfitGadget { - - private HashMap _colorPhase = new HashMap(); + private Map _colorPhase = new HashMap<>(); public OutfitRaveSuit(GadgetManager manager, String name, int cost, ArmorSlot slot, Material mat, byte data) @@ -39,14 +40,14 @@ public class OutfitRaveSuit extends OutfitGadget public void enableCustom(Player player, boolean message) { applyArmor(player, message); - _colorPhase.put(player.getName(), -1); + _colorPhase.put(player.getUniqueId(), -1); } @Override public void disableCustom(Player player, boolean message) { removeArmor(player, message); - _colorPhase.remove(player.getName()); + _colorPhase.remove(player.getUniqueId()); } @EventHandler @@ -109,14 +110,14 @@ public class OutfitRaveSuit extends OutfitGadget } //Rainbow - int phase = _colorPhase.get(player.getName()); + int phase = _colorPhase.get(player.getUniqueId()); LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta(); if (phase == -1) { meta.setColor(Color.fromRGB(250, 0, 0)); - _colorPhase.put(player.getName(), 0); + _colorPhase.put(player.getUniqueId(), 0); } //Red > Yellow else if (phase == 0) @@ -124,7 +125,7 @@ public class OutfitRaveSuit extends OutfitGadget meta.setColor(Color.fromRGB(250, Math.min(250, meta.getColor().getGreen() + 25), 0)); if (meta.getColor().getGreen() >= 250) - _colorPhase.put(player.getName(), 1); + _colorPhase.put(player.getUniqueId(), 1); } //Yellow > Green else if (phase == 1) @@ -132,7 +133,7 @@ public class OutfitRaveSuit extends OutfitGadget meta.setColor(Color.fromRGB(Math.max(0, meta.getColor().getRed() - 25), 250, 0)); if (meta.getColor().getRed() <= 0) - _colorPhase.put(player.getName(), 2); + _colorPhase.put(player.getUniqueId(), 2); } //Green > Blue else if (phase == 2) @@ -140,7 +141,7 @@ public class OutfitRaveSuit extends OutfitGadget meta.setColor(Color.fromRGB(0, Math.max(0, meta.getColor().getGreen() - 25), Math.min(250, meta.getColor().getBlue() + 25))); if (meta.getColor().getGreen() <= 0) - _colorPhase.put(player.getName(), 3); + _colorPhase.put(player.getUniqueId(), 3); } //Blue > Red else if (phase == 3) @@ -148,7 +149,7 @@ public class OutfitRaveSuit extends OutfitGadget meta.setColor(Color.fromRGB(Math.min(250, meta.getColor().getRed() + 25), 0, Math.max(0, meta.getColor().getBlue() - 25))); if (meta.getColor().getBlue() <= 0) - _colorPhase.put(player.getName(), 0); + _colorPhase.put(player.getUniqueId(), 0); } stack.setItemMeta(meta); @@ -158,7 +159,7 @@ public class OutfitRaveSuit extends OutfitGadget @EventHandler public void playerQuit(PlayerQuitEvent event) { - _colorPhase.remove(event.getPlayer().getName()); + _colorPhase.remove(event.getPlayer().getUniqueId()); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java index 1b3751877..9da1505f5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java @@ -56,7 +56,7 @@ public class ParticleKronos extends ParticleGadget /*Until it becomes purchasable*/if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.TITAN)) //if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java index e1f76d435..f99338a75 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java @@ -42,7 +42,7 @@ public class ParticleLegend extends ParticleGadget // TODO HARDCODED Legendary Aura Database Item Id - 552 if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) { - Manager.getInventoryManager().Get(event.getPlayer().getName()).addItem(new ClientItem(new Item(552, getName()), 1)); + Manager.getInventoryManager().Get(event.getPlayer()).addItem(new ClientItem(new Item(552, getName()), 1)); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java index f2df819c8..973c54471 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java @@ -96,7 +96,7 @@ public class ParticleTitan extends ParticleGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectBabyChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectBabyChicken.java index 1f16ff559..9b5836cfe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectBabyChicken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectBabyChicken.java @@ -115,9 +115,9 @@ public class WinEffectBabyChicken extends WinEffectGadget } else if(_tick == 20*2) { - Location loc = _npc.GetEntity().getBukkitEntity().getLocation(); + Location loc = _npc.getEntity().getBukkitEntity().getLocation(); - _npc.GetEntity().getBukkitEntity().remove(); + _npc.getEntity().getBukkitEntity().remove(); UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, loc.clone().add(0, 1, 0), 0.3f, 0.6f, 0.3f, 0.07f, 200, ViewDist.NORMAL); UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, loc.clone().add(0, 0.3, 0), 0.7f, 0.1f, 0.7f, 0.07f, 200, ViewDist.NORMAL); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFireworks.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFireworks.java index ec02b82b9..18b3fb26d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFireworks.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFireworks.java @@ -45,7 +45,7 @@ public class WinEffectFireworks extends WinEffectGadget start.setDirection(new Vector(1, 0, 0)); _npc = getNPC(_player, start); - AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.GetEntity().getBukkitEntity()); + AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.getEntity().getBukkitEntity()); for(double rad = 0; rad < Math.PI*2; rad+= Math.PI/points) @@ -65,7 +65,7 @@ public class WinEffectFireworks extends WinEffectGadget if(event.getType() != UpdateType.SEC) return; if(!isRunning()) return; - Location loc = _npc.GetEntity().getBukkitEntity().getLocation(); + Location loc = _npc.getEntity().getBukkitEntity().getLocation(); UtilFirework.launchFirework(loc, Type.values()[UtilMath.r(Type.values().length)], Color.fromRGB(UtilMath.r(255*255*255)), UtilMath.random.nextBoolean(), UtilMath.random.nextBoolean(), new Vector(0,0,0), 0); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFlames.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFlames.java index 8a99612eb..8a0760799 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFlames.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFlames.java @@ -49,7 +49,7 @@ public class WinEffectFlames extends WinEffectGadget start.setDirection(new Vector(1, 0, 0)); _npc = getNPC(_player, start); - AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.GetEntity().getBukkitEntity()); + AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.getEntity().getBukkitEntity()); for(double rad = 0; rad < Math.PI*2; rad+= Math.PI/points) @@ -69,12 +69,12 @@ public class WinEffectFlames extends WinEffectGadget if(!isRunning()) return; if(event.getType() == UpdateType.FASTEST) { - UtilParticle.PlayParticleToAll(ParticleType.FLAME, _npc.GetEntity().getBukkitEntity().getLocation(), null, 0.1f, 50, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.FLAME, _npc.getEntity().getBukkitEntity().getLocation(), null, 0.1f, 50, ViewDist.NORMAL); } if(event.getType() == UpdateType.FASTEST) { - Entity e = _npc.GetEntity().getBukkitEntity(); + Entity e = _npc.getEntity().getBukkitEntity(); if(_nextSound == 0) e.getWorld().playSound(e.getLocation(), Sound.FIRE, 3, UtilMath.random.nextFloat()*2); if(_nextSound == 1) e.getWorld().playSound(e.getLocation(), Sound.LAVA, 1.5f, UtilMath.random.nextFloat()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectLavaTrap.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectLavaTrap.java index 0f05294b6..6624ce9a8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectLavaTrap.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectLavaTrap.java @@ -63,7 +63,7 @@ public class WinEffectLavaTrap extends WinEffectGadget Location loc = getBaseLocation().add(f).add(r); loc.setDirection(getBaseLocation().subtract(loc).toVector()); - ((ArmorStand)getNPC(_nonTeam.get(index), loc).GetEntity().getBukkitEntity()).setGravity(true); + ((ArmorStand)getNPC(_nonTeam.get(index), loc).getEntity().getBukkitEntity()).setGravity(true); } for(int index = 0; index < _team.size(); index++) @@ -79,7 +79,7 @@ public class WinEffectLavaTrap extends WinEffectGadget Location loc = getBaseLocation().add(f).add(r); loc.setDirection(getBaseLocation().subtract(loc).toVector()); - ((ArmorStand)getNPC(_team.get(index), loc).GetEntity().getBukkitEntity()).setGravity(true); + ((ArmorStand)getNPC(_team.get(index), loc).getEntity().getBukkitEntity()).setGravity(true); } } @@ -101,7 +101,7 @@ public class WinEffectLavaTrap extends WinEffectGadget Location loc = getBaseLocation(); loc.setDirection(_lever.getLocation().add(0.5, 0, 0.5).subtract(loc.clone().add(0, 1.8, 0)).toVector()); - playerNPC.GetEntity().getBukkitEntity().teleport(loc); + playerNPC.getEntity().getBukkitEntity().teleport(loc); } if(_tick == 20*3) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectMrPunchMan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectMrPunchMan.java index ddc1638b0..6657102c5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectMrPunchMan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectMrPunchMan.java @@ -45,7 +45,7 @@ public class WinEffectMrPunchMan extends WinEffectGadget for(int i = 0; i < _other.size(); i++) { - _playersLeft.add((ArmorStand) getNPC(_other.get(i), circle.get(i)).GetEntity().getBukkitEntity()); + _playersLeft.add((ArmorStand) getNPC(_other.get(i), circle.get(i)).getEntity().getBukkitEntity()); } _nextHit = getNextHit() + 1000; @@ -64,9 +64,9 @@ public class WinEffectMrPunchMan extends WinEffectGadget ArmorStand player = _playersLeft.get(0); - Location loc = _npc.GetEntity().getBukkitEntity().getLocation(); + Location loc = _npc.getEntity().getBukkitEntity().getLocation(); loc.setDirection(player.getLocation().subtract(loc).toVector()); - _npc.GetEntity().getBukkitEntity().teleport(loc); + _npc.getEntity().getBukkitEntity().teleport(loc); _npc.sendHit(); @@ -93,7 +93,7 @@ public class WinEffectMrPunchMan extends WinEffectGadget @Override public void finish() { - _npc.GetEntity().getBukkitEntity().remove(); + _npc.getEntity().getBukkitEntity().remove(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPodium.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPodium.java index 5a4973f1f..34b7077e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPodium.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPodium.java @@ -1,7 +1,5 @@ package mineplex.core.gadget.gadgets.wineffect; -import org.bukkit.Color; -import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.event.EventHandler; @@ -11,8 +9,6 @@ import mineplex.core.common.animation.AnimationPoint; import mineplex.core.common.animation.AnimatorEntity; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; @@ -36,7 +32,7 @@ public class WinEffectPodium extends WinEffectGadget { _npc = getNPC(this._player, getBaseLocation()); - AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.GetEntity().getBukkitEntity()); + AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.getEntity().getBukkitEntity()); animator.addPoint(new AnimationPoint( 20, new Vector(0,0,0), new Vector(-1, 0.5, 0))); animator.addPoint(new AnimationPoint( 40, new Vector(0,0,0), new Vector( 0, 0.5,-1))); @@ -45,7 +41,7 @@ public class WinEffectPodium extends WinEffectGadget animator.setRepeat(true); - Location loc = _npc.GetEntity().getBukkitEntity().getLocation(); + Location loc = _npc.getEntity().getBukkitEntity().getLocation(); loc.setDirection(new Vector(0, 0.5, 1)); animator.start(loc); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectRiseOfTheElderGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectRiseOfTheElderGuardian.java index 0480418db..6539f59c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectRiseOfTheElderGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectRiseOfTheElderGuardian.java @@ -90,7 +90,7 @@ public class WinEffectRiseOfTheElderGuardian extends WinEffectGadget { for(DisguiseGuardian g : _guardians) { - g.setTarget(_npcPlayer.GetEntityId()); + g.setTarget(_npcPlayer.getEntityId()); Manager.getDisguiseManager().updateDisguise(g); } } @@ -116,7 +116,7 @@ public class WinEffectRiseOfTheElderGuardian extends WinEffectGadget Manager.getDisguiseManager().updateDisguise(g); } - ArmorStand stand = (ArmorStand) _npcPlayer.GetEntity().getBukkitEntity(); + ArmorStand stand = (ArmorStand) _npcPlayer.getEntity().getBukkitEntity(); Manager.getDisguiseManager().undisguise(stand); @@ -134,7 +134,7 @@ public class WinEffectRiseOfTheElderGuardian extends WinEffectGadget { for(DisguiseGuardian g : _guardians) { - g.GetEntity().getBukkitEntity().remove(); + g.getEntity().getBukkitEntity().remove(); } _guardians.clear(); _guardians = null; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectSnowTrails.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectSnowTrails.java index 536f8f539..42a8c5115 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectSnowTrails.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectSnowTrails.java @@ -48,7 +48,7 @@ public class WinEffectSnowTrails extends WinEffectGadget start.setDirection(new Vector(1, 0, 0)); _npc = getNPC(_player, start); - AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.GetEntity().getBukkitEntity()); + AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.getEntity().getBukkitEntity()); for(double rad = 0; rad < Math.PI*2; rad+= Math.PI/points) @@ -69,7 +69,7 @@ public class WinEffectSnowTrails extends WinEffectGadget if(event.getType() != UpdateType.TICK) return; - Location loc = _npc.GetEntity().getBukkitEntity().getLocation(); + Location loc = _npc.getEntity().getBukkitEntity().getLocation(); UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, loc.clone().add(0, 1, 0), 0.3f, 1, 0.3f, 0, 20, ViewDist.NORMAL); UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, loc.clone().add(0, 0.2, 0), 0.6f, 0.2f, 0.6f, 0, 20, ViewDist.NORMAL); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java index ed341aa82..b76e4e86b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java @@ -153,12 +153,12 @@ public abstract class Gadget extends SalesPackageBase implements Listener public boolean ownsGadget(Player player) { if(isFree() || _free) return true; - if(Manager.getDonationManager().Get(player.getName()).OwnsUnknownPackage(getName())) { return true; } + if(Manager.getDonationManager().Get(player).OwnsUnknownPackage(getName())) { return true; } if(Manager.getInventoryManager().Get(player).getItemCount(getName()) > 0) { return true; } for(String alt : _alternativePackageNames) { - if(Manager.getDonationManager().Get(player.getName()).OwnsUnknownPackage(alt)) { return true; } + if(Manager.getDonationManager().Get(player).OwnsUnknownPackage(alt)) { return true; } if(Manager.getInventoryManager().Get(player).getItemCount(alt) > 0) { return true; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java index 6c647876c..fb63ac704 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java @@ -15,7 +15,6 @@ import mineplex.core.gadget.GadgetManager; public abstract class HatGadget extends OutfitGadget { - private ItemStack _hat; private HatType _hatType; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java index 7be83f481..c328c1517 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java @@ -285,10 +285,10 @@ public abstract class WinEffectGadget extends Gadget stand.setMaxHealth(2048); stand.setHealth(2048); stand.setGravity(false); - + GameProfile profile = new GameProfile(UUID.randomUUID(), player.getName()); profile.getProperties().putAll(((CraftPlayer) player).getHandle().getProfile().getProperties()); - + DisguisePlayer disguise = new DisguisePlayer(stand, profile); Manager.getDisguiseManager().disguise(disguise); return disguise; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayManager.java b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayManager.java index 9d86ffa9c..e6f562472 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayManager.java @@ -161,9 +161,9 @@ public class GiveawayManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadPlayerGiveaway(resultSet)); + Set(uuid, _repository.loadPlayerGiveaway(resultSet)); } @Override @@ -173,7 +173,7 @@ public class GiveawayManager extends MiniDbClientPlugin } @Override - protected PlayerGiveawayData addPlayer(String player) + protected PlayerGiveawayData addPlayer(UUID uuid) { return new PlayerGiveawayData(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java index 5e2d8803e..b06707ed2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java @@ -42,7 +42,7 @@ public class Hologram { private boolean _makeSpawnPackets = true; private Packet[] _packets1_8; private Packet[] _packets1_9; - private HashSet _playersInList = new HashSet(); + private HashSet _playersInList = new HashSet<>(); private ArrayList _playersTracking = new ArrayList(); private boolean _removeEntityDeath; private HologramTarget _target = HologramTarget.BLACKLIST; @@ -84,13 +84,13 @@ public class Hologram { * Adds the player to the Hologram to be effected by Whitelist or Blacklist */ public Hologram addPlayer(Player player) { - return addPlayer(player.getName()); + return addPlayer(player.getUniqueId()); } /** * Adds the player to the Hologram to be effected by Whitelist or Blacklist */ - public Hologram addPlayer(String player) { + public Hologram addPlayer(UUID player) { _playersInList.add(player); return this; } @@ -109,14 +109,7 @@ public class Hologram { * Is there a player entry in the hologram for Whitelist and Blacklist */ public boolean containsPlayer(Player player) { - return _playersInList.contains(player.getName()); - } - - /** - * Is there a player entry in the hologram for Whitelist and Blacklist - */ - public boolean containsPlayer(String player) { - return _playersInList.contains(player); + return _playersInList.contains(player.getUniqueId()); } protected Packet getDestroyPacket() { @@ -295,14 +288,14 @@ public class Hologram { * Whitelist or Blacklist */ public Hologram removePlayer(Player player) { - return removePlayer(player.getName()); + return removePlayer(player.getUniqueId()); } /** * Removes the player from the Hologram so they are no longer effected by * Whitelist or Blacklist */ - public Hologram removePlayer(String player) { + public Hologram removePlayer(UUID player) { _playersInList.remove(player); return this; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java index 15c0fca39..774544f7e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java @@ -5,6 +5,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.UUID; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; @@ -80,7 +81,7 @@ public class IgnoreManager extends MiniDbClientPlugin } @Override - protected IgnoreData addPlayer(String player) + protected IgnoreData addPlayer(UUID uuid) { return new IgnoreData(); } @@ -230,9 +231,9 @@ public class IgnoreManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadClientInformation(resultSet)); + Set(uuid, _repository.loadClientInformation(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java index 2594b4188..6242b48ba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java @@ -25,6 +25,7 @@ import org.bukkit.plugin.java.JavaPlugin; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; public class IncognitoManager extends MiniDbClientPlugin { @@ -191,7 +192,7 @@ public class IncognitoManager extends MiniDbClientPlugin UtilPlayer.message(player, " "); } - protected IncognitoClient addPlayer(String player) + protected IncognitoClient addPlayer(UUID uuid) { return new IncognitoClient(); } @@ -208,11 +209,11 @@ public class IncognitoManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { while (resultSet.next()) { - Get(playerName).Status = resultSet.getInt("status") == 1; + Get(uuid).Status = resultSet.getInt("status") == 1; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index d3a3c4107..8da2ab80b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -343,7 +343,7 @@ public class InventoryManager extends MiniDbClientPlugin } @Override - protected ClientInventory addPlayer(String player) + protected ClientInventory addPlayer(UUID uuid) { return new ClientInventory(); } @@ -355,9 +355,9 @@ public class InventoryManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadClientInformation(resultSet, _itemIdNameMap)); + Set(uuid, _repository.loadClientInformation(resultSet, _itemIdNameMap)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index daac3f231..3cffd8cdf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -4,16 +4,25 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.chat.Chat; import mineplex.core.common.Rank; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.friend.FriendManager; import mineplex.core.friend.data.FriendData; import mineplex.core.friend.data.FriendStatus; import mineplex.core.ignore.IgnoreManager; import mineplex.core.incognito.IncognitoManager; -import mineplex.core.message.commands.*; -import mineplex.core.message.redis.AnnouncementHandler; -import mineplex.core.message.redis.MessageHandler; +import mineplex.core.message.commands.AdminCommand; +import mineplex.core.message.commands.AnnounceCommand; +import mineplex.core.message.commands.MessageAdminCommand; +import mineplex.core.message.commands.MessageCommand; +import mineplex.core.message.commands.ResendAdminCommand; +import mineplex.core.message.commands.ResendCommand; import mineplex.core.message.redis.RedisMessage; import mineplex.core.message.redis.RedisMessageCallback; import mineplex.core.preferences.PreferencesManager; @@ -62,14 +71,35 @@ public class MessageManager extends MiniClientPlugin _chat = chat; _serverName = getPlugin().getConfig().getString("serverstatus.name"); - MessageHandler messageHandler = new MessageHandler(this); + ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, command -> + { + Rank rank; + try + { + rank = Rank.valueOf(command.getRank()); + } + catch (Exception e) + { + e.printStackTrace(); + return; + } - ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, - new AnnouncementHandler(clientManager)); + String message = command.getMessage(); - ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, messageHandler); - ServerCommandManager.getInstance() - .registerCommandType("RedisMessageCallback", RedisMessageCallback.class, messageHandler); + for (Player player : Bukkit.getOnlinePlayers()) + { + if (_clientManager.hasRank(player, rank)) + { + if (command.getDisplayTitle()) + UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10, player); + + UtilPlayer.message(player, F.main("Announcement", C.cAqua + message)); + } + } + }); + + ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, this::receiveMessage); + ServerCommandManager.getInstance().registerCommandType("RedisMessageCallback", RedisMessageCallback.class, this::receiveMessageCallback); } public void addCommands() @@ -87,10 +117,10 @@ public class MessageManager extends MiniClientPlugin } @Override - protected ClientMessage addPlayer(String player) + protected ClientMessage addPlayer(UUID uuid) { - Set(player, new ClientMessage()); - return Get(player); + Set(uuid, new ClientMessage()); + return Get(uuid); } public boolean canMessage(Player from, Player to) @@ -235,7 +265,7 @@ public class MessageManager extends MiniClientPlugin public void DoMessageAdmin(Player from, Player to, String message) { // Inform - UtilPlayer.message(from, C.cPurple + "-> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + UtilPlayer.message(from, C.cPurple + "-> " + F.rank(_clientManager.Get(to).getRealOrDisguisedRank()) + " " + to.getName() + " " + C.cPurple + message); // Inform Admins @@ -245,8 +275,8 @@ public class MessageManager extends MiniClientPlugin { if (_clientManager.Get(staff).GetRank().has(Rank.HELPER)) { - UtilPlayer.message(staff, F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + C.cPurple - + " -> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + C.cPurple + message); + UtilPlayer.message(staff, F.rank(_clientManager.Get(from).getRealOrDisguisedRank()) + " " + from.getName() + C.cPurple + + " -> " + F.rank(_clientManager.Get(to).getRealOrDisguisedRank()) + " " + to.getName() + " " + C.cPurple + message); } } } @@ -255,7 +285,7 @@ public class MessageManager extends MiniClientPlugin Get(from).LastAdminTo = to.getName(); // Send - UtilPlayer.message(to, C.cPurple + "<- " + F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + " " + UtilPlayer.message(to, C.cPurple + "<- " + F.rank(_clientManager.Get(from).getRealOrDisguisedRank()) + " " + from.getName() + " " + C.cPurple + message); // Sound @@ -338,8 +368,13 @@ public class MessageManager extends MiniClientPlugin UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + "Err...something went wrong?")); } - public void receiveMessage(Player to, RedisMessage globalMessage) + public void receiveMessage(RedisMessage globalMessage) { + Player to = Bukkit.getPlayerExact(globalMessage.getTarget()); + + if (to == null) + return; + if (globalMessage.isStaffMessage()) { // Message the receiver @@ -348,7 +383,7 @@ public class MessageManager extends MiniClientPlugin to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f); - String toRank = F.rank(_clientManager.Get(to).GetRank()); + String toRank = F.rank(_clientManager.Get(to).getRealOrDisguisedRank()); // Message the sender RedisMessageCallback message = new RedisMessageCallback(globalMessage, true, to.getName(), @@ -431,7 +466,7 @@ public class MessageManager extends MiniClientPlugin if (message.isStaffMessage() && message.getLastReplied() != null) { - String recevierRank = F.rank(_clientManager.Get(target).GetRank()); + String recevierRank = F.rank(_clientManager.Get(target).getRealOrDisguisedRank()); // Inform Admins for (Player staff : UtilServer.getPlayers()) @@ -515,7 +550,7 @@ public class MessageManager extends MiniClientPlugin // If this is a message inside the server if (to != null) { - if (_incognitoManager.Get(to).Status && !_clientManager.Get(sender.getName()).GetRank().has(Rank.HELPER)) + if (_incognitoManager.Get(to).Status && !_clientManager.Get(sender.getUniqueId()).GetRank().has(Rank.HELPER)) { UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "].")); return; @@ -565,7 +600,7 @@ public class MessageManager extends MiniClientPlugin playerTarget, message, // Include the sender's rank if this is a admin message. So we can format the receivers chat. - adminMessage ? F.rank(_clientManager.Get(sender).GetRank()) : null); + adminMessage ? F.rank(_clientManager.Get(sender).getRealOrDisguisedRank()) : null); final UUID uuid = globalMessage.getUUID(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java index 78ff81799..24cd9db26 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java @@ -42,7 +42,7 @@ public class AdminCommand extends CommandBase String message = F.combine(args, 0, null, false); //Inform - UtilPlayer.message(caller, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message); + UtilPlayer.message(caller, F.rank(Plugin.GetClientManager().Get(caller).getRealOrDisguisedRank()) + " " + caller.getName() + " " + C.cPurple + message); //Send for (Player to : UtilServer.getPlayers()) @@ -51,7 +51,7 @@ public class AdminCommand extends CommandBase { if (!to.equals(caller)) - UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message); + UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).getRealOrDisguisedRank()) + " " + caller.getName() + " " + C.cPurple + message); if(Plugin.GetClientManager().Get(to).GetRank().has(Rank.JNR_DEV)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java deleted file mode 100644 index 3715bc60f..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -package mineplex.core.message.commands; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.message.MessageManager; - -public class AdminMessageCommand extends CommandBase -{ - public AdminMessageCommand(MessageManager plugin) - { - super(plugin, Rank.SNR_MODERATOR, "am"); - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args == null || args.length == 0) - { - Plugin.Help(caller); - } - else - { - if (args.length == 0) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Player argument missing.")); - return; - } - - // Parse Message - String message = "Beep!"; - if (args.length > 1) - { - message = F.combine(args, 1, null, false); - } - else - { - message = Plugin.GetRandomMessage(); - } - - Plugin.sendMessage(caller, args[0], message, false, true); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java index cdacc6ef3..738bf5e9d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java @@ -12,7 +12,7 @@ public class MessageAdminCommand extends CommandBase { public MessageAdminCommand(MessageManager plugin) { - super(plugin, Rank.ALL, "ma"); + super(plugin, Rank.HELPER, "ma"); } @Override @@ -20,30 +20,11 @@ public class MessageAdminCommand extends CommandBase { if (args == null || args.length == 0) { - Plugin.Help(caller); + UtilPlayer.message(caller, F.help(Plugin.getName(), "/ma [message]", GetRequiredRank())); } else { - if (!Plugin.GetClientManager().Get(caller).GetRank().has(caller, Rank.HELPER, true)) - return; - - if (args.length == 0) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Player argument missing.")); - return; - } - - // Parse Message - String message = "Beep!"; - if (args.length > 1) - { - message = F.combine(args, 1, null, false); - } - else - { - message = Plugin.GetRandomMessage(); - } - + String message = args.length > 1 ? F.combine(args, 1, null, false) : Plugin.GetRandomMessage(); Plugin.sendMessage(caller, args[0], message, false, true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/AnnouncementHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/AnnouncementHandler.java deleted file mode 100644 index 6901ad162..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/AnnouncementHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -package mineplex.core.message.redis; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.serverdata.commands.AnnouncementCommand; -import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -public class AnnouncementHandler implements CommandCallback -{ - private CoreClientManager _clientManager; - - public AnnouncementHandler(CoreClientManager clientManager) - { - _clientManager = clientManager; - } - - public void run(ServerCommand command) - { - if (command instanceof AnnouncementCommand) - { - AnnouncementCommand announcementCommand = (AnnouncementCommand)command; - - Rank rank; - try - { - rank = Rank.valueOf(announcementCommand.getRank()); - } - catch (Exception e) - { - e.printStackTrace(); - return; - } - - String message = announcementCommand.getMessage(); - - for (Player player : Bukkit.getOnlinePlayers()) - { - if (_clientManager.hasRank(player, rank)) - { - if (announcementCommand.getDisplayTitle()) - UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10, player); - - UtilPlayer.message(player, F.main("Announcement", C.cAqua + message)); - } - } - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/MessageHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/MessageHandler.java deleted file mode 100644 index d42424a9f..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/MessageHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -package mineplex.core.message.redis; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import mineplex.core.message.MessageManager; -import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; - -public class MessageHandler implements CommandCallback -{ - private MessageManager _messageManager; - - public MessageHandler(MessageManager messageManager) - { - _messageManager = messageManager; - } - - public void run(ServerCommand command) - { - if (command instanceof RedisMessage) - { - RedisMessage message = (RedisMessage) command; - - Player target = Bukkit.getPlayerExact(message.getTarget()); - - if (target != null) - { - _messageManager.receiveMessage(target, message); - } - } - else if (command instanceof RedisMessageCallback) - { - - _messageManager.receiveMessageCallback((RedisMessageCallback) command); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index 47c37044a..b4846dfc8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -36,6 +36,8 @@ public class LagMeter extends MiniPlugin private boolean _timingsRunning; private boolean _timingsPasted; private long _timingsStarted; + + private boolean _fakeTps = false; private HashSet _monitoring = new HashSet(); @@ -86,7 +88,7 @@ public class LagMeter extends MiniPlugin long now = System.currentTimeMillis(); _ticksPerSecond = 1000D / (now - _lastRun) * 20D; - + sendUpdates(); if (_count % 30 == 0) @@ -120,6 +122,10 @@ public class LagMeter extends MiniPlugin public double getTicksPerSecond() { + if (_fakeTps) + { + return 20.0; + } return _ticksPerSecond; } @@ -164,4 +170,10 @@ public class LagMeter extends MiniPlugin player.sendMessage(F.main(getName(), ChatColor.GRAY + "Free-------" + ChatColor.YELLOW + (Runtime.getRuntime().freeMemory() / 1048576) + "MB")); player.sendMessage(F.main(getName(), ChatColor.GRAY + "Max--------" + ChatColor.YELLOW + (Runtime.getRuntime().maxMemory() / 1048576)) + "MB"); } + + // I'm so sorry. Blame ServerMonitor for being so strict + public void setFakeTps(boolean fakeTps) + { + this._fakeTps = fakeTps; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java index bf17e7716..2233a9baf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java @@ -108,7 +108,7 @@ public class MountDragon extends DragonMount { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java index 5ee7e2377..9bd3f4f07 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java @@ -137,7 +137,7 @@ public class MountTitan extends Mount { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/movement/Movement.java b/Plugins/Mineplex.Core/src/mineplex/core/movement/Movement.java index 40d547a39..d93a7358f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/movement/Movement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/movement/Movement.java @@ -10,6 +10,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; +import java.util.UUID; + public class Movement extends MiniClientPlugin { public Movement(JavaPlugin plugin) @@ -40,7 +42,7 @@ public class Movement extends MiniClientPlugin } @Override - protected ClientMovement addPlayer(String player) + protected ClientMovement addPlayer(UUID uuid) { return new ClientMovement(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java index d8076b1cf..9b874b74a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java @@ -2,6 +2,7 @@ package mineplex.core.packethandler; import com.mineplex.spigot.PacketProcessor; import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; import net.minecraft.server.v1_8_R3.Packet; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -9,7 +10,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; import java.util.ArrayList; import java.util.HashMap; @@ -21,6 +21,7 @@ import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; +@ReflectivelyCreateMiniPlugin public class PacketHandler extends MiniPlugin { private Map _playerVerifierMap = new HashMap<>(); @@ -28,9 +29,9 @@ public class PacketHandler extends MiniPlugin private Map, Set> _forceMainThread = new HashMap<>(); private Map, Map>> _packetHandlers = new HashMap<>(); - public PacketHandler(JavaPlugin plugin) + private PacketHandler() { - super("PacketHandler", plugin); + super("PacketHandler"); } @EventHandler(priority = EventPriority.LOWEST) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketVerifier.java b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketVerifier.java index 0eb36e2d7..87ec559c9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketVerifier.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketVerifier.java @@ -39,4 +39,9 @@ public class PacketVerifier implements IPacketVerifier { return _packetHandler.handlePacket(new PacketInfo(_owner, packet, this)); } + + public Player getOwner() + { + return this._owner; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java b/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java index 3644bea91..a076a9a34 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java @@ -38,12 +38,7 @@ public class Party /** * The current leader of this party */ - private String _owner; - - /** - * The names of all current party members - */ - private List _members; + private UUID _owner; /** * The UUIDS of all current party members @@ -73,28 +68,16 @@ public class Party * * @param owner The owner / leader of the party. */ - public Party(String owner) + public Party(UUID owner) { _owner = owner; - _members = Lists.newArrayList(); _invites = Maps.newHashMap(); - _members.add(owner); _membersByUUID = Lists.newArrayList(); } public String getOwner() { - return _owner; - } - - /** - * Get the current members by their IGN - * - * @return The list of named party members - */ - public List getMembers() - { - return _members; + return Bukkit.getPlayer(_owner).getName(); } public Map getInvites() @@ -111,7 +94,12 @@ public class Party */ public String getName() { - return _owner; + return getOwner(); + } + + public List getMembers() + { + return this._membersByUUID; } /** @@ -145,12 +133,14 @@ public class Party */ public void onPlayerAdd(String player) { + Player pl = Bukkit.getPlayerExact(player); + UUID uuid = pl.getUniqueId(); _invites.remove(player); - if(_members.contains(player)) + if(_membersByUUID.contains(uuid)) { return; } - _members.add(player); + _membersByUUID.add(uuid); Lang.ADD_MEMBER.send(this, player); getMembers().forEach(s -> { @@ -162,33 +152,33 @@ public class Party /** * Called when a member of the party is removed * - * @param player The name of the player + * @param uuid The uuid of the player * @param reason The reason for his removal. */ - public void onPlayerRemove(String player, PartyRemoveReason reason) + public void onPlayerRemove(UUID uuid, PartyRemoveReason reason) { + Player bukkitPlayer = Bukkit.getPlayer(uuid); if(reason == PartyRemoveReason.DISBANDED) { - Player bukkitPlayer = Bukkit.getPlayerExact(player); Lang.DISBANDED.send(bukkitPlayer); bukkitPlayer.closeInventory(); return; } - if(_members.size() <= 0) + if(_membersByUUID.size() <= 0) { return; } if(reason == PartyRemoveReason.LEFT) { - if(player.equalsIgnoreCase(_owner) && _members.size() > 1) + if(uuid.equals(_owner) && _membersByUUID.size() > 1) { - _owner = _members.get(0); - Lang.TRANSFER_OWNER.send(this, player, _owner); - PartyTransferOwnerEvent event = new PartyTransferOwnerEvent(this, _owner, player, TransferReason.LEFT); + _owner = _membersByUUID.get(0); + Lang.TRANSFER_OWNER.send(this, bukkitPlayer.getName(), getOwner()); + PartyTransferOwnerEvent event = new PartyTransferOwnerEvent(this, getOwner(), bukkitPlayer.getName(), TransferReason.LEFT); UtilServer.getServer().getPluginManager().callEvent(event); return; } - Lang.REMOVE_PLAYER.send(this, player); + Lang.REMOVE_PLAYER.send(this, bukkitPlayer.getName()); return; } if(reason == PartyRemoveReason.OTHER) @@ -197,7 +187,7 @@ public class Party } if(reason == PartyRemoveReason.KICKED) { - Lang.REMOVE_PLAYER_KICK.send(this, player); + Lang.REMOVE_PLAYER_KICK.send(this, bukkitPlayer.getName()); } } @@ -228,7 +218,7 @@ public class Party */ public void setOwner(String owner) { - _owner = owner; + _owner = Bukkit.getPlayerExact(owner).getUniqueId(); } /** @@ -251,6 +241,11 @@ public class Party _alreadyTeamed = alreadyTeamed; } + public UUID getOwnerId() + { + return this._owner; + } + /** * Check to see if this party contains a certain player name * This is case-insensitive @@ -260,9 +255,9 @@ public class Party */ public boolean contains(String name) { - for(String s : _members) + for(UUID member : _membersByUUID) { - if(s.equalsIgnoreCase(name)) + if (Bukkit.getPlayer(member).getName().equalsIgnoreCase(name)) { return true; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyEventListener.java b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyEventListener.java index 06319bc04..71a8dd085 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyEventListener.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyEventListener.java @@ -47,11 +47,11 @@ public class PartyEventListener implements Listener Player bukkitPlayer = Bukkit.getPlayerExact(partyName); - if (party == null) + if (party == null && bukkitPlayer != null) { - party = new Party(partyName); + party = new Party(bukkitPlayer.getUniqueId()); - if (bukkitPlayer != null && _plugin.getClientManager().Get(bukkitPlayer).GetRank().has(Rank.ULTRA)) + if (_plugin.getClientManager().Get(bukkitPlayer).GetRank().has(Rank.ULTRA)) { party.setSize(); } else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java index 918d3f8b6..00b4cf38d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java @@ -15,6 +15,7 @@ import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.serverdata.Utility; import mineplex.serverdata.servers.ServerManager; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -57,7 +58,7 @@ public class PartyManager extends MiniPlugin /** * A map of owner (name) -> party server wide */ - private final Map _parties = Maps.newHashMap(); + private final Map _parties = Maps.newHashMap(); public PartyManager(JavaPlugin plugin, Portal portal, CoreClientManager clientManager, PreferencesManager preferenceManager) { @@ -83,7 +84,7 @@ public class PartyManager extends MiniPlugin public Party getParty(String party) { - return _parties.get(party); + return _parties.get(Bukkit.getPlayerExact(party).getUniqueId()); } public Party getParty(Player player) @@ -93,12 +94,12 @@ public class PartyManager extends MiniPlugin public void addParty(Party party) { - _parties.put(party.getName(), party); + _parties.put(party.getOwnerId(), party); } public void removeParty(Party party) { - _parties.remove(party.getName()); + _parties.remove(party.getOwnerId()); } public Portal getPortal() @@ -146,7 +147,7 @@ public class PartyManager extends MiniPlugin return _players; } - public Map getParties() + public Map getParties() { return _parties; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java index bfff39b40..ba6203f65 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java @@ -80,7 +80,7 @@ public class PartyInviteManager } if (newParty == null) { - newParty = new Party(possible.getName()); + newParty = new Party(possible.getUniqueId()); if(_plugin.getClientManager().Get(possible).GetRank().has(Rank.ULTRA)) { newParty.setSize(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyMethodManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyMethodManager.java index bc4955d44..74086d8ea 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyMethodManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyMethodManager.java @@ -83,7 +83,7 @@ public class PartyMethodManager if (party == null) { - if(_plugin.getParty(target) != null) + if(_plugin.getParty(possible) != null) { Lang.PLAYER_IN_DIFFERENT_PARTY.send(caller, target); return; @@ -117,7 +117,7 @@ public class PartyMethodManager } //Not on the same server - _plugin.getRedisManager().findAndInvite(target, caller.getName()); + _plugin.getRedisManager().findAndInvite(target, caller); } /** @@ -265,8 +265,7 @@ public class PartyMethodManager { return; } - String player = Bukkit.getPlayer(uuid).getName(); - party.onPlayerRemove(player, PartyRemoveReason.OTHER); + party.onPlayerRemove(uuid, PartyRemoveReason.OTHER); } public void removeFromParty(UUID uuid, PartyRemoveReason reason) @@ -294,7 +293,7 @@ public class PartyMethodManager } party.getMembers().remove(player.getName()); party.getMembersByUUID().remove(uuid); - party.onPlayerRemove(player.getName(), reason); + party.onPlayerRemove(player.getUniqueId(), reason); int size = party.getMembers().size(); if(size <= 1) @@ -304,7 +303,7 @@ public class PartyMethodManager _plugin.removeParty(party); return; } - _plugin.getPlayerParties().remove(Bukkit.getPlayerExact(party.getMembers().get(0)).getUniqueId()); + _plugin.getPlayerParties().remove(party.getMembers().get(0)); party.onPlayerRemove(party.getMembers().get(0), PartyRemoveReason.DISBANDED); _plugin.removeParty(party); } @@ -327,14 +326,14 @@ public class PartyMethodManager public void transferOwner(String newOwner, String oldOwner) { - Party party = _plugin.getParties().remove(oldOwner); + Party party = _plugin.getParties().remove(Bukkit.getPlayerExact(oldOwner).getUniqueId()); if(party == null) { return; } - _plugin.getParties().put(newOwner, party); + _plugin.getParties().put(Bukkit.getPlayerExact(newOwner).getUniqueId(), party); party.setOwner(newOwner); - party.getMembers().remove(oldOwner); - party.getMembers().add(oldOwner); + party.getMembers().remove(Bukkit.getPlayerExact(oldOwner).getUniqueId()); + party.getMembers().add(Bukkit.getPlayerExact(oldOwner).getUniqueId()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java index 993fe1a5f..f856d0bd8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java @@ -191,9 +191,9 @@ public class PartyRedisManager * @param player The player target * @param sender The sending player */ - public void findAndInvite(String player, String sender) + public void findAndInvite(String player, Player sender) { - Bukkit.getPlayerExact(sender).sendMessage(F.main("Party", "Locating " + F.elem(player) + "...")); + sender.sendMessage(F.main("Party", "Locating " + F.elem(player) + "...")); TASKS.put(player, new BukkitRunnable() { @Override @@ -205,25 +205,19 @@ public class PartyRedisManager return; } TASKS.remove(player); - Player senderPlayer = Bukkit.getPlayerExact(sender); - if (senderPlayer == null) - { - cancel(); - return; - } if (Bukkit.getPlayerExact(player) != null) { cancel(); return; } - senderPlayer.sendMessage(F.main("Party", "Could not locate " + F.elem(player) + ".")); + sender.sendMessage(F.main("Party", "Could not locate " + F.elem(player) + ".")); } }.runTaskLater(_plugin.getPlugin(), 20L * 5)); _plugin.runAsync(() -> { try (Jedis jedis = _writePool.getResource()) { - jedis.publish(FIND_PLAYERS_CHANNEL, RedisMessageType.PLAYER_FIND_REQUEST.format(_serverName, player, sender)); + jedis.publish(FIND_PLAYERS_CHANNEL, RedisMessageType.PLAYER_FIND_REQUEST.format(_serverName, player, sender.getName())); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java index 8870fd1c0..06d603113 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java @@ -11,9 +11,11 @@ import mineplex.core.party.ui.button.tools.owner.DisbandPartyButton; import mineplex.core.party.ui.button.tools.owner.KickPlayerButton; import mineplex.core.party.ui.button.tools.owner.SelectServerButton; import mineplex.core.party.ui.button.tools.owner.TransferOwnerButton; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import java.util.List; +import java.util.UUID; /** * The display menu for managing parties by the owner @@ -65,13 +67,13 @@ public class PartyOwnerMenu extends Menu //Disband buttons[DISBAND_PARTY_BUTTON_SLOW] = new DisbandPartyButton(_plugin); - List members = _party.getMembers(); - members.remove(_party.getOwner()); + List members = _party.getMembers(); + members.remove(_party.getOwnerId()); buttons[OWNER_HEAD_SLOT] = new PartyMemberIcon(_party.getOwner(), _party, true); int slot = STARTING_SLOT; //Players - for (String member : members) + for (UUID member: members) { if (slot == CUT_OFF_SLOT) { @@ -81,7 +83,7 @@ public class PartyOwnerMenu extends Menu slot = SKIP_TO_SLOT_2; } - buttons[slot++] = new PartyMemberIcon(member, _party, false); + buttons[slot++] = new PartyMemberIcon(Bukkit.getPlayer(member).getName(), _party, false); } if(_party.getSize() == 5) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java index e2e26352e..3a38e25b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java @@ -7,9 +7,11 @@ import mineplex.core.party.ui.Menu; import mineplex.core.party.ui.button.PartyMemberIcon; import mineplex.core.party.ui.button.tools.LeavePartyButton; import mineplex.core.party.ui.button.tools.view.SuggestPlayerButton; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import java.util.List; +import java.util.UUID; /** * The menu a player see's when he is a member, and not an owner, of a party. @@ -44,13 +46,13 @@ public class PartyViewMenu extends Menu //Suggest Player buttons[SUGGEST_PLAYER_BUTTON_SLOT] = new SuggestPlayerButton(_party, _plugin); - List members = _party.getMembers(); - members.remove(_party.getOwner()); + List members = _party.getMembers(); + members.remove(_party.getOwnerId()); buttons[OWNER_HEAD_SLOT] = new PartyMemberIcon(_party.getOwner(), _party, true); int slot = STARTING_SLOT; //Players - for (String member : members) + for (UUID member : members) { if (slot == CUT_OFF_SLOT) { @@ -60,7 +62,7 @@ public class PartyViewMenu extends Menu slot = SKIP_TO_SLOT_2; } - buttons[slot++] = new PartyMemberIcon(member, _party, false); + buttons[slot++] = new PartyMemberIcon(Bukkit.getPlayer(member).getName(), _party, false); } return addPanes(buttons); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java index 65d95c26a..06667e96d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java @@ -23,7 +23,7 @@ public class HostEventServerCommand extends CommandBase if(Plugin.getClients().Get(caller).isDisguised()) { - UtilPlayer.message(caller, F.main("Disguise", "You cant host Servers while you are disguised!")); + UtilPlayer.message(caller, F.main("Disguise", "You can't create a event server while you are disguised!")); return; } Plugin.hostServer(caller, caller.getName(), true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java index 8fe9045d6..1c85b6dfc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java @@ -23,7 +23,7 @@ public class HostServerCommand extends CommandBase if(Plugin.getClients().Get(caller).isDisguised()) { - UtilPlayer.message(caller, F.main("Disguise", "You cant host Servers while you are disguised!")); + UtilPlayer.message(caller, F.main("Disguise", "You can't create a MPS while you are disguised!")); return; } Plugin.hostServer(caller, caller.getName(), false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java index e24136065..f33ed7e5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java @@ -6,15 +6,16 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.pet.repository.token.ClientPetToken; import mineplex.core.pet.repository.token.PetToken; +import java.util.HashMap; +import java.util.Map; + public class PetClient { - private NautHashMap _pets; + private Map _pets = new HashMap<>(); private int _petNameTagCount; public void load(ClientPetToken token) { - _pets = new NautHashMap(); - for (PetToken petToken : token.Pets) { if (petToken.PetName == null) @@ -26,7 +27,7 @@ public class PetClient _petNameTagCount = Math.max(0, token.PetNameTagCount); } - public NautHashMap getPets() + public Map getPets() { return _pets; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index d5f48d43b..5b5442191 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -3,6 +3,7 @@ package mineplex.core.pet; import java.util.Collection; import java.util.Iterator; import java.util.Map.Entry; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -190,21 +191,21 @@ public class PetManager extends MiniClientPlugin { _creatureModule.SetForce(true); - DisguiseWither witherDisguise = new DisguiseWither(null); - - witherDisguise.setInvulTime(530); - - _disguiseManager.addFutureDisguise(witherDisguise); - pet = (Creature) location.getWorld().spawnEntity(location, EntityType.SILVERFISH); UtilEnt.silence(pet, true); + DisguiseWither witherDisguise = new DisguiseWither(pet); + + witherDisguise.setInvulTime(530); + Creature silverfish = (Creature) _creatureModule.SpawnEntity(location, EntityType.SILVERFISH); UtilEnt.Vegetate(silverfish, true); UtilEnt.silence(silverfish, true); - ((LivingEntity) silverfish).addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0)); + silverfish.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0)); pet.setPassenger(silverfish); + _disguiseManager.disguise(witherDisguise); + _creatureModule.SetForce(false); } //Default Spawn @@ -442,11 +443,11 @@ public class PetManager extends MiniClientPlugin { ClientPetTokenWrapper token = new Gson().fromJson(event.GetResponse(), ClientPetTokenWrapper.class); - Get(token.Name).load(token.DonorToken); + Get(event.getUniqueId()).load(token.DonorToken); } @Override - protected PetClient addPlayer(String player) + protected PetClient addPlayer(UUID uuid) { return new PetClient(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java index 64abfc3cf..12cd6f22e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java @@ -51,7 +51,7 @@ public class PollManager extends MiniDbClientPlugin } @Override - protected PlayerPollData addPlayer(String player) + protected PlayerPollData addPlayer(UUID uuid) { return new PlayerPollData(); } @@ -228,9 +228,9 @@ public class PollManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadPollData(resultSet)); + Set(uuid, _repository.loadPollData(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/TransferHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/TransferHandler.java index 32b8907f0..991d1e677 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/TransferHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/TransferHandler.java @@ -4,7 +4,6 @@ import mineplex.serverdata.commands.CommandCallback; import mineplex.serverdata.commands.ServerCommand; import mineplex.serverdata.commands.ServerTransfer; import mineplex.serverdata.commands.TransferCommand; - import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index 07592704a..6d46a269c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -1,9 +1,12 @@ package mineplex.core.preferences; +import java.lang.reflect.Field; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map.Entry; +import java.util.UUID; +import mineplex.core.utils.UtilGameProfile; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -40,13 +43,13 @@ public class PreferencesManager extends MiniDbClientPlugin private IncognitoManager _incognitoManager; private NautHashMap _saveBuffer = new NautHashMap(); - + public boolean GiveItem; - + public PreferencesManager(JavaPlugin plugin, IncognitoManager incognito, CoreClientManager clientManager, DonationManager donationManager) { super("Preferences", plugin, clientManager); - + _repository = new PreferencesRepository(plugin); _exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager); _shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop); @@ -54,12 +57,12 @@ public class PreferencesManager extends MiniDbClientPlugin _incognitoManager = incognito; _exclusiveShop.setPreferencesShop(_shop); - + addCommand(new PreferencesCommand(this)); } - + @Override - protected UserPreferences addPlayer(String player) + protected UserPreferences addPlayer(UUID uuid) { return new UserPreferences(); } @@ -68,20 +71,39 @@ public class PreferencesManager extends MiniDbClientPlugin { _saveBuffer.put(caller.getUniqueId().toString(), Get(caller)); } - + @EventHandler public void givePlayerItem(PlayerJoinEvent event) + { + handlePlayerJoin(event.getPlayer(), false); + } + + public void handlePlayerJoin(Player player, boolean force) { if (!GiveItem) return; - - Player player = event.getPlayer(); - - if (!UtilGear.isMat(player.getInventory().getItem(8), Material.SKULL_ITEM)) + + if (!UtilGear.isMat(player.getInventory().getItem(8), Material.SKULL_ITEM) || force) { ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "My Profile"); SkullMeta meta = ((SkullMeta) item.getItemMeta()); - meta.setOwner(player.getName()); + try + { + Field profileField = meta.getClass().getDeclaredField("profile"); + profileField.setAccessible(true); + profileField.set(meta, UtilGameProfile.getGameProfile(player)); + } + catch (Throwable t) + { + t.printStackTrace(); + } + finally + { + if (!meta.hasOwner()) + { + meta.setOwner(player.getName()); + } + } item.setItemMeta(meta); player.getInventory().setItem(8, item); @@ -89,22 +111,22 @@ public class PreferencesManager extends MiniDbClientPlugin UtilInv.Update(player); } } - + @EventHandler public void storeBuffer(UpdateEvent event) { if (event.getType() != UpdateType.SLOW) return; - + final NautHashMap bufferCopy = new NautHashMap(); - + for (Entry entry : _saveBuffer.entrySet()) { bufferCopy.put(entry.getKey(), entry.getValue()); } - + _saveBuffer.clear(); - + getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() { public void run() @@ -119,11 +141,11 @@ public class PreferencesManager extends MiniDbClientPlugin { if (!GiveItem) return; - + if (event.getItem() != null && event.getItem().getType() == Material.REDSTONE_COMPARATOR) { _shop.attemptShopOpen(event.getPlayer()); - + event.setCancelled(true); } } @@ -134,9 +156,9 @@ public class PreferencesManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadClientInformation(resultSet)); + Set(uuid, _repository.loadClientInformation(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java index 26ece8cbe..3dee2717c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java @@ -130,14 +130,21 @@ public class ExclusivePreferencesPage extends ShopPageBase _profileRepository; private Gson _gson; - public ProfileCacheManager(JavaPlugin plugin) + private ProfileCacheManager() { - super("Profile Cache", plugin); + super("Profile Cache"); _profileRepository = new RedisDataRepository(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), Region.ALL, ProfileData.class, "profileCacheRepo"); @@ -67,10 +65,11 @@ public class ProfileCacheManager extends MiniPlugin implements GameProfileReposi System.out.println("Are you using the correct modified Craftbukkit?"); System.out.println("================================================"); } - - INSTANCE = this; } + /** + * Tries to get a GameProfile; guaranteed to be an unique instance + */ public GameProfile attemptToLoadProfile(String playerName) { ProfileData profile = _profileRepository.getElement(playerName.toLowerCase()); @@ -134,9 +133,4 @@ public class ProfileCacheManager extends MiniPlugin implements GameProfileReposi ProfileData data = new ProfileData(profile.getId(), profile.getName(), _gson.toJson(profile.getProperties())); _profileRepository.addElement(data, 60 * 60 * 24); // 1 day } - - public static ProfileCacheManager getInstance() - { - return INSTANCE; - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java index 4c3a962ea..1ab09449e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java @@ -7,6 +7,8 @@ import mineplex.core.progression.data.PlayerKitDataManager; import mineplex.core.progression.gui.MenuListener; import org.bukkit.plugin.java.JavaPlugin; +import java.util.UUID; + /** * The main class, process logins and loads data. */ @@ -33,7 +35,7 @@ public class KitProgressionManager extends MiniClientPlugin @Override - protected PlayerKit addPlayer(String player) + protected PlayerKit addPlayer(UUID uuid) { return null; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java index 9f566aa2a..65e7affe0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java @@ -2,8 +2,13 @@ package mineplex.core.punish.Command; import java.util.Iterator; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import mineplex.core.account.CoreClient; +import mineplex.core.common.util.F; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -48,20 +53,41 @@ public class PunishCommand extends CommandBase final String finalReason = reason; //Match exact online first - Player target = UtilPlayer.searchExact(playerName); + Player target = Bukkit.getPlayerExact(playerName); + if (target != null) { - Plugin.GetRepository().LoadPunishClient(playerName, new Callback() + AtomicBoolean wasDisguised = new AtomicBoolean(false); + AtomicReference originalName = new AtomicReference<>(playerName); + AtomicReference disguisedName = new AtomicReference<>(playerName); + + CoreClient client = Plugin.GetClients().Get(target.getUniqueId()); + if (!client.getName().equals(target.getName())) { - public void run(PunishClientToken clientToken) + // Has to be the only possibility, but.... + if (client.isDisguised() && client.getDisguisedAs().equalsIgnoreCase(playerName)) { - Plugin.LoadClient(clientToken); - new PunishPage(Plugin, caller, playerName, finalReason); + originalName.set(client.getName()); + disguisedName.set(client.getDisguisedAs()); + wasDisguised.set(true); } + else + { + UtilPlayer.message(caller, F.main("Punish", "An unexpected error occured. Please contact a developer immediately")); + return; + } + } + + Plugin.GetRepository().LoadPunishClient(originalName.get(), clientToken -> + { + Plugin.LoadClient(clientToken); + new PunishPage(Plugin, caller, originalName.get(), finalReason, wasDisguised.get(), originalName.get(), disguisedName.get()); }); return; } + + String finalPlayerName = playerName; //Check repo Plugin.GetRepository().MatchPlayerName(new Callback>() @@ -72,7 +98,7 @@ public class PunishCommand extends CommandBase for (String match : matches) { - if (match.equalsIgnoreCase(playerName)) + if (match.equalsIgnoreCase(finalPlayerName)) { matchedExact = true; } @@ -82,7 +108,7 @@ public class PunishCommand extends CommandBase { for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext();) { - if (!matchIterator.next().equalsIgnoreCase(playerName)) + if (!matchIterator.next().equalsIgnoreCase(finalPlayerName)) { matchIterator.remove(); } @@ -103,12 +129,12 @@ public class PunishCommand extends CommandBase public void run(PunishClientToken clientToken) { Plugin.LoadClient(clientToken); - new PunishPage(Plugin, caller, target, finalReason); + new PunishPage(Plugin, caller, target, finalReason, false, null, null); } }); } - }, caller, playerName, true); + }, caller, finalPlayerName, true); } }, playerName); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index 0ce793810..84fead023 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -2,6 +2,7 @@ package mineplex.core.punish; import java.util.HashMap; +import mineplex.core.account.CoreClient; import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -162,14 +163,31 @@ public class Punish extends MiniPlugin AddPunishment(playerName, category, reason, caller == null ? null : caller.getName(), severity, ban, duration, false); } - public void AddPunishment(final String playerName, final Category category, final String reason, final String callerName, final int severity, boolean ban, long duration, final boolean silent) + public void AddPunishment(String playerName, final Category category, final String reason, String callerName, final int severity, boolean ban, long duration, final boolean silent) { + Player player = Bukkit.getPlayerExact(playerName); + if (player != null) + { + CoreClient client = _clientManager.Get(player); + playerName = client.getName(); + } + + String finalPlayerName = playerName; + + Player caller = callerName == null ? null : Bukkit.getPlayerExact(callerName); + if (caller != null) + { + CoreClient client = _clientManager.Get(caller); + callerName = client.getName(); + } + + String finalCallerName = callerName; + if (!_punishClients.containsKey(playerName.toLowerCase())) { _punishClients.put(playerName.toLowerCase(), new PunishClient()); } - final Player caller = (callerName == null ? null : UtilPlayer.searchExact(callerName)); final PunishmentSentence sentence = !ban ? PunishmentSentence.Mute : PunishmentSentence.Ban; final long finalDuration = duration; @@ -183,16 +201,16 @@ public class Punish extends MiniPlugin if (banResult == PunishmentResponse.AccountDoesNotExist) { if (caller != null) - caller.sendMessage(F.main(getName(), "Account with name " + F.elem(playerName) + " does not exist.")); + caller.sendMessage(F.main(getName(), "Account with name " + F.elem(finalPlayerName) + " does not exist.")); else - System.out.println(F.main(getName(), "Account with name " + F.elem(playerName) + " does not exist.")); + System.out.println(F.main(getName(), "Account with name " + F.elem(finalPlayerName) + " does not exist.")); } else if (banResult == PunishmentResponse.InsufficientPrivileges) { if (caller != null) - caller.sendMessage(F.main(getName(), "You have insufficient rights to punish " + F.elem(playerName) + ".")); + caller.sendMessage(F.main(getName(), "You have insufficient rights to punish " + F.elem(finalPlayerName) + ".")); else - System.out.println(F.main(getName(), "You have insufficient rights to punish " + F.elem(playerName) + ".")); + System.out.println(F.main(getName(), "You have insufficient rights to punish " + F.elem(finalPlayerName) + ".")); } else if (banResult == PunishmentResponse.Punished) { @@ -201,7 +219,7 @@ public class Punish extends MiniPlugin if (sentence == PunishmentSentence.Ban) { if (caller == null) - System.out.println(F.main(getName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " banned " + F.elem(playerName) + " because of " + F.elem(reason) + " for " + durationString + ".")); + System.out.println(F.main(getName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " banned " + F.elem(finalPlayerName) + " because of " + F.elem(reason) + " for " + durationString + ".")); Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { @@ -211,23 +229,22 @@ public class Punish extends MiniPlugin "\n" + C.cWhite + reason + "\n" + C.cDGreen + "Unfairly banned? Appeal at " + C.cGreen + "www.mineplex.com/appeals"; - Player target = UtilPlayer.searchOnline(null, playerName, false); - if (target != null) - target.kickPlayer(kickReason); + if (player != null) + player.kickPlayer(kickReason); else - new mineplex.serverdata.commands.PunishCommand(playerName, true, false, kickReason).publish(); + new mineplex.serverdata.commands.PunishCommand(finalPlayerName, true, false, kickReason).publish(); } }); if (!silent) { - informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " banned " + playerName + " for " + durationString + ".")); + informOfPunish(finalPlayerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " banned " + finalPlayerName + " for " + durationString + ".")); } } else { if (caller == null) - System.out.println(F.main(getName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " muted " + F.elem(playerName) + " because of " + F.elem(reason) + " for " + + System.out.println(F.main(getName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " muted " + F.elem(finalPlayerName) + " because of " + F.elem(reason) + " for " + durationString + ".")); //Warning @@ -235,28 +252,27 @@ public class Punish extends MiniPlugin { if (!silent) { - informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " issued a friendly warning to " + playerName + ".")); + informOfPunish(finalPlayerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " issued a friendly warning to " + finalPlayerName + ".")); } } else { if (!silent) { - informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " muted " + playerName + " for " + durationString + ".")); + informOfPunish(finalPlayerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " muted " + finalPlayerName + " for " + durationString + ".")); } } //Inform - Player target = UtilPlayer.searchExact(playerName); - if (target != null) + if (player != null) { - UtilPlayer.message(target, F.main("Punish", F.elem(C.cGray + C.Bold + "Reason: ") + reason)); - target.playSound(target.getLocation(), Sound.CAT_MEOW, 1f, 1f); + UtilPlayer.message(player, F.main("Punish", F.elem(C.cGray + C.Bold + "Reason: ") + reason)); + player.playSound(player.getLocation(), Sound.CAT_MEOW, 1f, 1f); } else - new mineplex.serverdata.commands.PunishCommand(playerName, false, finalDuration != 0, F.main("Punish", F.elem(C.cGray + C.Bold + (finalDuration != 0 ? "Mute" : "Warning") + " Reason: ") + reason)).publish(); + new mineplex.serverdata.commands.PunishCommand(finalPlayerName, false, finalDuration != 0, F.main("Punish", F.elem(C.cGray + C.Bold + (finalDuration != 0 ? "Mute" : "Warning") + " Reason: ") + reason)).publish(); - _repository.LoadPunishClient(playerName, new Callback() + _repository.LoadPunishClient(finalPlayerName, new Callback() { public void run(PunishClientToken token) { @@ -268,7 +284,7 @@ public class Punish extends MiniPlugin } - }, playerName, category.toString(), sentence, reason, duration, callerName == null ? "Mineplex Anti-Cheat" : callerName, severity); + }, playerName, category.toString(), sentence, reason, duration, finalCallerName == null ? "Mineplex Anti-Cheat" : finalCallerName, severity); } private void informOfPunish(String punishee, String msg) @@ -306,7 +322,8 @@ public class Punish extends MiniPlugin public void RemovePunishment(int punishmentId, String target, final Player admin, String reason, Callback callback) { - _repository.RemovePunishment(callback, punishmentId, target, reason, admin.getName()); + CoreClient client = _clientManager.Get(admin); + _repository.RemovePunishment(callback, punishmentId, target, reason, client.getName()); } public void RemoveBan(String name, String reason) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java index d18f837a2..bdbbce7e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java @@ -7,12 +7,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map.Entry; +import mineplex.core.Managers; import mineplex.core.antihack.AntiHack; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTime; import mineplex.core.punish.Category; import mineplex.core.punish.Punish; @@ -43,6 +46,9 @@ public class PunishPage extends CraftInventoryCustom implements Listener private Player _player; private String _target; private String _reason; + private boolean _wasDisguised; + private String _originalName; + private String _disguisedName; private ShopItem _chatOffenseButton; private ShopItem _exploitingButton; private ShopItem _hackingButton; @@ -50,7 +56,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener private ShopItem _permMuteButton; private ShopItem _permBanButton; - public PunishPage(Punish plugin, Player player, String target, String reason) + public PunishPage(Punish plugin, Player player, String target, String reason, boolean wasDisguised, String originalName, String disguisedName) { super(null, 54, " Punish"); @@ -60,6 +66,9 @@ public class PunishPage extends CraftInventoryCustom implements Listener _player = player; _target = target; _reason = reason; + _wasDisguised = wasDisguised; + _originalName = originalName; + _disguisedName = disguisedName; BuildPage(); @@ -247,7 +256,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener , 1, false, true), new PunishButton(this, Category.Hacking, 2, true, getDuration(Category.Hacking, 2, offenseMap))); - int flightSeverity = (AntiHack.Instance.isStrict() ? 3 : 2); + int flightSeverity = (Managers.get(AntiHack.class).isStrict() ? 3 : 2); AddButton(41, new ShopItem(Material.INK_SACK, (byte)1, "Severity 3",new String[] @@ -309,6 +318,21 @@ public class PunishPage extends CraftInventoryCustom implements Listener }); } + if (_wasDisguised) + { + ShopItem disguiseWarning = new ShopItem(Material.NETHER_STAR, "Disguise Warning", UtilText.splitLinesToArray(new String[] { + ChatColor.RESET + "The player you are attempting to punish is disguised.", + ChatColor.RESET + "Original Name: " + ChatColor.GREEN + ChatColor.BOLD + _originalName, + ChatColor.RESET + "Disguised Name: " + ChatColor.GREEN + ChatColor.BOLD + _disguisedName, + }, LineFormat.LORE), 1, true, true); + disguiseWarning.addGlow(); + + AddButton(8, disguiseWarning, (player, clickType) -> + { + + }); + } + Collections.sort(punishments, new PunishmentSorter()); int slot = 45; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index e0dc88f93..7ad4f881f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -155,7 +155,7 @@ public class ReportManager public boolean canReport(Player player) { - PlayerStats playerStats = _statsManager.Get(player.getName()); + PlayerStats playerStats = _statsManager.Get(player); long abusiveReportsCount = playerStats.getStat(ReportResult.ABUSIVE.getStatName()); return abusiveReportsCount < ABUSE_BAN_THRESHOLD; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java index 9589502eb..f869a2d5f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java @@ -61,7 +61,7 @@ public class PetReward extends UnknownPackageReward @Override public boolean canGiveReward(Player player) { - if (_donationManager.Get(player.getName()) == null) + if (_donationManager.Get(player) == null) { System.out.println("Could not give reward " + getPackageName() + " to Offline Player: " + player.getName()); return false; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java index aeb5b3550..edbc18dfe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java @@ -41,13 +41,13 @@ public class UnknownPackageReward extends Reward @Override public boolean canGiveReward(Player player) { - if (_donationManager.Get(player.getName()) == null) + if (_donationManager.Get(player) == null) { System.out.println("Could not give reward " + _packageName + " to Offline Player: " + player.getName()); return false; } - return !_donationManager.Get(player.getName()).OwnsUnknownPackage(_packageName); + return !_donationManager.Get(player).OwnsUnknownPackage(_packageName); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/MineplexScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/MineplexScoreboard.java new file mode 100644 index 000000000..d0324884d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/MineplexScoreboard.java @@ -0,0 +1,260 @@ +package mineplex.core.scoreboard; + +import org.apache.commons.lang3.StringUtils; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Score; +import org.bukkit.scoreboard.Scoreboard; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + *

+ * This is a Mineplex Scoreboard, featuring new and improved Anti Flickerâ„¢ technology
+ *
+ * To use, you must first define some {@link ScoreboardLine}s. Each ScoreboardLine must
+ *   be unique and implement {@link java.lang.Object#equals} and {@link java.lang.Object#hashCode}.
+ *   ScoreboardLines are only considered equal if both {@link java.lang.Object#equals} and {@link java.lang.Object#hashCode} are equal
+ *
+ * Once you've defined your ScoreboardLines, simply register them using {@link #register}. If you wish to remove a line, simply use {@link #unregister}
+ *
+ * Once you have finished registering and unregistering your lines, call {@link #recalculate} to push all the line changes to the actual scoreboard.
+ *   Please note that you must call {@link #recalculate} before doing any writing
+ *
+ * Once the line changes have been pushed, you can begin writing. First, get the {@link ScoreboardElement} by calling {@link #get} with your ScoreboardLine
+ *   Then, with the ScoreboardElement, call {@link ScoreboardElement#write} with a string of length up to 72 characters, including color codes
+ *
+ * Please note that some restrictions apply. If you have two line that are the same when substringed 16-56, then only one can be added
+ *   Most of the time the implementation will deal with collisions, but if it is unable to an {@link IllegalArgumentException} will be raised
+ * 
+ */ +public class MineplexScoreboard +{ + // The list of legal trackers (we use color codes followed by a reset to hide them) + private static final char[] CHARS = "1234567890abcdefklmnor".toCharArray(); + + // The owner + private final Player _owner; + + // The underlying scoreboard + private final Scoreboard _scoreboard; + + // The sidebar + private final Objective _sidebar; + + // The list of available trackers, implemented as a queue + private final LinkedList _availableTrackers = new LinkedList<>(); + + // The list of registered lines, which have been calculated, in the order of registration + // The ScoreboardLine at index 0 is the one at the top of the scoreboard + private final List _calculated = new ArrayList<>(); + // The map of registered lines to their writable elements + private final Map _calculatedMap = new HashMap<>(); + + // The list of buffered lines + private final List _buffered = new ArrayList<>(); + + /** + * Creates a MineplexScoreboard with no owner + */ + public MineplexScoreboard() + { + this(null); + } + + /** + * Creates a MineplexScoreboard with the given owner + */ + public MineplexScoreboard(Player owner) + { + this._owner = owner; + this._scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); + + this._sidebar = _scoreboard.registerNewObjective("sidebar", "sidebar"); + this._sidebar.setDisplaySlot(DisplaySlot.SIDEBAR); + + for (char c : CHARS) + { + _availableTrackers.add(String.valueOf(ChatColor.COLOR_CHAR) + String.valueOf(c) + ChatColor.RESET.toString()); + } + } + + /** + * Registers the given {@link ScoreboardLine}, placing it at the bottom of the scoreboard, so to speak + * + * @param line The ScoreboardLine to register + * @returns The same instance, to allow chaining + */ + public MineplexScoreboard register(ScoreboardLine line) + { + this._buffered.add(line); + return this; + } + + /** + * Registers the given {@link ScoreboardLine} {@code line}, but only after the ScoreboardLine {@code after} + * + * @param line The ScoreboardLine to register + * @param after The ScoreboardLine to register {@code line} after + * @return The same instance, to allow chaining + */ + public MineplexScoreboard registerAfter(ScoreboardLine line, ScoreboardLine after) + { + int index = _buffered.indexOf(after); + if (index == -1) + { + throw new IllegalStateException("Could not locate line: " + after); + } + _buffered.add(index, line); + return this; + } + + /** + * Unregisters the given {@link ScoreboardLine} from this scoreboard + * + * @param line The ScoreboardLine to unregister + * @return The same instance, to allow chaining + */ + public MineplexScoreboard unregister(ScoreboardLine line) + { + _buffered.remove(line); + return this; + } + + /** + * Recalculates and pushes line changes to the {@link org.bukkit.scoreboard.Scoreboard} + */ + public void recalculate() + { + // Starting fresh + if (this._calculated.size() == 0) + { + for (int i = 0; i < this._buffered.size() && !_availableTrackers.isEmpty(); i++) + { + String tracker = _availableTrackers.pop(); + ScoreboardLine line = this._buffered.get(i); + this._calculated.add(line); + this._calculatedMap.put(line, new ScoreboardElement(this, this._sidebar, line, tracker, this._buffered.size() - i)); + } + } + // Otherwise compute deltas + else + { + // Delete all removed lines + for (ScoreboardLine calculated : this._calculated) + { + if (!this._buffered.contains(calculated)) + { + ScoreboardElement element = get(calculated); + element.delete(); + } + } + + Map prevCalculatedMap = new HashMap<>(_calculatedMap); + + _calculated.clear(); + _calculatedMap.clear(); + + for (int i = 0; i < this._buffered.size(); i++) + { + ScoreboardLine line = this._buffered.get(i); + ScoreboardElement element = prevCalculatedMap.get(line); + int expectedScore = this._buffered.size() - i; + + // existing + if (element != null) + { + Score score = this._sidebar.getScore(element.getTracker()); + if (score.getScore() != expectedScore) + { + score.setScore(expectedScore); + element.setLineNumber(expectedScore); + } + + this._calculated.add(line); + this._calculatedMap.put(line, element); + } + // new + else + { + String tracker = _availableTrackers.pop(); + this._calculated.add(line); + this._calculatedMap.put(line, new ScoreboardElement(this, this._sidebar, line, tracker, expectedScore)); + } + } + } + + this._buffered.clear(); + this._buffered.addAll(this._calculated); + } + + /** + * Determines whether a {@link ScoreboardLine} is currently registered or not + * + * @param line The ScoreboardLine to check + * @return True if {@code line} is registered, and false if not + */ + public boolean isRegistered(ScoreboardLine line) + { + return _calculatedMap.containsKey(line); + } + + /** + * Gets the {@link ScoreboardElement} associated with the {@link ScoreboardLine} + * + * @param line The registered ScoreboardLine + * + * @return The ScoreboardElement, which can be written to + */ + public ScoreboardElement get(ScoreboardLine line) + { + return this._calculatedMap.get(line); + } + + /** + * Gets the owner of this scoreboard + * + * @return The owner, or null if no owner was provided + */ + public Player getOwner() + { + return this._owner; + } + + /** + * Sets the sidebar, or objective, name. This will be not be buffered, but updated instantly + * + * @param sidebarName The new String to be written to the sidebar + */ + public void setSidebarName(String sidebarName) + { + if (!StringUtils.equals(this._sidebar.getName(), sidebarName)) + { + this._sidebar.setDisplayName(sidebarName); + } + } + + /** + * Gets the underlying {@link org.bukkit.scoreboard.Scoreboard} instance, because you're a hacky person + * + * @return The Scoreboard that you want to screw around with + */ + public Scoreboard getHandle() + { + return this._scoreboard; + } + + void returnTracker(String tracker) + { + this._availableTrackers.add(tracker); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardElement.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardElement.java new file mode 100644 index 000000000..e86b873d8 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardElement.java @@ -0,0 +1,242 @@ +package mineplex.core.scoreboard; + +import org.apache.commons.lang3.StringUtils; +import org.bukkit.ChatColor; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Team; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +// fixme bulk send prefix/suffix packets? +public class ScoreboardElement +{ + private static final Set CUSTOM_TRACKER_TRACKER = new HashSet<>(); + + private static final AtomicInteger COUNTER = new AtomicInteger(); + + private MineplexScoreboard _scoreboard; + private Objective _sidebar; + + private ScoreboardLine _line; + + private Team _team; + + private String _tracker; + + private String _customTracker; + + private String _oldValue; + + private int _lineNumber; + + public ScoreboardElement(MineplexScoreboard scoreboard, Objective sidebar, ScoreboardLine line, String tracker, int lineNumber) + { + this._scoreboard = scoreboard; + this._sidebar = sidebar; + this._line = line; + this._tracker = tracker; + this._team = scoreboard.getHandle().registerNewTeam("SBE" + String.valueOf(COUNTER.getAndIncrement())); + this._team.addEntry(this._tracker); + this._lineNumber = lineNumber; + this._sidebar.getScore(_tracker).setScore(this._lineNumber); + } + + public void write(int value) + { + write(String.valueOf(value)); + } + + public void write(String value) + { + if (value.equals(this._oldValue)) return; + + this._oldValue = value; + + if (value.length() <= 16) + { + if (!StringUtils.equals(this._team.getPrefix(), value)) + _team.setPrefix(value); + if (!StringUtils.equals(this._team.getSuffix(), "")) + _team.setSuffix(""); + + clearCustomTracker(); + } + else + { + String left = value.substring(0, 16); + String right = value.substring(16); + String ending = ChatColor.getLastColors(left); + right = ending + right; + if (right.length() <= 16) + { + if (!StringUtils.equals(this._team.getPrefix(), left)) + _team.setPrefix(left); + if (!StringUtils.equals(this._team.getSuffix(), right)) + _team.setSuffix(right); + + clearCustomTracker(); + } + else + { + right = value.substring(16); + + // ensure unique custom trackers + if (right.length() <= 40) + { + if (_customTracker == null || !_customTracker.equals(right)) + { + if (!CUSTOM_TRACKER_TRACKER.add(right)) + { + String resets = ChatColor.RESET.toString(); + while (!CUSTOM_TRACKER_TRACKER.add(resets + ending + right)) + { + resets += ChatColor.RESET.toString(); + } + + right = resets + ending + right; + } + } + } + + if (right.length() <= 40) + { + if (this._customTracker == null) + { + this._customTracker = right; + + this._scoreboard.getHandle().resetScores(this._tracker); + + this._team.addEntry(this._customTracker); + this._sidebar.getScore(this._customTracker).setScore(this._lineNumber); + } + else if (!right.equals(this._customTracker)) + { + this._scoreboard.getHandle().resetScores(this._customTracker); + this._team.removeEntry(this._customTracker); + CUSTOM_TRACKER_TRACKER.remove(this._customTracker); + + this._customTracker = right; + + this._team.addEntry(this._customTracker); + this._sidebar.getScore(this._customTracker).setScore(this._lineNumber); + } + + if (!StringUtils.equals(this._team.getPrefix(), left)) + this._team.setPrefix(left); + if (!StringUtils.equals(this._team.getSuffix(), "")) + this._team.setSuffix(""); + } + else + { + CUSTOM_TRACKER_TRACKER.remove(right); + + String middle = right.substring(0, 40); + right = right.substring(40); + + if (_customTracker == null || !_customTracker.equals(middle)) + { + if (!CUSTOM_TRACKER_TRACKER.add(middle)) + { + String resets = ChatColor.RESET.toString(); + while (!CUSTOM_TRACKER_TRACKER.add(resets + ending + middle)) + { + resets += ChatColor.RESET.toString(); + } + + middle = resets + ending + middle; + + if (middle.length() > 40) + { + right = right + middle.substring(40); + middle = middle.substring(0, 40); + } + } + } + + if (right.length() <= 16) + { + if (this._customTracker == null) + { + this._customTracker = middle; + + this._scoreboard.getHandle().resetScores(this._tracker); + + this._team.addEntry(this._customTracker); + this._sidebar.getScore(this._customTracker).setScore(this._lineNumber); + + } + else if (!middle.equals(this._customTracker)) + { + this._scoreboard.getHandle().resetScores(this._customTracker); + this._team.removeEntry(this._customTracker); + CUSTOM_TRACKER_TRACKER.remove(this._customTracker); + + this._customTracker = middle; + + this._team.addEntry(this._customTracker); + this._sidebar.getScore(this._customTracker).setScore(this._lineNumber); + } + + if (!StringUtils.equals(this._team.getPrefix(), left)) + this._team.setPrefix(left); + if (!StringUtils.equals(this._team.getSuffix(), right)) + this._team.setSuffix(right); + } + else + { + throw new IllegalArgumentException("The following scoreboard line is too damn long: " + value); + } + } + } + } + } + + protected Team getHandle() + { + return this._team; + } + + protected String getTracker() + { + if (this._customTracker != null) + return this._customTracker; + return _tracker; + } + + public void setLineNumber(int lineNumber) + { + this._lineNumber = lineNumber; + this._sidebar.getScore(getTracker()).setScore(this._lineNumber); + } + + public void delete() + { + this._team.unregister(); + this._scoreboard.getHandle().resetScores(this._tracker); + if (this._customTracker != null) + { + this._scoreboard.getHandle().resetScores(this._customTracker); + CUSTOM_TRACKER_TRACKER.remove(this._customTracker); + } + this._scoreboard.returnTracker(this._tracker); + this._team = null; + this._scoreboard = null; + this._tracker = null; + } + + private void clearCustomTracker() + { + if (this._customTracker != null) + { + this._scoreboard.getHandle().resetScores(this._customTracker); + this._team.removeEntry(this._customTracker); + CUSTOM_TRACKER_TRACKER.remove(this._customTracker); + this._customTracker = null; + + this._team.addEntry(this._tracker); + this._sidebar.getScore(this._tracker).setScore(this._lineNumber); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardLine.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardLine.java new file mode 100644 index 000000000..6e9db2e69 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardLine.java @@ -0,0 +1,5 @@ +package mineplex.core.scoreboard; + +public interface ScoreboardLine +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardManager.java index ca76fa1e8..18b64a420 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardManager.java @@ -1,180 +1,99 @@ package mineplex.core.scoreboard; -import java.util.HashMap; -import java.util.Iterator; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.donation.DonationManager; -import mineplex.core.incognito.IncognitoManager; +import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scoreboard.Team; -public class ScoreboardManager extends MiniPlugin -{ - private CoreClientManager _clientManager; - private DonationManager _donationManager; - private IncognitoManager _incognito; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; - //This stores current scoreboard for the player - private HashMap _playerScoreboards = new HashMap(); +public abstract class ScoreboardManager extends MiniPlugin +{ + private final Map _scoreboards = new HashMap<>(); - //Scoreboards (can be shared between players) - private HashMap _scoreboards = new HashMap(); + private int _scoreboardTick = 0; - //Title - private String _title = " MINEPLEX "; - private int _shineIndex; - private boolean _shineDirection = true; - - public ScoreboardManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, IncognitoManager incognito) + public ScoreboardManager(JavaPlugin plugin) { super("Scoreboard Manager", plugin); - - _clientManager = clientManager; - _donationManager = donationManager; - _incognito = incognito; } - public CoreClientManager getClients() + @EventHandler (priority = EventPriority.LOW) + public void onJoin(PlayerJoinEvent event) { - return _clientManager; + MineplexScoreboard scoreboard = new MineplexScoreboard(event.getPlayer()); + + this._scoreboards.put(event.getPlayer().getUniqueId(), scoreboard); + + setup(scoreboard); + draw(scoreboard); + + event.getPlayer().setScoreboard(scoreboard.getHandle()); + + handlePlayerJoin(event.getPlayer()); } - public DonationManager getDonation() + @EventHandler (priority = EventPriority.HIGHEST) + public void onQuit(PlayerQuitEvent event) { - return _donationManager; + this._scoreboards.remove(event.getPlayer().getUniqueId()); + handlePlayerQuit(event.getPlayer()); } - public String getTitle() + public MineplexScoreboard get(Player player) { - return _title; - } - - public void setTitle(String title) - { - _title = title; - _shineIndex = 0; - } - - protected PlayerScoreboard createScoreboard(Player player) - { - return new PlayerScoreboard(this, player); + return _scoreboards.get(player.getUniqueId()); } @EventHandler - public void playerJoin(PlayerJoinEvent event) + public void UpdateScoreboard(UpdateEvent event) { - PlayerScoreboard scoreboard = createScoreboard(event.getPlayer()); - scoreboard.assignScoreboard(event.getPlayer()); - _playerScoreboards.put(event.getPlayer(), scoreboard); - } - - @EventHandler - public void playerQuit(PlayerQuitEvent event) - { - _playerScoreboards.remove(event.getPlayer()); - } - - public void draw() - { - Iterator playerIterator = _playerScoreboards.keySet().iterator(); - - while (playerIterator.hasNext()) - { - Player player = playerIterator.next(); - - //Offline - if (!player.isOnline()) - { - playerIterator.remove(); - continue; - } - - _playerScoreboards.get(player).draw(this, player); - } - } - - public PlayerScoreboard getCurrentScoreboard(Player player) - { - return _playerScoreboards.get(player); - } - - public ScoreboardData getData(String scoreboardName, boolean create) - { - if (!create) - return _scoreboards.get(scoreboardName); - - if (!_scoreboards.containsKey(scoreboardName)) - _scoreboards.put(scoreboardName, new ScoreboardData()); - - return _scoreboards.get(scoreboardName); - } - - @EventHandler - public void updateTitle(UpdateEvent event) - { - if (event.getType() != UpdateType.FASTER) + if (event.getType() != UpdateType.TICK) return; - - String out; - if (_shineDirection) - { - out = C.cGold + C.Bold; - } - else - { - out = C.cWhite + C.Bold; - } + _scoreboardTick = (_scoreboardTick + 1) % 3; - for (int i = 0; i < _title.length(); i++) - { - char c = _title.charAt(i); + if (_scoreboardTick != 0) + return; - if (_shineDirection) - { - if (i == _shineIndex) - out += C.cYellow + C.Bold; - - if (i == _shineIndex + 1) - out += C.cWhite + C.Bold; - } - else - { - if (i == _shineIndex) - out += C.cYellow + C.Bold; - - if (i == _shineIndex + 1) - out += C.cGold + C.Bold; - } - - out += c; - } - - for (PlayerScoreboard ps : _playerScoreboards.values()) - { - ps.setTitle(out); - } - - _shineIndex++; - - if (_shineIndex == _title.length() * 2) - { - _shineIndex = 0; - _shineDirection = !_shineDirection; - } + _scoreboards.values().forEach(this::draw); } - public IncognitoManager getIncognitoManager() + public void handlePlayerJoin(Player player) { - return _incognito; + handlePlayerJoin(player.getName()); + } + + /* + * Used in DisguisePlayer! + */ + public abstract void handlePlayerJoin(String player); + + public void handlePlayerQuit(Player player) + { + handlePlayerQuit(player.getName()); + } + + public abstract void handlePlayerQuit(String player); + + public abstract void setup(MineplexScoreboard scoreboard); + + public abstract void draw(MineplexScoreboard scoreboard); + + public Map getScoreboards() + { + return Collections.unmodifiableMap(this._scoreboards); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/WritableMineplexScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/WritableMineplexScoreboard.java new file mode 100644 index 000000000..dfd1b4267 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/WritableMineplexScoreboard.java @@ -0,0 +1,144 @@ +package mineplex.core.scoreboard; + +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + *
+ * The WritableMineplexScoreboard is a version of the MineplexScoreboard which does not require you to
+ * register your own lines, but instead allows you to write to it as if it were a canvas.
+ *
+ * As soon as the class is created, it is ready to be written to
+ *
+ * The general process of using this class is something like the following:
+ *
+ * * Call {@link #write} up to 15 times for each line in the scoreboard
+ * * When ready, call {@link #draw} to draw the lines onto the scoreboard
+ * * Upon drawing, the buffer of lines will be cleared. This allows you to use {@link #write} again, starting from scratch
+ *
+ * This class is optimized to minimize updates when possible, so it is alright to redraw the same line
+ *   over and over; they will not be sent to the player
+ * 
+ */ +public class WritableMineplexScoreboard extends MineplexScoreboard +{ + // The constant list of 15 lines which will be used + private final List _lines; + + // The list of lines currently buffered for drawing + private final List _bufferedLines = new ArrayList<>(15); + + // The list of lines which were drawn in the last draw + private final List _drawnLines = new ArrayList<>(15); + + /** + * Creates a new WritableMineplexScoreboard with no owner + */ + public WritableMineplexScoreboard() + { + this(null); + } + + /** + * Creates a new WritableMineplexScoreboard with the specified owner + * + * @param owner The owner of this scoreboard + */ + public WritableMineplexScoreboard(Player owner) + { + super(owner); + + List lines = new ArrayList<>(); + for (int i = 0; i < 15; i++) + { + lines.add(new WritableScoreboardLine()); + } + _lines = Collections.unmodifiableList(lines); + } + + /** + * Appends the given line to the buffer. This will not update the scoreboard + * + * @param line The line to buffer + */ + public void write(String line) + { + _bufferedLines.add(line); + } + + /** + * Appends a blank line to the buffer + */ + public void writeNewLine() + { + write(""); + } + + /** + * Draws the currently buffered lines to the actual scoreboard, then flushes the buffers to allow rewriting + */ + public void draw() + { + if (_bufferedLines.size() > 15) + { + throw new IllegalStateException("Too many lines! (" + _bufferedLines.size() + " > 15)"); + } + + if (_bufferedLines.size() > _drawnLines.size()) + { + for (int i = _drawnLines.size(); i < _bufferedLines.size(); i++) + { + super.register(_lines.get(i)); + } + } + else if (_bufferedLines.size() < _drawnLines.size()) + { + for (int i = _bufferedLines.size(); i < _drawnLines.size(); i++) + { + super.unregister(_lines.get(i)); + } + } + + recalculate(); + + for (int i = 0; i < _bufferedLines.size(); i++) + { + get(_lines.get(i)).write(_bufferedLines.get(i)); + } + + this._drawnLines.clear(); + this._drawnLines.addAll(this._bufferedLines); + this._bufferedLines.clear(); + } + + /** + * Resets the currently buffered lines + */ + public void reset() + { + this._bufferedLines.clear(); + } + + @Override + public MineplexScoreboard register(ScoreboardLine line) + { + throw new IllegalArgumentException("You cannot register lines with a WritableMineplexScoreboard!"); + } + + @Override + public MineplexScoreboard unregister(ScoreboardLine line) + { + throw new IllegalArgumentException("You cannot unregister lines with a WritableMineplexScoreboard!"); + } + + /** + * Simply an implementation of ScoreboardLine. More may be added later for metadata purposes + */ + private class WritableScoreboardLine implements ScoreboardLine + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java index f57097c2d..576e37ffd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java @@ -56,7 +56,7 @@ public class ServerConfiguration extends MiniPlugin @EventHandler public void onPlayerLogin(PlayerLoginEvent event) { - if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) + if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) event.disallow(Result.KICK_OTHER, "This is a staff only server."); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 52d19ec1e..6d6094c31 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -3,6 +3,7 @@ package mineplex.core.stats; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Iterator; +import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -300,14 +301,9 @@ public class StatsManager extends MiniDbClientPlugin { return _stats.get(statName); } - - public void replacePlayerHack(String playerName, PlayerStats playerStats) - { - Set(playerName, playerStats); - } - + @Override - protected PlayerStats addPlayer(String player) + protected PlayerStats addPlayer(UUID uuid) { return new PlayerStats(); } @@ -326,9 +322,9 @@ public class StatsManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadClientInformation(resultSet)); + Set(uuid, _repository.loadClientInformation(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java index d7815f41b..688a8aaa8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java @@ -40,17 +40,12 @@ public class GiveStatCommand extends CommandBase if (player == null) { - Plugin.getClientManager().loadClientByName(args[0], new Runnable() + Plugin.getClientManager().loadClientByName(args[0], client -> { - public void run() - { - final CoreClient client = Plugin.getClientManager().Get(args[0]); - - if (client != null) - Plugin.incrementStat(client.getAccountId(), statName, Long.parseLong(args[args.length - 1])); - else - caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + args[0] + "'s account!")); - } + if (client != null) + Plugin.incrementStat(client.getAccountId(), statName, Long.parseLong(args[args.length - 1])); + else + caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + args[0] + "'s account!")); }); } else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java index a8075985a..a5784bd2d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java @@ -68,23 +68,17 @@ public class MasterBuilderUnban extends CommandBase caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!")); return; } - Plugin.getClientManager().loadClientByName(target, new Runnable() + Plugin.getClientManager().loadClientByName(target, theClient -> { - @Override - public void run() + if(theClient != null) { - CoreClient theClient = Plugin.getClientManager().Get(target); - - if(theClient != null) - { - Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); // True = Resets the stat - caller.sendMessage(F.main("MasterBuilder Unban", "The user " + target + " has been unbanned from Master Builders")); - } - else - { - caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + target + "'s client!")); - return; - } + Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); // True = Resets the stat + caller.sendMessage(F.main("MasterBuilder Unban", "The user " + target + " has been unbanned from Master Builders")); + } + else + { + caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + target + "'s client!")); + return; } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java index ef09c15cb..a5dc99212 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java @@ -49,7 +49,7 @@ public class TaskManager extends MiniDbClientPlugin } @Override - protected TaskClient addPlayer(String playerName) + protected TaskClient addPlayer(UUID uuid) { return new TaskClient(); } @@ -100,7 +100,7 @@ public class TaskManager extends MiniDbClientPlugin return false; } - return Get(player.getName()).TasksCompleted.contains(_tasks.get(taskName)); + return Get(player).TasksCompleted.contains(_tasks.get(taskName)); } } @@ -110,7 +110,7 @@ public class TaskManager extends MiniDbClientPlugin { if (_tasks.containsKey(taskName)) { - Get(player.getName()).TasksCompleted.add(_tasks.get(taskName)); + Get(player).TasksCompleted.add(_tasks.get(taskName)); } } @@ -126,7 +126,7 @@ public class TaskManager extends MiniDbClientPlugin { if (_tasks.containsKey(taskName)) { - Get(player.getName()).TasksCompleted.remove(_tasks.get(taskName)); + Get(player).TasksCompleted.remove(_tasks.get(taskName)); } } } @@ -140,9 +140,9 @@ public class TaskManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadClientInformation(resultSet)); + Set(uuid, _repository.loadClientInformation(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java index db766014d..0b7ba2cfa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java @@ -1,18 +1,7 @@ package mineplex.core.teleport; -import java.util.LinkedList; -import java.util.UUID; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.teleport.command.LocateCommand; -import mineplex.core.teleport.command.TeleportCommand; -import mineplex.core.teleport.event.MineplexTeleportEvent; -import mineplex.core.teleport.redis.RedisLocate; -import mineplex.core.teleport.redis.RedisLocateCallback; -import mineplex.core.teleport.redis.RedisLocateHandler; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.ClickEvent; @@ -20,40 +9,77 @@ import mineplex.core.common.jsonchat.HoverEvent; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; +import mineplex.core.teleport.command.LocateCommand; +import mineplex.core.teleport.command.TeleportCommand; +import mineplex.core.teleport.event.MineplexTeleportEvent; +import mineplex.core.teleport.redis.RedisLocate; +import mineplex.core.teleport.redis.RedisLocateCallback; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.commands.ServerCommandManager; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.UUID; public class Teleport extends MiniPlugin { - private LinkedList teleportList = new LinkedList(); - private NautHashMap> _tpHistory = new NautHashMap>(); - private NautHashMap _failedRedisLocates = new NautHashMap(); + private Map _failedRedisLocates = new HashMap<>(); + + private LinkedList teleportList = new LinkedList<>(); + private Map> _tpHistory = new HashMap<>(); private String _serverName; private CoreClientManager _clientManager; public Teleport(JavaPlugin plugin, CoreClientManager clientManager) { super("Teleport", plugin); - + _serverName = getPlugin().getConfig().getString("serverstatus.name"); _clientManager = clientManager; - RedisLocateHandler locateHandler = new RedisLocateHandler(this); + ServerCommandManager.getInstance().registerCommandType("RedisLocate", RedisLocate.class, command -> + { + Player target = Bukkit.getPlayerExact(command.getTarget()); + if (target != null) + { + RedisLocateCallback callback = new RedisLocateCallback(command, _serverName, target.getName()); + callback.publish(); + } + }); + ServerCommandManager.getInstance().registerCommandType("RedisLocateCallback", RedisLocateCallback.class, callback -> + { + Integer taskId = _failedRedisLocates.remove(callback.getUUID()); + if (taskId != null) + { + getScheduler().cancelTask(taskId); + } - ServerCommandManager.getInstance().registerCommandType("RedisLocate", RedisLocate.class, locateHandler); - ServerCommandManager.getInstance().registerCommandType("RedisLocateCallback", RedisLocateCallback.class, locateHandler); + Player player = Bukkit.getPlayer(callback.getReceivingPlayerId()); + + if (player != null) + { + ChildJsonMessage message = new JsonMessage("").extra(C.mHead + "Locate" + "> " + C.mBody + "Located [" + C.mElem + + callback.getLocatedPlayer() + C.mBody + "] at "); + + message.add(C.cBlue + callback.getServer()).click(ClickEvent.RUN_COMMAND, + "/server " + callback.getServer()); + + message.hover(HoverEvent.SHOW_TEXT, "Teleport to " + callback.getServer()); + + message.sendToPlayer(player); + } + }); } @Override @@ -62,75 +88,41 @@ public class Teleport extends MiniPlugin addCommand(new TeleportCommand(this)); addCommand(new LocateCommand(this)); } - - public void handleLocateCallback(RedisLocateCallback callback) - { - BukkitRunnable runnable = _failedRedisLocates.remove(callback.getUUID()); - - if (runnable != null) - { - runnable.cancel(); - } - - Player player = Bukkit.getPlayerExact(callback.getReceivingPlayer()); - - if (player != null) - { - ChildJsonMessage message = new JsonMessage("").extra(C.mHead + "Locate" + "> " + C.mBody + "Located [" + C.mElem - + callback.getLocatedPlayer() + C.mBody + "] at "); - - message.add(C.cBlue + callback.getServer()).click(ClickEvent.RUN_COMMAND, - "/server " + callback.getServer()); - - message.hover(HoverEvent.SHOW_TEXT, "Teleport to " + callback.getServer()); - message.sendToPlayer(player); - } - } - public void locatePlayer(final Player player, final String target) { Player targetPlayer = Bukkit.getPlayerExact(target); - + if (targetPlayer != null) { UtilPlayer.message(player, F.main("Locate", C.mBody + " [" + C.mElem + target + C.mBody + "] is in the same server!")); return; } - - RedisLocate locate = new RedisLocate(_serverName, player.getName(), target); - final UUID uuid = locate.getUUID(); - - BukkitRunnable runnable = new BukkitRunnable() - { - @Override - public void run() - { - _failedRedisLocates.remove(uuid); - UtilPlayer.message(player, F.main("Locate", C.mBody + "Failed to locate [" + C.mElem + target + C.mBody + "].")); - } - - }; - - _failedRedisLocates.put(uuid, runnable); - runnable.runTaskLater(_plugin, 40); - + RedisLocate locate = new RedisLocate(_serverName, player.getName(), player.getUniqueId(), _clientManager.Get(player).GetRank().name(), target); locate.publish(); + + int id = getScheduler().runTaskLater(_plugin, () -> + { + _failedRedisLocates.remove(locate.getUUID()); + UtilPlayer.message(player, F.main("Locate", C.mBody + "Failed to locate [" + C.mElem + target + C.mBody + "].")); + }, 40L).getTaskId(); + + _failedRedisLocates.put(locate.getUUID(), id); } @EventHandler - public void UnloadHistory(ClientUnloadEvent event) + public void unloadHistory(ClientUnloadEvent event) { _tpHistory.remove(event.GetName()); } - + @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) - return; - + return; + if (teleportList.isEmpty()) return; @@ -145,7 +137,7 @@ public class Teleport extends MiniPlugin if (from.equals("%ALL%")) for (Player cur : UtilServer.getPlayers()) listA.add(cur); - //Normal + //Normal else listA = UtilPlayer.matchOnline(caller, from, true); @@ -171,7 +163,7 @@ public class Teleport extends MiniPlugin { mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to themself."); mB = F.main("Teleport", "You teleported " + F.elem(pA.getName()) + " to yourself."); - } + } else { mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to " + F.elem(pB.getName()) + "."); @@ -199,7 +191,7 @@ public class Teleport extends MiniPlugin { mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to themself."); mB = F.main("Teleport", "You teleported " + F.elem(listA.size() + " Players") + " to yourself."); - } + } else { mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to " + F.elem(pB.getName()) + "."); @@ -207,22 +199,22 @@ public class Teleport extends MiniPlugin } //Register - if (first) - Add(pA, pB.getLocation(), mA, true, caller, mB, pA.getName() + " teleported to " + pB.getName() + " via " + caller.getName()); - + if (first) + Add(pA, pB.getLocation(), mA, true, caller, mB, pA.getName() + " teleported to " + pB.getName() + " via " + caller.getName()); + else Add(pA, pB.getLocation(), mA, true, caller, null, pA.getName() + " teleported to " + pB.getName() + " via " + caller.getName()); - + first = false; } } - public void playerToLoc(Player caller, String target, String sX, String sY, String sZ) + public void playerToLoc(Player caller, String target, String sX, String sY, String sZ) { playerToLoc(caller, target, caller.getWorld().getName(), sX, sY, sZ); } - - public void playerToLoc(Player caller, String target, String world, String sX, String sY, String sZ) + + public void playerToLoc(Player caller, String target, String world, String sX, String sY, String sZ) { Player player = UtilPlayer.searchOnline(caller, target, true); @@ -250,8 +242,9 @@ public class Teleport extends MiniPlugin //Inform String mA = null; - if (caller == player) mA = F.main("Teleport", "You teleported to " + UtilWorld.locToStrClean(loc) + "."); - else mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to " + UtilWorld.locToStrClean(loc) + "."); + if (caller == player) mA = F.main("Teleport", "You teleported to " + UtilWorld.locToStrClean(loc) + "."); + else + mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to " + UtilWorld.locToStrClean(loc) + "."); //Register Add(player, loc, mA, true, caller, null, player.getName() + " teleported to " + UtilWorld.locToStrClean(loc) + " via " + caller.getName()); @@ -267,33 +260,35 @@ public class Teleport extends MiniPlugin { teleportList.addLast(new Teleporter(this, pA, pB, mA, mB, loc, record, log)); } - + public void TP(Player player, Location getLocation) { TP(player, getLocation, true); } - - public void TP(Player player, Location loc, boolean dettach) + + public void TP(Player player, Location loc, boolean dettach) { //Event MineplexTeleportEvent event = new MineplexTeleportEvent(player, loc); UtilServer.getServer().getPluginManager().callEvent(event); - + if (event.isCancelled()) return; - + + _tpHistory.computeIfAbsent(player.getName(), key -> new LinkedList<>()).addFirst(player.getLocation()); + if (dettach) { player.eject(); player.leaveVehicle(); } - + player.setFallDistance(0); UtilAction.zeroVelocity(player); - + player.teleport(loc); } - + public LinkedList GetTPHistory(Player player) { return _tpHistory.get(player.getName()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocate.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocate.java index 8cacaac53..d630a78ce 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocate.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocate.java @@ -7,13 +7,19 @@ import mineplex.serverdata.commands.ServerCommand; public class RedisLocate extends ServerCommand { private String _sender; + private UUID _senderUUID; + private String _senderRank; private String _sendingServer; + private String _target; + private UUID _uuid = UUID.randomUUID(); - public RedisLocate(String sendingServer, String sender, String target) + public RedisLocate(String sendingServer, String sender, UUID senderUUID, String senderRank, String target) { _sender = sender; + _senderUUID = senderUUID; + _senderRank = senderRank; _target = target; _sendingServer = sendingServer; } @@ -37,4 +43,9 @@ public class RedisLocate extends ServerCommand { return _uuid; } + + public UUID getSenderId() + { + return _senderUUID; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateCallback.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateCallback.java index 1c18f27f8..d841a188a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateCallback.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateCallback.java @@ -9,12 +9,15 @@ public class RedisLocateCallback extends ServerCommand private String _locatedPlayer; private String _server; private String _receivingPlayer; + private UUID _receivingPlayerUUID; + private UUID _uuid; public RedisLocateCallback(RedisLocate command, String server, String targetName) { _uuid = command.getUUID(); _receivingPlayer = command.getSender(); + _receivingPlayerUUID = command.getSenderId(); _locatedPlayer = targetName; _server = server; @@ -36,6 +39,11 @@ public class RedisLocateCallback extends ServerCommand return _receivingPlayer; } + public UUID getReceivingPlayerId() + { + return _receivingPlayerUUID; + } + public UUID getUUID() { return _uuid; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateHandler.java deleted file mode 100644 index 82694bda2..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package mineplex.core.teleport.redis; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import mineplex.core.teleport.Teleport; -import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; - -public class RedisLocateHandler implements CommandCallback -{ - private Teleport _plugin; - private String _serverName; - - public RedisLocateHandler(Teleport plugin) - { - _plugin = plugin; - _serverName = _plugin.getPlugin().getConfig().getString("serverstatus.name"); - } - - @Override - public void run(ServerCommand command) - { - if (command instanceof RedisLocate) - { - RedisLocate locate = (RedisLocate) command; - - Player target = Bukkit.getPlayerExact(locate.getTarget()); - - if (target != null) - { - RedisLocateCallback callback = new RedisLocateCallback(locate, _serverName, target.getName()); - callback.publish(); - } - } - else if (command instanceof RedisLocateCallback) - { - _plugin.handleLocateCallback((RedisLocateCallback) command); - } - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java index e258f82bb..e671e93ea 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java @@ -13,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; /** * This class handles /thank and amplifier thanks, along with allowing players to claim the rewards they earn @@ -177,17 +178,17 @@ public class ThankManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID playerUUID, int accountId, ResultSet resultSet) throws SQLException { if (resultSet.next()) { int thankToClaim = resultSet.getInt(1); - Set(playerName, new ThankData(thankToClaim)); + Set(playerUUID, new ThankData(thankToClaim)); } } @Override - protected ThankData addPlayer(String player) + protected ThankData addPlayer(UUID player) { return new ThankData(0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java index 272f24733..ac192cf67 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java @@ -1,4 +1,4 @@ -package mineplex.core.scoreboard; +package mineplex.core.thereallyoldscoreboardapiweshouldremove; import java.util.ArrayList; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardData.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardData.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardData.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardData.java index 58eaab05c..3353e7309 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardData.java @@ -1,11 +1,12 @@ -package mineplex.core.scoreboard; - -import mineplex.core.scoreboard.elements.*; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; +package mineplex.core.thereallyoldscoreboardapiweshouldremove; import java.util.ArrayList; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.*; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + public class ScoreboardData { private ArrayList _elements = new ArrayList(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardManager.java new file mode 100644 index 000000000..418399855 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardManager.java @@ -0,0 +1,180 @@ +package mineplex.core.thereallyoldscoreboardapiweshouldremove; + +import java.util.HashMap; +import java.util.Iterator; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.donation.DonationManager; +import mineplex.core.incognito.IncognitoManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class ScoreboardManager extends MiniPlugin +{ + private CoreClientManager _clientManager; + private DonationManager _donationManager; + private IncognitoManager _incognito; + + //This stores current scoreboard for the player + private HashMap _playerScoreboards = new HashMap(); + + //Scoreboards (can be shared between players) + private HashMap _scoreboards = new HashMap(); + + //Title + private String _title = " MINEPLEX "; + private int _shineIndex; + private boolean _shineDirection = true; + + public ScoreboardManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, IncognitoManager incognito) + { + super("Scoreboard Manager", plugin); + + _clientManager = clientManager; + _donationManager = donationManager; + _incognito = incognito; + } + + public CoreClientManager getClients() + { + return _clientManager; + } + + public DonationManager getDonation() + { + return _donationManager; + } + + public String getTitle() + { + return _title; + } + + public void setTitle(String title) + { + _title = title; + _shineIndex = 0; + } + + protected PlayerScoreboard createScoreboard(Player player) + { + return new PlayerScoreboard(this, player); + } + + @EventHandler + public void playerJoin(PlayerJoinEvent event) + { + PlayerScoreboard scoreboard = createScoreboard(event.getPlayer()); + scoreboard.assignScoreboard(event.getPlayer()); + _playerScoreboards.put(event.getPlayer(), scoreboard); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _playerScoreboards.remove(event.getPlayer()); + } + + public void draw() + { + Iterator playerIterator = _playerScoreboards.keySet().iterator(); + + while (playerIterator.hasNext()) + { + Player player = playerIterator.next(); + + //Offline + if (!player.isOnline()) + { + playerIterator.remove(); + continue; + } + + _playerScoreboards.get(player).draw(this, player); + } + } + + public PlayerScoreboard getCurrentScoreboard(Player player) + { + return _playerScoreboards.get(player); + } + + public ScoreboardData getData(String scoreboardName, boolean create) + { + if (!create) + return _scoreboards.get(scoreboardName); + + if (!_scoreboards.containsKey(scoreboardName)) + _scoreboards.put(scoreboardName, new ScoreboardData()); + + return _scoreboards.get(scoreboardName); + } + + @EventHandler + public void updateTitle(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + String out; + + if (_shineDirection) + { + out = C.cGold + C.Bold; + } + else + { + out = C.cWhite + C.Bold; + } + + for (int i = 0; i < _title.length(); i++) + { + char c = _title.charAt(i); + + if (_shineDirection) + { + if (i == _shineIndex) + out += C.cYellow + C.Bold; + + if (i == _shineIndex + 1) + out += C.cWhite + C.Bold; + } + else + { + if (i == _shineIndex) + out += C.cYellow + C.Bold; + + if (i == _shineIndex + 1) + out += C.cGold + C.Bold; + } + + out += c; + } + + for (PlayerScoreboard ps : _playerScoreboards.values()) + { + ps.setTitle(out); + } + + _shineIndex++; + + if (_shineIndex == _title.length() * 2) + { + _shineIndex = 0; + _shineDirection = !_shineDirection; + } + } + + public IncognitoManager getIncognitoManager() + { + return _incognito; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElement.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElement.java similarity index 55% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElement.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElement.java index cdb8a2e9b..b5dfee821 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElement.java @@ -1,10 +1,10 @@ -package mineplex.core.scoreboard.elements; +package mineplex.core.thereallyoldscoreboardapiweshouldremove.elements; import java.util.List; import org.bukkit.entity.Player; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; public interface ScoreboardElement { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementCoinCount.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementCoinCount.java similarity index 76% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementCoinCount.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementCoinCount.java index 2c7937411..63e200a01 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementCoinCount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementCoinCount.java @@ -1,7 +1,7 @@ -package mineplex.core.scoreboard.elements; +package mineplex.core.thereallyoldscoreboardapiweshouldremove.elements; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import org.bukkit.entity.Player; import java.util.ArrayList; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGemCount.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementGemCount.java similarity index 75% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGemCount.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementGemCount.java index 8caae6533..31a013ed0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGemCount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementGemCount.java @@ -1,7 +1,7 @@ -package mineplex.core.scoreboard.elements; +package mineplex.core.thereallyoldscoreboardapiweshouldremove.elements; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import org.bukkit.entity.Player; import java.util.ArrayList; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementRank.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementRank.java similarity index 50% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementRank.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementRank.java index 93af0af7e..17f4629bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementRank.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementRank.java @@ -1,4 +1,4 @@ -package mineplex.core.scoreboard.elements; +package mineplex.core.thereallyoldscoreboardapiweshouldremove.elements; import java.util.ArrayList; import java.util.List; @@ -6,7 +6,7 @@ import java.util.List; import org.bukkit.entity.Player; import mineplex.core.common.Rank; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; public class ScoreboardElementRank implements ScoreboardElement { @@ -19,11 +19,11 @@ public class ScoreboardElementRank implements ScoreboardElement { output.add(manager.getClients().Get(player).GetRank().Name); } - else if (manager.getDonation().Get(player.getName()).OwnsUnknownPackage("SuperSmashMobs ULTRA") || - manager.getDonation().Get(player.getName()).OwnsUnknownPackage("Survival Games ULTRA") || - manager.getDonation().Get(player.getName()).OwnsUnknownPackage("Minigames ULTRA") || - manager.getDonation().Get(player.getName()).OwnsUnknownPackage("CastleSiege ULTRA") || - manager.getDonation().Get(player.getName()).OwnsUnknownPackage("Champions ULTRA")) + else if (manager.getDonation().Get(player).OwnsUnknownPackage("SuperSmashMobs ULTRA") || + manager.getDonation().Get(player).OwnsUnknownPackage("Survival Games ULTRA") || + manager.getDonation().Get(player).OwnsUnknownPackage("Minigames ULTRA") || + manager.getDonation().Get(player).OwnsUnknownPackage("CastleSiege ULTRA") || + manager.getDonation().Get(player).OwnsUnknownPackage("Champions ULTRA")) { output.add("Single Ultra"); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementScores.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementScores.java similarity index 89% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementScores.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementScores.java index 73ced3d5b..cce770b87 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementScores.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementScores.java @@ -1,4 +1,4 @@ -package mineplex.core.scoreboard.elements; +package mineplex.core.thereallyoldscoreboardapiweshouldremove.elements; import java.util.ArrayList; import java.util.HashMap; @@ -6,7 +6,7 @@ import java.util.List; import org.bukkit.entity.Player; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; public class ScoreboardElementScores implements ScoreboardElement { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementText.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementText.java similarity index 75% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementText.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementText.java index b17be47ce..f9d4d99e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementText.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementText.java @@ -1,11 +1,11 @@ -package mineplex.core.scoreboard.elements; +package mineplex.core.thereallyoldscoreboardapiweshouldremove.elements; import java.util.ArrayList; import java.util.List; import org.bukkit.entity.Player; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; public class ScoreboardElementText implements ScoreboardElement { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java b/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java index 4166c6a36..26b9cc491 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java @@ -44,9 +44,9 @@ public class TournamentManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uid, int accountId, ResultSet resultSet) throws SQLException { - ClientTournamentData clientData = Get(playerName); + ClientTournamentData clientData = Get(uid); while (resultSet.next()) { @@ -80,7 +80,7 @@ public class TournamentManager extends MiniDbClientPlugin } @Override - protected ClientTournamentData addPlayer(String player) + protected ClientTournamentData addPlayer(UUID uuid) { return new ClientTournamentData(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index 2d7203f06..2b15453e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -60,11 +60,6 @@ public class BuyChestButton implements IButton player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); return; } - if(_inventoryManager.getClientManager().Get(player).isDisguised()) - { - UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!")); - return; - } SalesPackageBase salesPackage = new ChestPackage(_chestName, _chestMat, _chestCost); _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, salesPackage, _page.getDonationManager(), () -> { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilGameProfile.java b/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilGameProfile.java new file mode 100644 index 000000000..4d48e4ccc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilGameProfile.java @@ -0,0 +1,177 @@ +package mineplex.core.utils; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.mojang.authlib.GameProfile; +import mineplex.core.Managers; +import mineplex.core.profileCache.ProfileCacheManager; +import mineplex.core.thread.ThreadPool; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.UUID; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; +import java.util.regex.Pattern; + +public class UtilGameProfile +{ + private static final Cache TEXTURES = CacheBuilder.newBuilder() + .expireAfterWrite(5, TimeUnit.MINUTES) + .concurrencyLevel(4) + .build(); + + /** + * Get a {@link GameProfile} given a username. + * + * If you desperately must block the current thread, you may pass a null Consumer and use Future.get() + * + * @param username The username of the player + * @param nonNull If true, an OfflinePlayer GameProfile will be returned should the username not be valid + * @param fetched The Consumer which will receive the GameProfile instance. This Consumer will not be called on the main thread + * + * @return The GameProfile - always an unique instance + */ + public static Future getProfileByName(String username, boolean nonNull, Consumer fetched) + { + return ThreadPool.ASYNC.submit(() -> + { + // First, try to load it from the redis cache + GameProfile gameProfile = Managers.get(ProfileCacheManager.class).attemptToLoadProfile(username); + + if (gameProfile == null) + { + gameProfile = MinecraftServer.getServer().getUserCache().getProfile(username); + + // This profile is not guaranteed to be unique, and we don't want to be modifying the cache... + if (gameProfile != null) + { + gameProfile = clone(gameProfile); + } + } + + // We've found the profile + if (gameProfile != null) + { + if (!gameProfile.getProperties().containsKey("textures")) + { + // There are no textures in the GameProfile and we have not yet tried to load it + if (TEXTURES.getIfPresent(gameProfile.getId()) == null) + { + TEXTURES.put(gameProfile.getId(), true); + + // Try to fill it and cache the profile + MinecraftServer.getServer().aD().fillProfileProperties(gameProfile, true); + Managers.get(ProfileCacheManager.class).cacheProfile(gameProfile); + } + } + } + + // If a nonnull GameProfile is requested, then we'll use the default OfflinePlayer UUID format + if (gameProfile == null && nonNull) + { + gameProfile = new GameProfile(EntityPlayer.b(username), username); + } + + // Clone it one last time in case some Mojang API changes and we're left scratching our heads + // wondering why everything suddenly broke + gameProfile = clone(gameProfile); + + if (fetched != null) + { + fetched.accept(gameProfile); + } + + return gameProfile; + }); + } + + /** + * Clones a GameProfile + * + * @param input The GameProfile to clone + * + * @return A copy of the GameProfile + */ + public static GameProfile clone(GameProfile input) + { + GameProfile newProfile = new GameProfile(input.getId(), input.getName()); + newProfile.getProperties().putAll(input.getProperties()); + return newProfile; + } + + // Pattern to remove all non alphanumeric + underscore letters + private static final Pattern LEGAL_USERNAME = Pattern.compile("[^A-Za-z0-9_]"); + + /** + * Convert a string to a legal username equivalent + * + * @param in The original username + * + * @returns A legal version of the username (with illegal characters stripped out + */ + public static String legalize(String in) + { + return LEGAL_USERNAME.matcher(in).replaceAll(""); + } + + private static final Field GAME_PROFILE_NAME_FIELD; + private static final Field GAME_PROFILE_ID_FIELD; + + static + { + try + { + GAME_PROFILE_NAME_FIELD = GameProfile.class.getDeclaredField("name"); + GAME_PROFILE_NAME_FIELD.setAccessible(true); + GAME_PROFILE_ID_FIELD = GameProfile.class.getDeclaredField("id"); + GAME_PROFILE_ID_FIELD.setAccessible(true); + + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(GAME_PROFILE_NAME_FIELD, GAME_PROFILE_NAME_FIELD.getModifiers() & ~Modifier.FINAL); + modifiersField.setInt(GAME_PROFILE_ID_FIELD, GAME_PROFILE_ID_FIELD.getModifiers() & ~Modifier.FINAL); + + GameProfile testProfile = new GameProfile(UUID.randomUUID(), "Testing"); + String changedName = "TestSuccessful"; + UUID changedUUID = UUID.randomUUID(); + changeName(testProfile, changedName); + changeId(testProfile, changedUUID); + if (!testProfile.getName().equals(changedName)) + { + throw new RuntimeException("Could not change name of test GameProfile: Got " + testProfile.getName() + ", expected " + changedName); + } + if (!testProfile.getId().equals(changedUUID)) + { + throw new RuntimeException("Could not change UUID of test GameProfile: Got " + testProfile.getId() + ", expected " + changedUUID); + } + } + catch (ReflectiveOperationException ex) + { + throw new RuntimeException(ex); + } + } + + public static void changeName(GameProfile gameProfile, String changedName) throws ReflectiveOperationException + { + GAME_PROFILE_NAME_FIELD.set(gameProfile, changedName); + } + + public static void changeId(GameProfile gameProfile, UUID newUUID) throws ReflectiveOperationException + { + GAME_PROFILE_ID_FIELD.set(gameProfile, newUUID); + } + + /** + * Gets the GameProfile of a player, cloned + */ + public static GameProfile getGameProfile(Player player) + { + return clone(((CraftPlayer) player).getProfile()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/youtube/YoutubeManager.java b/Plugins/Mineplex.Core/src/mineplex/core/youtube/YoutubeManager.java index 5683c4b20..fd68c2475 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/youtube/YoutubeManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/youtube/YoutubeManager.java @@ -14,6 +14,7 @@ import java.sql.SQLException; import java.time.LocalDate; import java.time.ZoneOffset; import java.time.ZonedDateTime; +import java.util.UUID; public class YoutubeManager extends MiniDbClientPlugin { @@ -60,13 +61,13 @@ public class YoutubeManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { boolean hasRow = resultSet.next(); if (hasRow) - Set(playerName, new YoutubeClient(resultSet.getDate(1).toLocalDate())); + Set(uuid, new YoutubeClient(resultSet.getDate(1).toLocalDate())); else - Set(playerName, new YoutubeClient(null)); + Set(uuid, new YoutubeClient(null)); } @Override @@ -76,7 +77,7 @@ public class YoutubeManager extends MiniDbClientPlugin } @Override - protected YoutubeClient addPlayer(String player) + protected YoutubeClient addPlayer(UUID uuid) { return new YoutubeClient(null); } diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index 8591bbfb4..e0296c21b 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -85,31 +85,23 @@ public class Enjin extends MiniPlugin implements CommandExecutor { final String name = args[1]; - _clientManager.loadClientByName(name, new Runnable() + _clientManager.loadClientByName(name, client -> { - public void run() + if (client == null) { - final CoreClient client = _clientManager.Get(name); - - if (client == null) - { - System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", isn't in our database."); - } + System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", isn't in our database."); + } + else + { + UUID uuid = null; + + if (_cachedUUIDs.containsKey(name)) + uuid = _cachedUUIDs.get(name).getKey(); else { - UUID uuid = null; - - if (_cachedUUIDs.containsKey(name)) - uuid = _cachedUUIDs.get(name).getKey(); - else - { - // Fails if not in DB and if duplicate. - uuid = _clientManager.loadUUIDFromDB(name); - - if (uuid == null) - uuid = UUIDFetcher.getUUIDOf(name); - } - + // Fails if not in DB and if duplicate. + uuid = _clientManager.loadUUIDFromDB(name); + if (uuid == null) { System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", no UUID."); @@ -169,32 +161,23 @@ public class Enjin extends MiniPlugin implements CommandExecutor protected boolean checkForRankPurchase(String[] args, final String name, final UUID playerUUID, final CoreClient client) { if (args.length != 4 || !args[0].equalsIgnoreCase("rank")) - return false;; + return false; final Rank rank = mineplex.core.common.Rank.valueOf(args[2]); final boolean perm = Boolean.parseBoolean(args[3]); - _clientManager.loadClientByName(name, new Runnable() + _clientManager.loadClientByName(name, loadedClient -> { - public void run() + if (rank == Rank.ALL || loadedClient.GetRank() == Rank.ALL || !loadedClient.GetRank().has(rank) || loadedClient.GetRank() == rank) { - if (rank == Rank.ALL || _clientManager.Get(name).GetRank() == Rank.ALL || !_clientManager.Get(name).GetRank().has(rank) || _clientManager.Get(name).GetRank() == rank) - { - _clientManager.SaveRank(new Callback() - { - public void run(Rank data) - { - _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.Name + (perm ? " Permanent" : " Monthly"), 1, data == rank); - } - }, name, playerUUID, rank, perm); - - System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + rank + " " + (perm ? "permanently." : "for 1 month.")); - } - else - { - System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " DENIED INFERIOR " + rank + " " + (perm ? "permanently." : "for 1 month.")); - _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.Name + (perm ? " Permanent" : " Monthly"), 1, false); - } + _clientManager.SaveRank(data -> _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.Name + (perm ? " Permanent" : " Monthly"), 1, data == rank), name, playerUUID, rank, perm); + + System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + rank + " " + (perm ? "permanently." : "for 1 month.")); + } + else + { + System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " DENIED INFERIOR " + rank + " " + (perm ? "permanently." : "for 1 month.")); + _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.Name + (perm ? " Permanent" : " Monthly"), 1, false); } }); diff --git a/Plugins/Mineplex.Game.Clans/plugin.yml b/Plugins/Mineplex.Game.Clans/plugin.yml index 3bebeab2e..0d9f0bb90 100644 --- a/Plugins/Mineplex.Game.Clans/plugin.yml +++ b/Plugins/Mineplex.Game.Clans/plugin.yml @@ -1,3 +1,4 @@ name: Clans main: mineplex.game.clans.Clans -version: 1.0 \ No newline at end of file +version: 1.0 +loadbefore: [MineplexAnticheat] \ No newline at end of file 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 b9a4ff533..dee2ca0e9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -1,5 +1,11 @@ package mineplex.game.clans; +import mineplex.core.Managers; +import mineplex.core.antihack.AntiHackGuardian; +import mineplex.core.creature.Creature; +import mineplex.core.disguise.DisguiseManager; +import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; @@ -56,6 +62,8 @@ import mineplex.game.clans.spawn.travel.TravelShop; import mineplex.game.clans.world.WorldManager; import net.minecraft.server.v1_8_R3.MinecraftServer; +import static mineplex.core.Managers.require; + public class Clans extends JavaPlugin { public static final String MAP = "Map 1"; @@ -73,7 +81,7 @@ public class Clans extends JavaPlugin getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/"); getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG)); saveConfig(); - + String webServerAddress = getConfig().getString(WEB_CONFIG); // Logger.initialize(this); @@ -96,8 +104,8 @@ public class Clans extends JavaPlugin new FallingBlocks(this); new ServerConfiguration(this, _clientManager); - - PacketHandler packetHandler = new PacketHandler(this); + + PacketHandler packetHandler = require(PacketHandler.class); IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler); PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager); @@ -112,12 +120,92 @@ public class Clans extends JavaPlugin Teleport teleport = new Teleport(this, _clientManager); Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - + ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager); - + Punish punish = new Punish(this, webServerAddress, _clientManager); - AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); - AntiHack.Instance.setKick(false); + + DisguiseManager disguiseManager = require(DisguiseManager.class); + Creature creature = new Creature(this); + + AntiHack antiHack = require(AntiHack.class); + antiHack.setKick(false); + antiHack.enableNewAnticheat(); + + { + // West Shop + int maxX = -385; + int minX = -462; + int maxY = 100; + int minY = 90; + int maxZ = 46; + int minZ = -30; + Location spawn = new Location(Bukkit.getWorld("world"), -422, 95, 8); + for (int i = 0; i < 10; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); + } + } + + { + // East Shop + int maxX = 385; + int minX = -463; + int maxY = 100; + int minY = 90; + int maxZ = 31; + int minZ = -46; + Location spawn = new Location(Bukkit.getWorld("world"), 424, 95, -8); + for (int i = 0; i < 10; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); + } + } + + { + // North Spawn + int maxX = 25; + int minX = -8; + int maxY = 215; + int minY = 205; + int maxZ = -376; + int minZ = -410; + Location spawn = new Location(Bukkit.getWorld("world"), 9, 210, -393); + for (int i = 0; i < 10; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); + } + } + + { + // South Spawn + int maxX = 25; + int minX = -8; + int maxY = 215; + int minY = 205; + int maxZ = 407; + int minZ = 373; + Location spawn = new Location(Bukkit.getWorld("world"), 8, 210, 390); + for (int i = 0; i < 10; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); + } + } + + { + // Fields + int maxX = 50; + int minX = -60; + int maxY = 110; + int minY = 100; + int maxZ = 70; + int minZ = -70; + Location spawn = new Location(Bukkit.getWorld("world"), 0, 100, 0); + for (int i = 0; i < 40; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); + } + } BlockRestore blockRestore = new BlockRestore(this); @@ -165,10 +253,10 @@ public class Clans extends JavaPlugin // Disable item merging ((CraftWorld) world).getHandle().spigotConfig.itemMerge = 0; } - + //Updates new Updater(this); - + MinecraftServer.getServer().getPropertyManager().setProperty("debug", true); } 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 7736952a9..b31688444 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 @@ -9,8 +9,10 @@ import java.util.Set; import java.util.TimeZone; import java.util.UUID; +import mineplex.core.Managers; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.Achievement; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; @@ -269,9 +271,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati _gearManager = gearManager; _lootManager = new LootManager(gearManager, _goldManager); - _disguiseManager = new DisguiseManager(plugin, packetHandler); - Creature creature = new Creature(plugin); - _npcManager = new NpcManager(plugin, creature); + _disguiseManager = Managers.get(DisguiseManager.class); + _npcManager = new NpcManager(plugin, Managers.get(Creature.class)); _condition = new SkillConditionManager(plugin); _damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition); _damageManager.addCommand(new KillCommand(_damageManager)); @@ -297,7 +298,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati new InvseeManager(this); - _explosion = new Explosion(plugin, blockRestore); + _explosion = Managers.get(Explosion.class); _warPointEvasion = new WarPointEvasion(plugin); // new ClansLoginManager(getPlugin(), clientManager, _serverName); @@ -308,7 +309,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati // TODO: Re-enable customtagfix with NCP update? // new CustomTagFix(plugin, packetHandler); - new Field(plugin, creature, _condition, this, energy, serverName); + new Field(plugin, Managers.get(Creature.class), _condition, this, energy, serverName); // Required managers to be initialized new Spawn(plugin, this); @@ -374,8 +375,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati ServerCommandManager.getInstance().registerCommandType(ClanDeleteCommand.class, new ClanDeleteCommandHandler()); ServerCommandManager.getInstance().registerCommandType(ClanLoadCommand.class, new ClanLoadCommandHandler()); - EloManager eloManager = new EloManager(plugin, _clientManager); - AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager, incognitoManager, eloManager); + EloManager eloManager = Managers.get(EloManager.class); + AchievementManager achievementManager = Managers.get(AchievementManager.class); ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager); _classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop"); @@ -1060,7 +1061,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati } @Override - protected ClientClan addPlayer(String player) + protected ClientClan addPlayer(UUID uuid) { return new ClientClan(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java index 7432c7a66..ff64efdb3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java @@ -2,6 +2,7 @@ package mineplex.game.clans.clans.commands; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; import java.util.concurrent.ConcurrentLinkedQueue; import org.bukkit.ChatColor; @@ -69,7 +70,7 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor } @Override - public void processLoginResultSet(final String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(final String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { if (_enabled) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/murder/MurderManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/murder/MurderManager.java index 49143cff6..3e7735e01 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/murder/MurderManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/murder/MurderManager.java @@ -2,6 +2,7 @@ package mineplex.game.clans.clans.murder; import java.util.Arrays; import java.util.List; +import java.util.UUID; import org.bukkit.Location; import org.bukkit.Material; @@ -204,7 +205,7 @@ public class MurderManager extends MiniClientPlugin } @Override - protected ClientMurder addPlayer(String player) + protected ClientMurder addPlayer(UUID uuid) { return new ClientMurder(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java index c64fd698a..f85a8fe52 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java @@ -14,6 +14,8 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansPlayerStats; import mineplex.game.clans.clans.playtime.command.PlayTimeCommand; +import java.util.UUID; + public class Playtime extends MiniClientPlugin { private StatsManager _statsManager; @@ -45,7 +47,7 @@ public class Playtime extends MiniClientPlugin @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - Set(event.getPlayer(), addPlayer(event.getPlayer().getName())); + Set(event.getPlayer(), addPlayer(event.getPlayer().getUniqueId())); } @EventHandler @@ -73,9 +75,9 @@ public class Playtime extends MiniClientPlugin } @Override - protected PlayingClient addPlayer(String player) + protected PlayingClient addPlayer(UUID uuid) { - return new PlayingClient(Bukkit.getPlayer(player), TaskManager.Instance); + return new PlayingClient(Bukkit.getPlayer(uuid), TaskManager.Instance); } // Seconds diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java index c3e213da9..29950b8db 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java @@ -11,8 +11,8 @@ import org.bukkit.scoreboard.Team; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilText; -import mineplex.core.scoreboard.PlayerScoreboard; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.PlayerScoreboard; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility.ClanRelation; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java index a1fe7a874..d3e6f3bc4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java @@ -9,9 +9,9 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.OnlineRankUpdateEvent; import mineplex.core.donation.DonationManager; -import mineplex.core.scoreboard.PlayerScoreboard; -import mineplex.core.scoreboard.ScoreboardData; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.PlayerScoreboard; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardData; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.Clans; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java index 1227c8edb..5d5bbafea 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java @@ -4,8 +4,8 @@ import java.util.List; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilTime; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index 33c24cfff..3fb06b2f0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -3,8 +3,8 @@ package mineplex.game.clans.clans.scoreboard.elements; import java.util.List; import mineplex.core.common.util.C; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.core.repository.ClanTerritory; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java index 9b2f8c152..c427499ca 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java @@ -2,8 +2,8 @@ package mineplex.game.clans.clans.scoreboard.elements; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.game.clans.clans.ClansManager; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index 1892dae30..0265561c3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -14,8 +14,8 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index 2270b7ef0..3dd3cd94e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -10,8 +10,9 @@ import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; @@ -335,4 +336,9 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement { _skillFactory = skillManager; } + + public DisguiseManager getDisguiseManager() + { + return getClans().getDisguiseManager(); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index 75b0b5b6c..31d3ba205 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -61,7 +61,7 @@ public enum WorldEventType } else { - worldEvent = (WorldEvent) con.newInstance(eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), eventManager.getClans().getProjectile(), centerLocation); + worldEvent = (WorldEvent) con.newInstance(eventManager.getDisguiseManager(), eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), eventManager.getClans().getProjectile(), centerLocation); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java index d1aed67e0..5b6a64da3 100755 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java @@ -12,7 +12,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.WorldEventManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java index 108265536..fe7aa8421 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java @@ -35,18 +35,13 @@ public class GoldCommand extends CommandBase if (target == null) { - Plugin.getClientManager().loadClientByName(targetName, new Runnable() + Plugin.getClientManager().loadClientByName(targetName, client -> { - public void run() + if (client != null) + rewardGold(caller, null, targetName, client.getAccountId(), goldString); + else { - CoreClient client = Plugin.getClientManager().Get(targetName); - - if (client != null) - rewardGold(caller, null, targetName, client.getAccountId(), goldString); - else - { - UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName))); - } + UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName))); } }); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java index 0979e7148..43f125e28 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -295,7 +295,7 @@ public class GoldManager extends MiniDbClientPlugin private Donor getDonor(Player player) { - return _donationManager.Get(player.getName()); + return _donationManager.Get(player); } public static void notify(Player player, String message) @@ -404,11 +404,11 @@ public class GoldManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID playerUUID, int accountId, ResultSet resultSet) throws SQLException { if (resultSet.next()) { - Get(playerName).setBalance(resultSet.getInt(1)); + Get(playerUUID).setBalance(resultSet.getInt(1)); if (resultSet.getInt(1) < 0) { @@ -431,8 +431,7 @@ public class GoldManager extends MiniDbClientPlugin } @Override - protected GoldData addPlayer(String player) - { + protected GoldData addPlayer(UUID uuid) { return new GoldData(); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java index bd1a249d1..526805366 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java @@ -34,20 +34,15 @@ public class SetGoldCommand extends CommandBase { if (target == null) { - Plugin.getClientManager().loadClientByName(targetName, new Runnable() + Plugin.getClientManager().loadClientByName(targetName, client -> { - public void run() + if (client != null) { - CoreClient client = Plugin.getClientManager().Get(targetName); - - if (client != null) - { - setGold(caller, null, targetName, client.getAccountId(), Integer.parseInt(goldString)); - } - else - { - UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName))); - } + setGold(caller, null, targetName, client.getAccountId(), Integer.parseInt(goldString)); + } + else + { + UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName))); } }); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java index f83a7b0cb..1d0dd2814 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java @@ -203,13 +203,13 @@ public class CombatLogNPC skel.getEquipment().setLeggings(player.getInventory().getLeggings()); skel.getEquipment().setBoots(player.getInventory().getBoots()); skel.getEquipment().setItemInHand(player.getItemInHand()); - + // Get in range List inRange = UtilPlayer.getNearby(spawnLoc, 75d); // Disguise DisguisePlayer disguise = new DisguisePlayer(skel, ((CraftPlayer) player).getHandle().getProfile()); - _disguiseManager.disguise(disguise, inRange.toArray(new Player[inRange.size()])); + _disguiseManager.disguise(disguise, attempted -> inRange.contains(attempted)); if (!UtilEnt.isGrounded(player)) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java index b3221c89f..6dc7d8966 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java @@ -35,8 +35,8 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.donation.DonationManager; import mineplex.core.packethandler.PacketHandler; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java index 826fbccc1..135689cdc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java @@ -16,8 +16,8 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; import mineplex.core.hologram.HologramManager; import mineplex.core.npc.NpcManager; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.message.ClansMessageManager; diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java index df03752b3..661422a18 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -1,10 +1,12 @@ package mineplex.clanshub; import mineplex.core.CustomTagFix; +import mineplex.core.Managers; import mineplex.core.PacketsInteractionFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; +import mineplex.core.antihack.AntiHackGuardian; import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.boosters.BoosterManager; @@ -55,8 +57,11 @@ import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.plugin.java.JavaPlugin; +import static mineplex.core.Managers.require; + /** * Main class for clans hub */ @@ -80,7 +85,7 @@ public class ClansHub extends JavaPlugin new VelocityFix(this); //Static Modules - new ProfileCacheManager(this); + require(ProfileCacheManager.class); CommandCenter.Initialize(this); CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); CommandCenter.Instance.setClientManager(clientManager); @@ -96,8 +101,8 @@ public class ClansHub extends JavaPlugin ServerConfiguration serverConfiguration = new ServerConfiguration(this, clientManager); //Other Modules - PacketHandler packetHandler = new PacketHandler(this); - DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); + PacketHandler packetHandler = require(PacketHandler.class); + DisguiseManager disguiseManager = require(DisguiseManager.class); IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler); PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager, donationManager); @@ -116,7 +121,12 @@ public class ClansHub extends JavaPlugin Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); - AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); + AntiHack antiHack = require(AntiHack.class); + + for (int i = 0; i < 8; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(new Location(Bukkit.getWorld("world"), 0, 195, 0), 25, -8, 195, 185, 17, -16)); + } IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); @@ -134,6 +144,7 @@ public class ClansHub extends JavaPlugin ThankManager thankManager = new ThankManager(this, clientManager, donationManager); BoosterManager boosterManager = new BoosterManager(this, "", clientManager, donationManager, inventoryManager, thankManager); HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager); + HologramManager hologramManager = new HologramManager(this, packetHandler); ClansTransferManager serverManager = new ClansTransferManager(this, clientManager, donationManager, partyManager, portal, hubManager); @@ -150,8 +161,6 @@ public class ClansHub extends JavaPlugin AprilFoolsManager.Initialize(this, clientManager, disguiseManager); CombatManager combatManager = new CombatManager(this); - - ProjectileManager throwManager = new ProjectileManager(this); DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, condition); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java index 15d8c24fb..f91e02691 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java @@ -4,6 +4,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.List; +import java.util.UUID; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; @@ -267,7 +268,7 @@ public class ClansTransferManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { SimpleClanToken clanToken = new SimpleClanToken(); @@ -280,11 +281,11 @@ public class ClansTransferManager extends MiniDbClientPlugin clanToken = new SimpleClanToken(clanName, clanRole, homeServer, clanId); } - Set(playerName, clanToken); + Set(uuid, clanToken); } @Override - protected SimpleClanToken addPlayer(String player) + protected SimpleClanToken addPlayer(UUID uuid) { return new SimpleClanToken(); } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 0c598db11..3a584a0bb 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -3,11 +3,13 @@ package mineplex.clanshub; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.UUID; import mineplex.clanshub.commands.ForcefieldRadius; import mineplex.clanshub.commands.GadgetToggle; import mineplex.clanshub.commands.GameModeCommand; import mineplex.clanshub.profile.gui.GUIProfile; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; @@ -29,6 +31,7 @@ import mineplex.core.common.util.UtilTextTop; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.customdata.CustomData; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguiseBase; @@ -189,7 +192,7 @@ public class HubManager extends MiniPlugin _mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager); _inventoryManager = inventoryManager; new BenefitManager(plugin, clientManager, _inventoryManager); - _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager, packetHandler, hologramManager); + _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, Managers.get(ProjectileManager.class), achievementManager, packetHandler, hologramManager); FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); @@ -249,7 +252,7 @@ public class HubManager extends MiniPlugin _playerCountManager = new PlayerCountManager(plugin); - _customDataManager = new CustomDataManager(plugin, clientManager); + _customDataManager = Managers.get(CustomDataManager.class); _punishManager = punish; @@ -330,7 +333,7 @@ public class HubManager extends MiniPlugin @EventHandler(priority = EventPriority.LOW) public void login(final PlayerLoginEvent event) { - CoreClient client = _clientManager.Get(event.getPlayer().getName()); + CoreClient client = _clientManager.Get(event.getPlayer()); // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20) @@ -474,10 +477,7 @@ public class HubManager extends MiniPlugin Player player = event.getPlayer(); String playerName = player.getName(); - Rank rank = GetClients().Get(player).GetRank(); - - if (GetClients().Get(player).isDisguised()) - rank = GetClients().Get(player).getDisguisedRank(); + Rank rank = GetClients().Get(player).getRealOrDisguisedRank(); //Level Prefix String levelStr = _achievementManager.getMineplexLevel(player, rank); @@ -497,9 +497,9 @@ public class HubManager extends MiniPlugin event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s"); - for (String name : party.getMembers()) + for (UUID name : party.getMembers()) { - Player other = UtilPlayer.searchExact(name); + Player other = Bukkit.getPlayer(name); if (other != null) event.getRecipients().add(other); @@ -839,7 +839,7 @@ public class HubManager extends MiniPlugin /** * Checks if a player can portal yet - * @param The player to check + * @param player The player to check * @return Whether a player can portal yet */ public boolean CanPortal(Player player) diff --git a/Plugins/Mineplex.Hub/plugin.yml b/Plugins/Mineplex.Hub/plugin.yml index 9f010adb1..dbe6db4f4 100644 --- a/Plugins/Mineplex.Hub/plugin.yml +++ b/Plugins/Mineplex.Hub/plugin.yml @@ -1,3 +1,4 @@ name: Hub main: mineplex.hub.Hub -version: 0.1 \ No newline at end of file +version: 0.1 +loadbefore: [MineplexAnticheat] \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 6422c454f..90e938e8e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -1,8 +1,11 @@ package mineplex.hub; +import mineplex.core.Managers; +import mineplex.core.antihack.AntiHackGuardian; import mineplex.core.brawl.fountain.FountainManager; import mineplex.core.thank.ThankManager; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -74,6 +77,8 @@ import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; +import static mineplex.core.Managers.require; + public class Hub extends JavaPlugin implements IRelation { private String WEB_CONFIG = "webServer"; @@ -94,7 +99,7 @@ public class Hub extends JavaPlugin implements IRelation new VelocityFix(this); //Static Modules - new ProfileCacheManager(this); + require(ProfileCacheManager.class); CommandCenter.Initialize(this); CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); CommandCenter.Instance.setClientManager(clientManager); @@ -110,8 +115,8 @@ public class Hub extends JavaPlugin implements IRelation ServerConfiguration serverConfiguration = new ServerConfiguration(this, clientManager); //Other Modules - PacketHandler packetHandler = new PacketHandler(this); - DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); + PacketHandler packetHandler = require(PacketHandler.class); + DisguiseManager disguiseManager = require(DisguiseManager.class); IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler); PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager, donationManager); @@ -124,6 +129,8 @@ public class Hub extends JavaPlugin implements IRelation PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress); PollManager pollManager = new PollManager(this, clientManager, donationManager); //new TournamentManager(this, clientManager, donationManager); + + ProjectileManager throwManager = new ProjectileManager(this); //Main Modules ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); @@ -131,7 +138,12 @@ public class Hub extends JavaPlugin implements IRelation Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); - AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); + AntiHack antiHack = require(AntiHack.class); + + for (int i = 0; i < 8; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(new Location(Bukkit.getWorld("world"), 0, 100, 0), 50, -50, 105, 95, 50, -50)); + } IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); @@ -154,7 +166,7 @@ public class Hub extends JavaPlugin implements IRelation HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager); HologramManager hologramManager = new HologramManager(this, packetHandler); - QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); + QueueManager queueManager = new QueueManager(this, clientManager, donationManager, eloManager, partyManager); ServerManager serverManager = new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager, boosterManager); new FountainManager(this, clientManager, donationManager, hologramManager, statsManager, serverManager); @@ -172,7 +184,6 @@ public class Hub extends JavaPlugin implements IRelation CombatManager combatManager = new CombatManager(this); - ProjectileManager throwManager = new ProjectileManager(this); DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, conditionManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubClient.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubClient.java index 4b56eff02..247ba32a9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubClient.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubClient.java @@ -1,134 +1,128 @@ package mineplex.hub; public class HubClient -{ +{ public String ScoreboardString = " Hello, I am a big friendly cat!"; public int ScoreboardIndex = 0; - + public String NewsString = " Bridges v2.0 is coming soon! New gameplay, new kits, new maps!"; public int NewsIndex = 0; - + public String PurchaseString = " Purchase Ultra Rank at mineplex.com to unlock all game benefits!"; public int PurchaseIndex = 0; - + public String UltraString = " Thank you for your support!"; public int UltraIndex = 0; - + public String StaffString = "None"; public int StaffIndex = 0; - + public String BestPig = "0-Nobody"; - + public int DisplayLength = 16; - - private int _lastGemCount = 0; - + public HubClient(String name) { - ScoreboardString = " Welcome " + name + ", to the Mineplex Network!"; + setName(name); } - public void SetLastGemCount(int gems) + public void setName(String name) { - _lastGemCount = gems; + ScoreboardString = " Welcome " + name + ", to the Mineplex Network!"; + ScoreboardIndex = 0; } - - public int GetLastGemCount() - { - return _lastGemCount; - } - - public String GetScoreboardText() + + public String GetScoreboardText() { if (ScoreboardString.length() <= DisplayLength) return ScoreboardString; - - String display = ScoreboardString.substring(ScoreboardIndex, Math.min(ScoreboardIndex+DisplayLength, ScoreboardString.length())); - + + String display = ScoreboardString.substring(ScoreboardIndex, Math.min(ScoreboardIndex + DisplayLength, ScoreboardString.length())); + if (display.length() < DisplayLength && ScoreboardString.length() > DisplayLength) { int add = DisplayLength - display.length(); display += ScoreboardString.substring(0, add); } - + ScoreboardIndex = (ScoreboardIndex + 1) % ScoreboardString.length(); - + return display; } - - public String GetPurchaseText(boolean increment) + + public String GetPurchaseText(boolean increment) { if (PurchaseString.length() <= DisplayLength) return PurchaseString; - + if (increment) PurchaseIndex = (PurchaseIndex + 1) % PurchaseString.length(); - - String display = PurchaseString.substring(PurchaseIndex, Math.min(PurchaseIndex+DisplayLength, PurchaseString.length())); - + + String display = PurchaseString.substring(PurchaseIndex, Math.min(PurchaseIndex + DisplayLength, PurchaseString.length())); + if (display.length() < DisplayLength && PurchaseString.length() > DisplayLength) { int add = DisplayLength - display.length(); display += PurchaseString.substring(0, add); } - + return display; } - public String GetUltraText(boolean increment) + public String GetUltraText(boolean increment) { if (UltraString.length() <= DisplayLength) return UltraString; - + if (increment) UltraIndex = (UltraIndex + 1) % UltraString.length(); - - String display = UltraString.substring(UltraIndex, Math.min(UltraIndex+DisplayLength, UltraString.length())); - + + String display = UltraString.substring(UltraIndex, Math.min(UltraIndex + DisplayLength, UltraString.length())); + if (display.length() < DisplayLength) { int add = DisplayLength - display.length(); display += UltraString.substring(0, add); } - + return display; } - - public String GetStaffText(boolean increment) + + public String GetStaffText(boolean increment) { if (StaffString.length() <= DisplayLength) return StaffString; - + if (increment) StaffIndex = (StaffIndex + 1) % StaffString.length(); - - String display = StaffString.substring(StaffIndex, Math.min(StaffIndex+DisplayLength, StaffString.length())); - + + String display = StaffString.substring(StaffIndex, Math.min(StaffIndex + DisplayLength, StaffString.length())); + if (display.length() < DisplayLength && StaffString.length() > DisplayLength) { int add = DisplayLength - display.length(); display += StaffString.substring(0, add); } - + return display; } - - public String GetNewsText(boolean increment) + + public String GetNewsText(boolean increment) { if (NewsString.length() <= DisplayLength) return NewsString; - + if (increment) NewsIndex = (NewsIndex + 1) % NewsString.length(); - - String display = NewsString.substring(NewsIndex, Math.min(NewsIndex+DisplayLength, NewsString.length())); - + + String display = NewsString.substring(NewsIndex, Math.min(NewsIndex + DisplayLength, NewsString.length())); + if (display.length() < DisplayLength && NewsString.length() > DisplayLength) { int add = DisplayLength - display.length(); display += NewsString.substring(0, add); } - + return display; } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index e90a2c28e..90841c638 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -1,5 +1,6 @@ package mineplex.hub; +import mineplex.core.Managers; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; @@ -12,13 +13,22 @@ import mineplex.core.boosters.BoosterManager; import mineplex.core.botspam.BotSpamManager; import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.PlayerDisguiseManager; +import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager; import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.donation.DonationManager; +import mineplex.core.donation.Donor; import mineplex.core.facebook.FacebookManager; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.GadgetCollideEntityEvent; @@ -48,6 +58,8 @@ import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; +import mineplex.core.scoreboard.MineplexScoreboard; +import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; @@ -57,8 +69,20 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.valentines.ValentinesGiftManager; import mineplex.core.youtube.YoutubeManager; -import mineplex.hub.commands.*; -import mineplex.hub.modules.*; +import mineplex.hub.commands.ForcefieldRadius; +import mineplex.hub.commands.GadgetToggle; +import mineplex.hub.commands.GameModeCommand; +import mineplex.hub.commands.NewsCommand; +import mineplex.hub.modules.ForcefieldManager; +import mineplex.hub.modules.HubVisibilityManager; +import mineplex.hub.modules.JumpManager; +import mineplex.hub.modules.KothManager; +import mineplex.hub.modules.NewsManager; +import mineplex.hub.modules.ParkourManager; +import mineplex.hub.modules.SoccerManager; +import mineplex.hub.modules.TextManager; +import mineplex.hub.modules.ValentinesManager; +import mineplex.hub.modules.WorldManager; import mineplex.hub.modules.nonpremium.NonPremiumManager; import mineplex.hub.profile.gui.GUIProfile; import mineplex.hub.tutorial.TutorialManager; @@ -73,7 +97,11 @@ import net.md_5.bungee.api.chat.HoverEvent.Action; import net.md_5.bungee.api.chat.TextComponent; import net.minecraft.server.v1_8_R3.EntityInsentient; import net.minecraft.server.v1_8_R3.EntityPlayer; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; @@ -87,13 +115,17 @@ import org.bukkit.event.entity.EntityTargetEvent.TargetReason; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.*; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Scoreboard; import java.io.DataInputStream; import java.io.File; @@ -103,7 +135,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Random; -import java.util.stream.Collectors; +import java.util.UUID; public class HubManager extends MiniClientPlugin { @@ -145,12 +177,8 @@ public class HubManager extends MiniClientPlugin // private TrickOrTreatManager _trickOrTreatManager; private Location _spawn; - private int _scoreboardTick = 0; - private HashMap _scoreboards = new HashMap(); - - private String _serverName = ""; - private int _lastPlayerCount = 0; + private final String _serverName; private boolean _shuttingDown; private HashMap _portalTime = new HashMap(); @@ -160,15 +188,18 @@ public class HubManager extends MiniClientPlugin // Christmas Songs private Random _random = new Random(); private int _lastSong = 0; -// private final String[] _songNames = {"JingleBells.nbs", "TheFirstNoel.nbs", "Hark.nbs", "DeckTheHalls.nbs", "Joy.nbs", "MerryChristmas.nbs"}; + // private final String[] _songNames = {"JingleBells.nbs", "TheFirstNoel.nbs", "Hark.nbs", "DeckTheHalls.nbs", "Joy.nbs", "MerryChristmas.nbs"}; private final ArrayList _songs; public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager) { super("Hub Manager", plugin); + String serverName = getPlugin().getConfig().getString("serverstatus.name"); + _serverName = serverName.substring(0, Math.min(16, serverName.length())); + _incognito = incognito; - + _blockRestore = blockRestore; _clientManager = clientManager; _conditionManager = conditionManager; @@ -196,14 +227,14 @@ public class HubManager extends MiniClientPlugin _mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager); _inventoryManager = inventoryManager; new BenefitManager(plugin, clientManager, _inventoryManager); - _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager, packetHandler, hologramManager); + _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, Managers.get(ProjectileManager.class), achievementManager, packetHandler, hologramManager); FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager); _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager()); - new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); + CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); new SoccerManager(this, _gadgetManager); @@ -228,24 +259,24 @@ public class HubManager extends MiniClientPlugin new NotificationManager(getPlugin(), clientManager, _preferences); new BotSpamManager(plugin, clientManager, punish); - ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; + ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; // _halloweenManager = new HalloweenSpookinessManager(this); // new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); - new PlayerDisguiseManager(plugin, _clientManager); + require(PlayerDisguiseManager.class); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _gadgetManager, statsManager); _playerCountManager = new PlayerCountManager(plugin); - _customDataManager = new CustomDataManager(plugin, clientManager); - + _customDataManager = Managers.get(CustomDataManager.class); + _songs = new ArrayList(); - + _punishManager = punish; - + _valentinesManager = new ValentinesManager(plugin, clientManager, donationManager); new NonPremiumManager(plugin, clientManager); @@ -280,8 +311,121 @@ public class HubManager extends MiniClientPlugin playNextSong(); - _serverName = getPlugin().getConfig().getString("serverstatus.name"); - _serverName = _serverName.substring(0, Math.min(16, _serverName.length())); + ScoreboardManager scoreboardManager = new ScoreboardManager(plugin) + { + @Override + public void setup(MineplexScoreboard scoreboard) + { + for (Rank rank : Rank.values()) + { + if (rank == Rank.ALL) + scoreboard.getHandle().registerNewTeam(rank.Name).setPrefix(""); + else + scoreboard.getHandle().registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); + } + + scoreboard.register(HubScoreboardLine.SERVER_TITLE) + .register(HubScoreboardLine.SERVER_NAME) + .register(HubScoreboardLine.SERVER_EMPTY_SPACER) + .register(HubScoreboardLine.GEM_TITLE) + .register(HubScoreboardLine.GEM_COUNT) + .register(HubScoreboardLine.GEM_EMPTY_SPACER) + .register(HubScoreboardLine.PLAYER_TITLE) + .register(HubScoreboardLine.PLAYER_COUNT) + .register(HubScoreboardLine.PLAYER_EMPTY_SPACER) + .register(HubScoreboardLine.RANK_TITLE) + .register(HubScoreboardLine.RANK_NAME) + .register(HubScoreboardLine.RANK_EMPTY_SPACER) + .register(HubScoreboardLine.WEBSITE_TITLE) + .register(HubScoreboardLine.WEBSITE_VALUE) + .register(HubScoreboardLine.END_BREAKER) + .recalculate(); + + scoreboard.get(HubScoreboardLine.SERVER_TITLE).write(C.cAqua + C.Bold + "Server"); + scoreboard.get(HubScoreboardLine.SERVER_NAME).write(_serverName); + scoreboard.get(HubScoreboardLine.GEM_TITLE).write(C.cGreen + C.Bold + "Gems"); + scoreboard.get(HubScoreboardLine.PLAYER_TITLE).write(C.cYellow + C.Bold + "Players"); + scoreboard.get(HubScoreboardLine.RANK_TITLE).write(C.cGold + C.Bold + "Rank"); + scoreboard.get(HubScoreboardLine.WEBSITE_TITLE).write(C.cRed + C.Bold + "Website"); + scoreboard.get(HubScoreboardLine.WEBSITE_VALUE).write("www.mineplex.com"); + scoreboard.get(HubScoreboardLine.END_BREAKER).write("----------------"); + } + + @Override + public void draw(MineplexScoreboard scoreboard) + { + scoreboard.setSidebarName(C.cWhite + C.Bold + Get(scoreboard.getOwner()).GetScoreboardText()); + scoreboard.get(HubScoreboardLine.GEM_COUNT).write(GetDonation().Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM)); + scoreboard.get(HubScoreboardLine.PLAYER_COUNT).write(_playerCountManager.getPlayerCount()); + + String rankName = getRankName(GetClients().Get(scoreboard.getOwner()).GetRank(), GetDonation().Get(scoreboard.getOwner())); + + Rank disguisedRank = GetClients().Get(scoreboard.getOwner()).getDisguisedRank(); + String disguisedAs = GetClients().Get(scoreboard.getOwner()).getDisguisedAs(); + if (disguisedRank != null && disguisedAs != null) + { + rankName = getRankName(disguisedRank, GetDonation().Get(GetClients().Get(scoreboard.getOwner()).getDisguisedAsUUID())) + " (" + rankName + ")"; + } + + scoreboard.get(HubScoreboardLine.RANK_NAME).write(rankName); + } + + @Override + public void handlePlayerJoin(String playerName) + { + Player player = Bukkit.getPlayerExact(playerName); + + HubClient hubclient = HubManager.this.Get(player); + hubclient.setName(playerName); + + CoreClient client = GetClients().Get(player.getUniqueId()); + + for (MineplexScoreboard scoreboard : getScoreboards().values()) + { + scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().Name).addEntry(playerName); + } + + if (get(player) != null) + { + for (Player player1 : Bukkit.getOnlinePlayers()) + { + client = GetClients().Get(player1); + get(player).getHandle().getTeam(client.getRealOrDisguisedRank().Name).addEntry(player1.getName()); + } + } + } + + @Override + public void handlePlayerQuit(String playerName) + { + Player player = Bukkit.getPlayerExact(playerName); + + CoreClient client = GetClients().Get(player); + + for (MineplexScoreboard scoreboard : getScoreboards().values()) + { + scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().Name).removeEntry(playerName); + } + } + + private String getRankName(Rank rank, Donor donor) + { + String rankName; + if (rank.has(Rank.ULTRA)) + rankName = rank.Name; + else if (donor.OwnsUnknownPackage("SuperSmashMobs ULTRA") || + donor.OwnsUnknownPackage("Survival Games ULTRA") || + donor.OwnsUnknownPackage("Minigames ULTRA") || + donor.OwnsUnknownPackage("CastleSiege ULTRA") || + donor.OwnsUnknownPackage("Champions ULTRA")) + rankName = "Single Ultra"; + else + rankName = "No Rank"; + return rankName; + } + }; + + Managers.put(scoreboardManager, ScoreboardManager.class); } private void playNextSong() @@ -321,7 +465,6 @@ public class HubManager extends MiniClientPlugin addCommand(new GadgetToggle(this)); addCommand(new NewsCommand(this)); addCommand(new GameModeCommand(this)); - addCommand(new DisguiseCommand(this)); } @EventHandler(priority = EventPriority.HIGHEST) @@ -340,7 +483,7 @@ public class HubManager extends MiniClientPlugin if (ent instanceof Player) { - return !_preferences.Get((Player)ent).HubGames; + return !_preferences.Get((Player) ent).HubGames; } return true; @@ -389,13 +532,13 @@ public class HubManager extends MiniClientPlugin { if (entity instanceof LivingEntity) { - if (((LivingEntity)entity).isCustomNameVisible() && ((LivingEntity)entity).getCustomName() != null) + if (((LivingEntity) entity).isCustomNameVisible() && ((LivingEntity) entity).getCustomName() != null) { - if (ChatColor.stripColor(((LivingEntity)entity).getCustomName()).equalsIgnoreCase("Block Hunt")) + if (ChatColor.stripColor(((LivingEntity) entity).getCustomName()).equalsIgnoreCase("Block Hunt")) { DisguiseSlime disguise = new DisguiseSlime(entity); disguise.setCustomNameVisible(true); - disguise.setName(((LivingEntity)entity).getCustomName(), null); + disguise.setName(((LivingEntity) entity).getCustomName(), null); disguise.SetSize(2); _disguiseManager.disguise(disguise); } @@ -407,9 +550,9 @@ public class HubManager extends MiniClientPlugin @EventHandler(priority = EventPriority.LOW) public void login(final PlayerLoginEvent event) { - CoreClient client = _clientManager.Get(event.getPlayer().getName()); + CoreClient client = _clientManager.Get(event.getPlayer().getUniqueId()); - // Reserved Slot Check + // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20) { if (!client.GetRank().has(Rank.ULTRA)) @@ -434,13 +577,13 @@ public class HubManager extends MiniClientPlugin { // Give developers operator on their servers boolean testServer = _plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"); - + Rank minimum = Rank.OWNER; if (testServer) { minimum = Rank.JNR_DEV; } - + if (_clientManager.Get(event.getPlayer()).GetRank().has(minimum)) event.getPlayer().setOp(true); else @@ -488,38 +631,6 @@ public class HubManager extends MiniClientPlugin //Health player.setHealth(20); - //Scoreboard - Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); - player.setScoreboard(board); - _scoreboards.put(player, board); - - //Objective - Objective obj = board.registerNewObjective(C.Bold + "Player Data", "dummy"); - obj.setDisplaySlot(DisplaySlot.SIDEBAR); - - for (Rank rank : Rank.values()) - { - if (rank != Rank.ALL) - board.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); - else - board.registerNewTeam(rank.Name).setPrefix(""); - } - - for (Player otherPlayer : Bukkit.getOnlinePlayers()) - { - if (_clientManager.Get(otherPlayer) == null) - continue; - - String rankName = _clientManager.Get(player).GetRank().Name; - String otherRankName = _clientManager.Get(otherPlayer).GetRank().Name; - - //Add Other to Self - board.getTeam(otherRankName).addPlayer(otherPlayer); - - //Add Self to Other - otherPlayer.getScoreboard().getTeam(rankName).addPlayer(player); - } - //only give it in the hub player.getInventory().setItem(PartyManager.INTERFACE_SLOT, PartyManager.INTERFACE_ITEM); } @@ -532,11 +643,6 @@ public class HubManager extends MiniClientPlugin event.getPlayer().leaveVehicle(); event.getPlayer().eject(); - for (Player player : UtilServer.getPlayers()) - player.getScoreboard().resetScores(event.getPlayer().getName()); - - _scoreboards.remove(event.getPlayer()); - _portalTime.remove(event.getPlayer().getName()); } @@ -550,7 +656,7 @@ public class HubManager extends MiniClientPlugin event.setCancelled(true); } } - + @EventHandler public void Incog(IncognitoHidePlayerEvent event) { @@ -581,17 +687,14 @@ public class HubManager extends MiniClientPlugin if (AprilFoolsManager.Instance.isActive()) playerName = AprilFoolsManager.Instance.getName(player); - Rank rank = GetClients().Get(player).GetRank(); - - if(GetClients().Get(player).isDisguised()) - rank = GetClients().Get(player).getDisguisedRank(); + Rank rank = GetClients().Get(player).getRealOrDisguisedRank(); //Level Prefix String levelStr = _achievementManager.getMineplexLevel(player, rank); //Rank Prefix String rankStr = ""; - if (rank != Rank.ALL) + if (rank != Rank.ALL) rankStr = rank.getTag(true, true) + " "; //Party Chat if (event.getMessage().charAt(0) == '@') @@ -603,7 +706,14 @@ public class HubManager extends MiniClientPlugin event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s"); - event.getRecipients().addAll(party.getMembersByUUID().stream().map(Bukkit::getPlayer).collect(Collectors.toList())); + + for (UUID uuid: party.getMembers()) + { + Player other = Bukkit.getPlayer(uuid); + + if (other != null) + event.getRecipients().add(other); + } } else { @@ -690,100 +800,14 @@ public class HubManager extends MiniClientPlugin @EventHandler public void InventoryCancel(InventoryClickEvent event) { - if (event.getWhoClicked() instanceof Player && ((Player)event.getWhoClicked()).getGameMode() != GameMode.CREATIVE) + if (event.getWhoClicked() instanceof Player && ((Player) event.getWhoClicked()).getGameMode() != GameMode.CREATIVE) event.setCancelled(true); } - @EventHandler - public void UpdateScoreboard(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - _scoreboardTick = (_scoreboardTick + 1)%3; - - if (_scoreboardTick != 0) - return; - - int playerCount = _playerCountManager.getPlayerCount(); - - for (Player player : UtilServer.getPlayers()) - { - - //Return to Main Scoreboard - if (!player.getScoreboard().equals(_scoreboards.get(player))) - player.setScoreboard(_scoreboards.get(player)); - - //Objective - Objective obj = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR); - - //Title - obj.setDisplayName(C.cWhite + C.Bold + Get(player).GetScoreboardText()); - - int line = 15; - - //Stacker - obj.getScore(C.cAqua + C.Bold + "Server").setScore(line--); - obj.getScore(_serverName).setScore(line--); - - //Space - obj.getScore(" ").setScore(line--); - - //Gems - obj.getScore(C.cGreen + C.Bold + "Gems").setScore(line--); - // Remove Old/Add New - player.getScoreboard().resetScores(Get(player.getName()).GetLastGemCount() + ""); - obj.getScore(GetDonation().Get(player.getName()).getBalance(GlobalCurrency.GEM) + "").setScore(line--); - Get(player.getName()).SetLastGemCount(GetDonation().Get(player.getName()).getBalance(GlobalCurrency.GEM)); - - //Space - obj.getScore(" ").setScore(line--); - - //Players - obj.getScore(C.cYellow + C.Bold + "Players").setScore(line--); - player.getScoreboard().resetScores(_lastPlayerCount + ""); - obj.getScore(playerCount + "").setScore(line--); - - - //Space - obj.getScore(" ").setScore(line--); - - - //Display Rank - obj.getScore(C.cGold + C.Bold + "Rank").setScore(line--); - //Remove Old - player.getScoreboard().resetScores(_clientManager.Get(player).GetLastRank(false).Name); - player.getScoreboard().resetScores(_clientManager.Get(player).GetLastRank(true).Name); - player.getScoreboard().resetScores("No Rank"); - //Add New - if (GetClients().Get(player).GetRank().has(Rank.ULTRA)) - obj.getScore(GetClients().Get(player).GetRank().Name).setScore(line--); - else if (GetDonation().Get(player.getName()).OwnsUnknownPackage("SuperSmashMobs ULTRA") || - GetDonation().Get(player.getName()).OwnsUnknownPackage("Survival Games ULTRA") || - GetDonation().Get(player.getName()).OwnsUnknownPackage("Minigames ULTRA") || - GetDonation().Get(player.getName()).OwnsUnknownPackage("CastleSiege ULTRA") || - GetDonation().Get(player.getName()).OwnsUnknownPackage("Champions ULTRA")) - obj.getScore("Single Ultra").setScore(line--); - else - obj.getScore("No Rank").setScore(line--); - - - //Space - obj.getScore(" ").setScore(line--); - - //Website - obj.getScore(C.cRed + C.Bold + "Website").setScore(line--); - obj.getScore("www.mineplex.com").setScore(line--); - obj.getScore("----------------").setScore(line--); - } - - _lastPlayerCount = playerCount; - } - @Override - protected HubClient addPlayer(String player) + protected HubClient addPlayer(UUID uuid) { - return new HubClient(player); + return new HubClient(Bukkit.getPlayer(uuid).getName()); } public BlockRestore GetBlockRestore() @@ -843,9 +867,9 @@ public class HubManager extends MiniClientPlugin public PetManager getPetManager() { - return _petManager; + return _petManager; } - + public BonusManager getBonusManager() { return _bonusManager; @@ -870,7 +894,7 @@ public class HubManager extends MiniClientPlugin { return _customDataManager; } - + public Punish getPunishments() { return _punishManager; @@ -880,7 +904,7 @@ public class HubManager extends MiniClientPlugin // { // return _halloweenManager; // } - + @EventHandler(priority = EventPriority.MONITOR) public void gadgetCollide(GadgetCollideEntityEvent event) { @@ -891,7 +915,7 @@ public class HubManager extends MiniClientPlugin public void SetPortalDelay(Entity ent) { if (ent instanceof Player) - _portalTime.put(((Player)ent).getName(), System.currentTimeMillis()); + _portalTime.put(((Player) ent).getName(), System.currentTimeMillis()); } public boolean CanPortal(Player player) @@ -915,7 +939,7 @@ public class HubManager extends MiniClientPlugin if (BumpDisabled(ent)) return false; - if (!getPreferences().Get((Player)ent).ShowPlayers) + if (!getPreferences().Get((Player) ent).ShowPlayers) return false; return true; @@ -985,17 +1009,17 @@ public class HubManager extends MiniClientPlugin { if (entity instanceof EntityInsentient) { - EntityInsentient entityMonster = (EntityInsentient)entity; - + EntityInsentient entityMonster = (EntityInsentient) entity; + if (entityMonster.getGoalTarget() != null && entityMonster.getGoalTarget() instanceof EntityPlayer) { - if (((EntityPlayer)entityMonster.getGoalTarget()).playerConnection.isDisconnected()) + if (((EntityPlayer) entityMonster.getGoalTarget()).playerConnection.isDisconnected()) entityMonster.setGoalTarget(null, TargetReason.FORGOT_TARGET, false); } } } } - + @EventHandler public void clearGameMode(PlayerQuitEvent event) { @@ -1018,16 +1042,17 @@ public class HubManager extends MiniClientPlugin public PacketHandler getPacketHandler() { - return _packetHandler; + return _packetHandler; } @EventHandler public void openProfile(PlayerInteractEvent event) { - if(event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM) + if (event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM) return; - new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager, _personalServerManager).openInventory();; + new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager, _personalServerManager).openInventory(); + ; } @EventHandler @@ -1045,17 +1070,17 @@ public class HubManager extends MiniClientPlugin { playNextSong(); } - + @EventHandler public void trackPortalDelayPlayers(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - - for (Iterator playerNameIterator = _portalTime.keySet().iterator(); playerNameIterator.hasNext();) + + for (Iterator playerNameIterator = _portalTime.keySet().iterator(); playerNameIterator.hasNext(); ) { String playerName = playerNameIterator.next(); - + if (UtilTime.elapsed(_portalTime.get(playerName), 5000)) { playerNameIterator.remove(); @@ -1067,7 +1092,7 @@ public class HubManager extends MiniClientPlugin { return _incognito; } - + public JumpManager getJumpManager() { return _jumpManager; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubScoreboardLine.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubScoreboardLine.java new file mode 100644 index 000000000..4071a1db0 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubScoreboardLine.java @@ -0,0 +1,22 @@ +package mineplex.hub; + +import mineplex.core.scoreboard.ScoreboardLine; + +public enum HubScoreboardLine implements ScoreboardLine +{ + SERVER_TITLE, + SERVER_NAME, + SERVER_EMPTY_SPACER, + GEM_TITLE, + GEM_COUNT, + GEM_EMPTY_SPACER, + PLAYER_TITLE, + PLAYER_COUNT, + PLAYER_EMPTY_SPACER, + RANK_TITLE, + RANK_NAME, + RANK_EMPTY_SPACER, + WEBSITE_TITLE, + WEBSITE_VALUE, + END_BREAKER; +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java deleted file mode 100644 index bc34a9e79..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ /dev/null @@ -1,481 +0,0 @@ -package mineplex.hub.commands; - -import java.lang.reflect.Field; -import java.util.UUID; - -import mineplex.core.account.CoreClient; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.ProfileLoader; -import mineplex.core.common.util.UUIDFetcher; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.disguise.PlayerUndisguiseEvent; -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.types.GadgetType; -import mineplex.core.punish.PunishClient; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.HubManager; -import net.minecraft.server.v1_8_R3.ChatComponentText; -import net.minecraft.server.v1_8_R3.EntityHuman; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.IChatBaseComponent; -import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData; -import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerLoginEvent.Result; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.scoreboard.Team; - -import com.mojang.authlib.GameProfile; - -public class DisguiseCommand extends CommandBase implements Listener -{ - - private NautHashMap _disguisedPlayers = new NautHashMap<>(); - private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); - private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); - - public DisguiseCommand(HubManager plugin) - { - super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, "disguise"); - - plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); - } - - @Override - public void Execute(final Player caller, final String[] args) - { - if(args == null || args.length == 0) - { - if(!Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); - return; - } - try - { - GameProfile profile = _disguisedPlayers.get(caller); - _disguisedPlayers.remove(caller); - _disguisedPlayerDisguises.remove(caller); - Plugin.GetDisguise().undisguise(caller); - String playerName = _disguisedPlayersNames.get(caller); - Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller)); - - CoreClient client = Plugin.GetClients().Get(caller); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(caller, playerName, true); - - for(Player other : UtilServer.getPlayers()) - updateTabInfo(((CraftPlayer) caller).getProfile(), profile, other, false); - - Field field; - try - { - field = GameProfile.class.getDeclaredField("id"); - field.setAccessible(true); - UUID old = ((CraftPlayer) caller).getProfile().getId(); - UUID newUUID = profile.getId(); - field.set(profile, old); - field.set(((CraftPlayer) caller).getProfile(), newUUID); - } - catch(Exception e) - { - e.printStackTrace(); - } - - // removed "due to Kicked for Flying" - //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); - //UtilPlayer.sendPacket(caller, packet); - - for(Player other : UtilServer.getPlayers()) - { - for(Team team : other.getScoreboard().getTeams()) - { - team.removePlayer(caller); - } - other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); - } - - UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); - return; - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - if(args != null && args.length > 1) - { - UtilPlayer.message(caller, F.main("Disguise", "/disguise ")); - return; - } - - Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() - { - @Override - public void run() - { - if(Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); - return; - } - for(Player other : UtilServer.getPlayers()) - { - if(other.getName().equalsIgnoreCase(args[0])) - { - UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); - return; - } - } - if(_disguisedPlayersNames.containsValue(args[0])) - { - UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); - return; - } - if(args[0].length() > 16) - { - UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); - return; - } - - try - { - CoreClient client = Plugin.GetClients().Get(caller); - UUID uuid = UUID.randomUUID(); - GameProfile profile = null; - try - { - uuid = UUIDFetcher.getUUIDOf(args[0]); - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } catch (Exception e) - { - uuid = UUID.randomUUID(); - profile = new ProfileLoader(null, args[0]).loadProfile(); - } - - Rank otherRank = Rank.ALL; - CoreClient other = null; - try - { - other = new CoreClient(args[0]); - Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); - otherRank = other.GetRank(); - } catch(NullPointerException exception) - { - other = null; - } - if(otherRank.has(Rank.TWITCH)) - { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, Youtubers or Twitchers!")); - return; - } - if(other != null) - { - PunishClient pclient = Plugin.getPunishments().GetClient(args[0]); - if(pclient.IsBanned() || pclient.IsMuted()) - { - UtilPlayer.message(caller, F.main("Disguise", "Unable to disguise as this Player!")); - return; - } - } - _disguisedPlayers.put(caller, profile); - _disguisedPlayersNames.put(caller, caller.getName()); - client.setDisguisedRank(otherRank); - client.setDisguised(true); - - client.setDisguisedAs(args[0]); - - changeName(caller, args[0], true); - - Plugin.GetGadget().removeGadgetType(caller, GadgetType.ITEM); - - // Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); - UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0])); - - Field field; - try - { - field = GameProfile.class.getDeclaredField("id"); - field.setAccessible(true); - UUID old = ((CraftPlayer) caller).getProfile().getId(); - UUID newUUID = profile.getId(); - field.set(profile, old); - field.set(((CraftPlayer) caller).getProfile(), newUUID); - } - catch(Exception e) - { - e.printStackTrace(); - } - - // removed "due to Kicked for Flying" - //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); - //UtilPlayer.sendPacket(caller, packet); - - tablistRefresh(caller); - } catch(Exception e) - { - e.printStackTrace(); - UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); - return; - } - } - }); - } - - @EventHandler - public void refreshTabNames(UpdateEvent event) - { - if(event.getType() != UpdateType.FAST) - return; - - for(Player player : _disguisedPlayers.keySet()) - { - if(!player.isOnline()) - return; - - tablistRefresh(player); - } - } - - public void tablistRefresh(Player player) - { - for (Player other : UtilServer.getPlayers()) - { - if (player.canSee(other)) - { - updateTabInfo(_disguisedPlayers.get(player), ((CraftPlayer) player).getProfile(), other, false); - } - } - } - - public void updateTabInfo(GameProfile profileToAdd, GameProfile profileToRemove, Player target, boolean refreshOnly) - { - ChatColor team = ChatColor.WHITE; - Player player = Bukkit.getPlayer(profileToAdd.getName()); - EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - String tag = Plugin.GetClients().Get(player).GetRank().getTag(true, true) + " "; - if(Plugin.GetClients().Get(player).isDisguised()) - { - tag = Plugin.GetClients().Get(player).getDisguisedRank().getTag(true, true) + " "; - } - - IChatBaseComponent component = new ChatComponentText(tag + team + player.getName()); - - if(!refreshOnly) - { - PacketPlayOutPlayerInfo removePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); - PlayerInfoData removeData = removePacket.new PlayerInfoData(profileToRemove, entityPlayer.ping, EnumGamemode.SURVIVAL, component); - removePacket.b.add(removeData); - UtilPlayer.sendPacket(target, removePacket); - - PacketPlayOutPlayerInfo addPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); - PlayerInfoData addData = addPacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); - addPacket.b.add(addData); - UtilPlayer.sendPacket(target, addPacket); - } - - PacketPlayOutPlayerInfo updatePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME); - PlayerInfoData updateData = updatePacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); - updatePacket.b.add(updateData); - UtilPlayer.sendPacket(target, updatePacket); - } - - @EventHandler - public void updateDisguises(UpdateEvent event) - { - if(event.getType() != UpdateType.FASTEST) - return; - - for(final Player player : UtilServer.getPlayers()) - { - if(!_disguisedPlayers.containsKey(player)) - continue; - - for(Player other : UtilServer.getPlayers()) - { - try - { - if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player)) - { - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player); - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); - } - } catch(NullPointerException exp) - {} - } - - if(Plugin.GetDisguise().isDisguised(player)) - continue; - - DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); - _disguisedPlayerDisguises.put(player, playerDisguise); - Plugin.GetDisguise().disguise(playerDisguise); - } - } - - public void changeName(final Player player, String changedName, boolean skin) - { - try - { - GameProfile gameProfile = ((CraftPlayer) player).getProfile(); - - Field name = GameProfile.class.getDeclaredField("name"); - name.setAccessible(true); - name.set(gameProfile, changedName); - name.setAccessible(false); - - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Quit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - try - { - _disguisedPlayers.remove(player); - _disguisedPlayerDisguises.remove(player); - Plugin.GetDisguise().undisguise(player); - String playerName = _disguisedPlayersNames.get(player); - _disguisedPlayersNames.remove(player); - - CoreClient client = Plugin.GetClients().Get(player); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(player, playerName, true); - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Join(PlayerLoginEvent event) - { - for(Player player : _disguisedPlayers.keySet()) - { - if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) - { - event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); - } - } - } - - @EventHandler - public void gadget(GadgetEnableEvent event) - { - if(!event.getGadget().getName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.MORPH) - return; - - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler - public void chest(TreasureStartEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerSneak(PlayerToggleSneakEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - DisguisePlayer dp = _disguisedPlayerDisguises.get(player); - - dp.setSneaking(!dp.getSneaking()); - } - } - - @EventHandler - public void onPlayerLeftClick(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(player)) - { - EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); - human.world.broadcastEntityEffect(human, (byte) 0); - } - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onDPlayerChat(AsyncPlayerChatEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setFormat(" *" + event.getMessage()); - } - } - - @EventHandler - public void on(PlayerInteractEvent event) - { - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - - Player player = event.getPlayer(); - - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = player.getEntityId(); - - for(Player p : Bukkit.getOnlinePlayers()) - { - if(p != player) - { - Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); - } - } - } - } - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailManager.java index a31b07381..fc29c38e8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailManager.java @@ -1,6 +1,7 @@ package mineplex.hub.mail; import java.util.List; +import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -27,7 +28,7 @@ public class MailManager extends MiniClientPlugin implements Not } @Override - protected PlayerMailData addPlayer(String player) + protected PlayerMailData addPlayer(UUID uuid) { return new PlayerMailData(); } @@ -40,7 +41,7 @@ public class MailManager extends MiniClientPlugin implements Not @Override public void run() { - Set(event.getPlayer().getName(), _repository.loadMailData(event.getPlayer().getUniqueId())); + Set(event.getPlayer(), _repository.loadMailData(event.getPlayer().getUniqueId())); } }); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubScoreboardManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubScoreboardManager.java deleted file mode 100644 index 9e5a6be02..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubScoreboardManager.java +++ /dev/null @@ -1,74 +0,0 @@ -package mineplex.hub.modules; - -import org.bukkit.event.EventHandler; - -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.donation.DonationManager; -import mineplex.core.scoreboard.ScoreboardData; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.HubManager; - -public class HubScoreboardManager extends MiniPlugin -{ - private ScoreboardManager _scoreboardManager; - private String _serverName; - - public HubScoreboardManager(HubManager manager, CoreClientManager clientManager, DonationManager donationManager) - { - super("Hub Scoreboard Manager", manager.getPlugin()); - - _scoreboardManager = new ScoreboardManager(manager.getPlugin(), clientManager, donationManager, manager.getIncognitoManager()); - - init(); - } - - private String getServerName() - { - if (_serverName == null) - _serverName = getPlugin().getConfig().getString("serverstatus.name"); - - return _serverName; - } - - private void init() - { - ScoreboardData data = _scoreboardManager.getData("default", true); - - data.writeEmpty(); - - //Server - data.write(C.cAqua + C.Bold + "Server"); - data.write(getServerName()); - data.writeEmpty(); - - //Gems - data.write(C.cGreen + C.Bold + "Gems"); - data.writePlayerGems(); - data.writeEmpty(); - - //Coins - data.write(C.cYellow + C.Bold + "Coins"); - data.writePlayerCoins(); - data.writeEmpty(); - - //Rank - data.write(C.cGold + C.Bold + "Rank"); - data.writePlayerRank(); - data.writeEmpty(); - - //Website - data.write(C.cRed + C.Bold + "Website"); - data.write("www.mineplex.com"); - } - - @EventHandler - public void drawUpdate(UpdateEvent event) - { - if (event.getType() == UpdateType.FAST) - _scoreboardManager.draw(); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index 4ff70bf32..142e07954 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -2,6 +2,7 @@ package mineplex.hub.modules; import java.util.HashSet; +import mineplex.core.Managers; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; @@ -56,7 +57,7 @@ public class StackerManager extends MiniPlugin implements IThrown Manager = manager; - _projectileManager = new ProjectileManager(manager.getPlugin()); + _projectileManager = Managers.get(ProjectileManager.class); } @EventHandler diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/queue/ui/QueuePage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/queue/ui/QueuePage.java index 7a44aee11..48efd5a9d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/queue/ui/QueuePage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/queue/ui/QueuePage.java @@ -138,7 +138,7 @@ public class QueuePage extends ShopPageBase } if(party.getOwner().equalsIgnoreCase(player.getName())) { - List players = party.getMembers().stream().map(Bukkit::getPlayerExact).collect(Collectors.toList()); + List players = party.getMembers().stream().map(Bukkit::getPlayer).collect(Collectors.toList()); getPlugin().queuePlayer(gameType, players.toArray(new Player[players.size()])); } buildPage(); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index dfd80ec8d..c85d9e402 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -8,6 +8,7 @@ import java.util.Iterator; import java.util.List; import java.util.Random; import java.util.Set; +import java.util.UUID; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; @@ -747,7 +748,7 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider { int slots = 0; - if (!_clientManager.Get(player).GetRank().has(Rank.ULTRA) && !_donationManager.Get(player.getName()).OwnsUnknownPackage(serverType + " ULTRA")) + if (!_clientManager.Get(player).GetRank().has(Rank.ULTRA) && !_donationManager.Get(player).OwnsUnknownPackage(serverType + " ULTRA")) slots++; return slots; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java index 18df137c9..8a3feb293 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -119,7 +119,7 @@ public class ServerNpcPage extends ShopPageInventory lore = new ArrayList(); @@ -206,7 +206,7 @@ public class ServerNpcPage extends ShopPageInventory 0 && serverList.get(0).Name.contains("BETA"); boolean tournament = serverList.size() > 0 && serverList.get(0).Name.contains("T_"); boolean privateServer = serverList.size() > 0 && serverList.get(0).ServerType.equals("Player"); - boolean ownsUltraPackage = getClient().GetRank().has(Rank.ULTRA) || (serverList.size() > 0 && getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(serverList.get(0).ServerType + " ULTRA")); + boolean ownsUltraPackage = getClient().GetRank().has(Rank.ULTRA) || (serverList.size() > 0 && getDonationManager().Get(getPlayer()).OwnsUnknownPackage(serverList.get(0).ServerType + " ULTRA")); long portalTime = getPlugin().getMillisecondsUntilPortal(getPlayer(), beta); if (portalTime > 0) @@ -471,7 +471,7 @@ public class ServerNpcPage extends ShopPageInventory implements IClas private HashMap _classes; private HashMap _classSalesPackageIdMap; - private Object _clientLock = new Object(); + private final Object _clientLock = new Object(); private boolean _enabled = true; @@ -88,24 +89,16 @@ public class ClassManager extends MiniClientPlugin implements IClas public void OnClientWebResponse(ClientWebResponseEvent event) { ClientClassTokenWrapper token = new Gson().fromJson(event.GetResponse(), ClientClassTokenWrapper.class); - LoadClassBuilds(token); + LoadClassBuilds(token, event.getUniqueId()); } - private void LoadClassBuilds(ClientClassTokenWrapper token) + private void LoadClassBuilds(ClientClassTokenWrapper token, UUID uuid) { synchronized (_clientLock) { - Set(token.Name, - new ClientClass(this, _skillFactory, _itemFactory, _clientManager.Get(token.Name), _donationManager - .Get(token.Name), token.DonorToken)); - } - } - - public ClientClass Get(String name) - { - synchronized (_clientLock) - { - return super.Get(name); + Set(uuid, + new ClientClass(this, _skillFactory, _itemFactory, _clientManager.Get(uuid), _donationManager + .Get(uuid), token.DonorToken)); } } @@ -322,9 +315,9 @@ public class ClassManager extends MiniClientPlugin implements IClas } @Override - protected ClientClass addPlayer(String player) + protected ClientClass addPlayer(UUID uuid) { - return new ClientClass(this, _skillFactory, _itemFactory, _clientManager.Get(player), _donationManager.Get(player), null); + return new ClientClass(this, _skillFactory, _itemFactory, _clientManager.Get(uuid), _donationManager.Get(uuid), null); } public ClassRepository GetRepository() @@ -363,7 +356,7 @@ public class ClassManager extends MiniClientPlugin implements IClas } } - ClientClass client = Get(target.getName()); + ClientClass client = Get(target.getUniqueId()); if (client == null) event.getPlayer().sendMessage(target.getName() + " does not have a ClientClass."); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index bddac25dd..123874341 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -232,7 +232,7 @@ public class ClientClass public void SaveActiveCustomBuild() { - _savingCustomBuild.PlayerName = _client.GetPlayerName(); + _savingCustomBuild.PlayerName = _client.getName(); _classFactory.GetRepository().SaveCustomBuild(_savingCustomBuild); _savingCustomBuild = null; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java index a87c6fc53..8c7fe10d2 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Set; +import java.util.UUID; import org.bukkit.Material; import org.bukkit.Sound; @@ -110,14 +111,14 @@ public class Illusion extends SkillActive skel.getEquipment().setItemInHand(Math.random() > 0.5 ? player.getItemInHand() : new ItemStack(Material.IRON_AXE)); //Get in range - ArrayList inRange = new ArrayList(); + ArrayList inRange = new ArrayList<>(); for (Player other : UtilServer.getPlayers()) if (UtilMath.offset2d(skel, other) < 70) - inRange.add(other); + inRange.add(other.getUniqueId()); //Disguise DisguisePlayer disguise = new DisguisePlayer(skel, ((CraftPlayer)player).getHandle().getProfile()); - Factory.Disguise().disguise(disguise, inRange.toArray(new Player[inRange.size()])); + Factory.Disguise().disguise(disguise, attempted -> inRange.contains(attempted.getUniqueId())); //Invis Factory.Condition().Factory().Cloak(GetName(), player, player, 2 + 1*level, false, true); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java index 90eac4190..bfa289da2 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java @@ -394,7 +394,7 @@ public class SkillPage extends ShopPageBase private boolean isSkillLocked(ISkill skill) { - if (skill.IsFree() || getClientManager().Get(getPlayer().getName()).GetRank().has(Rank.HELPER) || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions ULTRA") || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions " + skill.GetName())) + if (skill.IsFree() || getClientManager().Get(getPlayer()).GetRank().has(Rank.HELPER) || getDonationManager().Get(getPlayer()).OwnsUnknownPackage("Champions ULTRA") || getDonationManager().Get(getPlayer()).OwnsUnknownPackage("Champions " + skill.GetName())) return false; return true; @@ -402,7 +402,7 @@ public class SkillPage extends ShopPageBase private boolean isItemLocked(Item item) { - if (item.isFree() || getClientManager().Get(getPlayer().getName()).GetRank().has(Rank.HELPER) || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions ULTRA") || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions " + item.GetName())) + if (item.isFree() || getClientManager().Get(getPlayer()).GetRank().has(Rank.HELPER) || getDonationManager().Get(getPlayer()).OwnsUnknownPackage("Champions ULTRA") || getDonationManager().Get(getPlayer()).OwnsUnknownPackage("Champions " + item.GetName())) return false; return true; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java index 1841cb81d..70c8f7a17 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java @@ -23,8 +23,8 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilWorld; import mineplex.core.disguise.DisguiseManager; import mineplex.core.projectile.ProjectileManager; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.ConditionManager; @@ -174,7 +174,7 @@ public abstract class WorldEvent implements Listener, ScoreboardElement { customStart(); } - + @Override public List getLines(ScoreboardManager manager, Player player, List out) { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java index 612113429..303e6757c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java @@ -19,9 +19,9 @@ import org.bukkit.event.entity.ItemSpawnEvent; public class SpiderBoss extends WorldEvent { - public SpiderBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) + public SpiderBoss(DisguiseManager disguiseManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { - super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation, + super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation, "schematic/Golem.schematic"); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java index 1e6c7ffc7..75891e616 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java @@ -15,9 +15,9 @@ import org.bukkit.Location; public class GolemBoss extends WorldEvent { - public GolemBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) + public GolemBoss(DisguiseManager disguiseManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { - super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Iron Wizard", cornerLocation); + super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Iron Wizard", cornerLocation); } @Override diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java index f6a1a6af7..f2509954c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java @@ -18,9 +18,9 @@ public class SkeletonBoss extends WorldEvent { protected boolean canMove = false; - public SkeletonBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) + public SkeletonBoss(DisguiseManager disguiseManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { - super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Skeleton King", cornerLocation); + super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Skeleton King", cornerLocation); } @Override diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java index 53f9d55ca..d7cf66624 100755 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java @@ -25,9 +25,9 @@ public class SlimeBoss extends WorldEvent private static final int MAX_SIZE = 16; private static final int MIN_SIZE = 2; - public SlimeBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) + public SlimeBoss(DisguiseManager disguiseManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { - super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Slime King", cornerLocation, "schematic/ClansSlime.schematic"); + super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Slime King", cornerLocation, "schematic/ClansSlime.schematic"); } @Override diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java index 6dda3daa5..45a9d5c51 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java @@ -1,8 +1,10 @@ package mineplex.minecraft.game.core.combat; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.UUID; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; @@ -13,20 +15,23 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; public class CombatComponent -{ +{ private boolean _player = false; private LinkedList _damage; protected String EntityName; protected long LastDamage = 0; - + + private UUID _entityUUID; + public CombatComponent(String name, LivingEntity ent) { EntityName = name; if (ent != null) { + _entityUUID = ent.getUniqueId(); if (ent instanceof Player) { _player = true; @@ -51,6 +56,15 @@ public class CombatComponent return EntityName; } + public UUID getUniqueIdOfEntity() + { + if (_entityUUID == null) + { + return UUID.nameUUIDFromBytes(GetName().getBytes(StandardCharsets.UTF_8)); + } + return _entityUUID; + } + public LinkedList GetDamage() { if (_damage == null) @@ -58,12 +72,12 @@ public class CombatComponent return _damage; } - + public String GetReason() { if (_damage.isEmpty()) return null; - + return _damage.get(0).GetName(); } @@ -116,7 +130,7 @@ public class CombatComponent + F.elem(GetTotalDamage() + "dmg") + "" + "] [" + F.elem(GetBestWeapon()) + "] [" + F.time(time) + "]"; } - + public String Display(long _deathTime, CombatDamage damage) { // Time diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java index c00c1b3d4..24a848c3e 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java @@ -1,7 +1,10 @@ package mineplex.minecraft.game.core.combat; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; +import java.util.UUID; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; @@ -44,7 +47,7 @@ public class CombatManager extends MiniPlugin } private NautHashMap _active = new NautHashMap(); - private NautHashMap _combatClients = new NautHashMap(); + private Map _combatClients = new HashMap<>(); private HashSet _removeList = new HashSet(); @@ -63,12 +66,12 @@ public class CombatManager extends MiniPlugin _combatClients.remove(event.GetName()); } - public ClientCombat Get(String name) + public ClientCombat Get(UUID uuid) { - if (!_combatClients.containsKey(name)) - _combatClients.put(name, new ClientCombat()); + if (!_combatClients.containsKey(uuid)) + _combatClients.put(uuid, new ClientCombat()); - return _combatClients.get(name); + return _combatClients.get(uuid); } //This is a backup, for when CustomDamageEvent is disabled (manually) @@ -423,7 +426,7 @@ public class CombatManager extends MiniPlugin log.SetDeathTime(System.currentTimeMillis()); // Save Death - Get(event.getEntity().getName()).GetDeaths().addFirst(log); + Get(event.getEntity().getUniqueId()).GetDeaths().addFirst(log); // Add Kill/Assist int assists = 0; @@ -440,7 +443,7 @@ public class CombatManager extends MiniPlugin { log.SetKiller(log.GetAttackers().get(i)); - ClientCombat killerClient = Get(log.GetAttackers().get(i).GetName()); + ClientCombat killerClient = Get(log.GetAttackers().get(i).getUniqueIdOfEntity()); if (killerClient != null) killerClient.GetKills().addFirst(log); @@ -450,7 +453,7 @@ public class CombatManager extends MiniPlugin { assists++; - ClientCombat assistClient = Get(log.GetAttackers().get(i).GetName()); + ClientCombat assistClient = Get(log.GetAttackers().get(i).getUniqueIdOfEntity()); if (assistClient != null) assistClient.GetAssists().addFirst(log); @@ -460,7 +463,7 @@ public class CombatManager extends MiniPlugin log.SetAssists(assists); // Event - CombatDeathEvent deathEvent = new CombatDeathEvent(event, Get(event.getEntity().getName()), log, "killed"); + CombatDeathEvent deathEvent = new CombatDeathEvent(event, Get(event.getEntity().getUniqueId()), log, "killed"); UtilServer.getServer().getPluginManager().callEvent(deathEvent); //XXX Death MSG diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index c679ba060..dcaf61de3 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -360,7 +360,7 @@ public class DamageManager extends MiniPlugin //Limit Mob/World Damage Rate if (!event.IgnoreRate()) { - if (!_combatManager.Get(damagee.getName()).CanBeHurtBy(event.GetDamagerEntity(true))) + if (!_combatManager.Get(damagee.getUniqueId()).CanBeHurtBy(event.GetDamagerEntity(true))) { event.SetCancelled("World/Monster Damage Rate"); return; @@ -381,7 +381,7 @@ public class DamageManager extends MiniPlugin //Damage Rate if (!event.IgnoreRate()) - if (!_combatManager.Get(damager.getName()).CanHurt(event.GetDamageeEntity())) + if (!_combatManager.Get(damager.getUniqueId()).CanHurt(event.GetDamageeEntity())) { event.SetCancelled("PvP Damage Rate"); return; diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java index cd172b8e5..2153d4758 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java @@ -1,8 +1,8 @@ package mineplex.serverdata.commands; -public interface CommandCallback +public interface CommandCallback { - public void run(ServerCommand command); + void run(T command); } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java index 0b0779035..089f29e97 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java @@ -117,7 +117,7 @@ public class ServerCommandManager * Register a new type of {@link ServerCommand}. * @param commandType - the {@link ServerCommand} type to register. */ - public void registerCommandType(String commandName, Class commandType, CommandCallback callback) + public void registerCommandType(String commandName, Class commandType, CommandCallback callback) { if (_commandTypes.containsKey(commandName)) { @@ -128,12 +128,12 @@ public class ServerCommandManager _commandTypes.put(commandName, cmdType); System.out.println("Registered : " + commandName); } - - public void registerCommandType(Class commandType, CommandCallback callback) + + public void registerCommandType(Class commandType, CommandCallback callback) { registerCommandType(commandType.getSimpleName(), commandType, callback); } - + public void registerCommandType(String commandName, Class commandType) { registerCommandType(commandName, commandType, null); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index 89a6523c0..bdef1bc65 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -2,6 +2,7 @@ package mineplex.staffServer; import java.util.UUID; +import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; @@ -9,12 +10,14 @@ import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.common.Rank; import mineplex.core.creature.Creature; +import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.memory.MemoryFix; import mineplex.core.monitor.LagMeter; import mineplex.core.npc.NpcManager; +import mineplex.core.packethandler.PacketHandler; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.profileCache.ProfileCacheManager; @@ -34,6 +37,8 @@ import org.bukkit.plugin.java.JavaPlugin; import com.mojang.authlib.GameProfile; +import static mineplex.core.Managers.require; + public class StaffServer extends JavaPlugin { private String WEB_CONFIG = "webServer"; @@ -66,7 +71,10 @@ public class StaffServer extends JavaPlugin new Chat(this, null, clientManager, preferenceManager, new AchievementManager(new StatsManager(this, clientManager), clientManager, donationManager, null, eloManager), serverStatusManager.getCurrentServerName()); new MemoryFix(this); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); + + require(PacketHandler.class); + require(DisguiseManager.class); + require(AntiHack.class); new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this, clientManager), new StatsManager(this, clientManager))); //new Password(this, serverStatusManager.getCurrentServerName()); @@ -95,6 +103,6 @@ public class StaffServer extends JavaPlugin ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("6edf17d5-6bb2-4ed9-92e9-bed8e96fff68"), "BlueBeetleHD")); - new ProfileCacheManager(this); + require(ProfileCacheManager.class); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index d64184f6c..ae823b7fa 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -1,5 +1,12 @@ package mineplex.staffServer.customerSupport; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; @@ -26,12 +33,6 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - public class CustomerSupport extends MiniPlugin implements ResultSetCallable { private CoreClientManager _clientManager; @@ -90,18 +91,18 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(F.main(getName(), "Usage : /check defek7")); } - public void addAgentMapping(Player caller, String playerName) + public void addAgentMapping(Player caller, CoreClient client) { if (!_agentCacheMap.containsKey(caller)) _agentCacheMap.put(caller, new HashSet()); - _agentCacheMap.get(caller).add(playerName); + _agentCacheMap.get(caller).add(client.getName()); } - public void showPlayerInfo(Player caller, String playerName) + public void showPlayerInfo(Player caller, CoreClient client) { - CoreClient client = _clientManager.Get(playerName); - Donor donor = _donationManager.Get(playerName); + String playerName = client.getName(); + Donor donor = _donationManager.Get(client.getUniqueId()); CustomerSupport instance = this; runAsync(new Runnable() @@ -275,16 +276,16 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cDGreen + C.Strike + "============================================="); _salesPackageManager.displaySalesPackages(caller, playerName); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); - caller.sendMessage(C.cBlue + "Freedom Mount: " + getLockedFreedomStr(playerName, "Freedom Mount")); - caller.sendMessage(C.cBlue + "Uncle Sam Morph: " + getLockedFreedomStr(playerName, "Uncle Sam Morph")); - caller.sendMessage(C.cBlue + "Freedom Aura: " + getLockedFreedomStr(playerName, "Freedom Aura")); - caller.sendMessage(C.cBlue + "Shock and Awe: " + getLockedFreedomStr(playerName, "Shock and Awe")); - caller.sendMessage(C.cBlue + "Leap of Freedom: " + getLockedFreedomStr(playerName, "Leap of Freedom")); - caller.sendMessage(C.cBlue + "Price of Freedom: " + getLockedFreedomStr(playerName, "Price of Freedom")); - caller.sendMessage(C.cBlue + "Uncle Sam Hat: " + getLockedFreedomStr(playerName, "Uncle Sam Hat")); + caller.sendMessage(C.cBlue + "Freedom Mount: " + getLockedFreedomStr(client.getUniqueId(), "Freedom Mount")); + caller.sendMessage(C.cBlue + "Uncle Sam Morph: " + getLockedFreedomStr(client.getUniqueId(), "Uncle Sam Morph")); + caller.sendMessage(C.cBlue + "Freedom Aura: " + getLockedFreedomStr(client.getUniqueId(), "Freedom Aura")); + caller.sendMessage(C.cBlue + "Shock and Awe: " + getLockedFreedomStr(client.getUniqueId(), "Shock and Awe")); + caller.sendMessage(C.cBlue + "Leap of Freedom: " + getLockedFreedomStr(client.getUniqueId(), "Leap of Freedom")); + caller.sendMessage(C.cBlue + "Price of Freedom: " + getLockedFreedomStr(client.getUniqueId(), "Price of Freedom")); + caller.sendMessage(C.cBlue + "Uncle Sam Hat: " + getLockedFreedomStr(client.getUniqueId(), "Uncle Sam Hat")); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); - caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(playerName, "Clan Banner Usage")); - caller.sendMessage(C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(playerName, "Clan Banner Editor")); + caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Usage")); + caller.sendMessage(C.cBlue + "Uncle Sam Morph: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor")); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); _accountBonusLog.remove(client.getAccountId()); @@ -338,9 +339,9 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable _accountBonusLog.put(accountId, log); } - private String getLockedFreedomStr(String player, String name) + private String getLockedFreedomStr(UUID uuid, String name) { - if (_donationManager.Get(player).OwnsUnknownPackage(name)) + if (_donationManager.Get(uuid).OwnsUnknownPackage(name)) { return C.cGreen + C.Bold + "Unlocked"; } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java index 63f11315b..62017cba3 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java @@ -1,5 +1,7 @@ package mineplex.staffServer.customerSupport; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; @@ -24,21 +26,22 @@ public class checkCommand extends CommandBase { String playerName = args[0]; - _commandCenter.GetClientManager().checkPlayerName(caller, playerName, new Callback() + _commandCenter.GetClientManager().checkPlayerName(caller, playerName, name -> { - public void run(final String name) + if (name != null) { - if (name != null) + _commandCenter.GetClientManager().loadClientByName(name, client -> { - _commandCenter.GetClientManager().loadClientByName(name, new Runnable() + if (client != null) { - public void run() - { - Plugin.showPlayerInfo(caller, name); - Plugin.addAgentMapping(caller, name); - } - }); - } + Plugin.showPlayerInfo(caller, client); + Plugin.addAgentMapping(caller, client); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not load data for " + name)); + } + }); } }); } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java index 3ced1fbc3..f4d3cca6f 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java @@ -29,33 +29,24 @@ public class CoinCommand extends CommandBase final String playerName = args[0]; final int amount = Integer.parseInt(args[1]); - Plugin.getClientManager().loadClientByName(playerName, new Runnable() + Plugin.getClientManager().loadClientByName(playerName, client -> { - public void run() + if (client != null) { - CoreClient client = Plugin.getClientManager().Get(playerName); - - if (client != null) + Plugin.getDonationManager().RewardCoins(completed -> { - Plugin.getDonationManager().RewardCoins(new Callback() + if (completed) { - public void run(Boolean completed) - { - if (completed) - { - caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " shards to " + playerName + "'s account!")); - } - else - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "There was an error giving " + F.elem(amount + "Shards") + " to " + F.name(playerName) + ".")); - } - } - }, caller.getName(), playerName, client.getAccountId(), amount); - - } - else - caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); + caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " shards to " + playerName + "'s account!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "There was an error giving " + F.elem(amount + "Shards") + " to " + F.name(playerName) + ".")); + } + }, caller.getName(), playerName, client.getAccountId(), amount); } + else + caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); }); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java index 42d53f513..f77065d03 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java @@ -32,21 +32,16 @@ public class GemHunterCommand extends CommandBase final long experience = tempExp; - Plugin.getClientManager().loadClientByName(playerName, new Runnable() + Plugin.getClientManager().loadClientByName(playerName, client -> { - public void run() + if (client != null) { - CoreClient client = Plugin.getClientManager().Get(playerName); - - if (client != null) - { - Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, client.getAccountId(), "Gem Hunter Level " + amount, GlobalCurrency.GEM, 0, false); - Plugin.getStatsManager().incrementStat(client.getAccountId(), "Global.GemsEarned", experience); - caller.sendMessage(F.main(Plugin.getName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!")); - } - else - caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); + Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, client.getAccountId(), "Gem Hunter Level " + amount, GlobalCurrency.GEM, 0, false); + Plugin.getStatsManager().incrementStat(client.getAccountId(), "Global.GemsEarned", experience); + caller.sendMessage(F.main(Plugin.getName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!")); } - }); + else + caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); + }); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java index 7f834cf3e..c983848f0 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java @@ -25,57 +25,53 @@ public class ItemCommand extends CommandBase { if (args == null) return; - + final String playerName = args[0]; int amountSpecified = Integer.parseInt(args[1]); final String category = args[2]; String tempName = args[3]; - + for (int i = 4; i < args.length; i++) { tempName += " " + args[i]; } - + final String itemName = tempName; final int amount = amountSpecified; - + if (!Plugin.getInventoryManager().validItem(itemName)) { caller.sendMessage(F.main(Plugin.getName(), "You have entered an invalid Item.")); return; } - - Plugin.getClientManager().loadClientByName(playerName, new Runnable() + + Plugin.getClientManager().loadClientByName(playerName, client -> { - public void run() + final UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); + + if (uuid != null) { - final UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); - final CoreClient client = Plugin.getClientManager().Get(playerName); - - if (uuid != null) + Plugin.getDonationManager().PurchaseUnknownSalesPackage(new Callback() { - Plugin.getDonationManager().PurchaseUnknownSalesPackage(new Callback() + public void run(TransactionResponse data) { - public void run(TransactionResponse data) + Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback() { - Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback() + public void run(Boolean success) { - public void run(Boolean success) + if (success) + UtilPlayer.message(caller, F.main(Plugin.getName(), playerName + " received " + amount + " " + itemName + ".")); + else { - if (success) - UtilPlayer.message(caller, F.main(Plugin.getName(), playerName + " received " + amount + " " + itemName + ".")); - else - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " " + itemName + ".")); - } + UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " " + itemName + ".")); } - }, uuid, itemName, amount); - } - }, playerName, client.getAccountId(), (amount == 1 ? itemName : itemName + " " + amount), GlobalCurrency.GEM, 0, false); - } - else - caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); + } + }, uuid, itemName, amount); + } + }, playerName, client.getAccountId(), (amount == 1 ? itemName : itemName + " " + amount), GlobalCurrency.GEM, 0, false); } + else + caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); }); } } diff --git a/Plugins/Nautilus.Game.Arcade/plugin.yml b/Plugins/Nautilus.Game.Arcade/plugin.yml index 808eefbe4..e03cfc73b 100644 --- a/Plugins/Nautilus.Game.Arcade/plugin.yml +++ b/Plugins/Nautilus.Game.Arcade/plugin.yml @@ -1,3 +1,4 @@ name: Arcade main: nautilus.game.arcade.Arcade -version: 0.1 \ No newline at end of file +version: 0.1 +loadbefore: [MineplexAnticheat] \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index e1a22a7bf..cf01b4520 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -3,9 +3,12 @@ package nautilus.game.arcade; import java.io.File; import java.util.HashMap; +import mineplex.core.Managers; +import mineplex.core.antihack.AntiHackGuardian; import mineplex.core.boosters.BoosterManager; import mineplex.core.thank.ThankManager; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -66,6 +69,8 @@ import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import nautilus.game.arcade.game.GameServerConfig; +import static mineplex.core.Managers.require; + public class Arcade extends JavaPlugin { private String WEB_CONFIG = "webServer"; @@ -99,7 +104,7 @@ public class Arcade extends JavaPlugin CommandCenter.Initialize(this); _clientManager = new CoreClientManager(this, webServerAddress); CommandCenter.Instance.setClientManager(_clientManager); - new ProfileCacheManager(this); + require(ProfileCacheManager.class); ItemStackFactory.Initialize(this, false); @@ -114,7 +119,7 @@ public class Arcade extends JavaPlugin _serverConfiguration = new ServerConfiguration(this, _clientManager); - PacketHandler packetHandler = new PacketHandler(this); + PacketHandler packetHandler = require(PacketHandler.class); IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler); PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager); @@ -129,14 +134,20 @@ public class Arcade extends JavaPlugin Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); + DisguiseManager disguiseManager = require(DisguiseManager.class); NpcManager npcmanager = new NpcManager(this, creature); _damageManager = new DamageManager(this, new CombatManager(this), npcmanager, disguiseManager, null); Punish punish = new Punish(this, webServerAddress, _clientManager); - AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); - AntiHack.Instance.setKick(false); + + AntiHack antiHack = require(AntiHack.class); + antiHack.setKick(false); + + for (int i = 0; i < 10; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(new Location(Bukkit.getWorld("world"), 0, 125, 0), 23, -23, 130, 120, 23, -23)); + } IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); StatsManager statsManager = new StatsManager(this, _clientManager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 9ad8f7c99..e9782bf7e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -1,23 +1,31 @@ package nautilus.game.arcade; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; +import mineplex.core.antihack.AntiHack; +import mineplex.core.antihack.AntiHackGuardian; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.bonuses.BonusManager; import mineplex.core.boosters.BoosterManager; import mineplex.core.chat.Chat; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.*; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.PlayerDisguiseManager; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.energy.Energy; +import mineplex.core.event.JoinMessageBroadcastEvent; import mineplex.core.explosion.Explosion; import mineplex.core.explosion.ExplosionEvent; import mineplex.core.facebook.FacebookManager; @@ -42,6 +50,8 @@ import mineplex.core.punish.Punish; import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.rewards.PetReward; +import mineplex.core.scoreboard.MineplexScoreboard; +import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.sponsorbranding.BrandingManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; @@ -68,7 +78,6 @@ import nautilus.game.arcade.addons.SoupAddon; import nautilus.game.arcade.addons.TeamArmorAddon; import nautilus.game.arcade.addons.compass.CompassAddon; import nautilus.game.arcade.booster.GameBoosterManager; -import nautilus.game.arcade.command.DisguiseCommand; import nautilus.game.arcade.command.GameCmdModeCommand; import nautilus.game.arcade.command.GameCommand; import nautilus.game.arcade.command.KitUnlockCommand; @@ -81,6 +90,7 @@ import nautilus.game.arcade.game.GameServerConfig; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.event.EventModule; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.managers.*; import nautilus.game.arcade.managers.chat.GameChatManager; @@ -106,6 +116,7 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.*; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.potion.PotionEffect; +import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; import java.io.File; @@ -173,7 +184,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation private BoosterManager _boosterManager; private GameSpectatorManager _spectatorManager; private ServerUptimeManager _serverUptimeManager; - + private ScoreboardManager _scoreboardManager; + private IncognitoManager _incognitoManager; private TaskManager _taskManager; @@ -211,7 +223,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _serverConfig = serverConfig; // Modules - _blockRestore = new BlockRestore(plugin); + _blockRestore = Managers.get(BlockRestore.class); _incognitoManager = incognitoManager; @@ -300,7 +312,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation // new HolidayManager(this, titanGiveaway); new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager); new GameTestingManager(this); - new PlayerDisguiseManager(plugin, _clientManager); + require(PlayerDisguiseManager.class); new GameBoosterManager(plugin, boosterManager, disguiseManager, hologramManager, npcManager, serverConfig.BoosterGroup); // Game Addons @@ -332,7 +344,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _kitProgressionManager = new KitProgressionManager(getPlugin(), clientManager); _progressionKitManager = new ProgressingKitManager(this); _serverUptimeManager = new ServerUptimeManager(this); - + if (GetHost() != null && !GetHost().isEmpty()) { Bukkit.getScheduler().runTaskLater(plugin, () -> Portal.transferPlayer(GetHost(), _serverStatusManager.getCurrentServerName()), 80L); @@ -341,6 +353,187 @@ public class ArcadeManager extends MiniPlugin implements IRelation loadRequiredRank(); _gameCommandMode = checkGameCommandMode(); + + this._scoreboardManager = new ScoreboardManager(_plugin) + { + @Override + public void handlePlayerJoin(String playerName) + { + CoreClient client = GetClients().Get(playerName); + + for (MineplexScoreboard scoreboard : getScoreboards().values()) + { + scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().Name).addEntry(playerName); + } + + Player player = Bukkit.getPlayerExact(playerName); + + if (player != null && get(player) != null) + { + for (Player player1 : Bukkit.getOnlinePlayers()) + { + client = GetClients().Get(player1); + + get(player).getHandle().getTeam(client.getRealOrDisguisedRank().Name).addEntry(player1.getName()); + } + } + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) + { + GameTeam gameTeam = null; + if (GetGame() != null && GetGame().GetTeam(onlinePlayer) != null) + gameTeam = GetGame().GetTeam(onlinePlayer); + + _gameLobbyManager.AddPlayerToScoreboards(onlinePlayer, gameTeam); + } + + System.out.println("Handling player join " + playerName + " " + player.getName() + " " + GetGame()); + + if (GetGame() != null) + { + System.out.println(GetGame().IsAlive(player)); + if (GetGame().IsAlive(player)) + { + GetGame().GetScoreboard().setPlayerTeam(player, GetGame().GetTeam(player)); + } + else + { + GetGame().GetScoreboard().setSpectating(player); + } + } + } + + @Override + public void handlePlayerQuit(String playerName) + { + CoreClient client = GetClients().Get(playerName); + + for (MineplexScoreboard scoreboard : getScoreboards().values()) + { + scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().Name).removeEntry(playerName); + } + } + + @Override + public void setup(MineplexScoreboard scoreboard) + { + for (Rank rank : Rank.values()) + { + if (rank == Rank.ALL) + scoreboard.getHandle().registerNewTeam(rank.Name).setPrefix(""); + else + scoreboard.getHandle().registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); + } + + scoreboard.register(ArcadeScoreboardLine.PLAYERS_SPACER) + .register(ArcadeScoreboardLine.PLAYERS_NAME) + .register(ArcadeScoreboardLine.PLAYERS_VALUE) + .register(ArcadeScoreboardLine.KIT_SPACER) + .register(ArcadeScoreboardLine.KIT_NAME) + .register(ArcadeScoreboardLine.KIT_VALUE) + .register(ArcadeScoreboardLine.GEM_SPACER) + .register(ArcadeScoreboardLine.GEM_NAME) + .register(ArcadeScoreboardLine.GEM_VALUE) + .register(ArcadeScoreboardLine.SERVER_SPACER) + .register(ArcadeScoreboardLine.SERVER_NAME) + .register(ArcadeScoreboardLine.SERVER_VALUE) + .recalculate(); + + scoreboard.get(ArcadeScoreboardLine.PLAYERS_NAME).write(C.cYellow + C.Bold + "Players"); + scoreboard.get(ArcadeScoreboardLine.KIT_NAME).write(C.cGray + C.Bold + "Kit"); + scoreboard.get(ArcadeScoreboardLine.GEM_NAME).write(C.cGreen + C.Bold + "Gems"); + scoreboard.get(ArcadeScoreboardLine.SERVER_NAME).write(C.cAqua + C.Bold + "Server"); + scoreboard.get(ArcadeScoreboardLine.SERVER_VALUE).write(_plugin.getConfig().getString("serverstatus.name")); + } + + @Override + public void draw(MineplexScoreboard scoreboard) + { + if (GetGame() != null && GetGame().GetCountdown() >= 0) + { + if (GetGame().GetCountdown() > 0) + scoreboard.setSidebarName(C.Bold + "§lStarting in " + C.cGreen + "§l" + GetGame().GetCountdown() + (GetGame().GetCountdown() == 1 ? " Second" : " Seconds")); + else if (GetGame().GetCountdown() == 0) + scoreboard.setSidebarName(ChatColor.WHITE + "§lIn Progress..."); + } + else + { + if (GetGame() instanceof UHC && !((UHC) GetGame()).isMapLoaded()) + { + scoreboard.setSidebarName(((UHC) GetGame()).getObjectiveName(_gameLobbyManager._colorTick)); + } + else + { + scoreboard.setSidebarName(ChatColor.GREEN + "§l" + "Waiting for Players"); + } + } + + int spectatorCount = 0; + + for (Player players : UtilServer.getPlayersCollection()) + { + if (isVanished(players)) + { + spectatorCount++; + } + } + + scoreboard.get(ArcadeScoreboardLine.PLAYERS_VALUE).write(UtilServer.getPlayers().length - spectatorCount + "/" + GetPlayerFull()); + scoreboard.get(ArcadeScoreboardLine.GEM_VALUE).write(donationManager.Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM)); + + if (GetGame() != null) + { + ChatColor teamColor = null; + String kitName = "None"; + + if (GetGame().GetTeam(scoreboard.getOwner()) != null) + { + teamColor = GetGame().GetTeam(scoreboard.getOwner()).GetColor(); + } + + if (GetGame().GetKit(scoreboard.getOwner()) != null) + { + kitName = GetGame().GetKit(scoreboard.getOwner()).GetName() + ""; + } + + if (teamColor == null) + { + teamColor = ChatColor.GRAY; + } + + scoreboard.get(ArcadeScoreboardLine.KIT_NAME).write(teamColor + C.Bold + "Kit"); + scoreboard.get(ArcadeScoreboardLine.KIT_VALUE).write(kitName); + } + + if (GetGame() instanceof MinecraftLeague) + { + if (!scoreboard.isRegistered(ArcadeScoreboardLine.DIVISION_SPACER)) + { + scoreboard.register(ArcadeScoreboardLine.DIVISION_SPACER) + .register(ArcadeScoreboardLine.DIVISION_NAME) + .register(ArcadeScoreboardLine.DIVISION_VALUE) + .recalculate(); + } + scoreboard.get(ArcadeScoreboardLine.DIVISION_NAME).write(C.cPurpleB + "Division"); + + + EloManager.EloDivision ed = EloManager.EloDivision.getDivision(getEloManager().getElo(scoreboard.getOwner(), GetGame().GetType().getGameId())); + scoreboard.get(ArcadeScoreboardLine.DIVISION_VALUE).write(ed.getDisplayName()); + } + else + { + if (scoreboard.isRegistered(ArcadeScoreboardLine.DIVISION_SPACER)) + { + scoreboard.unregister(ArcadeScoreboardLine.DIVISION_SPACER) + .unregister(ArcadeScoreboardLine.DIVISION_NAME) + .unregister(ArcadeScoreboardLine.DIVISION_VALUE) + .recalculate(); + } + } + } + }; + + Managers.put(this._scoreboardManager, ScoreboardManager.class); } @Override @@ -349,7 +542,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation addCommand(new GameCommand(this)); addCommand(new WriteCommand(this)); addCommand(new KitUnlockCommand(this)); - addCommand(new DisguiseCommand(this)); addCommand(new RequiredRankCommand(this)); addCommand(new GameCmdModeCommand(this)); } @@ -549,7 +741,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _serverStatusManager; } - public CustomDataManager getCustomDataManager() { return _customDataManager; } + public CustomDataManager getCustomDataManager() + { + return _customDataManager; + } public ChatColor GetColor(Player player) { @@ -616,12 +811,12 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler public void StaffIncognito(IncognitoStatusChangeEvent event) - { - if(event.getNewState()) //Is going into incognito + { + if (event.getNewState()) //Is going into incognito { UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName())); - - if(_game.GetCountdown() > 0) //Lobby is counting down + + if (_game.GetCountdown() > 0) //Lobby is counting down { // Clean if (_game != null) @@ -640,11 +835,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation } } } - else if(_game.GetState() != GameState.Recruit) //Game is NOT in lobby + else if (_game.GetState() != GameState.Recruit) //Game is NOT in lobby { addSpectator(event.getPlayer(), true); _specList.add(event.getPlayer()); - if(_game.GetTeam(event.getPlayer()) != null) + if (_game.GetTeam(event.getPlayer()) != null) _game.GetTeam(event.getPlayer()).SetPlayerState(event.getPlayer(), PlayerState.OUT); } else //Game is in lobby @@ -655,11 +850,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation else //Is coming out of incognito { UtilServer.broadcast(F.sys("Join", event.getPlayer().getName())); - - if(!(_game.GetState() == GameState.Live || _game.GetState() == GameState.Prepare)) + + if (!(_game.GetState() == GameState.Live || _game.GetState() == GameState.Prepare)) { _specList.remove(event.getPlayer()); - if(_game.GetTeam(event.getPlayer()) != null) + if (_game.GetTeam(event.getPlayer()) != null) _game.GetTeam(event.getPlayer()).SetPlayerState(event.getPlayer(), PlayerState.IN); } @@ -732,8 +927,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler public void MessageJoin(PlayerJoinEvent event) { - String name = event.getPlayer().getName(); - if (_incognitoManager.Get(event.getPlayer()).Status) { event.setJoinMessage(null); @@ -744,10 +937,18 @@ public class ArcadeManager extends MiniPlugin implements IRelation return; if (_game != null && _game.AnnounceJoinQuit) - event.setJoinMessage(F.sys("Join", GetColor(event.getPlayer()) + name)); - + { + JoinMessageBroadcastEvent joinMessageBroadcastEvent = new JoinMessageBroadcastEvent(event.getPlayer()); + UtilServer.CallEvent(joinMessageBroadcastEvent); + if (joinMessageBroadcastEvent.getUsername() != null) + { + event.setJoinMessage(F.sys("Join", GetColor(event.getPlayer()) + joinMessageBroadcastEvent.getUsername())); + } + } else + { event.setJoinMessage(null); + } } @EventHandler @@ -808,7 +1009,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation 8, ItemStackFactory.Instance.CreateStack(Material.WATCH, (byte) 0, 1, (short) 0, C.cGreen + "Return to Hub", new String[]{"", ChatColor.RESET + "Click while holding this", - ChatColor.RESET + "to return to the Hub."})); + ChatColor.RESET + "to return to the Hub."})); UtilInv.Update(player); } @@ -819,14 +1020,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation { if (Bukkit.getServer().hasWhitelist()) { - if(_requiredRank != null) + if (_requiredRank != null) { - if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), _requiredRank, false)) + if (_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), _requiredRank, false)) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); - if (_serverConfig.Tournament && _clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false)) + if (_serverConfig.Tournament && _clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false)) { event.getPlayer().setOp(true); } @@ -847,9 +1048,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation return; } } - if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false) || - _clientManager.Get(event.getPlayer().getName()).GetRank() == Rank.MAPDEV || - _clientManager.Get(event.getPlayer().getName()).GetRank() == Rank.MAPLEAD) + if (_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false) || + _clientManager.Get(event.getPlayer().getUniqueId()).GetRank() == Rank.MAPDEV || + _clientManager.Get(event.getPlayer().getUniqueId()).GetRank() == Rank.MAPLEAD) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); @@ -880,14 +1081,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers()) { - if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) + if (_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); return; } - else if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.ULTRA, false) - || _donationManager.Get(event.getPlayer().getName()).OwnsUnknownPackage(_serverConfig.ServerType + " ULTRA")) + else if (_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.ULTRA, false) + || _donationManager.Get(event.getPlayer().getUniqueId()).OwnsUnknownPackage(_serverConfig.ServerType + " ULTRA")) { if (GetGame() != null && GetGame().DontAllowOverfill) @@ -943,6 +1144,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation /** * Checks if a player is participating in/has been participating in the current game + * * @param player The player to check * @return Whether they are/have been playing */ @@ -1014,8 +1216,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation HubClock(player); - GetDisguise().undisguise(player); - Gadget morph = getCosmeticManager().getGadgetManager().getActive(player, GadgetType.MORPH); if (morph != null && morph.isActive(player)) morph.disable(player); @@ -1027,7 +1227,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation File folder = new File(".." + File.separatorChar + ".." + File.separatorChar + "update" + File.separatorChar + "maps" + File.separatorChar + gameName); - System.out.println(folder.getAbsolutePath()+" -=-=-=-=-=" ); + System.out.println(folder.getAbsolutePath() + " -=-=-=-=-="); if (!folder.exists()) folder.mkdirs(); @@ -1200,7 +1400,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation } return _specList.contains(player); } - + public boolean isVanished(Player player) { return _incognitoManager.Get(player).Status; @@ -1475,11 +1675,12 @@ public class ArcadeManager extends MiniPlugin implements IRelation PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager, pet, pet, type, RewardRarity.OTHER, 0, 0); if (reward.canGiveReward(player)) - reward.giveReward(null, player, data -> { + reward.giveReward(null, player, data -> + { }); } - + public void enableChampionsModules() { _classManager.setEnabled(true); @@ -1488,11 +1689,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation _itemFactory.registerSelf(); _energy.registerSelf(); _eloManager.registerSelf(); - + //Class Shop _plugin.getServer().getPluginManager().registerEvents(_classShop, _plugin); } - + public void disableChampionsModules() { _classManager.setEnabled(false); @@ -1501,11 +1702,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation _itemFactory.deregisterSelf(); _energy.deregisterSelf(); _eloManager.deregisterSelf(); - + //Class Shop HandlerList.unregisterAll(_classShop); } - + public void toggleChampionsModules(GameType gameType) { boolean isChamps = gameType == GameType.ChampionsDominate || gameType == GameType.ChampionsTDM || gameType == GameType.ChampionsCTF || gameType == GameType.BossBattles; @@ -1545,7 +1746,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation player.teleport(GetGame().GetSpectatorLocation()); //Set Spec State - UtilAction.velocity(player, new Vector(0,1,0)); + UtilAction.velocity(player, new Vector(0, 1, 0)); player.setAllowFlight(true); player.setFlying(true); player.setFlySpeed(0.1f); @@ -1556,7 +1757,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation GetCondition().Factory().Cloak("Spectator", player, player, 7777, true, true); //Game Team - GetGame().GetScoreboard().SetPlayerTeam(player, "SPEC"); + GetGame().GetScoreboard().setSpectating(player); } public boolean isSpectator(Entity player) @@ -1570,9 +1771,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation { _requiredRank = null; - for(File file : new File(".").listFiles()) + for (File file : new File(".").listFiles()) { - if(!file.getName().startsWith("RequiredRank")) + if (!file.getName().startsWith("RequiredRank")) continue; try @@ -1600,7 +1801,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _requiredRank = rank; } - @EventHandler(priority=EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOWEST) public void explosionCancel(EntityExplodeEvent event) { if (GetGame() == null || !GetGame().InProgress()) @@ -1698,6 +1899,86 @@ public class ArcadeManager extends MiniPlugin implements IRelation return true; } + @EventHandler + public void clearDisguises(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Dead) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + while (true) + { + DisguiseBase activeDisguise = _disguiseManager.getActiveDisguise(player); + if (activeDisguise == null) + { + break; + } + if (!(activeDisguise instanceof DisguisePlayer)) + { + _disguiseManager.undisguise(player); + } + else + { + break; + } + } + } + } + } + + @EventHandler + public void clearGameTeams(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Dead) + { + for (MineplexScoreboard scoreboard : _scoreboardManager.getScoreboards().values()) + { + for (Team team : scoreboard.getHandle().getTeams()) + { + if (team.getName().startsWith("GT")) + { + team.unregister(); + } + } + } + for (Player player : Bukkit.getOnlinePlayers()) + { + _gameLobbyManager.AddPlayerToScoreboards(player, null); + } + } + } + + @EventHandler + public void spawnGuardians(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Live) + { + require(AntiHack.class).clearGuardians(); + + Location specLocation = GetGame().GetSpectatorLocation().add(0, 5, 0); + int maxX = (int) (specLocation.getX() + 50); + int minX = (int) (specLocation.getX() - 50); + int maxY = (int) (specLocation.getY() + 5); + int minY = (int) (specLocation.getY() - 5); + int maxZ = (int) (specLocation.getZ() + 50); + int minZ = (int) (specLocation.getZ() - 50); + + for (int i = 0; i < 10; i++) + { + require(AntiHack.class).registerGuardian(new AntiHackGuardian(specLocation, maxX, minX, maxY, minY, maxZ, minZ)); + } + } + else if (event.GetState() == GameState.Recruit) + { + require(AntiHack.class).clearGuardians(); + + for (int i = 0; i < 10; i++) + { + require(AntiHack.class).registerGuardian(new AntiHackGuardian(new Location(Bukkit.getWorld("world"), 0, 125, 0), 23, -23, 130, 120, 23, -23)); + } + } + } + public ProgressingKitManager getProgressionKitManager() { return _progressionKitManager; @@ -1712,4 +1993,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation { return _spectatorManager; } + + public ScoreboardManager getScoreboardManager() + { + return this._scoreboardManager; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeScoreboardLine.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeScoreboardLine.java new file mode 100644 index 000000000..d2c1d202c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeScoreboardLine.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade; + +import mineplex.core.scoreboard.ScoreboardLine; + +public enum ArcadeScoreboardLine implements ScoreboardLine +{ + PLAYERS_SPACER, + PLAYERS_NAME, + PLAYERS_VALUE, + KIT_SPACER, + KIT_NAME, + KIT_VALUE, + GEM_SPACER, + GEM_NAME, + GEM_VALUE, + SERVER_SPACER, + SERVER_NAME, + SERVER_VALUE, + DIVISION_SPACER, + DIVISION_NAME, + DIVISION_VALUE +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java deleted file mode 100644 index 118be3200..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java +++ /dev/null @@ -1,507 +0,0 @@ -package nautilus.game.arcade.command; - -import java.lang.reflect.Field; -import java.util.UUID; - -import mineplex.core.account.CoreClient; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.ProfileLoader; -import mineplex.core.common.util.UUIDFetcher; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.disguise.PlayerUndisguiseEvent; -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.types.GadgetType; -import mineplex.core.punish.PunishClient; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.Game.GameState; -import net.minecraft.server.v1_8_R3.ChatComponentText; -import net.minecraft.server.v1_8_R3.EntityHuman; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.IChatBaseComponent; -import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData; -import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerLoginEvent.Result; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.scoreboard.Team; - -import com.mojang.authlib.GameProfile; - -public class DisguiseCommand extends CommandBase implements Listener -{ - - private NautHashMap _disguisedPlayers = new NautHashMap<>(); - private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); - private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); - - public DisguiseCommand(ArcadeManager plugin) - { - super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, "disguise"); - - plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); - } - - @Override - public void Execute(final Player caller, final String[] args) - { - if(args == null || args.length == 0) - { - if(!Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); - return; - } - try - { - GameProfile profile = _disguisedPlayers.get(caller); - _disguisedPlayers.remove(caller); - _disguisedPlayerDisguises.remove(caller); - Plugin.GetDisguise().undisguise(caller); - String playerName = _disguisedPlayersNames.get(caller); - Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller)); - - CoreClient client = Plugin.GetClients().Get(caller); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(caller, playerName, true); - - for(Player other : UtilServer.getPlayers()) - updateTabInfo(((CraftPlayer) caller).getProfile(), profile, other, false); - - Field field; - try - { - field = GameProfile.class.getDeclaredField("id"); - field.setAccessible(true); - UUID old = ((CraftPlayer) caller).getProfile().getId(); - UUID newUUID = profile.getId(); - field.set(profile, old); - field.set(((CraftPlayer) caller).getProfile(), newUUID); - } - catch(Exception e) - { - e.printStackTrace(); - } - - - // removed "due to Kicked for Flying" - //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); - //UtilPlayer.sendPacket(caller, packet); - - for(Player other : UtilServer.getPlayers()) - { - for(Team team : other.getScoreboard().getTeams()) - { - team.removePlayer(caller); - } - other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); - } - - UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); - return; - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - if(args != null && args.length > 1) - { - UtilPlayer.message(caller, F.main("Disguise", "/disguise ")); - return; - } - - Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() - { - @Override - public void run() - { - if(Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); - return; - } - for(Player other : UtilServer.getPlayers()) - { - if(other.getName().equalsIgnoreCase(args[0])) - { - UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); - return; - } - } - if(_disguisedPlayersNames.containsValue(args[0])) - { - UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); - return; - } - if(args[0].length() > 16) - { - UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); - return; - } - - try - { - CoreClient client = Plugin.GetClients().Get(caller); - UUID uuid = UUID.randomUUID(); - GameProfile profile = null; - try - { - uuid = UUIDFetcher.getUUIDOf(args[0]); - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } catch (Exception e) - { - uuid = UUID.randomUUID(); - profile = new ProfileLoader(null, args[0]).loadProfile(); - } - - Rank otherRank = Rank.ALL; - CoreClient other = null; - try - { - other = new CoreClient(args[0]); - Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); - otherRank = other.GetRank(); - } catch(NullPointerException exception) - { - other = null; - } - if(otherRank.has(Rank.TWITCH)) - { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, Youtubers or Twitchers!")); - return; - } - if(other != null) - { - PunishClient pclient = Plugin.getPunishments().GetClient(args[0]); - if(pclient.IsBanned() || pclient.IsMuted()) - { - UtilPlayer.message(caller, F.main("Disguise", "Unable to disguise as this Player!")); - return; - } - } - - _disguisedPlayers.put(caller, profile); - _disguisedPlayersNames.put(caller, caller.getName()); - client.setDisguisedRank(otherRank); - client.setDisguised(true); - - client.setDisguisedAs(args[0]); - - changeName(caller, args[0], true); - - Plugin.getCosmeticManager().getGadgetManager().removeGadgetType(caller, GadgetType.ITEM); - - // Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); - UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0])); - - Field field; - try - { - field = GameProfile.class.getDeclaredField("id"); - field.setAccessible(true); - UUID old = ((CraftPlayer) caller).getProfile().getId(); - UUID newUUID = profile.getId(); - field.set(profile, old); - field.set(((CraftPlayer) caller).getProfile(), newUUID); - } - catch(Exception e) - { - e.printStackTrace(); - } - - // removed "due to Kicked for Flying" - //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); - //UtilPlayer.sendPacket(caller, packet); - - tablistRefresh(caller); - } catch(Exception e) - { - e.printStackTrace(); - UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); - return; - } - } - }); - } - - @EventHandler - public void refreshTabNames(UpdateEvent event) - { - if(event.getType() != UpdateType.FAST) - return; - - for(Player player : _disguisedPlayers.keySet()) - { - if(!player.isOnline()) - return; - - tablistRefresh(player); - } - } - - public void tablistRefresh(Player player) - { - for (Player other : UtilServer.getPlayers()) - { - if (player.canSee(other)) - { - updateTabInfo(_disguisedPlayers.get(player), ((CraftPlayer) player).getProfile(), other, false); - } - } - } - - public void updateTabInfo(GameProfile profileToAdd, GameProfile profileToRemove, Player target, boolean refreshOnly) - { - ChatColor team = ChatColor.WHITE; - Player player = Bukkit.getPlayer(profileToAdd.getName()); - EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - if(Plugin.GetGame().GetTeam(player) != null) - { - team = Plugin.GetGame().GetTeam(player).GetColor(); - } - String tag = Plugin.GetClients().Get(player).GetRank().getTag(true, true) + " "; - if(Plugin.GetClients().Get(player).isDisguised()) - { - tag = Plugin.GetClients().Get(player).getDisguisedRank().getTag(true, true) + " "; - } - if(Plugin.GetGame().GetState() != GameState.Recruit) - tag = ""; - - IChatBaseComponent component = new ChatComponentText(tag + team + player.getName()); - - if(!refreshOnly) - { - PacketPlayOutPlayerInfo removePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); - PlayerInfoData removeData = removePacket.new PlayerInfoData(profileToRemove, entityPlayer.ping, EnumGamemode.SURVIVAL, component); - removePacket.b.add(removeData); - UtilPlayer.sendPacket(target, removePacket); - - PacketPlayOutPlayerInfo addPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); - PlayerInfoData addData = addPacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); - addPacket.b.add(addData); - UtilPlayer.sendPacket(target, addPacket); - } - - PacketPlayOutPlayerInfo updatePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME); - PlayerInfoData updateData = updatePacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); - updatePacket.b.add(updateData); - UtilPlayer.sendPacket(target, updatePacket); - } - - @EventHandler - public void updateDisguises(UpdateEvent event) - { - if(event.getType() != UpdateType.FASTEST) - return; - - for(final Player player : UtilServer.getPlayers()) - { - if(!_disguisedPlayers.containsKey(player)) - continue; - - for(Player other : UtilServer.getPlayers()) - { - try - { - if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player)) - { - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player); - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); - } - if(other.getScoreboard().getTeam( - Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) != null) - { - if(other.getScoreboard() - .getTeam(Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) - .getPlayers().contains(player)) - { - other.getScoreboard() - .getTeam( - Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) - .removePlayer(player); - other.getScoreboard() - .getTeam( - Plugin.GetClients().Get(player).getDisguisedRank().Name - + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()).addPlayer(player); - } - } - } catch(NullPointerException exp) - {} - } - - if(Plugin.GetDisguise().isDisguised(player)) - continue; - - DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); - _disguisedPlayerDisguises.put(player, playerDisguise); - Plugin.GetDisguise().disguise(playerDisguise); - } - } - - public void changeName(final Player player, String changedName, boolean skin) - { - try - { - GameProfile gameProfile = ((CraftPlayer) player).getProfile(); - - Field name = GameProfile.class.getDeclaredField("name"); - name.setAccessible(true); - name.set(gameProfile, changedName); - name.setAccessible(false); - - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Quit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - try - { - _disguisedPlayers.remove(player); - _disguisedPlayerDisguises.remove(player); - Plugin.GetDisguise().undisguise(player); - String playerName = _disguisedPlayersNames.get(player); - _disguisedPlayersNames.remove(player); - - CoreClient client = Plugin.GetClients().Get(player); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(player, playerName, true); - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Join(PlayerLoginEvent event) - { - for(Player player : _disguisedPlayers.keySet()) - { - if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) - { - event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); - } - } - } - - @EventHandler - public void gadget(GadgetEnableEvent event) - { - if(!event.getGadget().getName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.MORPH) - return; - - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler - public void chest(TreasureStartEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerSneak(PlayerToggleSneakEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - DisguisePlayer dp = _disguisedPlayerDisguises.get(player); - - dp.setSneaking(!dp.getSneaking()); - } - } - - @EventHandler - public void onPlayerLeftClick(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(player)) - { - EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); - human.world.broadcastEntityEffect(human, (byte) 0); - } - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onDPlayerChat(AsyncPlayerChatEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setFormat(" *" + event.getMessage()); - } - } - - @EventHandler - public void on(PlayerInteractEvent event) - { - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - - Player player = event.getPlayer(); - - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = player.getEntityId(); - - for(Player p : Bukkit.getOnlinePlayers()) - { - if(p != player) - { - Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); - } - } - } - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 8d5435b32..b334e814a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -1,8 +1,12 @@ package nautilus.game.arcade.game; import com.google.common.collect.Lists; +import com.mineplex.anticheat.api.GameEndEvent; +import com.mineplex.anticheat.api.GameStartEvent; import com.mojang.authlib.GameProfile; +import mineplex.core.Managers; +import mineplex.core.antihack.AntiHack; import mineplex.core.common.util.*; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.elo.EloPlayer; @@ -11,10 +15,9 @@ import mineplex.core.gadget.types.GadgetType; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; -import mineplex.core.party.Party; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; @@ -25,6 +28,12 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.games.hideseek.HideSeek; +import nautilus.game.arcade.game.games.minestrike.Minestrike; +import nautilus.game.arcade.game.games.sneakyassassins.SneakyAssassins; +import nautilus.game.arcade.game.games.survivalgames.SurvivalGames; +import nautilus.game.arcade.game.games.uhc.UHC; +import nautilus.game.arcade.game.games.wither.WitherGame; import nautilus.game.arcade.game.modules.Module; import nautilus.game.arcade.kit.*; import nautilus.game.arcade.managers.GameLobbyManager; @@ -35,19 +44,15 @@ import nautilus.game.arcade.wineffect.WinEffectManager; import nautilus.game.arcade.world.WorldData; import net.minecraft.server.v1_8_R3.EntityItem; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; -import net.minecraft.server.v1_8_R3.WorldServer; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItem; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.entity.Hanging; -import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -58,13 +63,10 @@ import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingPlaceEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.scoreboard.NameTagVisibility; -import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; @@ -143,7 +145,7 @@ public abstract class Game implements Listener // Gameplay Flags public long GameTimeout = 1200000; - + public boolean SpectatorAllowed = true; public boolean Damage = true; @@ -186,7 +188,7 @@ public abstract class Game implements Listener public double DeathSpectateSecs = 0; public boolean DeathTeleport = true; - + public boolean QuitOut = true; public boolean QuitDropItems = false; @@ -219,8 +221,6 @@ public abstract class Game implements Listener public boolean AnnounceJoinQuit = true; public boolean AnnounceSilence = true; - public boolean DisplayLobbySide = true; - public GameState KitRegisterState = GameState.Live; public boolean JoinInProgress = false; @@ -257,7 +257,7 @@ public abstract class Game implements Listener public long PrepareTime = 9000; public boolean PlaySoundGameStart = true; - + public double XpMult = 1; // Chat Stats @@ -297,11 +297,11 @@ public abstract class Game implements Listener public String Winner = "Nobody"; public GameTeam WinnerTeam = null; - + //ELO public boolean EloRanking = false; public int EloStart = 1000; - + public boolean CanAddStats = true; public boolean CanGiveLoot = true; @@ -316,13 +316,13 @@ public abstract class Game implements Listener public boolean EnableTutorials = false; public boolean FixSpawnFacing = true; - + public boolean AllowEntitySpectate = true; - + public boolean TeamMode = false; - + public boolean TeamPerSpawn = false; - + public boolean ForceTeamSize = true; public int PlayersPerTeam = 2; public int TeamCount = 0; @@ -333,7 +333,7 @@ public abstract class Game implements Listener private NautHashMap _deadBodiesExpire = new NautHashMap(); private final Set> _statTrackers = new HashSet<>(); - + private NautHashMap _teamReqs = new NautHashMap(); public WinEffectManager WinEffectManager = new WinEffectManager(); @@ -464,14 +464,14 @@ public abstract class Game implements Listener { return _gameType.GetName(); } - + public GameType[] GetWorldHostNames() { GameType[] mapSource = new GameType[] - { - GetType() - }; - + { + GetType() + }; + if (GetType().getMapSource() != null) { if (GetType().ownMaps()) @@ -490,11 +490,11 @@ public abstract class Game implements Listener mapSource = GetType().getMapSource(); } } - + if (GetType().isUsingGameModesMaps()) { GameType mode = GetType().getModeGameType(getClass()); - + if (mode.getMapSource() != null) return mode.getMapSource(); else @@ -552,7 +552,7 @@ public abstract class Game implements Listener { _customWinLine = line; } - + public void SetCustomWinMessage(Player player, String message) { _customWinMessages.put(player, message); @@ -563,11 +563,6 @@ public abstract class Game implements Listener return Scoreboard; } - private Objective GetObjectiveSide() - { - return Scoreboard.GetObjectiveSide(); - } - public ArrayList GetTeamList() { return _teamList; @@ -623,6 +618,35 @@ public abstract class Game implements Listener _gameState = state; _gameStateTime = System.currentTimeMillis(); + if (this._gameState == Game.GameState.Prepare) + { + Managers.get(AntiHack.class).enableNewAnticheat(); + if (this instanceof HideSeek) + { + Managers.get(AntiHack.class).registerFilter(player -> + { + if (GetTeam(player) == ((HideSeek) this).getHiders()) + { + return false; + } + return true; + }); + } + else if (this instanceof SurvivalGames || this instanceof Minestrike || this instanceof SneakyAssassins || this instanceof UHC || this instanceof WitherGame) + { + Managers.get(AntiHack.class).registerFilter(player -> + { + return false; + }); + } + } + else if (this._gameState == Game.GameState.End) + { + Managers.get(AntiHack.class).disableNewAnticheat(); + Managers.get(AntiHack.class).registerFilter(null); + } + + if (_gameState == GameState.Live) setGameLiveTime(_gameStateTime); @@ -632,7 +656,7 @@ public abstract class Game implements Listener // Event GameStateChangeEvent stateEvent = new GameStateChangeEvent(this, state); UtilServer.getServer().getPluginManager().callEvent(stateEvent); - + System.out.println(GetName() + " state set to " + state.toString()); } @@ -688,7 +712,7 @@ public abstract class Game implements Listener { for (Kit kit : _kits) { - if(kit == null) + if (kit == null) { continue; } @@ -706,7 +730,7 @@ public abstract class Game implements Listener { for (Kit kit : _kits) { - if(kit == null) + if (kit == null) { continue; } @@ -739,10 +763,10 @@ public abstract class Game implements Listener team.AddPlayer(player, in); // Game Scoreboard - Scoreboard.SetPlayerTeam(player, team.GetName().toUpperCase()); + Scoreboard.setPlayerTeam(player, team); // Lobby Scoreboard - Manager.GetLobby().AddPlayerToScoreboards(player, team.GetName().toUpperCase()); + Manager.GetLobby().AddPlayerToScoreboards(player, team); // Save Tournament Team Manager.GetGameTournamentManager().setTournamentTeam(player, team); @@ -839,7 +863,7 @@ public abstract class Game implements Listener } player.sendMessage(F.main("Kit", "Your current kit is not applicable with your team. Please select a different kit")); Optional newKit = Lists.newArrayList(GetKits()) - .stream().filter(team::KitAllowed).findFirst(); + .stream().filter(team::KitAllowed).findFirst(); if (newKit.isPresent()) { SetKit(player, newKit.get(), false); @@ -885,7 +909,7 @@ public abstract class Game implements Listener { SetKit(player, kit, announce, true); } - + public void SetKit(Player player, Kit kit, boolean announce, boolean apply) { GameTeam team = GetTeam(player); @@ -895,9 +919,9 @@ public abstract class Game implements Listener { player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 0.5f); UtilPlayer.message( - player, - F.main("Kit", F.elem(team.GetFormattedName()) + " cannot use " + F.elem(kit.GetFormattedName() + " Kit") - + ".")); + player, + F.main("Kit", F.elem(team.GetFormattedName()) + " cannot use " + F.elem(kit.GetFormattedName() + " Kit") + + ".")); return; } } @@ -959,8 +983,6 @@ public abstract class Game implements Listener public boolean SetPlayerState(Player player, PlayerState state) { - GetScoreboard().ResetScore(player.getName()); - GameTeam team = GetTeam(player); if (team == null) @@ -997,7 +1019,7 @@ public abstract class Game implements Listener } }, 0); } - + public void RespawnPlayerTeleport(Player player) { player.teleport(GetTeam(player).GetSpawn()); @@ -1145,7 +1167,7 @@ public abstract class Game implements Listener public boolean CanJoinTeam(GameTeam team) { - if(TeamMode) + if (TeamMode) { return team.GetSize() < PlayersPerTeam; } @@ -1156,7 +1178,7 @@ public abstract class Game implements Listener public final void onFoodLevelChangeEvent(FoodLevelChangeEvent event) { ((Player) event.getEntity()).setSaturation(3.8F); // While not entirely accurate, this is a pretty good guess at original - // food level changes + // food level changes } public GameTeam GetTeamPreference(Player player) @@ -1242,8 +1264,8 @@ public abstract class Game implements Listener { if (!IsLive()) return; - - if(team != null && !team.GetPlacements(true).isEmpty()) + + if (team != null && !team.GetPlacements(true).isEmpty()) { List teamList = new ArrayList<>(); List otherList = new ArrayList<>(); @@ -1252,7 +1274,7 @@ public abstract class Game implements Listener otherList.removeAll(teamList); Player player = teamList.remove(0); WinEffectManager.prePlay(this, player, teamList, otherList); - + Location loc = GetSpectatorLocation().clone().add(1000, 0, 1000); loc.setY(200); WinEffectManager.playWinEffect(loc); @@ -1293,14 +1315,14 @@ public abstract class Game implements Listener { UtilPlayer.message(player, _customWinLine); } - + UtilPlayer.message(player, _customWinMessages.get(player)); } else { UtilPlayer.message(player, _customWinLine); } - + UtilPlayer.message(player, ""); UtilPlayer.message(player, "§aMap - §f§l" + WorldData.MapName + C.cGray + " created by " + "§f§l" + WorldData.MapAuthor); @@ -1309,10 +1331,10 @@ public abstract class Game implements Listener } UtilTextMiddle.display(winnerText, subColor + "won the game", 20, 120, 20); - + if (AnnounceSilence) Manager.GetChat().Silence(5000, false); - + endElo(); } @@ -1320,17 +1342,17 @@ public abstract class Game implements Listener { String winnerText = ChatColor.WHITE + "§lNobody won the game..."; ChatColor subColor = ChatColor.WHITE; - - if(places != null && !places.isEmpty()) + + if (places != null && !places.isEmpty()) { List teamList = new ArrayList<>(); List nonTeamList = new ArrayList<>(); nonTeamList.addAll(places); Player player = places.get(0); nonTeamList.remove(player); - + WinEffectManager.prePlay(this, player, teamList, nonTeamList); - + Location loc = GetSpectatorLocation().clone().add(1000, 0, 1000); loc.setY(200); WinEffectManager.playWinEffect(loc); @@ -1383,10 +1405,10 @@ public abstract class Game implements Listener } UtilTextMiddle.display(winnerText, subColor + "won the game", 20, 120, 20); - + if (AnnounceSilence) Manager.GetChat().Silence(5000, false); - + endElo(); } @@ -1410,7 +1432,7 @@ public abstract class Game implements Listener System.out.println("[Announcement] " + message); } - + public boolean AdvertiseText(GameLobbyManager gameLobbyManager, int _advertiseStage) { return false; @@ -1646,22 +1668,22 @@ public abstract class Game implements Listener if (player.isOnline()) AddGems(player, 10, "Participation", false, false); } - + endElo(); - + // End SetState(GameState.End); } - + @EventHandler public void disableParticles(GameStateChangeEvent event) { if (event.GetState() == GameState.Prepare && Manager.getCosmeticManager().getGadgetManager().hideParticles()) { - for (Player player : GetPlayers(false)) - { - getArcadeManager().getCosmeticManager().getGadgetManager().removeGadgetType(player, GadgetType.PARTICLE); - } + for (Player player : GetPlayers(false)) + { + getArcadeManager().getCosmeticManager().getGadgetManager().removeGadgetType(player, GadgetType.PARTICLE); + } } } @@ -1679,15 +1701,15 @@ public abstract class Game implements Listener for (Player player : team.GetPlayers(false)) { - eloTeam.addPlayer(new EloPlayer(player, Manager.GetClients().getAccountId(player), Manager.getEloManager().getElo(player, GetType().getGameId()))); + eloTeam.addPlayer(new EloPlayer(player, Manager.GetClients().getAccountId(player), Manager.getEloManager().getElo(player, GetType().getGameId()))); } - + Manager.getEloManager().addTeam(team.getDisplayName(), eloTeam); } } } } - + // Handle Elo at end of game -- method can be overridden in different game modes to meet their individual needs protected void endElo() { @@ -1695,12 +1717,12 @@ public abstract class Game implements Listener { if (WinnerTeam != null) Manager.getEloManager().setWinningTeam(WinnerTeam.getDisplayName()); - + Manager.getEloManager().endMatch(GetType().getGameId()); } } - - + + @EventHandler public void handleInteractEntityPacket(GameStateChangeEvent event) { @@ -1761,51 +1783,48 @@ public abstract class Game implements Listener return; } + Location loc = player.getLocation(); + String name = "Body #" + _deadBodyCount++; - Team team = Scoreboard.GetScoreboard().getTeam(ChatColor.COLOR_CHAR + "DeadBodies"); + Team team = Scoreboard.getScoreboard().getTeam(ChatColor.COLOR_CHAR + "DeadBodies"); if (team == null) { - team = Scoreboard.GetScoreboard().registerNewTeam(ChatColor.COLOR_CHAR + "DeadBodies"); + team = Scoreboard.getScoreboard().registerNewTeam(ChatColor.COLOR_CHAR + "DeadBodies"); team.setNameTagVisibility(NameTagVisibility.NEVER); } - team.addEntry(name); - GameProfile newProfile = new GameProfile(UUID.randomUUID(), name); + EntityItem entityItem = new EntityItem( + ((CraftWorld) loc.getWorld()).getHandle(), + loc.getX(), + loc.getY() + 0.5, + loc.getZ(), + CraftItemStack.asNMSCopy(new ItemBuilder(Material.STONE).setTitle(System.currentTimeMillis() + "").build()) + ); + entityItem.pickupDelay = Integer.MAX_VALUE; + entityItem.yaw = player.getLocation().getYaw(); + entityItem.pitch = player.getLocation().getPitch(); - newProfile.getProperties().putAll(((CraftPlayer) player).getHandle().getProfile().getProperties()); + UtilEnt.CreatureLook(entityItem.getBukkitEntity(), player.getLocation().getPitch(), player.getLocation().getYaw()); - DisguisePlayer disguise = new DisguisePlayer(null, newProfile); + GameProfile profile = UtilGameProfile.getGameProfile(player); + GameProfile cloned = new GameProfile(UUID.randomUUID(), name); + cloned.getProperties().putAll(profile.getProperties()); + + DisguisePlayer disguise = new DisguisePlayer(entityItem.getBukkitEntity(), cloned); disguise.setSleeping(getSleepingFace(player.getLocation())); - getArcadeManager().GetDisguise().addFutureDisguise(disguise); - - Location loc = player.getLocation(); - WorldServer world = ((CraftWorld) loc.getWorld()).getHandle(); - - EntityItem nmsItem = new EntityItem(world, loc.getX(), loc.getY() + 0.5, loc.getZ(), - CraftItemStack.asNMSCopy(new ItemBuilder(Material.STONE).setTitle(System.currentTimeMillis() + "").build())); - - nmsItem.motX = 0; - nmsItem.motY = 0; - nmsItem.motZ = 0; - nmsItem.yaw = 0; - - world.addEntity(nmsItem); - - Item entity = new CraftItem(world.getServer(), nmsItem); - - entity.setPickupDelay(Integer.MAX_VALUE); - - _deadBodies.put(player.getName(), entity); + _deadBodies.put(player.getName(), entityItem.getBukkitEntity()); if (DeadBodiesExpire > 0) { _deadBodiesExpire.put(player.getName(), System.currentTimeMillis() + (DeadBodiesExpire * 1000)); } + + getArcadeManager().GetDisguise().disguise(disguise); } @EventHandler(priority = EventPriority.HIGHEST) @@ -1850,10 +1869,10 @@ public abstract class Game implements Listener // A complicated way to get the face the dead body should be towards. for (HashSet validBlocks : new HashSet[] - { - UtilBlock.blockAirFoliageSet, - UtilBlock.blockPassSet - }) + { + UtilBlock.blockAirFoliageSet, + UtilBlock.blockPassSet + }) { if (validBlocks.contains((byte) block.getRelative(proper).getTypeId())) @@ -1862,12 +1881,12 @@ public abstract class Game implements Listener } for (BlockFace face : new BlockFace[] - { - BlockFace.EAST, - BlockFace.SOUTH, - BlockFace.NORTH, - BlockFace.WEST - }) + { + BlockFace.EAST, + BlockFace.SOUTH, + BlockFace.NORTH, + BlockFace.WEST + }) { if (validBlocks.contains((byte) block.getRelative(face).getTypeId())) { @@ -2049,7 +2068,7 @@ public abstract class Game implements Listener if (UtilBlock.airFoliage(newSpawn.getBlock()) && UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.UP)) && !UtilBlock - .airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN))) + .airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN))) { spawns.add(newSpawn); } @@ -2057,10 +2076,10 @@ public abstract class Game implements Listener } } } - + private enum TeamColors { - + YELLOW(ChatColor.YELLOW, new String[]{"Banana", "Sunshine", "Custard", "Sponge", "Star", "Giraffe", "Lego", "Light"}), GREEN(ChatColor.GREEN, new String[]{"Creepers", "Alien", "Seaweed", "Emerald", "Grinch", "Shrub", "Snake", "Leaf"}), AQUA(ChatColor.AQUA, new String[]{"Diamond", "Ice", "Pool", "Kraken", "Aquatic", "Ocean"}), @@ -2074,26 +2093,26 @@ public abstract class Game implements Listener DARK_GREEN(ChatColor.DARK_GREEN, new String[]{"Forest", "Zombies", "Cactus", "Slime", "Toxic", "Poison"}), DARK_PURPLE(ChatColor.DARK_PURPLE, new String[]{"Amethyst", "Slugs", "Grape", "Witch", "Magic", "Zula"}), DARK_AQUA(ChatColor.DARK_AQUA, new String[]{"Snorlax", "Aquatic", "Clam", "Fish"}); - + private ChatColor color; private String[] names; - + private TeamColors(ChatColor color, String[] names) { this.color = color; this.names = names; } - + public ChatColor getColor() { return color; } - + public String[] getNames() { return names; } - + } private String[] getColorName(ChatColor color) @@ -2135,6 +2154,7 @@ public abstract class Game implements Listener module.cleanup(); HandlerList.unregisterAll(module); } + this._modules.clear(); } public T getModule(Class clazz) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java index d6302e4b1..fd2620b91 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.concurrent.atomic.AtomicLong; import mineplex.core.account.CoreClient; import mineplex.core.common.util.C; @@ -26,8 +27,10 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.scoreboard.Team; -public class GameTeam +public class GameTeam { + private static final AtomicLong TEAM_ID = new AtomicLong(); + private Game Host; private double _respawnTime = 0; @@ -40,7 +43,7 @@ public class GameTeam private String name; private ChatColor color; - private PlayerState(String name, ChatColor color) + private PlayerState(String name, ChatColor color) { this.name = name; this.color = color; @@ -57,16 +60,18 @@ public class GameTeam } } + private final long _teamId = TEAM_ID.getAndIncrement(); + private String _name; private String _displayName; private ChatColor _color; - + private GameTutorial _tutorial; private HashMap _players = new HashMap(); private ArrayList _spawns; - + private Creature _teamEntity = null; private HashSet _kitRestrict = new HashSet(); @@ -74,7 +79,7 @@ public class GameTeam private boolean _visible = true; private boolean _displayTag; - + //Records order players go out in protected ArrayList _places = new ArrayList(); private long _teamCreatedTime = System.currentTimeMillis(); // Used just for SpectatorPage so that teams remain ordered @@ -89,7 +94,7 @@ public class GameTeam _spawns = spawns; _displayTag = tags; } - + public GameTeam(Game host, String name, ChatColor color, ArrayList spawns) { this(host, name, color, spawns, false); @@ -120,9 +125,9 @@ public class GameTeam if (Host.FixSpawnFacing) { float yaw = UtilAlg.GetYaw(UtilAlg.getTrajectory2d(loc, Host.GetSpectatorLocation())); - + yaw = (int) (yaw / 90) * 90; - + loc = loc.clone(); loc.setYaw(yaw); } @@ -130,8 +135,8 @@ public class GameTeam return loc; } - public Location GetSpawn() - { + public Location GetSpawn() + { //Keep allies together if (!Host.IsLive() && Host.SpawnNearAllies) { @@ -139,9 +144,9 @@ public class GameTeam Location loc = UtilAlg.getLocationNearPlayers(_spawns, GetPlayers(true), Host.GetPlayers(true)); if (loc != null) return fixFacing(loc); - + //No allies existed spawned yet - + //Spawn near enemies (used for SG) if (Host.SpawnNearEnemies) { @@ -155,7 +160,7 @@ public class GameTeam loc = UtilAlg.getLocationAwayFromPlayers(_spawns, Host.GetPlayers(true)); if (loc != null) return fixFacing(loc); - } + } } else { @@ -182,44 +187,27 @@ public class GameTeam { _players.put(player, in ? PlayerState.IN : PlayerState.OUT); - UtilPlayer.message(player, F.main("Team", _color + C.Bold + "You joined " + getDisplayName() + " Team.")); + UtilPlayer.message(player, F.main("Team", _color + C.Bold + "You joined " + getDisplayName() + " Team.")); VisibilityManager.Instance.refreshPlayerToAll(player); } - public void DisbandTeam() + public void DisbandTeam() { for (Player player : _players.keySet()) { - for(Player other : UtilServer.getPlayers()) - { - Team team = other.getScoreboard().getTeam(Host.Manager.GetClients().Get(player).GetRank().Name + _name.toUpperCase()); - if (team != null) - { - team.removePlayer(player); - } - other.getScoreboard().getTeam(Host.Manager.GetClients().Get(player).GetRank().Name).addPlayer(player); - } - UtilPlayer.message(player, F.main("Team", _color + C.Bold + getDisplayName() + " Team was disbanded.")); + Host.getArcadeManager().GetLobby().RemovePlayerFromTeam(player, this); + UtilPlayer.message(player, F.main("Team", _color + C.Bold + getDisplayName() + " Team was disbanded.")); } - + _players.clear(); } - + public void RemovePlayer(Player player) { _players.remove(player); } - public Player GetPlayer(String name) - { - for (Player player : _players.keySet()) - if (player.getName().equals(name)) - return player; - - return null; - } - public boolean HasPlayer(Player player) { return _players.containsKey(player); @@ -240,7 +228,7 @@ public class GameTeam return _players.size(); } - public void SetPlayerState(Player player, PlayerState state) + public void SetPlayerState(Player player, PlayerState state) { if (player == null) return; @@ -268,7 +256,7 @@ public class GameTeam return alive; } - public String GetFormattedName() + public String GetFormattedName() { return GetColor() + "§l" + GetName(); } @@ -287,12 +275,12 @@ public class GameTeam player.teleport(location); } - public void SpawnTeleport() + public void SpawnTeleport() { SpawnTeleport(true); } - public void SpawnTeleport(boolean aliveOnly) + public void SpawnTeleport(boolean aliveOnly) { for (Player player : GetPlayers(aliveOnly)) { @@ -321,7 +309,7 @@ public class GameTeam return player.isOnline() && _players.get(player) == PlayerState.IN; } - public void SetColor(ChatColor color) + public void SetColor(ChatColor color) { _color = color; } @@ -330,7 +318,7 @@ public class GameTeam { _name = name; } - + public void setDisplayName(String name) { _displayName = name; @@ -340,52 +328,52 @@ public class GameTeam { if (_displayName == null) return _name; - + return _displayName; } public byte GetColorData() { - if (GetColor() == ChatColor.WHITE) return (byte)0; - if (GetColor() == ChatColor.GOLD) return (byte)1; - if (GetColor() == ChatColor.LIGHT_PURPLE) return (byte)2; - if (GetColor() == ChatColor.AQUA) return (byte)3; - if (GetColor() == ChatColor.YELLOW) return (byte)4; - if (GetColor() == ChatColor.GREEN) return (byte)5; + if (GetColor() == ChatColor.WHITE) return (byte) 0; + if (GetColor() == ChatColor.GOLD) return (byte) 1; + if (GetColor() == ChatColor.LIGHT_PURPLE) return (byte) 2; + if (GetColor() == ChatColor.AQUA) return (byte) 3; + if (GetColor() == ChatColor.YELLOW) return (byte) 4; + if (GetColor() == ChatColor.GREEN) return (byte) 5; //if (GetColor() == ChatColor.PINK) return (byte)6; - if (GetColor() == ChatColor.DARK_GRAY) return (byte)7; - if (GetColor() == ChatColor.GRAY) return (byte)8; - if (GetColor() == ChatColor.DARK_AQUA) return (byte)9; - if (GetColor() == ChatColor.DARK_PURPLE) return (byte)10; - if (GetColor() == ChatColor.BLUE) return (byte)11; - if (GetColor() == ChatColor.DARK_BLUE) return (byte)11; + if (GetColor() == ChatColor.DARK_GRAY) return (byte) 7; + if (GetColor() == ChatColor.GRAY) return (byte) 8; + if (GetColor() == ChatColor.DARK_AQUA) return (byte) 9; + if (GetColor() == ChatColor.DARK_PURPLE) return (byte) 10; + if (GetColor() == ChatColor.BLUE) return (byte) 11; + if (GetColor() == ChatColor.DARK_BLUE) return (byte) 11; //if (GetColor() == ChatColor.BROWN) return (byte)12; - if (GetColor() == ChatColor.DARK_GREEN) return (byte)13; - if (GetColor() == ChatColor.RED) return (byte)14; - if (GetColor() == ChatColor.DARK_RED) return (byte)14; - else return (byte)15; + if (GetColor() == ChatColor.DARK_GREEN) return (byte) 13; + if (GetColor() == ChatColor.RED) return (byte) 14; + if (GetColor() == ChatColor.DARK_RED) return (byte) 14; + else return (byte) 15; } public Color GetColorBase() { - if (GetColor() == ChatColor.WHITE) return Color.WHITE; - if (GetColor() == ChatColor.GOLD) return Color.ORANGE; - if (GetColor() == ChatColor.LIGHT_PURPLE) return Color.PURPLE; - if (GetColor() == ChatColor.AQUA) return Color.AQUA; - if (GetColor() == ChatColor.YELLOW) return Color.YELLOW; - if (GetColor() == ChatColor.GREEN) return Color.GREEN; - if (GetColor() == ChatColor.DARK_GRAY) return Color.GRAY; - if (GetColor() == ChatColor.GRAY) return Color.GRAY; - if (GetColor() == ChatColor.DARK_AQUA) return Color.AQUA; - if (GetColor() == ChatColor.DARK_PURPLE) return Color.PURPLE; - if (GetColor() == ChatColor.BLUE) return Color.BLUE; - if (GetColor() == ChatColor.DARK_BLUE) return Color.BLUE; - if (GetColor() == ChatColor.DARK_GREEN) return Color.GREEN; - if (GetColor() == ChatColor.RED) return Color.RED; - else return Color.WHITE; + if (GetColor() == ChatColor.WHITE) return Color.WHITE; + if (GetColor() == ChatColor.GOLD) return Color.ORANGE; + if (GetColor() == ChatColor.LIGHT_PURPLE) return Color.PURPLE; + if (GetColor() == ChatColor.AQUA) return Color.AQUA; + if (GetColor() == ChatColor.YELLOW) return Color.YELLOW; + if (GetColor() == ChatColor.GREEN) return Color.GREEN; + if (GetColor() == ChatColor.DARK_GRAY) return Color.GRAY; + if (GetColor() == ChatColor.GRAY) return Color.GRAY; + if (GetColor() == ChatColor.DARK_AQUA) return Color.AQUA; + if (GetColor() == ChatColor.DARK_PURPLE) return Color.PURPLE; + if (GetColor() == ChatColor.BLUE) return Color.BLUE; + if (GetColor() == ChatColor.DARK_BLUE) return Color.BLUE; + if (GetColor() == ChatColor.DARK_GREEN) return Color.GREEN; + if (GetColor() == ChatColor.RED) return Color.RED; + else return Color.WHITE; } - public void SetTeamEntity(Creature ent) + public void SetTeamEntity(Creature ent) { _teamEntity = ent; } @@ -395,7 +383,7 @@ public class GameTeam return _teamEntity; } - public void SetSpawns(ArrayList spawns) + public void SetSpawns(ArrayList spawns) { _spawns = spawns; } @@ -409,12 +397,10 @@ public class GameTeam { return _visible; } - - public void setDisplayTag(boolean b) - { - _displayTag = b; - } - + + /* + * Whether this GameTeam should show a prefix + */ public boolean GetDisplaytag() { return _displayTag; @@ -430,12 +416,12 @@ public class GameTeam return _respawnTime; } - public void SetPlacement(Player player, PlayerState state) + public void SetPlacement(Player player, PlayerState state) { if (state == PlayerState.OUT) { if (!_places.contains(player)) - _places.add(0, player); + _places.add(0, player); } else _places.remove(player); @@ -452,7 +438,7 @@ public class GameTeam placesClone.add(player); } - for (Player player : GetPlayers(true)) + for (Player player : GetPlayers(true)) { placesClone.add(0, player); } @@ -462,15 +448,19 @@ public class GameTeam return _places; } - + public GameTutorial getTutorial() { return _tutorial; } - + public void setTutorial(GameTutorial tutorial) { _tutorial = tutorial; } - + + public long getTeamId() + { + return this._teamId; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/RankedTeamGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/RankedTeamGame.java index 7abcab96e..702e5ddb8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/RankedTeamGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/RankedTeamGame.java @@ -100,7 +100,7 @@ public abstract class RankedTeamGame extends TeamGame if (Bukkit.getOnlinePlayers().size() < MaxPlayers) return; String message = ChatColor.RED + "This game has reached maximum capacity!"; - if (Manager.GetClients().Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) + if (Manager.GetClients().Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) { if (InProgress()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java index 6e029034f..6a8873016 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java @@ -83,9 +83,9 @@ public abstract class SoloGame extends Game if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); GameTeam team = GetTeamList().get(0); @@ -95,11 +95,11 @@ public abstract class SoloGame extends Game { if (team.IsAlive(player)) { - Scoreboard.Write(C.cGreen + player.getName()); + Scoreboard.write(C.cGreen + player.getName()); } else { - Scoreboard.Write(C.cGray + player.getName()); + Scoreboard.write(C.cGray + player.getName()); } } } @@ -107,20 +107,20 @@ public abstract class SoloGame extends Game { for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(C.cGreen + player.getName()); + Scoreboard.write(C.cGreen + player.getName()); } } else { - Scoreboard.Write(C.cGreen + "Players Alive"); - Scoreboard.Write("" + team.GetPlayers(true).size()); + Scoreboard.write(C.cGreen + "Players Alive"); + Scoreboard.write("" + team.GetPlayers(true).size()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Players Dead"); - Scoreboard.Write("" + (team.GetPlayers(false).size() - team.GetPlayers(true).size())); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRed + "Players Dead"); + Scoreboard.write("" + (team.GetPlayers(false).size() - team.GetPlayers(true).size())); } - Scoreboard.Draw(); + Scoreboard.draw(); } public int GetScoreboardScore(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java index 1f55a9039..c59d26e5a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java @@ -92,7 +92,10 @@ public abstract class TeamGame extends Game RejoinHealth.put(player.getName(), player.getHealth()); - GetLocationStore().put(player.getName(), player.getLocation()); + if (!GetLocationStore().containsKey(player.getName())) + { + GetLocationStore().put(player.getName(), player.getLocation()); + } //Announcement Announce(team.GetColor() + C.Bold + player.getName() + " has disconnected! " + UtilTime.convert(RejoinTime, 0, TimeUnit.MINUTES) + " minutes to rejoin.", false); @@ -135,7 +138,7 @@ public abstract class TeamGame extends Game } //Do this on Join, not Login, otherwise player no get heal. - @EventHandler + @EventHandler (priority = EventPriority.MONITOR) public void playerRejoinGame(PlayerJoinEvent event) { if (!InProgress() || QuitOut) @@ -154,14 +157,6 @@ public abstract class TeamGame extends Game }, 1L); } } - - if (GetLocationStore().containsKey(player.getName())) - { - getArcadeManager().runSyncLater(() -> - { - player.teleport(GetLocationStore().remove(player.getName())); - }, 1L); - } } @EventHandler @@ -261,7 +256,7 @@ public abstract class TeamGame extends Game if (event != null && event.getType() != UpdateType.FAST) return; - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : this.GetTeamList()) { @@ -271,25 +266,25 @@ public abstract class TeamGame extends Game if (!team.IsTeamAlive()) continue; - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(team.GetColor() + player.getName()); + Scoreboard.write(team.GetColor() + player.getName()); } } //Display Players Alive else { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(team.GetColor() + team.GetName()); - Scoreboard.Write(team.GetPlayers(true).size() + "" + team.GetColor() + " Alive"); + Scoreboard.write(team.GetColor() + team.GetName()); + Scoreboard.write(team.GetPlayers(true).size() + "" + team.GetColor() + " Alive"); } } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index e09833334..812ad20c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -1449,7 +1449,7 @@ public class Bridge extends TeamGame implements OreObsfucation return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Display Players Alive if (!_tournament) @@ -1462,20 +1462,20 @@ public class Bridge extends TeamGame implements OreObsfucation if (!team.IsTeamAlive()) continue; - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(team.GetColor() + player.getName()); + Scoreboard.write(team.GetColor() + player.getName()); } } //Display Players Alive else { - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetColor() + team.GetName() + " Team"); - Scoreboard.Write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); + Scoreboard.writeNewLine(); + Scoreboard.write(team.GetColor() + team.GetName() + " Team"); + Scoreboard.write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); } } } @@ -1488,14 +1488,14 @@ public class Bridge extends TeamGame implements OreObsfucation if (_tournamentKills.containsKey(team)) kills = _tournamentKills.get(team); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(team.GetColor() + " " + team.GetPlayers(true).size() + " Players"); - Scoreboard.Write(team.GetColor() + " " + kills + " Kills"); + Scoreboard.write(team.GetColor() + " " + team.GetPlayers(true).size() + " Players"); + Scoreboard.write(team.GetColor() + " " + kills + " Kills"); } } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); long time = _bridgeTime @@ -1503,16 +1503,16 @@ public class Bridge extends TeamGame implements OreObsfucation if (time > 0) { - Scoreboard.Write(C.cYellow + C.Bold + "Bridges In"); - Scoreboard.Write(UtilTime.MakeStr(time, 0)); + Scoreboard.write(C.cYellow + C.Bold + "Bridges In"); + Scoreboard.write(UtilTime.MakeStr(time, 0)); } else { - Scoreboard.Write(C.cYellow + C.Bold + "Time Left"); - Scoreboard.Write(UtilTime.MakeStr(5400000 - (System.currentTimeMillis() - this.GetStateTime()), 0)); + Scoreboard.write(C.cYellow + C.Bold + "Time Left"); + Scoreboard.write(UtilTime.MakeStr(5400000 - (System.currentTimeMillis() - this.GetStateTime()), 0)); } - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java index e5aab2079..c3b553407 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java @@ -1333,24 +1333,24 @@ public class Build extends Game public void writeScoreboard() { //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Build Theme"); - Scoreboard.Write(_word); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Build Theme"); + Scoreboard.write(_word); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (_buildGameState == 0) { - Scoreboard.Write(C.cYellow + C.Bold + "Build Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _buildTime - (System.currentTimeMillis() - this.GetStateTime())), 0)); + Scoreboard.write(C.cYellow + C.Bold + "Build Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, _buildTime - (System.currentTimeMillis() - this.GetStateTime())), 0)); } else if (_buildGameState == 2) { - Scoreboard.Write(C.cYellow + C.Bold + "Vote Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _voteTime - (System.currentTimeMillis() - _buildStateTime)), 0)); + Scoreboard.write(C.cYellow + C.Bold + "Vote Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, _voteTime - (System.currentTimeMillis() - _buildStateTime)), 0)); // if (_viewData != null) // { @@ -1370,12 +1370,12 @@ public class Build extends Game { for (Entry score : _scoreboardPlaces) { - Scoreboard.Write(BuildQuality.getFinalQuality(score.getValue()).getColor() + (int)(score.getValue().intValue()/10) + " " + ChatColor.RESET + score.getKey().getName()); + Scoreboard.write(BuildQuality.getFinalQuality(score.getValue()).getColor() + (int)(score.getValue().intValue()/10) + " " + ChatColor.RESET + score.getKey().getName()); } } - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java index 0fb700e65..3b2d98bb5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java @@ -115,35 +115,35 @@ public class TeamBuild extends Build public void writeScoreboard() { //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Build Theme"); - Scoreboard.Write(getWord()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Build Theme"); + Scoreboard.write(getWord()); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (getBuildGameState() == 0) { - Scoreboard.Write(C.cYellow + C.Bold + "Build Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, getBuildTime() - (System.currentTimeMillis() - this.GetStateTime())), 0)); + Scoreboard.write(C.cYellow + C.Bold + "Build Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, getBuildTime() - (System.currentTimeMillis() - this.GetStateTime())), 0)); } else if (getBuildGameState() == 2) { - Scoreboard.Write(C.cYellow + C.Bold + "Vote Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, getVoteTime() - (System.currentTimeMillis() - getBuildStateTime())), 0)); + Scoreboard.write(C.cYellow + C.Bold + "Vote Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, getVoteTime() - (System.currentTimeMillis() - getBuildStateTime())), 0)); } else if (getBuildGameState() == 4) { for (Entry score : _scoreboardPlaces) { - Scoreboard.Write(BuildQuality.getFinalQuality(score.getValue()).getColor() + (int)(score.getValue().intValue()/10) + " " + ChatColor.RESET + score.getKey().getDisplayName()); + Scoreboard.write(BuildQuality.getFinalQuality(score.getValue()).getColor() + (int)(score.getValue().intValue()/10) + " " + ChatColor.RESET + score.getKey().getDisplayName()); } } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java index e890a34a2..f038c1fb2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java @@ -229,44 +229,44 @@ public class Cards extends SoloGame public void writeScoreboard() { //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (_roundState == RoundState.PlaceCards) { - Scoreboard.Write(C.cYellow + C.Bold + "Select Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _playTime - (System.currentTimeMillis() - _roundStateTime)), 1)); + Scoreboard.write(C.cYellow + C.Bold + "Select Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, _playTime - (System.currentTimeMillis() - _roundStateTime)), 1)); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellow + C.Bold + "Judge"); - Scoreboard.Write(C.cWhite + _roundDealer.getName()); + Scoreboard.write(C.cYellow + C.Bold + "Judge"); + Scoreboard.write(C.cWhite + _roundDealer.getName()); } else if (_roundState == RoundState.Judge) { - Scoreboard.Write(C.cYellow + C.Bold + "Judge Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _judgeTime - (System.currentTimeMillis() - _roundStateTime)), 1)); + Scoreboard.write(C.cYellow + C.Bold + "Judge Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, _judgeTime - (System.currentTimeMillis() - _roundStateTime)), 1)); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellow + C.Bold + "Judge"); - Scoreboard.Write(C.cWhite + _roundDealer.getName()); + Scoreboard.write(C.cYellow + C.Bold + "Judge"); + Scoreboard.write(C.cWhite + _roundDealer.getName()); } else if (_roundState == RoundState.View) { - Scoreboard.Write(C.cYellow + C.Bold + "View Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _viewTime - (System.currentTimeMillis() - _roundStateTime)), 1)); + Scoreboard.write(C.cYellow + C.Bold + "View Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, _viewTime - (System.currentTimeMillis() - _roundStateTime)), 1)); } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Round Wins"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Round Wins"); for (GameScore score : _ranks) { - Scoreboard.Write((int)score.Score + " " + C.Bold + score.Player.getName()); + Scoreboard.write((int)score.Score + " " + C.Bold + score.Player.getName()); } - Scoreboard.Draw(); + Scoreboard.draw(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index 2aced88d1..60ff984a0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -71,7 +71,6 @@ import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadGhoul; import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadZombie; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; -import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.BloodThirstyStatTracker; import nautilus.game.arcade.stats.KingDamageStatTracker; import nautilus.game.arcade.stats.KingSlayerStatTracker; @@ -537,22 +536,22 @@ public class CastleSiege extends TeamGame } //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Teams for (String group : _scoreGroup.keySet()) { - Scoreboard.WriteBlank(); - Scoreboard.Write(group); - Scoreboard.Write(ChatColor.getLastColors(group) + _scoreGroup.get(group) + " Players"); + Scoreboard.writeNewLine(); + Scoreboard.write(group); + Scoreboard.write(ChatColor.getLastColors(group) + _scoreGroup.get(group) + " Players"); } //King if (_king != null && _king.isValid()) { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "King"); - Scoreboard.Write(_kingHealth + " Health"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "King"); + Scoreboard.write(_kingHealth + " Health"); } long timeLeft = 24000 - WorldTimeSet; @@ -561,21 +560,21 @@ public class CastleSiege extends TeamGame if (timeLeft > 0) { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Sun Rise"); - Scoreboard.Write(UtilTime.MakeStr(timeLeft, 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); + Scoreboard.write(UtilTime.MakeStr(timeLeft, 0)); } else { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Sun Rise"); - Scoreboard.Write("Undead Burning!"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); + Scoreboard.write("Undead Burning!"); for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) Manager.GetCondition().Factory().Ignite("Sun Damage", player, player, 5, false, false); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java index 5e68140ee..5733e3108 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java @@ -615,61 +615,61 @@ public class Christmas extends SoloGame if (!IsLive()) { - Scoreboard.Reset(); + Scoreboard.reset(); String line = ""; for (int i = 0 ; i < 20 ; i++) line += ((i % 2 == 0 ? C.cRed : C.cDGreen) + "█"); - Scoreboard.WriteBlank(); - Scoreboard.Write(line); + Scoreboard.writeNewLine(); + Scoreboard.write(line); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cWhiteB + "May your winter"); - Scoreboard.Write(C.cWhiteB + "be filled with"); - Scoreboard.Write(C.cYellowB + "joy" + C.cWhiteB + " and " + C.cYellowB + "cheer."); + Scoreboard.write(C.cWhiteB + "May your winter"); + Scoreboard.write(C.cWhiteB + "be filled with"); + Scoreboard.write(C.cYellowB + "joy" + C.cWhiteB + " and " + C.cYellowB + "cheer."); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cAquaB + "Happy Holidays!"); + Scoreboard.write(C.cAquaB + "Happy Holidays!"); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cWhiteB + "- Your friends at"); - Scoreboard.Write(C.cGoldB + "MINEPLEX"); + Scoreboard.write(C.cWhiteB + "- Your friends at"); + Scoreboard.write(C.cGoldB + "MINEPLEX"); - Scoreboard.WriteBlank(); - Scoreboard.Write(line); + Scoreboard.writeNewLine(); + Scoreboard.write(line); - Scoreboard.Draw(); + Scoreboard.draw(); return; } //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Rounds - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGoldB + "Challenge"); - Scoreboard.Write(C.cWhite + (5 - _parts.size()) + " of " + 5); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGoldB + "Challenge"); + Scoreboard.write(C.cWhite + (5 - _parts.size()) + " of " + 5); //Presents - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreenB + "Presents"); - Scoreboard.Write(C.cWhite + GetSleigh().GetPresents().size() + " of " + 10); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreenB + "Presents"); + Scoreboard.write(C.cWhite + GetSleigh().GetPresents().size() + " of " + 10); //Players - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellowB + "Players"); - Scoreboard.Write(C.cWhite + GetPlayers(true).size()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellowB + "Players"); + Scoreboard.write(C.cWhite + GetPlayers(true).size()); //Time - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellowB + "Time Left"); - Scoreboard.Write(C.cWhite + UtilTime.MakeStr(_gameTime - (System.currentTimeMillis() - GetStateTime()))); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellowB + "Time Left"); + Scoreboard.write(C.cWhite + UtilTime.MakeStr(_gameTime - (System.currentTimeMillis() - GetStateTime()))); - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java index 6ecb96ed2..cd88da9c3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java @@ -16,9 +16,6 @@ import mineplex.core.common.util.UtilRadar; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; -import mineplex.core.elo.EloPlayer; -import mineplex.core.elo.EloTeam; -import mineplex.core.elo.GameResult; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatComponent; @@ -443,12 +440,12 @@ public class CaptureTheFlag extends TeamGame return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Scores - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRedB + "Red Team"); - Scoreboard.Write(_redScore + " Captures"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRedB + "Red Team"); + Scoreboard.write(_redScore + " Captures"); String redMessage = "Flag Dropped"; if (getFlag(true).isAtHome()) @@ -460,19 +457,19 @@ public class CaptureTheFlag extends TeamGame if (_flickerStage) { if (!getFlag(true).isAtHome()) - Scoreboard.Write(C.cRed + redMessage); + Scoreboard.write(C.cRed + redMessage); else - Scoreboard.Write(redMessage); + Scoreboard.write(redMessage); } else { - Scoreboard.Write(redMessage); + Scoreboard.write(redMessage); } //Flag in play stuff - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cAquaB + "Blue Team"); - Scoreboard.Write(_blueScore + " Captures"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cAquaB + "Blue Team"); + Scoreboard.write(_blueScore + " Captures"); String blueMessage = "Flag Dropped"; if (getFlag(false).isAtHome()) @@ -486,37 +483,37 @@ public class CaptureTheFlag extends TeamGame if (_flickerStage) { if (!getFlag(false).isAtHome()) - Scoreboard.Write(C.cAqua + blueMessage); + Scoreboard.write(C.cAqua + blueMessage); else - Scoreboard.Write(blueMessage); + Scoreboard.write(blueMessage); } else { - Scoreboard.Write(blueMessage); + Scoreboard.write(blueMessage); } _flickerStage = !_flickerStage; //Flag in play stuff - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellowB + "Score to Win"); - Scoreboard.Write(_victoryCaps + " Captures"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellowB + "Score to Win"); + Scoreboard.write(_victoryCaps + " Captures"); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (_suddenDeath) { - Scoreboard.Write(C.cYellowB + "Sudden Death"); - Scoreboard.Write("Next Cap Wins"); - Scoreboard.Write("No Respawns"); + Scoreboard.write(C.cYellowB + "Sudden Death"); + Scoreboard.write("Next Cap Wins"); + Scoreboard.write("No Respawns"); } else { - Scoreboard.Write(C.cYellowB + "Time Left"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(_gameTime - (System.currentTimeMillis() - GetStateTime()), 0)) + C.cWhite); + Scoreboard.write(C.cYellowB + "Time Left"); + Scoreboard.write(UtilTime.MakeStr(Math.max(_gameTime - (System.currentTimeMillis() - GetStateTime()), 0)) + C.cWhite); } - Scoreboard.Draw(); + Scoreboard.draw(); } public void endCheckScore(int needed) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java index 80fa91b70..ea8a79135 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java @@ -3,7 +3,6 @@ package nautilus.game.arcade.game.games.common; import java.util.ArrayList; import java.util.HashMap; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; @@ -15,8 +14,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ItemDespawnEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; @@ -26,10 +23,6 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilRadar; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextTop; -import mineplex.core.elo.EloPlayer; -import mineplex.core.elo.EloTeam; -import mineplex.core.elo.GameResult; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatComponent; @@ -265,29 +258,29 @@ public class Domination extends TeamGame return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Scores - Scoreboard.WriteBlank(); - Scoreboard.Write("First to " + _victoryScore); + Scoreboard.writeNewLine(); + Scoreboard.write("First to " + _victoryScore); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Red Team"); - Scoreboard.Write(_redScore + C.cRed); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRed + "Red Team"); + Scoreboard.write(_redScore + C.cRed); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cAqua + "Blue Team"); - Scoreboard.Write(_blueScore + C.cAqua); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cAqua + "Blue Team"); + Scoreboard.write(_blueScore + C.cAqua); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); //Write CPs for (int i=0 ; i<_points.size() ; i++) { - Scoreboard.Write(_points.get(i).GetScoreboardName()); + Scoreboard.write(_points.get(i).GetScoreboardName()); } - Scoreboard.Draw(); + Scoreboard.draw(); } public void EndCheckScore() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/TeamDeathmatch.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/TeamDeathmatch.java index 5b016f0a3..f6d2bc073 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/TeamDeathmatch.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/TeamDeathmatch.java @@ -274,14 +274,14 @@ public class TeamDeathmatch extends TeamGame public void ScoreboardWrite() { - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : this.GetTeamList()) { //Display Individual Players if (this.GetPlayers(false).size() <= 10) { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); for (Player player : team.GetPlayers(false)) { @@ -290,38 +290,38 @@ public class TeamDeathmatch extends TeamGame kills = _kills.get(player); if (IsAlive(player)) - Scoreboard.Write(kills + " " + team.GetColor() + player.getName()); + Scoreboard.write(kills + " " + team.GetColor() + player.getName()); else - Scoreboard.Write(kills + " " + C.cGray + player.getName()); + Scoreboard.write(kills + " " + C.cGray + player.getName()); } } //Display Players Alive else { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(team.GetColor() + team.GetName() + " Team"); - Scoreboard.Write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); + Scoreboard.write(team.GetColor() + team.GetName() + " Team"); + Scoreboard.write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); } } if (_beacon != null) { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + _beacon.GetName()); - Scoreboard.Write(_beacon.GetOwnership()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + _beacon.GetName()); + Scoreboard.write(_beacon.GetOwnership()); } else { long timeLeft = _beaconTime - (System.currentTimeMillis() - GetStateTime()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Beacon"); - Scoreboard.Write(UtilTime.MakeStr(timeLeft, 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Beacon"); + Scoreboard.write(UtilTime.MakeStr(timeLeft, 0)); } - Scoreboard.Draw(); + Scoreboard.draw(); } public void EndCheckScore() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java index d4c96743c..a115c82c0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java @@ -350,17 +350,17 @@ public class DeathTag extends SoloGame return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(_runners.GetPlayers(true).size() + " " +_runners.GetColor() + " Runners"); + Scoreboard.write(_runners.GetPlayers(true).size() + " " +_runners.GetColor() + " Runners"); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(_chasers.GetPlayers(true).size() + " " +_chasers.GetColor() + " Chasers"); + Scoreboard.write(_chasers.GetPlayers(true).size() + " " +_chasers.GetColor() + " Chasers"); - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index cc43ec8b1..23d67fb7e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -4,7 +4,9 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; +import mineplex.core.common.Pair; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -197,7 +199,7 @@ public class DragonEscape extends SoloGame if (event.GetState() != GameState.Prepare) return; - for (Team team : GetScoreboard().GetScoreboard().getTeams()) + for (Team team : GetScoreboard().getScoreboard().getTeams()) team.setCanSeeFriendlyInvisibles(true); this.CreatureAllowOverride = true; @@ -395,23 +397,21 @@ public class DragonEscape extends SoloGame SortScores(); //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - - //Write New - for (int i=0 ; i<_ranks.size() && i<14 ; i++) - { - DragonScore score = _ranks.get(i); + Scoreboard.writeNewLine(); + AtomicInteger index = new AtomicInteger(0); + + Scoreboard.writeGroup(_ranks.subList(0, Math.min(_ranks.size(), 14)), score -> + { ChatColor col = ChatColor.GREEN; if (!IsAlive(score.Player)) col = ChatColor.RED; + return Pair.create(col + score.Player.getName(), index.incrementAndGet()); + }, true); - Scoreboard.WriteOrdered("Rank", col + score.Player.getName(), i+1, true); - } - - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java index 0b6764bb5..5e43f436e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java @@ -5,10 +5,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Set; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; -import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -40,9 +38,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.dragonescape.kits.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -399,7 +395,7 @@ public class DragonEscapeTeams extends TeamGame return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); HashMap scores = GetTeamScores(); for (GameTeam team : scores.keySet()) @@ -407,12 +403,12 @@ public class DragonEscapeTeams extends TeamGame //Time int score = scores.get(team).intValue(); - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetColor() + team.GetName()); - Scoreboard.Write(score + "" + team.GetColor() + " Score"); + Scoreboard.writeNewLine(); + Scoreboard.write(team.GetColor() + team.GetName()); + Scoreboard.write(score + "" + team.GetColor() + " Score"); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/DragonsTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/DragonsTeams.java index 9743a5aaf..b088fe019 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/DragonsTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/DragonsTeams.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; -import org.bukkit.Bukkit; import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.Sound; @@ -15,7 +14,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; @@ -28,7 +26,6 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.dragons.kits.*; @@ -258,19 +255,19 @@ public class DragonsTeams extends TeamGame private void WriteScoreboard() { //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : _teamScore.keySet()) { //Time int seconds = _teamScore.get(team); - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetColor() + team.GetName()); - Scoreboard.Write(team.GetColor() + "" + seconds + " Seconds"); + Scoreboard.writeNewLine(); + Scoreboard.write(team.GetColor() + team.GetName()); + Scoreboard.write(team.GetColor() + "" + seconds + " Seconds"); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 728e12e57..8ec8474f7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -1,5 +1,32 @@ package nautilus.game.arcade.game.games.draw; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; + +import mineplex.core.common.Pair; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -34,31 +61,6 @@ import nautilus.game.arcade.stats.DrawGuessStatTracker; import nautilus.game.arcade.stats.KeenEyeStatTracker; import nautilus.game.arcade.stats.MrSquiggleStatTracker; import nautilus.game.arcade.stats.PureLuckStatTracker; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; public class Draw extends SoloGame { @@ -991,31 +993,29 @@ public class Draw extends SoloGame SortScores(); //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Rounds - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cWhite + "Round:"); - Scoreboard.Write(C.cYellow + Math.min(_roundCount+1, _roundMax) + " of " + _roundMax); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cWhite + "Round:"); + Scoreboard.write(C.cYellow + Math.min(_roundCount+1, _roundMax) + " of " + _roundMax); //Drawer - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cWhite + "Drawer:"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cWhite + "Drawer:"); if (_round == null) - Scoreboard.Write(C.cYellow + "None"); + Scoreboard.write(C.cYellow + "None"); else - Scoreboard.Write(C.cYellow + _round.Drawer.getName()); + Scoreboard.write(C.cYellow + _round.Drawer.getName()); //Scores - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cWhite + "Scores:"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cWhite + "Scores:"); + + + Scoreboard.writeGroup(_ranks, score -> Pair.create(C.cYellow + score.Player.getName(), (int) score.Score), true); - for (int i=0 ; i<_ranks.size() ; i++) - { - Scoreboard.WriteOrdered("Score", C.cYellow + _ranks.get(i).Player.getName(), (int)_ranks.get(i).Score, true); - } - - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java index 315e8c117..c2d56aebb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java @@ -50,9 +50,7 @@ public class EventGame extends Game { private GameHostManager _mps; - private String[] _sideText = new String[] { - " "," "," "," "," "," "," "," "," "," "," "," " - ," "," "," "}; + private String[] _sideText = new String[] {"","","","","","","","","","","","","","",""}; private boolean _doubleJump = false; private boolean _gadgetsEnabled = true; @@ -384,16 +382,14 @@ public class EventGame extends Game if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); - - Scoreboard.WriteBlank(); + Scoreboard.reset(); for (int i=_sideText.length-1 ; i>=0 ; i--) { - Scoreboard.Write(_sideText[i]); + Scoreboard.write(_sideText[i]); } - Scoreboard.Draw(); + Scoreboard.draw(); } //This re-enables cosmetic hotbar, because MPS disables it - temp fix until i find out whats disabling it repeatedly diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index 9f19b1475..0ceb25143 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -1147,7 +1147,7 @@ public class EventModule extends MiniPlugin int line = 0; try { - line = Integer.parseInt(args[1]); + line = Integer.parseInt(args[1]) - 1; } catch (Exception e) { @@ -1155,7 +1155,7 @@ public class EventModule extends MiniPlugin return; } - if (line < 1 || line > 14) + if (line < 0 || line > 14) { UtilPlayer.message(player, F.main("Scoreboard", "Invalid Line Number.")); return; @@ -1180,7 +1180,7 @@ public class EventModule extends MiniPlugin ((EventGame) Manager.GetGame()).getSideText()[line] = ChatColor.translateAlternateColorCodes('&', lineText); - UtilPlayer.message(player, F.main("Scoreboard", "Set Line " + F.elem(line+"") + " to " + F.elem(lineText) + ".")); + UtilPlayer.message(player, F.main("Scoreboard", "Set Line " + F.elem((line + 1)+"") + " to " + F.elem(lineText) + ".")); return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index 65eaad951..73d5fc452 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.evolution; import com.google.common.collect.Maps; +import mineplex.core.common.Pair; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -810,19 +811,16 @@ public class Evolution extends SoloGame if (event.getType() != UpdateType.FAST) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellow + C.Bold + "First to " + _mobKits.size()); + Scoreboard.write(C.cYellow + C.Bold + "First to " + _mobKits.size()); - Scoreboard.WriteBlank(); - - for (Player player : GetPlayers(true)) - { - Scoreboard.WriteOrdered("Score", C.cGreen + player.getName(), getScore(player), true); - } + Scoreboard.writeNewLine(); + + Scoreboard.writeGroup(GetPlayers(true), player -> Pair.create(C.cGreen + player.getName(), getScore(player)), true); - Scoreboard.Draw(); + Scoreboard.draw(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitGolem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitGolem.java index 2e52e42a9..85c2e7c9d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitGolem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitGolem.java @@ -41,8 +41,7 @@ public class KitGolem extends EvoKit DisguiseIronGolem disguise = new DisguiseIronGolem(player); disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); disguise.setCustomNameVisible(true); - - Manager.GetDisguise().undisguise(player); + Manager.GetDisguise().disguise(disguise); player.getWorld().playSound(player.getLocation(), Sound.IRONGOLEM_DEATH, 4f, 1f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 020f3fddb..59dd19d6c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -239,7 +239,7 @@ public class Gladiators extends SoloGame // Zombie hit one PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).GetEntityId(); + packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).getEntityId(); packet.b = 0; for (Player p : UtilServer.getPlayers()) @@ -259,7 +259,7 @@ public class Gladiators extends SoloGame // Zombie hit two PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).GetEntityId(); + packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).getEntityId(); packet.b = 0; for (Player p : UtilServer.getPlayers()) @@ -958,10 +958,10 @@ public class Gladiators extends SoloGame if (GetState() != GameState.Live) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + C.Bold + "Status"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + C.Bold + "Status"); if (_roundState == RoundState.FIGHTING) { double start = -1D; @@ -976,34 +976,34 @@ public class Gladiators extends SoloGame double number = ((start + 60000) - System.currentTimeMillis()); int time = (int)(number / 1000.0 + 0.5); if (time < 0) - Scoreboard.Write("Poison Active"); + Scoreboard.write("Poison Active"); else - Scoreboard.Write("Poison in " + time + "s"); + Scoreboard.write("Poison in " + time + "s"); } else { - Scoreboard.Write(_roundState.getScoreboardText()); + Scoreboard.write(_roundState.getScoreboardText()); } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cAqua + C.Bold + "Matches Left"); - Scoreboard.Write(C.cWhite + getMatchesFighting()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cAqua + C.Bold + "Matches Left"); + Scoreboard.write(C.cWhite + getMatchesFighting()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Players"); if (GetPlayers(true).size() > 7) { - Scoreboard.Write(C.cWhite + GetPlayers(true).size() + " Players"); + Scoreboard.write(C.cWhite + GetPlayers(true).size() + " Players"); } else { for (Player p : GetPlayers(true)) { - Scoreboard.Write(C.cWhite + p.getName()); + Scoreboard.write(C.cWhite + p.getName()); } } - Scoreboard.Draw(); + Scoreboard.draw(); } private int getMatchesFighting() @@ -1096,20 +1096,20 @@ public class Gladiators extends SoloGame if (e.GetState() != GameState.End) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + C.Bold + "Status"); - Scoreboard.Write(C.cWhite + "Ended"); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cAqua + C.Bold + "Matches Left"); - Scoreboard.Write(C.cWhite + "0"); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + C.Bold + "Status"); + Scoreboard.write(C.cWhite + "Ended"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cAqua + C.Bold + "Matches Left"); + Scoreboard.write(C.cWhite + "0"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Players"); if (getWinners() != null && !getWinners().isEmpty()) - Scoreboard.Write(C.cWhite + getWinners().get(0).getName()); + Scoreboard.write(C.cWhite + getWinners().get(0).getName()); - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java index 29f27d376..3f4c10226 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java @@ -537,34 +537,34 @@ public class Halloween extends SoloGame return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Rounds - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Wave"); - Scoreboard.Write(Math.min(6, _wave+1) + " of 6"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Wave"); + Scoreboard.write(Math.min(6, _wave+1) + " of 6"); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Monsters"); - Scoreboard.Write("" + _mobs.size()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Monsters"); + Scoreboard.write("" + _mobs.size()); //Drawer - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Players"); if (GetPlayers(true).size() < 8) { for (Player player : GetPlayers(true)) { - Scoreboard.Write(C.cWhite + player.getName()); + Scoreboard.write(C.cWhite + player.getName()); } } else { - Scoreboard.Write(GetPlayers(true).size() + " Alive"); + Scoreboard.write(GetPlayers(true).size() + " Alive"); } - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index c21d4e824..ac294cd0b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -1,5 +1,7 @@ package nautilus.game.arcade.game.games.hideseek; +import mineplex.core.Managers; +import mineplex.core.antihack.AntiHack; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -1098,8 +1100,6 @@ public class HideSeek extends TeamGame SetPlayerTeam(player, _seekers, true); - Manager.GetDisguise().undisguise(player); - // Remove Form Form form = _forms.remove(player); if (form != null) @@ -1267,32 +1267,32 @@ public class HideSeek extends TeamGame private void WriteScoreboard() { // Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : this.GetTeamList()) { - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + Scoreboard.writeNewLine(); + Scoreboard.write(team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); } if (!_started) { long timeLeft = _hideTime - (System.currentTimeMillis() - GetStateTime()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Hide Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Hide Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); } else { long timeLeft = _gameTime - (System.currentTimeMillis() - GetStateTime() - _hideTime); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Seek Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Seek Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java index d4c95961f..aba4c1463 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import mineplex.core.common.Pair; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilGear; @@ -29,7 +30,6 @@ import nautilus.game.arcade.game.games.milkcow.kits.KitSturdyFarmhand; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.Navigation; import net.minecraft.server.v1_8_R3.NavigationAbstract; import org.bukkit.Bukkit; @@ -95,7 +95,7 @@ public class MilkCow extends SoloGame this.CompassEnabled = true; this.DeathOut = false; - _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Milk", "dummy"); + _scoreObj = Scoreboard.getScoreboard().registerNewObjective("Milk", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); registerChatStats( @@ -487,21 +487,21 @@ public class MilkCow extends SoloGame return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - for (Player player : GetPlayers(true)) + Scoreboard.writeGroup(GetPlayers(true), player -> { int score = (int)GetScore(player); GameTeam team = GetTeam(player); - if (team == null) continue; - - Scoreboard.WriteOrdered("Milk", team.GetColor() + player.getName(), score, true); - } - - Scoreboard.Draw(); + if (team == null) return null; + + return Pair.create(team.GetColor() + player.getName(), score); + }, true); + + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 4ec6f2edd..981dd22c5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -482,14 +482,14 @@ public class MinecraftLeague extends RankedTeamGame public void writeEndSb(String winner) { - Scoreboard.Reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cDRedB + GetName()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGoldB + "Winner:"); - Scoreboard.Write(winner); + Scoreboard.reset(); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cDRedB + GetName()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGoldB + "Winner:"); + Scoreboard.write(winner); - Scoreboard.Draw(); + Scoreboard.draw(); } private void scoreboardWrite(boolean sec) @@ -501,23 +501,23 @@ public class MinecraftLeague extends RankedTeamGame { if (!sec) return; - Scoreboard.Reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cDRedB + GetName()); - Scoreboard.WriteBlank(); + Scoreboard.reset(); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cDRedB + GetName()); + Scoreboard.writeNewLine(); if (_yellow) { - Scoreboard.Write(C.cYellow + "Loading..."); + Scoreboard.write(C.cYellow + "Loading..."); _yellow = false; } else { - Scoreboard.Write("Loading..."); + Scoreboard.write("Loading..."); _yellow = true; } - Scoreboard.Draw(); + Scoreboard.draw(); return; } @@ -553,41 +553,41 @@ public class MinecraftLeague extends RankedTeamGame _liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0); - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRedB + "Red Team"); - Scoreboard.Write("Towers: " + reds); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRedB + "Red Team"); + Scoreboard.write("Towers: " + reds); for (String s : _vman.getSelected().getTeamScoreboardAdditions(red)) { - Scoreboard.Write(s); + Scoreboard.write(s); } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cAquaB + "Blue Team"); - Scoreboard.Write("Towers: " + blues); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cAquaB + "Blue Team"); + Scoreboard.write("Towers: " + blues); for (String s : _vman.getSelected().getTeamScoreboardAdditions(blue)) { - Scoreboard.Write(s); + Scoreboard.write(s); } int i = 1; for (ExtraScoreboardData sbD : ExtraSb.keySet()) { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); sbD.write(); if (i < ExtraSb.size()) - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); i++; } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellowB + "Time Elapsed"); - Scoreboard.Write(UtilTime.MakeStr(_liveTime)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellowB + "Time Elapsed"); + Scoreboard.write(UtilTime.MakeStr(_liveTime)); if (OverTime) - Scoreboard.Write(C.cDRedB + "Overtime"); + Scoreboard.write(C.cDRedB + "Overtime"); - Scoreboard.Draw(); + Scoreboard.draw(); } /*@Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java index 0b655ae09..d4a1c8f85 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java @@ -30,13 +30,13 @@ public class WitherSkeletonTimer extends ExtraScoreboardData public void write() { - Scoreboard.Write(C.cYellowB + "Wither Skeleton Spawn"); + Scoreboard.write(C.cYellowB + "Wither Skeleton Spawn"); if (_frozen != -1) { if (_frozen == -2) - Scoreboard.Write("WITHER ALIVE"); + Scoreboard.write("WITHER ALIVE"); else - Scoreboard.Write(_frozen + " Seconds"); + Scoreboard.write(_frozen + " Seconds"); } else { @@ -44,7 +44,7 @@ public class WitherSkeletonTimer extends ExtraScoreboardData if (_end - System.currentTimeMillis() > 0) seconds = UtilTime.convert(_end - System.currentTimeMillis(), TimeUnit.MILLISECONDS, TimeUnit.SECONDS); - Scoreboard.Write(UtilTime.MakeStr(UtilTime.convert(seconds, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))); + Scoreboard.write(UtilTime.MakeStr(UtilTime.convert(seconds, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java index 862ead445..6c7fa3b4e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java @@ -13,7 +13,6 @@ import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -157,7 +156,7 @@ public class Minestrike extends TeamGame this.DontAllowOverfill = true; - _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("HP", "dummy"); + _scoreObj = Scoreboard.getScoreboard().registerNewObjective("HP", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); this._help = new String[] @@ -225,7 +224,7 @@ public class Minestrike extends TeamGame return; System.out.println("Hiding Scoreboard Nametags for Other Teams"); - for (Team curTeam : Scoreboard.GetScoreboard().getTeams()) + for (Team curTeam : Scoreboard.getScoreboard().getTeams()) { curTeam.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); //UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), @@ -939,7 +938,7 @@ public class Minestrike extends TeamGame //Update Scoreboard Teams for (GameTeam team : GetTeamList()) for (Player teamMember : team.GetPlayers(true)) - GetScoreboard().SetPlayerTeam(teamMember, team.GetName().toUpperCase()); + GetScoreboard().setPlayerTeam(teamMember, team); //Alternate Bullets if (_gunModule.BulletAlternate) @@ -1114,45 +1113,45 @@ public class Minestrike extends TeamGame public void drawScoreboard() { - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : this.GetTeamList()) { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(getScore(team) + " " + team.GetColor() + C.Bold + team.GetName()); + Scoreboard.write(getScore(team) + " " + team.GetColor() + C.Bold + team.GetName()); //Scoreboard.Write(team.GetColor() + "" + getScore(team) + "" + " Wins" + team.GetColor()); - Scoreboard.Write(team.GetPlayers(true).size() + "" + " Alive" + team.GetColor()); + Scoreboard.write(team.GetPlayers(true).size() + "" + " Alive" + team.GetColor()); } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGold + C.Bold + "Playing To"); - Scoreboard.Write(_roundsToWin + " Wins"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGold + C.Bold + "Playing To"); + Scoreboard.write(_roundsToWin + " Wins"); if (InProgress()) { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (_gunModule.getBomb() == null) { - Scoreboard.Write(C.cGold + C.Bold + "Time Left"); - Scoreboard.Write(UtilTime.MakeStr(_roundTime - (System.currentTimeMillis() - this.GetStateTime()), 1)); + Scoreboard.write(C.cGold + C.Bold + "Time Left"); + Scoreboard.write(UtilTime.MakeStr(_roundTime - (System.currentTimeMillis() - this.GetStateTime()), 1)); } else { if (_bombScoreboardFlash) - Scoreboard.Write(C.cRed + C.Bold + "Bomb Active"); + Scoreboard.write(C.cRed + C.Bold + "Bomb Active"); else - Scoreboard.Write(C.cWhite + C.Bold + "Bomb Active"); + Scoreboard.write(C.cWhite + C.Bold + "Bomb Active"); _bombScoreboardFlash = !_bombScoreboardFlash; } } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java index 87f40aa8d..3fed98d5d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import mineplex.core.common.Pair; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; @@ -462,7 +463,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown if (_lives.get(player) > 0) { Manager.Clear(player); - Scoreboard.SetPlayerTeam(player, _playerTeam.GetName().toUpperCase()); + Scoreboard.setPlayerTeam(player, _playerTeam); } } } @@ -1352,7 +1353,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown if (event.getType() != UpdateType.FAST) return; - Scoreboard.Reset(); + Scoreboard.reset(); if (getPlayersWithRemainingLives() >= GENERIC_SCOREBOARD_PLAYER_COUNT) { @@ -1363,7 +1364,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown displayDetailedScoreboard(); } - Scoreboard.Draw(); + Scoreboard.draw(); } private void displayGenericScoreboard() @@ -1376,76 +1377,70 @@ public class BawkBawkBattles extends TeamGame implements IThrown private void displayPlayerTotal() { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); - Scoreboard.Write(getPlayersWithRemainingLives() + " "); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Players"); + Scoreboard.write(getPlayersWithRemainingLives() + " "); } private void displayAlivePlayers() { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + C.Bold + "Alive"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + C.Bold + "Alive"); if (_settings.isChallengeStarted()) { int data = _challenge.getPlayersIn(false).size(); - Scoreboard.Write("" + data); + Scoreboard.write("" + data); } else { - Scoreboard.Write("-"); + Scoreboard.write("-"); } } private void displayCompletedPlayers() { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGold + C.Bold + "Completed"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGold + C.Bold + "Completed"); if (_settings.isChallengeStarted()) { int data = _challenge.getData().getCompletedPlayers().size(); - Scoreboard.Write("" + data); + Scoreboard.write("" + data); } else { - Scoreboard.Write("-"); + Scoreboard.write("-"); } } private void displayDeadPlayers() { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGray + C.Bold + "Dead"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGray + C.Bold + "Dead"); if (_settings.isChallengeStarted()) { int data = _challenge.getData().getLostPlayers().size(); - Scoreboard.Write("" + data); + Scoreboard.write("" + data); } else { - Scoreboard.Write("-"); + Scoreboard.write("-"); } } private void displayDetailedScoreboard() { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - for (Player player : super.GetPlayers(true)) // Use super.GetPlayers(true) to show players during chicken attack. + Scoreboard.writeGroup(super.GetPlayers(true), player -> { - displayPersonalScore(player); - } - } - - private void displayPersonalScore(Player player) - { - int lives = lives(player); - String state = definePlayerState(player); - String display = definePlayerDisplay(player.getName(), lives, state); - - Scoreboard.WriteOrdered("Lives Left", display, lives, true); + int lives = lives(player); + String state = definePlayerState(player); + String display = definePlayerDisplay(player.getName(), lives, state); + return Pair.create(display, lives); + }, true); } private String definePlayerDisplay(String name, int lives, String state) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/Challenge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/Challenge.java index 384ab9280..c6fdc6a31 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/Challenge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/Challenge.java @@ -329,7 +329,6 @@ public abstract class Challenge implements Listener if (lives <= 0 && alive > CHICKEN_ATTACK_CRITERIA) { - Host.GetScoreboard().ResetScore(player.getName()); Host.getChickenAttack().start(player); } else @@ -496,7 +495,6 @@ public abstract class Challenge implements Listener } Data.addCompletedPlayer(player); - Host.Manager.GetDisguise().undisguise(player); UtilPlayer.clearPotionEffects(player); UtilInv.Clear(player); } @@ -542,7 +540,6 @@ public abstract class Challenge implements Listener Host.showLivesLeft(player); player.playSound(player.getLocation(), Sound.NOTE_BASS, LOST_SOUND_VOLUME, LOST_SOUND_PITCH); - Host.Manager.GetDisguise().undisguise(player); UtilPlayer.clearPotionEffects(player); UtilInv.Clear(player); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeDogsVersusCats.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeDogsVersusCats.java index 86abbfedf..cea7b74e6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeDogsVersusCats.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeDogsVersusCats.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.mineware.challenge.type; import java.util.ArrayList; +import mineplex.core.disguise.disguises.DisguiseVillager; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; @@ -156,6 +157,15 @@ public class ChallengeDogsVersusCats extends TeamChallenge { _catScore = 0; _dogScore = 0; + + for (Player player : Host.GetPlayers(false)) + { + if (Host.getArcadeManager().GetDisguise().getActiveDisguise(player) instanceof DisguiseCat || + Host.getArcadeManager().GetDisguise().getActiveDisguise(player) instanceof DisguiseWolf) + { + Host.Manager.GetDisguise().undisguise(player); + } + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java index 311983f81..49037ba6f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java @@ -6,6 +6,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; +import mineplex.core.disguise.disguises.DisguiseVillager; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -114,6 +115,14 @@ public class ChallengeLavaRun extends Challenge _modifiedDelay = 0; _modifiedDelayMin = 0; _disappearingBlocks = 0; + + for (Player player : Host.GetPlayers(false)) + { + if (Host.getArcadeManager().GetDisguise().getActiveDisguise(player) instanceof DisguiseMagmaCube) + { + Host.Manager.GetDisguise().undisguise(player); + } + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeMilkACow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeMilkACow.java index d4fed513e..b1f43a0ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeMilkACow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeMilkACow.java @@ -174,6 +174,14 @@ public class ChallengeMilkACow extends Challenge implements NumberTracker cow.remove(); } + for (Player player : Host.GetPlayers(false)) + { + if (Host.getArcadeManager().GetDisguise().getActiveDisguise(player) instanceof DisguiseVillager) + { + Host.Manager.GetDisguise().undisguise(player); + } + } + _farmer.remove(); _farmer = null; _milkedCows.clear(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeZombieInfection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeZombieInfection.java index 2d7dd04fe..765bfda6c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeZombieInfection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeZombieInfection.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Set; +import mineplex.core.disguise.disguises.DisguiseVillager; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -268,6 +269,14 @@ public class ChallengeZombieInfection extends Challenge _zombie.spawn(); Host.CreatureAllow = false; + for (Player player : Host.GetPlayers(false)) + { + if (Host.getArcadeManager().GetDisguise().getActiveDisguise(player) instanceof DisguiseZombie) + { + Host.Manager.GetDisguise().undisguise(player); + } + } + _zombie.setSpeed(_defaultSpeed); _zombie.extinguish(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java index 02f34c55d..7599ab638 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java @@ -127,7 +127,7 @@ public class ChickenAttack DisguiseChicken disguise = new DisguiseChicken(player); disguise.setBaby(); - _host.Manager.GetDisguise().disguise(disguise, UtilServer.getPlayers()); + _host.Manager.GetDisguise().disguise(disguise); player.teleport(_host.GetSpectatorLocation()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/Maze.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/Maze.java index 3d1d29c40..1eef92624 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/Maze.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/Maze.java @@ -327,7 +327,7 @@ public class Maze implements Listener animation.b = 0; if (_host.Manager.GetDisguise().isDisguised(ent)) - animation.a = _host.Manager.GetDisguise().getDisguise(ent).GetEntityId(); + animation.a = _host.Manager.GetDisguise().getDisguise(ent).getEntityId(); for (Player cur : UtilServer.getPlayers()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/MonsterMaze.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/MonsterMaze.java index dc3538511..fadbfffa1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/MonsterMaze.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/MonsterMaze.java @@ -130,7 +130,7 @@ public class MonsterMaze extends SoloGame UtilTextMiddle.display("", C.cYellow + C.Bold + "Get to the Safe Pad!", 5, 40, 5); - for (Team team : GetScoreboard().GetScoreboard().getTeams()) + for (Team team : GetScoreboard().getScoreboard().getTeams()) team.setCanSeeFriendlyInvisibles(true); } else if(event.GetState() == GameState.Recruit) @@ -411,43 +411,43 @@ public class MonsterMaze extends SoloGame if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); + Scoreboard.write(C.cYellow + C.Bold + "Players"); if (GetPlayers(true).size() > 5) { - Scoreboard.Write(C.cWhite + GetPlayers(true).size() + " Alive"); + Scoreboard.write(C.cWhite + GetPlayers(true).size() + " Alive"); } else { for (Player p : GetPlayers(true)) { - Scoreboard.Write(C.cWhite + p.getName()); + Scoreboard.write(C.cWhite + p.getName()); } } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cGreen + C.Bold + "Safe Pad"); + Scoreboard.write(C.cGreen + C.Bold + "Safe Pad"); if (_maze.getSafePad() != null) { - Scoreboard.Write(C.cWhite + _maze.getPhaseTimer() + " Seconds"); + Scoreboard.write(C.cWhite + _maze.getPhaseTimer() + " Seconds"); } else { - Scoreboard.Write("None"); + Scoreboard.write("None"); } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cGold + C.Bold + "Stage"); + Scoreboard.write(C.cGold + C.Bold + "Stage"); - Scoreboard.Write(C.cWhite + getMaze().getCurrentSafePadCount()); + Scoreboard.write(C.cWhite + getMaze().getCurrentSafePadCount()); - Scoreboard.Draw(); + Scoreboard.draw(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/oldmineware/OldMineWare.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/oldmineware/OldMineWare.java index e127ed2aa..f550a929b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/oldmineware/OldMineWare.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/oldmineware/OldMineWare.java @@ -267,8 +267,6 @@ public class OldMineWare extends SoloGame player.playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f); player.damage(5000); - - Scoreboard.ResetScore(player.getName()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java index 20641932c..8fffdb878 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java @@ -144,7 +144,7 @@ public class Paintball extends TeamGame public void onNameTag(GameStateChangeEvent event) { if (event.GetState() == GameState.Prepare) - for (Team team : Scoreboard.GetScoreboard().getTeams()) + for (Team team : Scoreboard.getScoreboard().getTeams()) team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java index eb581769f..7ecd12499 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; + +import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -102,7 +104,7 @@ public class Quiver extends SoloGame this.DeathSpectateSecs = 1; - _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Kills", "dummy"); + _scoreObj = Scoreboard.getScoreboard().registerNewObjective("Kills", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); } @@ -306,17 +308,13 @@ public class Quiver extends SoloGame SortScores(); //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - //Write New - for (QuiverScore score : _ranks) - { - Scoreboard.WriteOrdered("Score", C.cGreen + score.Player.getName(), score.Kills, true); - } + Scoreboard.writeGroup(_ranks, score -> Pair.create(C.cGreen + score.Player.getName(), score.Kills), true); - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java index 4626d4f24..7da21409b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java @@ -192,22 +192,22 @@ public class QuiverTeams extends TeamGame private void WriteScoreboard() { //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : _teamKills.keySet()) { int kills = _teamKills.get(team); - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetColor() + team.GetName()); - Scoreboard.Write(kills + "" + team.GetColor() + " Kills"); + Scoreboard.writeNewLine(); + Scoreboard.write(team.GetColor() + team.GetName()); + Scoreboard.write(kills + "" + team.GetColor() + " Kills"); } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.Bold + "First To"); - Scoreboard.Write(C.cGold + C.Bold + _reqKills + " Kills"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.Bold + "First To"); + Scoreboard.write(C.cGold + C.Bold + _reqKills + " Kills"); - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java index 5fc2ba8df..052b288b8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java @@ -390,9 +390,9 @@ public class SearchAndDestroy extends TeamGame private void drawScoreboard() { - GetScoreboard().Reset(); + GetScoreboard().reset(); - GetScoreboard().WriteBlank(); + GetScoreboard().writeNewLine(); ArrayList aliveTeams = new ArrayList(); for (GameTeam team : GetTeamList()) { @@ -411,8 +411,8 @@ public class SearchAndDestroy extends TeamGame GameTeam team = itel.next(); if (!team.IsTeamAlive()) continue; - GetScoreboard().Write(team.GetColor() + C.Bold + team.GetName() + " Team"); - GetScoreboard().Write(team.GetPlayers(true).size() + " alive"); + GetScoreboard().write(team.GetColor() + C.Bold + team.GetName() + " Team"); + GetScoreboard().write(team.GetPlayers(true).size() + " alive"); int bombsArmed = 0; for (TeamBomb bomb : bombs) @@ -424,20 +424,20 @@ public class SearchAndDestroy extends TeamGame } if (bombsArmed > 0) { - GetScoreboard().Write(team.GetColor() + "" + bombsArmed + " Bomb" + (bombsArmed > 1 ? "s" : "") + " Armed"); + GetScoreboard().write(team.GetColor() + "" + bombsArmed + " Bomb" + (bombsArmed > 1 ? "s" : "") + " Armed"); } else { - GetScoreboard().Write("Bombs Safe"); + GetScoreboard().write("Bombs Safe"); } if (itel.hasNext()) { - GetScoreboard().WriteBlank(); + GetScoreboard().writeNewLine(); } } - GetScoreboard().Draw(); + GetScoreboard().draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java index 2f56ba572..5274a0fc1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import mineplex.core.common.Pair; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -596,34 +597,30 @@ public class SheepGame extends TeamGame return; //Wipe Last - Scoreboard.Reset(); - Scoreboard.WriteBlank(); + Scoreboard.reset(); + Scoreboard.writeNewLine(); - //Write New - for (GameTeam team : _sheepPens.keySet()) + Scoreboard.writeGroup(_sheepPens.keySet(), team -> { - int score = getSheepCount(team); - - Scoreboard.WriteOrdered("Sheep", team.GetColor() + team.GetName(), score, true); - - _teamScore.put(team, score); - } + _teamScore.put(team, getSheepCount(team)); + return Pair.create(team.GetColor() + team.GetName(), getSheepCount(team)); + }, true); if (!IsLive()) return; - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Next Sheep"); - Scoreboard.Write(UtilTime.MakeStr(_sheepDelay - (System.currentTimeMillis() - _sheepTimer), 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Next Sheep"); + Scoreboard.write(UtilTime.MakeStr(_sheepDelay - (System.currentTimeMillis() - _sheepTimer), 0)); long time = _gameTime - (System.currentTimeMillis() - this.GetStateTime()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Time Left"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, time), 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Time Left"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, time), 0)); - Scoreboard.Draw(); + Scoreboard.draw(); } public void GetTeamPen(SheepData data) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java index 207ee85e8..65383badd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java @@ -99,51 +99,51 @@ public class SoloSkywars extends Skywars if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); GameTeam team = GetTeamList().get(0); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Players"); if (team.GetPlayers(true).size() > 4) { - Scoreboard.Write("" + team.GetPlayers(true).size()); + Scoreboard.write("" + team.GetPlayers(true).size()); } else { for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(C.cWhite + player.getName()); + Scoreboard.write(C.cWhite + player.getName()); } } if (IsLive()) { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Time"); - Scoreboard.Write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Time"); + Scoreboard.write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); - Scoreboard.WriteBlank(); - Scoreboard.Write((this.getTnTGen().active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); - Scoreboard.Write(this.getTnTGen().getScoreboardInfo()); + Scoreboard.writeNewLine(); + Scoreboard.write((this.getTnTGen().active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); + Scoreboard.write(this.getTnTGen().getScoreboardInfo()); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (UtilTime.elapsed(GetStateTime(), this.getCrumbleTime())) { - Scoreboard.Write(C.cRed + C.Bold + "Map Crumble"); - Scoreboard.Write("Active"); + Scoreboard.write(C.cRed + C.Bold + "Map Crumble"); + Scoreboard.write("Active"); } else { - Scoreboard.Write(C.cGreen + C.Bold + "Map Crumble"); - Scoreboard.Write(UtilTime.convertString(this.getCrumbleTime() - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); + Scoreboard.write(C.cGreen + C.Bold + "Map Crumble"); + Scoreboard.write(UtilTime.convertString(this.getCrumbleTime() - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); } } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java index 2b470ce33..33ef1b2a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java @@ -1,24 +1,16 @@ package nautilus.game.arcade.game.games.skywars; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.modules.TeamModule; import nautilus.game.arcade.stats.DeathBomberStatTracker; import nautilus.game.arcade.stats.SkywarsKillZombieStatTracker; @@ -26,16 +18,8 @@ import nautilus.game.arcade.stats.SkywarsTNTStatTracker; import nautilus.game.arcade.stats.WinWithoutOpeningChestStatTracker; import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; public class TeamSkywars extends Skywars { @@ -96,10 +80,10 @@ public class TeamSkywars extends Skywars if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Teams"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Teams"); ArrayList alive = new ArrayList(); for (GameTeam team : GetTeamList()) @@ -114,7 +98,7 @@ public class TeamSkywars extends Skywars { for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(team.GetColor() + player.getName()); + Scoreboard.write(team.GetColor() + player.getName()); } } } @@ -122,39 +106,39 @@ public class TeamSkywars extends Skywars { for (GameTeam team : alive) { - Scoreboard.Write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + Scoreboard.write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); } } else { - Scoreboard.Write(C.cWhite + alive.size() + " Alive"); + Scoreboard.write(C.cWhite + alive.size() + " Alive"); } if (IsLive()) { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Time"); - Scoreboard.Write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Time"); + Scoreboard.write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); - Scoreboard.WriteBlank(); - Scoreboard.Write((this.getTnTGen().active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); - Scoreboard.Write(this.getTnTGen().getScoreboardInfo()); + Scoreboard.writeNewLine(); + Scoreboard.write((this.getTnTGen().active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); + Scoreboard.write(this.getTnTGen().getScoreboardInfo()); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (UtilTime.elapsed(GetStateTime(), this.getCrumbleTime())) { - Scoreboard.Write(C.cRed + C.Bold + "Map Crumble"); - Scoreboard.Write("Active"); + Scoreboard.write(C.cRed + C.Bold + "Map Crumble"); + Scoreboard.write("Active"); } else { - Scoreboard.Write(C.cGreen + C.Bold + "Map Crumble"); - Scoreboard.Write(UtilTime.convertString(this.getCrumbleTime() - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); + Scoreboard.write(C.cGreen + C.Bold + "Map Crumble"); + Scoreboard.write(UtilTime.convertString(this.getCrumbleTime() - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); } } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/UHCSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/UHCSkywars.java index b6e016af5..1cbc14f81 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/UHCSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/UHCSkywars.java @@ -13,7 +13,6 @@ import org.bukkit.scoreboard.Objective; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.AbsorptionFix; import nautilus.game.arcade.game.games.skywars.SoloSkywars; @@ -39,7 +38,7 @@ public class UHCSkywars extends SoloSkywars { if(event.GetState() == GameState.Prepare) { - Objective objective = Scoreboard.GetScoreboard().registerNewObjective("Health", "health"); + Objective objective = Scoreboard.getScoreboard().registerNewObjective("Health", "health"); objective.setDisplaySlot(DisplaySlot.PLAYER_LIST); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java index 22af827c9..478341edb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import mineplex.core.common.Pair; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -16,7 +17,6 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.FreeKitWinStatTracker; import nautilus.game.arcade.stats.KillFastStatTracker; @@ -93,24 +93,23 @@ public class SoloSuperSmash extends SuperSmash return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); if (GetPlayers(true).size() > 14) { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + "Players Alive"); - Scoreboard.Write(GetPlayers(true).size() + " "); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + "Players Alive"); + Scoreboard.write(GetPlayers(true).size() + " "); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Players Dead"); - Scoreboard.Write((GetPlayers(false).size() - GetPlayers(true).size()) + " "); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRed + "Players Dead"); + Scoreboard.write((GetPlayers(false).size() - GetPlayers(true).size()) + " "); } else { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - //Write New - for (Player player : GetPlayers(true)) + Scoreboard.writeGroup(GetPlayers(true), player -> { int lives = GetLives(player); @@ -121,13 +120,13 @@ public class SoloSuperSmash extends SuperSmash else if (lives == 1) out = C.cRed + player.getName(); else if (lives == 0) out = C.cRed + player.getName(); else - continue; + return null; - Scoreboard.WriteOrdered("Lives", out, lives, true); - } + return Pair.create(out, lives); + }, true); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java index 3fb05c19c..7d560c10a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java @@ -1,19 +1,13 @@ package nautilus.game.arcade.game.games.smash; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.modules.TeamModule; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -23,14 +17,8 @@ import nautilus.game.arcade.stats.OneVThreeStatTracker; import nautilus.game.arcade.stats.RecoveryMasterStatTracker; import nautilus.game.arcade.stats.WinWithoutDyingStatTracker; -import org.bukkit.ChatColor; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; public class TeamSuperSmash extends SuperSmash { @@ -95,8 +83,8 @@ public class TeamSuperSmash extends SuperSmash } //Wipe Last - Scoreboard.Reset(); - Scoreboard.WriteBlank(); + Scoreboard.reset(); + Scoreboard.writeNewLine(); if (GetPlayers(true).size() < 16) { @@ -107,7 +95,7 @@ public class TeamSuperSmash extends SuperSmash { int lives = GetLives(player); - Scoreboard.Write(C.cWhite + lives + " " + team.GetColor() + player.getName()); + Scoreboard.write(C.cWhite + lives + " " + team.GetColor() + player.getName()); } } } @@ -122,16 +110,16 @@ public class TeamSuperSmash extends SuperSmash lives += GetLives(player); } - Scoreboard.Write(C.cWhite + lives + " " + team.GetColor() + team.GetName()); + Scoreboard.write(C.cWhite + lives + " " + team.GetColor() + team.GetName()); } } else { - Scoreboard.Write(C.cYellow + C.Bold + "Teams Alive"); - Scoreboard.Write(C.cWhite + alive.size()); + Scoreboard.write(C.cYellow + C.Bold + "Teams Alive"); + Scoreboard.write(C.cWhite + alive.size()); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java index 0c19539cf..362c4b4c4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.sneakyassassins; +import mineplex.core.common.Pair; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; @@ -209,47 +210,47 @@ public class SneakyAssassins extends SoloGame if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + if (GetState() == GameState.End || GetState() == GameState.Dead) + return; - Scoreboard.WriteBlank(); + Scoreboard.reset(); + + Scoreboard.writeNewLine(); GameTeam team = GetTeamList().get(0); if (team.GetPlayers(false).size() < 13) { - for (Player player : team.GetPlayers(false)) + Scoreboard.writeGroup(team.GetPlayers(false), player -> { if (team.IsAlive(player)) { - Scoreboard.WriteOrdered("Powerups", C.cGreen + player.getName(), getPowerUpManager().getPowerUpCount(player), true); + return Pair.create(C.cGreen + player.getName(), getPowerUpManager().getPowerUpCount(player)); } else { - Scoreboard.WriteOrdered("Powerups", C.cGray + player.getName(), getPowerUpManager().getPowerUpCount(player), true); + return Pair.create(C.cGray + player.getName(), getPowerUpManager().getPowerUpCount(player)); } - } + }, true); } else if (team.GetPlayers(true).size() < 13) { - for (Player player : team.GetPlayers(true)) - { - Scoreboard.WriteOrdered("Powerups", C.cGreen + player.getName(), getPowerUpManager().getPowerUpCount(player), true); - } + Scoreboard.writeGroup(team.GetPlayers(true), player -> Pair.create(C.cGreen + player.getName(), getPowerUpManager().getPowerUpCount(player)), true); } else { - Scoreboard.Write(C.cGreen + "Players Alive"); - Scoreboard.Write("" + team.GetPlayers(true).size()); + Scoreboard.write(C.cGreen + "Players Alive"); + Scoreboard.write("" + team.GetPlayers(true).size()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Players Dead"); - Scoreboard.Write("" + (team.GetPlayers(false).size() - team.GetPlayers(true).size())); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRed + "Players Dead"); + Scoreboard.write("" + (team.GetPlayers(false).size() - team.GetPlayers(true).size())); } - GetScoreboard().WriteBlank(); - GetScoreboard().Write(C.cYellow + "Player Reveal"); - GetScoreboard().Write(String.valueOf(Math.max(0, _revealCountdown)) + (_revealCountdown == 1 ? " Second" : " Seconds")); - GetScoreboard().Draw(); + GetScoreboard().writeNewLine(); + GetScoreboard().write(C.cYellow + "Player Reveal"); + GetScoreboard().write(String.valueOf(Math.max(0, _revealCountdown)) + (_revealCountdown == 1 ? " Second" : " Seconds")); + GetScoreboard().draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java index 9aaf3396d..c31ddd3b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java @@ -1,34 +1,27 @@ package nautilus.game.arcade.game.games.snowfight; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.Map.Entry; -import java.util.Set; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import mineplex.minecraft.game.core.explosion.CustomExplosion; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -40,13 +33,10 @@ import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman; import nautilus.game.arcade.kit.Kit; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.World; -import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; @@ -57,8 +47,6 @@ import org.bukkit.entity.Projectile; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockDamageEvent; -import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; @@ -67,8 +55,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; public class SnowFight extends TeamGame @@ -486,9 +472,9 @@ public class SnowFight extends TeamGame if (event.getType() != UpdateType.FAST) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if(GetPlayers(true).size() <= 8) { for (GameTeam team : this.GetTeamList()) @@ -498,19 +484,19 @@ public class SnowFight extends TeamGame for(Player player : team.GetPlayers(true)) { - Scoreboard.Write(team.GetColor() + player.getName()); + Scoreboard.write(team.GetColor() + player.getName()); } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); } } else { for (GameTeam team : this.GetTeamList()) { - Scoreboard.Write(team.GetColor() + C.Bold + team.GetName()); - Scoreboard.Write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); - Scoreboard.WriteBlank(); + Scoreboard.write(team.GetColor() + C.Bold + team.GetName()); + Scoreboard.write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); + Scoreboard.writeNewLine(); } } @@ -520,17 +506,17 @@ public class SnowFight extends TeamGame { if (time > 0) { - Scoreboard.Write(C.cYellow + C.Bold + "Meteors in"); - Scoreboard.Write(UtilTime.MakeStr(time, 0)); + Scoreboard.write(C.cYellow + C.Bold + "Meteors in"); + Scoreboard.write(UtilTime.MakeStr(time, 0)); } else { - Scoreboard.Write(C.cGold + C.Bold + "Meteors!"); + Scoreboard.write(C.cGold + C.Bold + "Meteors!"); } } - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java index 0c02a2c71..c03f7f326 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java @@ -1807,23 +1807,23 @@ public class SpeedBuilders extends SoloGame if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellowB + "Build"); + Scoreboard.write(C.cYellowB + "Build"); if (_currentBuild == null) - Scoreboard.Write("(None)"); + Scoreboard.write("(None)"); else - Scoreboard.Write(C.cWhite + _currentBuild.BuildText); + Scoreboard.write(C.cWhite + _currentBuild.BuildText); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellowB + "Round"); - Scoreboard.Write("" + _roundsPlayed); + Scoreboard.write(C.cYellowB + "Round"); + Scoreboard.write("" + _roundsPlayed); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); List playersAlive = GetTeamList().get(0).GetPlayers(true); @@ -1832,19 +1832,19 @@ public class SpeedBuilders extends SoloGame if (GetTeamList().size() > 1) playersDead.addAll(GetTeamList().get(1).GetPlayers(false)); - Scoreboard.Write(C.cYellowB + "Players"); + Scoreboard.write(C.cYellowB + "Players"); for (Player player : playersAlive) { - Scoreboard.Write(player.getName()); + Scoreboard.write(player.getName()); } for (Player player : playersDead) { - Scoreboard.Write(C.cDGray + player.getName()); + Scoreboard.write(C.cDGray + player.getName()); } - Scoreboard.Draw(); + Scoreboard.draw(); } public Location getJudgeSpawn() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java index a77b8817b..dfb29abb3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java @@ -2,10 +2,9 @@ package nautilus.game.arcade.game.games.squidshooter; import java.util.ArrayList; -import org.bukkit.Bukkit; +import mineplex.core.common.Pair; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilEnt; @@ -15,7 +14,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.quiver.QuiverScore; import nautilus.game.arcade.game.games.squidshooter.kits.*; @@ -112,13 +110,11 @@ public class SquidShooter extends SoloGame SortScores(); //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - //Write New - for (QuiverScore score : _ranks) - Scoreboard.WriteOrdered("Kills", C.cGreen + score.Player.getName(), score.Kills, true); + Scoreboard.writeGroup(_ranks, score -> Pair.create(C.cGreen + score.Player.getName(), score.Kills), true); - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java index b97097648..d6e8b49a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java @@ -105,50 +105,50 @@ public class SoloSurvivalGames extends SurvivalGames if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); GameTeam team = GetTeamList().get(0); - Scoreboard.Write(C.cGreen + C.Bold + "Time"); - Scoreboard.Write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); + Scoreboard.write(C.cGreen + C.Bold + "Time"); + Scoreboard.write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellow + C.Bold + "Tributes"); + Scoreboard.write(C.cYellow + C.Bold + "Tributes"); if (team.GetPlayers(true).size() > 7) { - Scoreboard.Write("" + team.GetPlayers(true).size()); + Scoreboard.write("" + team.GetPlayers(true).size()); } else { for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(C.cWhite + player.getName()); + Scoreboard.write(C.cWhite + player.getName()); } } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (this.getChestRefillTime() > 0 && this.getDeathMatchTime() > 60) { - Scoreboard.Write(C.cGold + C.Bold + "Chest Refill"); - Scoreboard.Write(UtilTime.convertString(this.getChestRefillTime() * 1000, 0, TimeUnit.FIT)); + Scoreboard.write(C.cGold + C.Bold + "Chest Refill"); + Scoreboard.write(UtilTime.convertString(this.getChestRefillTime() * 1000, 0, TimeUnit.FIT)); } else if (this.getDeathMatchTime() > 0) { - Scoreboard.Write(C.cRed + C.Bold + "Deathmatch"); - Scoreboard.Write(UtilTime.convertString( + Scoreboard.write(C.cRed + C.Bold + "Deathmatch"); + Scoreboard.write(UtilTime.convertString( Math.min(this.getDeathMatchTime(), this.isDeathMatchTeleported() ? 10 : this.getDeathMatchTime()) * 1000, 0, TimeUnit.FIT)); } else { - Scoreboard.Write(C.cRed + C.Bold + "Game End"); - Scoreboard.Write(UtilTime.convertString(Math.max(0, this.getGameEndTime()) * 1000, 0, TimeUnit.FIT)); + Scoreboard.write(C.cRed + C.Bold + "Game End"); + Scoreboard.write(UtilTime.convertString(Math.max(0, this.getGameEndTime()) * 1000, 0, TimeUnit.FIT)); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index ea5d5e663..021f988ea 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.survivalgames; import java.lang.reflect.Field; import java.util.*; +import org.apache.commons.lang.StringUtils; import org.bukkit.*; import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; @@ -13,6 +14,7 @@ import org.bukkit.block.DoubleChest; import org.bukkit.block.Furnace; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLargeFireball; +import org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftScoreboard; import org.bukkit.entity.Boat; import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; @@ -91,11 +93,6 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.survivalgames.kit.*; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; -import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker; -import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker; -import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker; -import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; import net.minecraft.server.v1_8_R3.EntityLargeFireball; import net.minecraft.server.v1_8_R3.PacketPlayOutScoreboardTeam; import net.minecraft.server.v1_8_R3.ScoreboardTeam; @@ -141,11 +138,9 @@ public abstract class SurvivalGames extends Game private boolean _informedDeathmatchCommand; private int _gameEndTime = 3 * 60; - private Field _packetTeam; - private int _chestRefillTime = 60 * 7; - public SurvivalGames(ArcadeManager manager, GameType type, String[] description) + public SurvivalGames(ArcadeManager manager, GameType type, String[] description) { this(manager, new Kit[] { @@ -172,20 +167,20 @@ public abstract class SurvivalGames extends Game new KitHorseman(manager), }, type, description); } - + public SurvivalGames(ArcadeManager manager, Kit[] kits, GameType type, - String[] description) + String[] description) { super(manager, type, kits, description); _help = new String[] - { - C.cGreen + "Use a Compass to find and kill enemies!", + { + C.cGreen + "Use a Compass to find and kill enemies!", - C.cGreen + "You lose Speed 2 at start of game if you attack.", + C.cGreen + "You lose Speed 2 at start of game if you attack.", - C.cAqua + "Avoid enemies who have better gear than you!" - }; + C.cAqua + "Avoid enemies who have better gear than you!" + }; // Manager.GetAntiStack().SetEnabled(false); @@ -248,19 +243,6 @@ public abstract class SurvivalGames extends Game // "chestsOpened"); setupLoot(); - - try - { - - _packetTeam = Class.forName( - "org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftTeam") - .getDeclaredField("team"); - _packetTeam.setAccessible(true); - } - catch (Exception ex) - { - ex.printStackTrace(); - } } @EventHandler @@ -345,52 +327,52 @@ public abstract class SurvivalGames extends Game switch (_chestRefillTime) { - case 0: + case 0: - Announce(C.cGold + C.Bold + "The chests have been refilled!", false); + Announce(C.cGold + C.Bold + "The chests have been refilled!", false); - for (Player player : Bukkit.getOnlinePlayers()) - { - player.playSound(player.getEyeLocation(), - Sound.IRONGOLEM_DEATH, 1000, 0); - } + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getEyeLocation(), + Sound.IRONGOLEM_DEATH, 1000, 0); + } - refillChests(); + refillChests(); - _chestRefillTime--; - break; - case 300: - case 180: - case 120: - case 60: - case 30: - case 15: - case 10: - case 5: - case 4: - case 3: - case 2: - case 1: + _chestRefillTime--; + break; + case 300: + case 180: + case 120: + case 60: + case 30: + case 15: + case 10: + case 5: + case 4: + case 3: + case 2: + case 1: - String time; + String time; - if (_chestRefillTime >= 60) - { - time = (_chestRefillTime / 60) + " minute" - + (_chestRefillTime > 60 ? "s" : ""); - } - else - { - time = _chestRefillTime + " second" - + (_chestRefillTime != 1 ? "s" : ""); - } + if (_chestRefillTime >= 60) + { + time = (_chestRefillTime / 60) + " minute" + + (_chestRefillTime > 60 ? "s" : ""); + } + else + { + time = _chestRefillTime + " second" + + (_chestRefillTime != 1 ? "s" : ""); + } - Announce(C.cGold + C.Bold + "The chests will be refilled in " - + time, false); + Announce(C.cGold + C.Bold + "The chests will be refilled in " + + time, false); - break; - default: - break; + break; + default: + break; } } @@ -413,7 +395,7 @@ public abstract class SurvivalGames extends Game { Block block = UtilBlock.getHighest(WorldData.World, WorldData.MinX - + UtilMath.r(xDiff), WorldData.MinZ + UtilMath.r(zDiff), + + UtilMath.r(xDiff), WorldData.MinZ + UtilMath.r(zDiff), ignore); if (!UtilBlock.airFoliage(block) @@ -587,7 +569,7 @@ public abstract class SurvivalGames extends Game || _deathMatchTime == 15 || _deathMatchTime == 10 || (_deathMatchTeleported ? _deathMatchTime <= 10 - : _deathMatchTime <= 5)) + : _deathMatchTime <= 5)) { if (_deathMatchTeleported && _deathMatchTime <= 10) { @@ -644,7 +626,7 @@ public abstract class SurvivalGames extends Game } _borderStartedMoving = System.currentTimeMillis(); - + WorldBorder border = WorldData.World.getWorldBorder(); border.setSize(_currentBorder * 2, 1); @@ -764,7 +746,7 @@ public abstract class SurvivalGames extends Game { item = buildCompass(5); } - + handlePickup(item); chest.getBlockInventory().setItem(UtilMath.r(27), item); @@ -802,46 +784,46 @@ public abstract class SurvivalGames extends Game { if (event.getEntity().getItemStack().hasItemMeta()) return; - + Material mat = event.getEntity().getItemStack().getType(); switch (mat) { - case SEEDS: - case SAPLING: - case VINE: - case LEAVES: - case LONG_GRASS: - case RED_ROSE: - case YELLOW_FLOWER: - case DEAD_BUSH: - case WATER_LILY: - event.setCancelled(true); - return; - case CARROT_ITEM: - if (UtilMath.r(10) != 0) - { + case SEEDS: + case SAPLING: + case VINE: + case LEAVES: + case LONG_GRASS: + case RED_ROSE: + case YELLOW_FLOWER: + case DEAD_BUSH: + case WATER_LILY: event.setCancelled(true); - } - return; - case POTATO_ITEM: - if (UtilMath.r(10) != 0) - { + return; + case CARROT_ITEM: + if (UtilMath.r(10) != 0) + { + event.setCancelled(true); + } + return; + case POTATO_ITEM: + if (UtilMath.r(10) != 0) + { + event.setCancelled(true); + } + return; + case WHEAT: + if (UtilMath.r(6) != 0) + { + event.setCancelled(true); + } + return; + case WOOD: event.setCancelled(true); - } - return; - case WHEAT: - if (UtilMath.r(6) != 0) - { - event.setCancelled(true); - } - return; - case WOOD: - event.setCancelled(true); - return; + return; - default: - break; + default: + break; } for (Player player : GetPlayers(true)) @@ -1008,27 +990,27 @@ public abstract class SurvivalGames extends Game { handlePickup(event.getItem().getItemStack()); } - + public void handlePickup(ItemStack stack) { if (stack.getType() == Material.CARROT - || stack.getType() == Material.POTATO - || stack.getType() == Material.WHEAT - || stack.getType() == Material.CARROT_ITEM - || stack.getType() == Material.POTATO_ITEM) + || stack.getType() == Material.POTATO + || stack.getType() == Material.WHEAT + || stack.getType() == Material.CARROT_ITEM + || stack.getType() == Material.POTATO_ITEM) { String name = "Carrot"; if (stack.getType() == Material.POTATO || stack.getType() == Material.POTATO_ITEM) name = "Potato"; if (stack.getType() == Material.WHEAT) name = "Wheat"; - + ItemMeta meta = stack.getItemMeta(); meta.setDisplayName(name); stack.setItemMeta(meta); } } - + @EventHandler public void OpenChest(PlayerInteractEvent event) { @@ -1300,7 +1282,7 @@ public abstract class SurvivalGames extends Game } private ArrayList buildBorders(int seconds, double border, - double leaveRemaining) + double leaveRemaining) { double totalNumber = Math.pow(seconds, 1.9D) + (seconds * 50); @@ -1676,7 +1658,7 @@ public abstract class SurvivalGames extends Game if (event.GetState() != GameState.Live) return; - Scoreboard board = GetScoreboard().GetScoreboard(); + Scoreboard board = GetScoreboard().getScoreboard(); for (Player player : GetPlayers(true)) { @@ -1693,12 +1675,6 @@ public abstract class SurvivalGames extends Game player.setHealth(player.getMaxHealth()); - Team team = board.registerNewTeam(player.getName()); - - team.setPrefix(board.getPlayerTeam(player).getPrefix()); - - team.addPlayer(player); - _hiddenNames.put(player, new HashSet()); } } @@ -1811,7 +1787,7 @@ public abstract class SurvivalGames extends Game } UtilParticle.PlayParticle(ParticleType.SPELL, block.getLocation() - .add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1, ViewDist.LONG, + .add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); } } @@ -1870,8 +1846,8 @@ public abstract class SurvivalGames extends Game if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte) 0)) return; - - if(!IsAlive(player)) + + if (!IsAlive(player)) return; event.setCancelled(true); @@ -1940,7 +1916,7 @@ public abstract class SurvivalGames extends Game } } } - + @EventHandler public void craftedItems(CraftItemEvent event) { @@ -1961,24 +1937,41 @@ public abstract class SurvivalGames extends Game ArrayList alivePlayers = new ArrayList( _hiddenNames.keySet()); - HashMap> checkedPlayers = new HashMap>(); + HashMap> checkedPlayers = new HashMap<>(); for (Player target : alivePlayers) { + Team originalTeam = GetScoreboard().getScoreboard().getTeam(getArcadeManager().GetLobby().getTeamId(GetTeam(target), target)); - PacketPlayOutScoreboardTeam packet = null; - - try + // If it's null this tick, it'll be set next tick. We can wait a tick + if (originalTeam == null) { - ScoreboardTeam nmsTeam = (ScoreboardTeam) _packetTeam - .get(target.getScoreboard().getTeam(target.getName())); + System.out.println("Skipping " + target.getName() + " because of a null originalTeam"); + continue; + } - packet = new PacketPlayOutScoreboardTeam(nmsTeam, 2); - } - catch (Exception ex) + Team requestedTeam = GetScoreboard().getScoreboard().getTeam(target.getName()); + + if (requestedTeam == null) { - ex.printStackTrace(); + requestedTeam = GetScoreboard().getScoreboard().registerNewTeam(target.getName()); + requestedTeam.addEntry(target.getName()); + requestedTeam.setPrefix(originalTeam.getPrefix()); + requestedTeam.setSuffix(originalTeam.getSuffix()); } + else + { + if (!StringUtils.equals(requestedTeam.getPrefix(), originalTeam.getPrefix())) + { + requestedTeam.setPrefix(originalTeam.getPrefix()); + } + if (!StringUtils.equals(requestedTeam.getSuffix(), originalTeam.getSuffix())) + { + requestedTeam.setSuffix(originalTeam.getSuffix()); + } + } + + PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam(((CraftScoreboard) GetScoreboard().getScoreboard()).getHandle().getTeam(requestedTeam.getName()), 2); for (Player player : alivePlayers) { @@ -1986,11 +1979,9 @@ public abstract class SurvivalGames extends Game { boolean hideName = false; - if (!checkedPlayers.containsKey(target) - || !checkedPlayers.get(target).containsKey(player)) + if (!checkedPlayers.containsKey(target) || !checkedPlayers.get(target).containsKey(player)) { - if (player.getLocation().distance(target.getLocation()) > (GetKit(target) instanceof KitAssassin ? 8 - : 24)) + if (player.getLocation().distance(target.getLocation()) > (GetKit(target) instanceof KitAssassin ? 8 : 24)) { hideName = true; } @@ -2001,9 +1992,9 @@ public abstract class SurvivalGames extends Game } Player[] players = new Player[] - { - target, player - }; + { + target, player + }; if (!(GetKit(player) instanceof KitAssassin || GetKit(target) instanceof KitAssassin)) { @@ -2048,11 +2039,11 @@ public abstract class SurvivalGames extends Game } } } - + @EventHandler public void onInventoryOpen(InventoryOpenEvent event) { - if(event.getInventory() instanceof BeaconInventory) + if (event.getInventory() instanceof BeaconInventory) { event.setCancelled(true); } @@ -2082,50 +2073,50 @@ public abstract class SurvivalGames extends Game { return _gameEndTime; } - + public ArrayList getSupplyBlocks() { return _supplyCrates; } - + public HashSet getLootedBlocks() { return _lootedBlocks; } - + public ChestLoot getBaseLoot() { return _baseLoot; } - + public ChestLoot getCrateLoot() { return _crateLoot; } - + public ChestLoot getSpawnLoot() { return _spawnLoot; } - + public ChestLoot getDeathMatch() { return _deathMatchLoot; } - + public ChestLoot getRawFurnace() { return _rawFurnace; } - + public ChestLoot getFurnace() { return _cookedFurnace; } - + public Location getSpawn() { return _spawn; } - + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java index 99d49393b..f6c6b1820 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java @@ -1,21 +1,15 @@ package nautilus.game.arcade.game.games.survivalgames; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.modules.TeamModule; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -24,14 +18,8 @@ import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker; import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker; import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; -import org.bukkit.ChatColor; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; public class TeamSurvivalGames extends SurvivalGames { @@ -89,15 +77,15 @@ public class TeamSurvivalGames extends SurvivalGames if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cGreen + C.Bold + "Time"); - Scoreboard.Write(UtilTime.convertString(getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); + Scoreboard.write(C.cGreen + C.Bold + "Time"); + Scoreboard.write(UtilTime.convertString(getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Teams"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Teams"); ArrayList alive = new ArrayList(); for (GameTeam team : GetTeamList()) @@ -112,7 +100,7 @@ public class TeamSurvivalGames extends SurvivalGames { for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(team.GetColor() + player.getName()); + Scoreboard.write(team.GetColor() + player.getName()); } } } @@ -120,34 +108,34 @@ public class TeamSurvivalGames extends SurvivalGames { for (GameTeam team : alive) { - Scoreboard.Write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + Scoreboard.write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); } } else { - Scoreboard.Write(C.cWhite + alive.size() + " Alive"); + Scoreboard.write(C.cWhite + alive.size() + " Alive"); } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (getChestRefillTime() > 0 && getDeathMatchTime() > 60) { - Scoreboard.Write(C.cGold + C.Bold + "Chest Refill"); - Scoreboard.Write(UtilTime.convertString(getChestRefillTime() * 1000, 0, TimeUnit.FIT)); + Scoreboard.write(C.cGold + C.Bold + "Chest Refill"); + Scoreboard.write(UtilTime.convertString(getChestRefillTime() * 1000, 0, TimeUnit.FIT)); } else if (getDeathMatchTime() > 0) { - Scoreboard.Write(C.cRed + C.Bold + "Deathmatch"); - Scoreboard.Write(UtilTime.convertString( + Scoreboard.write(C.cRed + C.Bold + "Deathmatch"); + Scoreboard.write(UtilTime.convertString( Math.min(getDeathMatchTime(), isDeathMatchTeleported() ? 10 : getDeathMatchTime()) * 1000, 0, TimeUnit.FIT)); } else { - Scoreboard.Write(C.cRed + C.Bold + "Game End"); - Scoreboard.Write(UtilTime.convertString(Math.max(0, getGameEndTime()) * 1000, 0, TimeUnit.FIT)); + Scoreboard.write(C.cRed + C.Bold + "Game End"); + Scoreboard.write(UtilTime.convertString(Math.max(0, getGameEndTime()) * 1000, 0, TimeUnit.FIT)); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java index 8c2ba3e65..fa44f00ed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java @@ -118,7 +118,7 @@ public class UHCSurvivalgames extends SoloSurvivalGames else if (event.GetState() != GameState.Live) getCrateLoot().addLoot(new RandomItem(new ItemStack(Material.GOLDEN_APPLE), 100)); - Objective objective = Scoreboard.GetScoreboard().registerNewObjective("Health", "health"); + Objective objective = Scoreboard.getScoreboard().registerNewObjective("Health", "health"); objective.setDisplaySlot(DisplaySlot.PLAYER_LIST); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/Tug.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/Tug.java index 30a7e7a17..a232d4115 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/Tug.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/Tug.java @@ -15,7 +15,6 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Creature; import org.bukkit.entity.Pig; -import org.bukkit.entity.Player; import org.bukkit.entity.Sheep; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -30,13 +29,10 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.tug.kits.*; import nautilus.game.arcade.kit.Kit; @@ -327,17 +323,17 @@ public class Tug extends TeamGame public void ScoreboardWrite() { - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Pig Team"); - Scoreboard.Write(_redLives.size() + " Wheat"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRed + "Pig Team"); + Scoreboard.write(_redLives.size() + " Wheat"); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cAqua + "Sheep Team"); - Scoreboard.Write(_blueLives.size() + " Carrots"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cAqua + "Sheep Team"); + Scoreboard.write(_blueLives.size() + " Carrots"); - Scoreboard.Draw(); + Scoreboard.draw(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 3f11f4fad..15ffadb9f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -44,9 +44,6 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; -import mineplex.core.elo.EloPlayer; -import mineplex.core.elo.EloTeam; -import mineplex.core.elo.GameResult; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -618,7 +615,7 @@ public class TurfForts extends TeamGame if (event.getType() != UpdateType.FAST) return; - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : this.GetTeamList()) { @@ -626,17 +623,17 @@ public class TurfForts extends TeamGame if (team.GetColor() == ChatColor.RED) lines = GetRedLines(); else lines = GetBlueLines(); - Scoreboard.WriteBlank(); - Scoreboard.Write(lines + " " + team.GetColor() + team.GetName()); + Scoreboard.writeNewLine(); + Scoreboard.write(lines + " " + team.GetColor() + team.GetName()); } if (!_fight) { long time = _buildTime - (System.currentTimeMillis() - _phaseTime); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Build Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, time), 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Build Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, time), 0)); } @@ -644,12 +641,12 @@ public class TurfForts extends TeamGame { long time = _fightTime - (System.currentTimeMillis() - _phaseTime); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Combat Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, time), 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Combat Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, time), 0)); } - Scoreboard.Draw(); + Scoreboard.draw(); } public int GetRedLines() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java index dcd4f94d2..2a71c63a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java @@ -969,24 +969,24 @@ public class TypeWars extends TeamGame } } - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); for(GameTeam team : GetTeamList()) { - Scoreboard.Write(team.GetColor() + C.Bold + team.GetName() + " Team"); - Scoreboard.Write(team.GetColor() + "Health: " + Math.round(getScore(team))); - Scoreboard.Write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); + Scoreboard.write(team.GetColor() + C.Bold + team.GetName() + " Team"); + Scoreboard.write(team.GetColor() + "Health: " + Math.round(getScore(team))); + Scoreboard.write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); String wpm = String.valueOf((double) getTeamKills(team) / ((double) (System.currentTimeMillis() - GetStateTime())/60000)); if(wpm.length() > 4) wpm = wpm.substring(0, 4); - Scoreboard.Write(team.GetColor() + "WPM: " + wpm); - Scoreboard.WriteBlank(); + Scoreboard.write(team.GetColor() + "WPM: " + wpm); + Scoreboard.writeNewLine(); } - Scoreboard.Draw(); + Scoreboard.draw(); //End Manager.GetCreature().SetDisableCustomDrops(false); @@ -1169,24 +1169,24 @@ public class TypeWars extends TeamGame if(!IsLive()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); for(GameTeam team : GetTeamList()) { - Scoreboard.Write(team.GetColor() + C.Bold + team.GetName() + " Team"); - Scoreboard.Write(team.GetColor() + "Health: " + Math.round(getScore(team))); - Scoreboard.Write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); + Scoreboard.write(team.GetColor() + C.Bold + team.GetName() + " Team"); + Scoreboard.write(team.GetColor() + "Health: " + Math.round(getScore(team))); + Scoreboard.write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); String wpm = String.valueOf((double) getTeamKills(team) / ((double) (System.currentTimeMillis() - GetStateTime())/60000)); if(wpm.length() > 4) wpm = wpm.substring(0, 4); - Scoreboard.Write(team.GetColor() + "WPM: " + wpm); - Scoreboard.WriteBlank(); + Scoreboard.write(team.GetColor() + "WPM: " + wpm); + Scoreboard.writeNewLine(); } - Scoreboard.Draw(); + Scoreboard.draw(); } public ArrayList getMinions(GameTeam team) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index 6ae58980a..3ddb02053 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -5,8 +5,10 @@ import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.access.IViolationInfo; import fr.neatmonster.nocheatplus.hooks.NCPHook; import fr.neatmonster.nocheatplus.hooks.NCPHookManager; +import mineplex.core.Managers; import mineplex.core.account.CoreClient; import mineplex.core.boosters.event.BoosterItemGiveEvent; +import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -23,6 +25,7 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.monitor.LagMeter; import mineplex.core.recharge.Recharge; import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; @@ -39,6 +42,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.uhc.helpers.ChunkLoadingThread; import nautilus.game.arcade.game.games.uhc.helpers.WorldGenThread; +import nautilus.game.arcade.game.modules.AntiExpOrbModule; import nautilus.game.arcade.game.modules.OreVeinEditorModule; import nautilus.game.arcade.game.modules.TeamModule; import nautilus.game.arcade.game.modules.combatlog.CombatLogModule; @@ -59,10 +63,10 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; -import org.bukkit.entity.ExperienceOrb; import org.bukkit.entity.Ghast; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; @@ -80,7 +84,6 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent; @@ -92,6 +95,8 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.event.world.ChunkLoadEvent; +import org.bukkit.event.world.ChunkPopulateEvent; import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.inventory.CraftingInventory; @@ -102,7 +107,6 @@ import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.material.MaterialData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; @@ -130,12 +134,24 @@ public class UHC extends TeamGame implements NCPHook // The number of chunks to unload per tick public static final int CHUNKS_UNLOAD_PER_TICK = 1; + // The number of ticks to delay chunk unloading by + public static final long CHUNKS_UNLOAD_DELAY = 5 * 20L; + + // The number of ticks to wait between each chunk unload period + public static final long CHUNKS_UNLOAD_PERIOD = 2 * 20L; + // This is the region in which nothing can be done (block placing, flowing, etc) public static final int SAFE_REGION = 36; // The amount of damage to give from hitting the world border public static final int WORLD_BORDER_DAMAGE = 5; + // The number of ticks to delay before teleporting each player + public static final long DELAY_BETWEEN_PLAYER_TELEPORT = 5L; + + // The centers of the spawn for each team + private Map _teamCenter = new HashMap<>(); + // The thread responsible for generating the world private final WorldGenThread _worldGenThread = new WorldGenThread(this); @@ -146,7 +162,7 @@ public class UHC extends TeamGame implements NCPHook private final Set _loadedChunks = new HashSet<>(); // The task which will unload chunks periodically - private BukkitRunnable _chunkUnloadTask; + private int _chunkUnloadTaskId = -1; // The number of minutes passed in this game private int _minutesSinceStart = 0; @@ -184,6 +200,7 @@ public class UHC extends TeamGame implements NCPHook new OreVeinEditorModule() .removeNonAirVeins() ); + registerModule(new AntiExpOrbModule()); } public UHC(ArcadeManager manager, GameType type) @@ -230,8 +247,6 @@ public class UHC extends TeamGame implements NCPHook this.AnnounceStay = false; - this.DisplayLobbySide = true; - this.DeathMessages = false; this.SoupEnabled = false; @@ -270,7 +285,7 @@ public class UHC extends TeamGame implements NCPHook // Damage Settings Manager.GetDamage().SetEnabled(false); - _healthObjective = Scoreboard.GetScoreboard().registerNewObjective("Health", "health"); + _healthObjective = Scoreboard.getScoreboard().registerNewObjective("Health", "health"); _healthObjective.setDisplaySlot(DisplaySlot.PLAYER_LIST); NCPHookManager.addHook(CheckType.ALL, this); @@ -278,6 +293,24 @@ public class UHC extends TeamGame implements NCPHook registerModule(new TeamModule()); } + @EventHandler + public void onLoad(ChunkLoadEvent event) + { + if (event.getChunk().getWorld().equals(WorldData.World) && _isTeleporting) + { + new Exception(event.getChunk().getX() + " " + event.getChunk().getZ()).printStackTrace(); + } + } + + @EventHandler + public void onPopulate(ChunkPopulateEvent event) + { + if (event.getChunk().getWorld().equals(WorldData.World) && _isTeleporting) + { + new Exception(event.getChunk().getX() + " " + event.getChunk().getZ()).printStackTrace(); + } + } + @Override public void ParseData() { @@ -448,7 +481,7 @@ public class UHC extends TeamGame implements NCPHook { while (GetTeamList().get(0).GetSpawns().size() < this.GetPlayers(true).size()) { - Location loc = GetRandomSpawn(null); + Location loc = GetRandomSpawn(null, false); // Dynamically scale distance requirement based on how many teams need to fit double dist = (2 * _currentBorder) / (Math.sqrt(this.GetPlayers(true).size()) + 3); @@ -470,7 +503,7 @@ public class UHC extends TeamGame implements NCPHook if (!clash) break; - loc = GetRandomSpawn(null); + loc = GetRandomSpawn(null, false); } GetTeamList().get(0).GetSpawns().add(loc); @@ -481,7 +514,7 @@ public class UHC extends TeamGame implements NCPHook { for (GameTeam team : GetTeamList()) { - Location loc = GetRandomSpawn(null); + Location loc = GetRandomSpawn(null, false); // Dynamically scale distance requirement based on how many teams need to fit double dist = (2 * _currentBorder) / (Math.sqrt(GetTeamList().size()) + 3); @@ -506,23 +539,17 @@ public class UHC extends TeamGame implements NCPHook if (!clash) break; - loc = GetRandomSpawn(null); + loc = GetRandomSpawn(null, false); } + _teamCenter.put(team, loc); team.GetSpawns().add(loc); - - while (team.GetSpawns().size() < 20) - { - Location other = GetRandomSpawn(loc); - - team.GetSpawns().add(other); - } } } TimingManager.stop("UHC Spawn Generation"); - Location spawn = GetRandomSpawn(WorldData.World.getSpawnLocation()); + Location spawn = GetRandomSpawn(WorldData.World.getSpawnLocation(), true); WorldData.World.setSpawnLocation(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()); WorldServer worldServer = ((CraftWorld) WorldData.World).getHandle(); @@ -577,69 +604,67 @@ public class UHC extends TeamGame implements NCPHook this.DamagePvP = true; this.CompassGiveItem = true; this.RejoinTime = 300000; // 5 minutes - registerModule( - new CombatLogModule() - .setSpawnForCreative(false) - .setCombatLogTime(300000) - .setOnDeathAction(npc -> + registerModule(new CombatLogModule()) + .setSpawnForCreative(false) + .setCombatLogTime(300000) + .setOnDeathAction(npc -> + { + if (npc.getLastDamager() instanceof Player) + { + Player killer = (Player) npc.getLastDamager(); + Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName() + + C.cGray + C.Bold + " was killed by " + getArcadeManager().GetColor(killer) + + C.Bold + npc.getLastDamager().getName() + C.cGray + C.Bold + " while logged out."); + } + else + { + String cause = UtilParser.parseDamageCause(npc.getLastDamageCause()); + if (npc.getLastDamager() != null) { - if (npc.getLastDamager() instanceof Player) - { - Player killer = (Player) npc.getLastDamager(); - Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName() - + C.cGray + C.Bold + " was killed by " + getArcadeManager().GetColor(killer) - + C.Bold + npc.getLastDamager().getName() + C.cGray + C.Bold + " while logged out."); - } - else - { - String cause = UtilParser.parseDamageCause(npc.getLastDamageCause()); - if (npc.getLastDamager() != null) - { - cause = npc.getLastDamager().getName(); - } - Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName() - + C.cGray + C.Bold + " was killed by " + cause + " while logged out."); - } + cause = npc.getLastDamager().getName(); + } + Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName() + + C.cGray + C.Bold + " was killed by " + cause + " while logged out."); + } - ItemStack stack = new ItemBuilder(Material.SKULL_ITEM) - .setData((byte) 3) - .setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head") - .build(); + ItemStack stack = new ItemBuilder(Material.SKULL_ITEM) + .setData((byte) 3) + .setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head") + .build(); - SkullMeta meta = (SkullMeta) stack.getItemMeta(); - meta.setOwner(npc.getPlayerInfo().getName()); - stack.setItemMeta(meta); + SkullMeta meta = (SkullMeta) stack.getItemMeta(); + meta.setOwner(npc.getPlayerInfo().getName()); + stack.setItemMeta(meta); - npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack); + npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack); - Location location = npc.getNPC().getLocation(); + Location location = npc.getNPC().getLocation(); - for (ItemStack item : npc.getPlayerInfo().getItems()) - { - location.getWorld().dropItemNaturally(location, item); - } - }) - .setOnExpireAction(npc -> - { - ItemStack stack = new ItemBuilder(Material.SKULL_ITEM) - .setData((byte) 3) - .setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head") - .build(); + for (ItemStack item : npc.getPlayerInfo().getItems()) + { + location.getWorld().dropItemNaturally(location, item); + } + }) + .setOnExpireAction(npc -> + { + ItemStack stack = new ItemBuilder(Material.SKULL_ITEM) + .setData((byte) 3) + .setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head") + .build(); - SkullMeta meta = (SkullMeta) stack.getItemMeta(); - meta.setOwner(npc.getPlayerInfo().getName()); - stack.setItemMeta(meta); + SkullMeta meta = (SkullMeta) stack.getItemMeta(); + meta.setOwner(npc.getPlayerInfo().getName()); + stack.setItemMeta(meta); - npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack); + npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack); - Location location = npc.getNPC().getLocation(); + Location location = npc.getNPC().getLocation(); - for (ItemStack item : npc.getPlayerInfo().getItems()) - { - location.getWorld().dropItemNaturally(location, item); - } - }) - ); + for (ItemStack item : npc.getPlayerInfo().getItems()) + { + location.getWorld().dropItemNaturally(location, item); + } + }); } } @@ -690,6 +715,19 @@ public class UHC extends TeamGame implements NCPHook } } + @EventHandler + public void toggleFakeTps(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Dead) + { + Managers.get(LagMeter.class).setFakeTps(true); + } + else + { + Managers.get(LagMeter.class).setFakeTps(false); + } + } + @EventHandler public void generateWorld(GameStateChangeEvent event) { @@ -704,35 +742,26 @@ public class UHC extends TeamGame implements NCPHook HandlerList.unregisterAll(_chunkLoadingThread); NCPHookManager.removeHook(this); - if (_chunkUnloadTask != null) - { - try - { - _chunkUnloadTask.cancel(); - } - catch (IllegalStateException ex) - { - // bukkit - } - } - - Iterator iterator = _loadedChunks.iterator(); - while (iterator.hasNext()) - { - Chunk chunk = iterator.next(); - WorldData.World.unloadChunk(chunk.getX(), chunk.getZ()); - iterator.remove(); - } +// if (_chunkUnloadTaskId != -1) +// { +// Bukkit.getScheduler().cancelTask(_chunkUnloadTaskId); +// } +// +// Iterator iterator = _loadedChunks.iterator(); +// while (iterator.hasNext()) +// { +// Chunk chunk = iterator.next(); +// WorldData.World.unloadChunk(chunk.getX(), chunk.getZ()); +// iterator.remove(); +// } return; } - if (event.GetState() != GameState.Recruit) + if (event.GetState() == GameState.Recruit) { - return; + _worldGenThread.start(); } - - _worldGenThread.start(); } @EventHandler(priority = EventPriority.MONITOR) @@ -741,7 +770,7 @@ public class UHC extends TeamGame implements NCPHook if (!IsLive()) { event.setCancelled(true); - _loadedChunks.add(event.getChunk()); +// _loadedChunks.add(event.getChunk()); } } @@ -750,7 +779,7 @@ public class UHC extends TeamGame implements NCPHook { if (_isTeleporting) { - System.out.println("WARNING: TRIED TO LOAD CHUNK WHILE TELEPORTING: " + event.getX() + " " + event.getZ()); + new Exception("WARNING: TRIED TO LOAD CHUNK WHILE TELEPORTING: " + event.getX() + " " + event.getZ()).printStackTrace(); } } @@ -764,6 +793,15 @@ public class UHC extends TeamGame implements NCPHook } } + @EventHandler(priority = EventPriority.LOWEST) + public void on(PlayerQuitEvent event) + { + if (_isTeleporting) + { + GetLocationStore().put(event.getPlayer().getName(), GetTeam(event.getPlayer()).GetSpawn()); + } + } + @EventHandler(priority = EventPriority.LOW) public void PlayerPrepare(GameStateChangeEvent event) { @@ -772,6 +810,13 @@ public class UHC extends TeamGame implements NCPHook if (event.GetState() != GameState.Prepare) return; + for (Map.Entry entries : _teamCenter.entrySet()) + { + while (entries.getKey().GetSpawns().size() < 20) + { + entries.getKey().GetSpawns().add(GetRandomSpawn(entries.getValue(), true)); + } + } Manager.GetChat().Silence(1000 * 120, false); @@ -781,16 +826,30 @@ public class UHC extends TeamGame implements NCPHook Location zero = WorldData.World.getSpawnLocation(); - // fixme if you leave while teleporting you'll rejoin at 0,0 - for (Player player : players) { player.teleport(zero); + + // Update scoreboard + _healthObjective.getScore(player.getName()).setScore((int) player.getMaxHealth()); + + game.addPlayerInTime(player); + + Manager.Clear(player); + UtilInv.Clear(player); + // Heal player.setHealth(player.getMaxHealth()); // Resistance and regen player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 30 * 20, 128), true); player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 30 * 20, 128), true); + + + game.ValidateKit(player, game.GetTeam(player)); + + if (game.GetKit(player) != null) + game.GetKit(player).ApplyKit(player); + } Announce(C.cGreen + C.Bold + "Please wait, you will be teleported soon", false); @@ -824,8 +883,8 @@ public class UHC extends TeamGame implements NCPHook // Heal player.setHealth(player.getMaxHealth()); // Resistance and regen - player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 30 * 20, 128), true); - player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 30 * 20, 128), true); + player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 10 * 20, 128), true); + player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 10 * 20, 128), true); } teleportedLocations.clear(); @@ -843,39 +902,32 @@ public class UHC extends TeamGame implements NCPHook Manager.runSyncLater(() -> { - for (Player player : players) - { - player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); - player.removePotionEffect(PotionEffectType.REGENERATION); - } - WorldData.World.setAutoSave(true); - _chunkUnloadTask = new BukkitRunnable() - { - @Override - public void run() - { - Iterator iterator = _loadedChunks.iterator(); - int amount = 0; - - while (amount < CHUNKS_UNLOAD_PER_TICK && iterator.hasNext()) - { - Chunk next = iterator.next(); - if (WorldData.World.unloadChunkRequest(next.getX(), next.getZ())) - { - System.out.println("Requesting unload of chunk " + next.getX() + " " + next.getZ()); - } - iterator.remove(); - amount++; - } - - if (_loadedChunks.size() == 0) - { - cancel(); - } - } - }; +// _chunkUnloadTaskId = Bukkit.getScheduler().runTaskTimer(getArcadeManager().getPlugin(), () -> +// { +// Iterator iterator = _loadedChunks.iterator(); +// int amount = 0; +// +// while (amount < CHUNKS_UNLOAD_PER_TICK && iterator.hasNext()) +// { +// if (WorldData == null || WorldData.World == null) +// { +// Bukkit.getScheduler().cancelTask(_chunkUnloadTaskId); +// return; +// } +// +// Chunk next = iterator.next(); +// WorldData.World.unloadChunkRequest(next.getX(), next.getZ()); +// iterator.remove(); +// amount++; +// } +// +// if (_loadedChunks.size() == 0) +// { +// Bukkit.getScheduler().cancelTask(_chunkUnloadTaskId); +// } +// }, CHUNKS_UNLOAD_DELAY, CHUNKS_UNLOAD_PERIOD).getTaskId(); }, 10 * 20L); } }, 5 * 20L); @@ -893,31 +945,11 @@ public class UHC extends TeamGame implements NCPHook // Save where they teleported teleportedLocations.put(player.getUniqueId(), team.SpawnTeleport(player)); - // Update scoreboard - _healthObjective.getScore(player).setScore((int) player.getMaxHealth()); - - game.addPlayerInTime(player); - - Manager.Clear(player); - UtilInv.Clear(player); - - // Heal - player.setHealth(player.getMaxHealth()); - // Resistance and regen - player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 30 * 20, 128), true); - player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 30 * 20, 128), true); - - - game.ValidateKit(player, game.GetTeam(player)); - - if (game.GetKit(player) != null) - game.GetKit(player).ApplyKit(player); - //Event PlayerPrepareTeleportEvent playerStateEvent = new PlayerPrepareTeleportEvent(game, player); UtilServer.getServer().getPluginManager().callEvent(playerStateEvent); } - }, 5 * 20L, 5L).getTaskId()); + }, 5 * 20L, DELAY_BETWEEN_PLAYER_TELEPORT).getTaskId()); //Spectators Move for (Player player : UtilServer.getPlayers()) @@ -939,36 +971,7 @@ public class UHC extends TeamGame implements NCPHook SpectatorSpawn = WorldData.World.getSpawnLocation(); - // Move Up - Out Of Blocks - while (!UtilBlock.airFoliage(SpectatorSpawn.getBlock()) - || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) - { - SpectatorSpawn.add(0, 1, 0); - } - - int Up = 0; - - // Move Up - Through Air - for (int i = 0; i < 15; i++) - { - if (UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) - { - SpectatorSpawn.add(0, 1, 0); - Up++; - } - else - { - break; - } - } - - // Move Down - Out Of Blocks - while (Up > 0 && !UtilBlock.airFoliage(SpectatorSpawn.getBlock()) - || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) - { - SpectatorSpawn.subtract(0, 1, 0); - Up--; - } + SpectatorSpawn.add(0, 10, 0); SpectatorSpawn = SpectatorSpawn.getBlock().getLocation().add(0.5, 0.1, 0.5); @@ -1024,11 +1027,6 @@ public class UHC extends TeamGame implements NCPHook isIllegal = event.getPlayer().getItemInHand().getType() == Material.INK_SACK && event.getPlayer().getItemInHand().getData().getData() == (byte) 15; } - if (!isIllegal) - { - isIllegal = event.getPlayer().getItemInHand().getType() == Material.WATER_BUCKET - || event.getPlayer().getItemInHand().getType() == Material.LAVA_BUCKET; - } if (isIllegal && isInSafeZone(event.getClickedBlock().getLocation())) { @@ -1058,55 +1056,80 @@ public class UHC extends TeamGame implements NCPHook private boolean isInSafeZone(Location location) { return location.getX() <= SAFE_REGION && location.getX() >= -SAFE_REGION - && location.getZ() < SAFE_REGION && location.getZ() >= -SAFE_REGION; + && location.getZ() <= SAFE_REGION && location.getZ() >= -SAFE_REGION; } - // fixme world decoration means random spawns which were clear before might not be after - public Location GetRandomSpawn(Location around) + private Location GetRandomSpawn(Location around, boolean sameChunk) { - // Sometimes getting a random spawn at 0,0 hangs forever int tries = 0; - Location loc = null; + Chunk chunk = around == null ? null : around.getChunk(); - while (loc == null) + while (true) { tries++; - Block block = null; - // Get Team Location + if (tries > 100) + { + System.out.println("Tries > 100, returning spawn"); + return WorldData.World.getSpawnLocation(); + } + + Block targetBlock; + if (around == null) { // Return a int from 0 - 1800, then remove 900 so its a int from -900 to 900 int x = (int) (UtilMath.r((int) (1.8 * _currentBorder)) - (0.9 * _currentBorder)); int z = (int) (UtilMath.r((int) (1.8 * _currentBorder)) - (0.9 * _currentBorder)); - block = UtilBlock.getHighest(WorldData.World, x, z, null); + targetBlock = UtilBlock.getHighest(WorldData.World, x, z, null); } - // Get Radius Location else { - block = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 4 + UtilMath.r(tries < 10 ? 8 : 30), around.getBlockZ() - 4 - + UtilMath.r(tries < 10 ? 8 : 30), null); + if (sameChunk) + { + if (tries > 20) + { + System.out.println("----------- WARNING ---------------"); + System.out.println("DISABLED SAMECHUNK CHECK AFTER 20 ATTEMPTS"); + sameChunk = false; + continue; + } + + targetBlock = UtilBlock.getHighest(WorldData.World, chunk.getBlock(UtilMath.r(15), 0, UtilMath.r(15)).getLocation()); + } + else + { + targetBlock = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 4 + UtilMath.r(tries < 10 ? 8 : 30), around.getBlockZ() - 4 + + UtilMath.r(tries < 10 ? 8 : 30), null); + } + } + + if (sameChunk && around != null && !around.getChunk().equals(targetBlock.getChunk())) + { + System.out.println("Failed same chunk check: " + around.getChunk() + " " + targetBlock.getChunk() + " " + tries); + continue; } // Check Validity // Liquid - if (block.getRelative(BlockFace.DOWN).isLiquid()) - continue; - - if (!block.getRelative(BlockFace.DOWN).getType().isSolid()) + if (targetBlock.getRelative(BlockFace.DOWN).isLiquid()) + { + System.out.println("Failed liquid check: " + targetBlock.getRelative(BlockFace.DOWN) + " " + tries); continue; + } // Suffocated - if (block.getType() != Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR) + if (CraftMagicNumbers.getBlock(targetBlock.getRelative(BlockFace.UP)).w()) + { + System.out.println("Failed suffocation check: " + targetBlock.getRelative(BlockFace.UP) + " " + tries); continue; + } - loc = block.getLocation().add(0.5, 0.5, 0.5); + return targetBlock.getLocation().add(0.5, 0.5, 0.5); } - - return loc; } @EventHandler @@ -1215,25 +1238,6 @@ public class UHC extends TeamGame implements NCPHook } } - @EventHandler - public void on(EntityTargetLivingEntityEvent event) - { - if (event.getEntity() instanceof ExperienceOrb) - { - if (event.getTarget() instanceof Player) - { - Player player = (Player) event.getTarget(); - - Game game = Manager.GetGame(); - - if (game == null || !game.IsAlive(player) || game.GetState() != GameState.Live) - { - event.setCancelled(true); - } - } - } - } - @EventHandler(priority = EventPriority.LOWEST) public void PlayerKick(PlayerKickEvent event) { @@ -1536,7 +1540,10 @@ public class UHC extends TeamGame implements NCPHook } } - AnnounceEnd(teamsAlive.get(0)); + if (teamsAlive.size() > 0) + { + AnnounceEnd(teamsAlive.get(0)); + } SetState(GameState.End); } } @@ -1554,24 +1561,21 @@ public class UHC extends TeamGame implements NCPHook public void ScoreboardWrite() { - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); // Solo if (GetTeamList().size() == 1) { if (GetPlayers(true).size() < 8) { - for (Player player : GetPlayers(true)) - { - Scoreboard.WriteOrdered("Health", player.getName(), GetHealth(player), true); - } + Scoreboard.writeGroup(GetPlayers(true), player -> Pair.create(player.getName(), GetHealth(player)), true); } else { - Scoreboard.Write(C.cYellow + C.Bold + "Players"); - Scoreboard.Write(GetPlayers(true).size() + " Alive"); + Scoreboard.write(C.cYellow + C.Bold + "Players"); + Scoreboard.write(GetPlayers(true).size() + " Alive"); } } // Team @@ -1585,37 +1589,42 @@ public class UHC extends TeamGame implements NCPHook if (GetPlayers(true).size() < 8) { - for (Player player : GetPlayers(true)) - { - Scoreboard.WriteOrdered("Health", GetTeam(player).GetColor() + player.getName(), GetHealth(player), true); - } + Scoreboard.writeGroup(GetPlayers(true), player -> Pair.create(GetTeam(player).GetColor() + player.getName(), GetHealth(player)), true); } else { - Scoreboard.Write(C.cYellow + C.Bold + "Teams"); - Scoreboard.Write(aliveList.size() + " Alive"); + Scoreboard.write(C.cYellow + C.Bold + "Teams"); + Scoreboard.write(aliveList.size() + " Alive"); } } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Status"); if (GetState() == GameState.Prepare) { - Scoreboard.Write(C.cYellow + C.Bold + "Status"); int players = _teleportedPlayers + 1; if (players > _totalPlayers) players = _totalPlayers; - Scoreboard.Write("Teleporting Players (" + players + "/" + _totalPlayers + ")"); + Scoreboard.write("Teleporting Players (" + players + "/" + _totalPlayers + ")"); + } + else if (GetState() == GameState.Live) + { + Scoreboard.write("Live (" + UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime()) + ")"); } else { - Scoreboard.Write(C.cYellow + C.Bold + "Time"); - Scoreboard.Write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); + Scoreboard.write("Finished"); } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Borders"); - Scoreboard.Write("-" + (int) _currentBorder + " to " + "+" + (int) _currentBorder); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Borders"); + Scoreboard.write("-" + (int) _currentBorder + " to " + "+" + (int) _currentBorder); - Scoreboard.Draw(); + Scoreboard.draw(); + + for (Player player : GetPlayers(true)) + { + _healthObjective.getScore(player.getName()).setScore((int) player.getHealth()); + } } public int GetHealth(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/helpers/WorldGenThread.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/helpers/WorldGenThread.java index 39012869c..c019c337b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/helpers/WorldGenThread.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/helpers/WorldGenThread.java @@ -138,16 +138,10 @@ public class WorldGenThread extends Thread TimingManager.start("Map Generation"); long start = System.currentTimeMillis(); - long last = start; while (!_stopGen) { long now = System.currentTimeMillis(); - if ((now - last) >= 10 * 1000) - { - _game.Announce(C.cGreen + C.Bold + "Generating Map: " + C.cWhite + getMapLoadETA() + " Remaining...", false); - last = now; - } long hash = LongHash.toLong(_chunkX, _chunkZ); @@ -174,7 +168,6 @@ public class WorldGenThread extends Thread else { _mapLoaded = true; - System.out.println("Map Loading Finished! Took " + TimeUnit.MILLISECONDS.toSeconds(now - start) + " seconds"); break; } @@ -215,13 +208,6 @@ public class WorldGenThread extends Thread this._stopGen = true; } - public String getMapLoadETA() - { - int chunksToGo = _chunkTotal - _chunksLoaded; - - return UtilTime.MakeStr((long) ((double) chunksToGo / (double) (_chunksPerTick * 20) * 1000d), 1); - } - public boolean isMapLoaded() { return this._mapLoaded; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java index e902d5f44..3007c7085 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java @@ -5,7 +5,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.stream.Collectors; import org.bukkit.EntityEffect; import org.bukkit.Location; @@ -21,11 +20,9 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; import mineplex.core.common.util.C; @@ -36,7 +33,6 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; @@ -58,12 +54,8 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.games.christmas.ChristmasAudio; -import nautilus.game.arcade.game.games.gladiators.tutorial.TutorialGladiators; import nautilus.game.arcade.game.games.valentines.kit.KitMasterOfLove; import nautilus.game.arcade.game.games.valentines.tutorial.TutorialValentines; -import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; import nautilus.game.arcade.kit.Kit; public class Valentines extends SoloGame @@ -726,28 +718,28 @@ public class Valentines extends SoloGame if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + "Players Alive"); - Scoreboard.Write("" + GetPlayers(true).size()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + "Players Alive"); + Scoreboard.write("" + GetPlayers(true).size()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + "Items Left"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + "Items Left"); if (_roundState == 1) - Scoreboard.Write("" + _pigs.size()); + Scoreboard.write("" + _pigs.size()); else - Scoreboard.Write("-"); + Scoreboard.write("-"); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + "Time Left"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + "Time Left"); if (_roundState == 1) - Scoreboard.Write("" + UtilTime.MakeStr(_roundTimeLimit - (System.currentTimeMillis() - _roundTime), 0)); + Scoreboard.write("" + UtilTime.MakeStr(_roundTimeLimit - (System.currentTimeMillis() - _roundTime), 0)); else - Scoreboard.Write("-"); + Scoreboard.write("-"); - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java index 20e743fc8..516caaf7f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java @@ -544,32 +544,32 @@ public class WitherGame extends TeamGame implements IBlockRestorer // lives += i; // Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(_runners.GetColor() + C.Bold + _runners.GetName()); - Scoreboard.Write(_runners.GetColor() + "" + Scoreboard.writeNewLine(); + Scoreboard.write(_runners.GetColor() + C.Bold + _runners.GetName()); + Scoreboard.write(_runners.GetColor() + "" + _runners.GetPlayers(true).size() + " Players"); - Scoreboard.WriteBlank(); - Scoreboard.Write(_withers.GetColor() + C.Bold + _withers.GetName()); - Scoreboard.Write(_withers.GetColor() + "" + Scoreboard.writeNewLine(); + Scoreboard.write(_withers.GetColor() + C.Bold + _withers.GetName()); + Scoreboard.write(_withers.GetColor() + "" + _withers.GetPlayers(true).size() + " Players"); // Scoreboard.WriteBlank(); // Scoreboard.Write(C.cYellow + C.Bold + "Humans Alive"); // Scoreboard.Write(lives + " / " + (_lives.size() * _livesPerPlayer)); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Time Left"); - Scoreboard.Write(UtilTime.MakeStr( + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Time Left"); + Scoreboard.write(UtilTime.MakeStr( Math.max( 0, _gameTime - (System.currentTimeMillis() - this .GetStateTime())), 1)); - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index 18a6494aa..c4463ea18 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -1637,14 +1637,14 @@ public class Wizards extends SoloGame @EventHandler public void ScoreboardUpdate(UpdateEvent event) { - GetScoreboard().Reset(); + GetScoreboard().reset(); - GetScoreboard().WriteBlank(); + GetScoreboard().writeNewLine(); - GetScoreboard().Write(C.cYellow + C.Bold + "Wizards"); - GetScoreboard().Write(C.cWhite + GetPlayers(true).size()); + GetScoreboard().write(C.cYellow + C.Bold + "Wizards"); + GetScoreboard().write(C.cWhite + GetPlayers(true).size()); - GetScoreboard().WriteBlank(); + GetScoreboard().writeNewLine(); double time = UtilTime.convert(( @@ -1652,10 +1652,10 @@ public class Wizards extends SoloGame + (10 * 60 * 1000)) - System.currentTimeMillis(), 1, TimeUnit.MINUTES); - GetScoreboard().Write((time >= 0 ? C.cYellow : C.cRed) + C.Bold + (time >= 0 ? "Time Left" : "Overtime")); - GetScoreboard().Write(C.cWhite + Math.abs(time) + " Minute" + (Math.abs(time) != 1 ? "s" : "")); + GetScoreboard().write((time >= 0 ? C.cYellow : C.cRed) + C.Bold + (time >= 0 ? "Time Left" : "Overtime")); + GetScoreboard().write(C.cWhite + Math.abs(time) + " Minute" + (Math.abs(time) != 1 ? "s" : "")); - GetScoreboard().Draw(); + GetScoreboard().draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java index 3f118fbb9..92c5ce0c5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java @@ -35,7 +35,6 @@ import nautilus.game.arcade.game.games.zombiesurvival.kits.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.Navigation; import net.minecraft.server.v1_8_R3.NavigationAbstract; public class ZombieSurvival extends SoloGame @@ -357,15 +356,15 @@ public class ZombieSurvival extends SoloGame if (_survivors == null || _undead == null) return; - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : this.GetTeamList()) { - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + Scoreboard.writeNewLine(); + Scoreboard.write(team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/AntiExpOrbModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/AntiExpOrbModule.java new file mode 100644 index 000000000..6928d08f7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/AntiExpOrbModule.java @@ -0,0 +1,100 @@ +package nautilus.game.arcade.game.modules; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.Game; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.ExperienceOrb; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/* + * This module will prevent spectators from picking up xp orbs + * + * fixme: there are still some graphical glitches + */ +public class AntiExpOrbModule extends Module +{ + private Set _playersLastUpdated = new HashSet<>(); + + @EventHandler + public void on(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Game game = getGame(); + + for (Player player : Bukkit.getOnlinePlayers()) + { + boolean disallow = game.GetState() != Game.GameState.Live || !game.IsAlive(player); + + if (disallow) + { + updateTimer(player, 86000); + _playersLastUpdated.add(player.getUniqueId()); + } + else + { + if (_playersLastUpdated.remove(player.getUniqueId())) + { + updateTimer(player, 2); + } + } + } + } + + @EventHandler + public void on(EntityTargetLivingEntityEvent event) + { + if (event.getEntity() instanceof ExperienceOrb) + { + if (event.getTarget() instanceof Player) + { + Player player = (Player) event.getTarget(); + + Game game = getGame(); + + if (game.GetState() != Game.GameState.Live || !game.IsAlive(player)) + { + // Setting the target to null sets the actual target in EntityExperienceOrb to null + event.setTarget(null); + // Cancelling the event is a sanity check + event.setCancelled(true); + } + } + } + } + + @EventHandler + public void on(PlayerQuitEvent event) + { + _playersLastUpdated.remove(event.getPlayer().getUniqueId()); + } + + @Override + public void cleanup() + { + for (UUID uuid : _playersLastUpdated) + { + Player player = Bukkit.getPlayer(uuid); + if (player != null) + { + updateTimer(player, 0); + } + } + _playersLastUpdated.clear(); + } + + private void updateTimer(Player player, int ticksToWait) + { + ((CraftPlayer) player).getHandle().bp = ticksToWait; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamModule.java index 38e54b55e..12c709f29 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamModule.java @@ -137,7 +137,7 @@ public class TeamModule extends Module } } - @EventHandler + @EventHandler (priority = EventPriority.LOWEST) public void teamQuit(PlayerQuitEvent event) { if (getGame().GetState() != Game.GameState.Recruit) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayModule.java index 216cf8355..3c3caf09e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayModule.java @@ -43,6 +43,7 @@ public class AntiXrayModule extends Module public void cleanup() { _service.setEnabled(false); + _service.clearCache(); } public AntiXrayModule setEnabled(boolean enabled) @@ -87,6 +88,12 @@ public class AntiXrayModule extends Module return this; } + public AntiXrayModule setDarknessHideBlocks(boolean darknessHideBlocks) + { + _service.setDarknessHideBlocks(darknessHideBlocks); + return this; + } + public AntiXrayModule setObfuscateBlocks(Material... materials) { return setObfuscateBlocks(Arrays.asList(materials)); @@ -108,4 +115,31 @@ public class AntiXrayModule extends Module _service.setRandomBlocks(materials); return this; } + + public AntiXrayModule setProximityBlocks(Material... materials) + { + return setProximityBlocks(Arrays.asList(materials)); + } + + public AntiXrayModule setProximityBlocks(List materials) + { + _service.setProximityBlocks(materials); + return this; + } + public AntiXrayModule setDarknessBlocks(Material... materials) + { + return setDarknessBlocks(Arrays.asList(materials)); + } + + public AntiXrayModule setDarknessBlocks(List materials) + { + _service.setDarknessBlocks(materials); + return this; + } + + public AntiXrayModule setUseCache(boolean useCache) + { + _service.setUseCache(true); + return this; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayService.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayService.java index 9c1619bbf..d84ff27cc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayService.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayService.java @@ -17,11 +17,41 @@ public interface AntiXrayService void setUpdateRadius(int updateRadius); + void setUseWorldsAsBlacklist(boolean useWorldsAsBlacklist); + + void setUseCache(boolean useCache); + + void setMaxLoadedCacheFiles(int maxLoadedCacheFiles); + + void clearCache(); + + void setProximityHiderRate(int proximityHiderRate); + + void setProximityHiderDistance(int proximityHiderDistance); + + void setProximityHiderId(int proximityHiderId); + + void setProximityHiderEnd(int proximityHiderEnd); + + void setUseSpecialBlockForProximityHider(boolean useSpecialBlockForProximityHider); + + void setUseYLocationProximity(boolean useYLocationProximity); + + void setAirGeneratorMaxChance(int airGeneratorMaxChance); + + void setWorlds(List worlds); + void setUseProximityHider(boolean useProximityHider); void setAntiTexturePacksAndFreecam(boolean antiTexturePacksAndFreecam); + void setDarknessHideBlocks(boolean darknessHideBlocks); + void setObfuscateBlocks(List materials); void setRandomBlocks(List materials); + + void setDarknessBlocks(List materials); + + void setProximityBlocks(List materials); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java index 25b2d3b73..6e23a2ad6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java @@ -181,6 +181,8 @@ public class CombatLogModule extends Module _logoutNpcs.clear(); _killedBy.clear(); + + Bukkit.getScheduler().cancelTask(_locationTaskId); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java index 37e11c948..fcd06cc4a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java @@ -50,7 +50,7 @@ public abstract class Kit implements Listener _kitAvailability = kitAvailability; _cost = cost; - + _entityType = entityType; _itemInHand = itemInHand; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index c4ef3eaf9..2e1b90360 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.managers; import java.util.concurrent.ConcurrentHashMap; +import mineplex.core.Managers; import mineplex.core.antihack.AntiHack; import mineplex.core.common.MinecraftVersion; import mineplex.core.common.Rank; @@ -1235,10 +1236,10 @@ public class GameFlagManager implements Listener public void AntiHackStrict(GameStateChangeEvent event) { if (event.GetState() == GameState.Prepare || event.GetState() == GameState.Live) - AntiHack.Instance.setStrict(event.GetGame().StrictAntiHack); + Managers.get(AntiHack.class).setStrict(event.GetGame().StrictAntiHack); else - AntiHack.Instance.setStrict(true); + Managers.get(AntiHack.class).setStrict(true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index b8450e200..62e5a3711 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -2,13 +2,22 @@ package nautilus.game.arcade.managers; import mineplex.core.account.CoreClient; import mineplex.core.common.Rank; -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlockText; import mineplex.core.common.util.UtilBlockText.TextAlign; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; import mineplex.core.donation.Donor; -import mineplex.core.elo.EloManager.EloDivision; import mineplex.core.event.CustomTagEvent; import mineplex.core.packethandler.PacketHandler; +import mineplex.core.scoreboard.MineplexScoreboard; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -22,11 +31,22 @@ import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitSorter; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.DyeColor; import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.entity.*; +import org.bukkit.entity.Creature; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; +import org.bukkit.entity.Slime; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -34,15 +54,16 @@ import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.weather.WeatherChangeEvent; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.Team; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; import java.util.Map.Entry; +import java.util.UUID; public class GameLobbyManager implements Listener { @@ -54,7 +75,7 @@ public class GameLobbyManager implements Listener private Location _teamText; private Location _kitDisplay; - private Location _teamDisplay; + private Location _teamDisplay; private Location spawn; @@ -68,32 +89,22 @@ public class GameLobbyManager implements Listener private Color _fireworkColor; private int _advertiseStage = 0; - - //Scoreboard - private NautHashMap _scoreboardMap = new NautHashMap(); - private NautHashMap _gemMap = new NautHashMap(); - private NautHashMap _eloMap = new NautHashMap(); - private NautHashMap _divisionMap = new NautHashMap(); - private NautHashMap _kitMap = new NautHashMap(); - - private int _oldPlayerCount = 0; - private int _oldMaxPlayerCount = 0; // Used for scoreboard when max player count changes private String _serverName; - - private boolean _colorTick = false; + + public boolean _colorTick = false; public GameLobbyManager(ArcadeManager manager, PacketHandler packetHandler) { Manager = manager; World world = UtilWorld.getWorld("world"); - + world.setTime(6000); world.setStorm(false); world.setThundering(false); world.setGameRuleValue("doDaylightCycle", "false"); - + spawn = new Location(world, 0, 104, 0); _gameText = new Location(world, 0, 130, 50); @@ -116,87 +127,9 @@ public class GameLobbyManager implements Listener _teamDisplay.setYaw(yaw); Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); - + _serverName = Manager.getPlugin().getConfig().getString("serverstatus.name"); - _serverName = _serverName.substring(0, Math.min(16, _serverName.length())); - } - - private boolean HasScoreboard(Player player) - { - return _scoreboardMap.containsKey(player); - } - - public void CreateScoreboards() - { - for (Player player : UtilServer.getPlayers()) - { - CreateScoreboard(player, false); - } - - for (Player otherPlayer : UtilServer.getPlayers()) - { - AddPlayerToScoreboards(otherPlayer, null); - } - } - - private void CreateScoreboard(Player player, boolean resendToAll) - { - _scoreboardMap.put(player, Bukkit.getScoreboardManager().getNewScoreboard()); - - Scoreboard scoreboard = _scoreboardMap.get(player); - Objective objective = scoreboard.registerNewObjective("§l" + "Lobby", "dummy"); - objective.setDisplaySlot(DisplaySlot.SIDEBAR); - - for (Rank rank : Rank.values()) - { - if (rank == Rank.ALL) - { - scoreboard.registerNewTeam(rank.Name).setPrefix(""); - } - else - { - scoreboard.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " " + ChatColor.WHITE); - } - - if (Manager.GetGame() != null && !Manager.GetGame().GetTeamList().isEmpty()) - { - for (GameTeam team : Manager.GetGame().GetTeamList()) - { - if(team.GetDisplaytag()) - { - scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + C.Bold + team.GetName() + team.GetColor() + " "); - } - else - { - if (rank == Rank.ALL) - { - scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + ""); - } - else - { - scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " " + team.GetColor()); - } - } - } - } - } - - if (resendToAll) - { - for (Player otherPlayer : UtilServer.getPlayers()) - { - String teamName = null; - if (Manager.GetGame() != null && Manager.GetGame().GetTeam(otherPlayer) != null) - teamName = Manager.GetGame().GetTeam(otherPlayer).GetName().toUpperCase(); - - AddPlayerToScoreboards(otherPlayer, teamName); - } - } - } - - public Collection GetScoreboards() - { - return _scoreboardMap.values(); + _serverName = _serverName.substring(0, Math.min(16, _serverName.length())); } public void WriteLine(Player player, int x, int y, int z, BlockFace face, int line, String text) @@ -216,7 +149,7 @@ public class GameLobbyManager implements Listener } if (line > 0) - loc.add(0, line*-6, 0); + loc.add(0, line * -6, 0); UtilBlockText.MakeText(text, loc, face, id, data, TextAlign.CENTER); @@ -228,7 +161,7 @@ public class GameLobbyManager implements Listener Location loc = new Location(_gameText.getWorld(), _gameText.getX(), _gameText.getY(), _gameText.getZ()); if (line > 0) - loc.add(0, line*-6, 0); + loc.add(0, line * -6, 0); BlockFace face = BlockFace.WEST; @@ -240,7 +173,7 @@ public class GameLobbyManager implements Listener Location loc = new Location(_advText.getWorld(), _advText.getX(), _advText.getY(), _advText.getZ()); if (line > 0) - loc.add(0, line*-6, 0); + loc.add(0, line * -6, 0); BlockFace face = BlockFace.EAST; @@ -252,7 +185,7 @@ public class GameLobbyManager implements Listener Location loc = new Location(_kitText.getWorld(), _kitText.getX(), _kitText.getY(), _kitText.getZ()); if (line > 0) - loc.add(0, line*-6, 0); + loc.add(0, line * -6, 0); BlockFace face = BlockFace.NORTH; @@ -264,7 +197,7 @@ public class GameLobbyManager implements Listener Location loc = new Location(_teamText.getWorld(), _teamText.getX(), _teamText.getY(), _teamText.getZ()); if (line > 0) - loc.add(0, line*-6, 0); + loc.add(0, line * -6, 0); BlockFace face = BlockFace.SOUTH; @@ -287,24 +220,24 @@ public class GameLobbyManager implements Listener } @EventHandler(priority = EventPriority.MONITOR) - public void TeamGeneration(GameStateChangeEvent event) + public void TeamGeneration(GameStateChangeEvent event) { if (event.GetState() != GameState.Recruit) return; if (event.GetGame().GetMode() == null) - WriteGameLine(event.GetGame().WorldData.MapName, 1, 159, (byte)4); + WriteGameLine(event.GetGame().WorldData.MapName, 1, 159, (byte) 4); else - WriteGameLine(event.GetGame().WorldData.MapName, 2, 159, (byte)4); - + WriteGameLine(event.GetGame().WorldData.MapName, 2, 159, (byte) 4); + CreateTeams(event.GetGame()); } public void CreateTeams(Game game) { //Text - WriteTeamLine("Select", 0, 159, (byte)15); - WriteTeamLine("Team", 1, 159, (byte)4); + WriteTeamLine("Select", 0, 159, (byte) 15); + WriteTeamLine("Team", 1, 159, (byte) 4); //Remove Old Ents for (Entity ent : _teams.keySet()) @@ -315,33 +248,32 @@ public class GameLobbyManager implements Listener for (Block block : _teamBlocks.keySet()) block.setType(_teamBlocks.get(block)); _teamBlocks.clear(); - + //Smash if (game.HideTeamSheep) { //Text - WriteTeamLine("Select", 0, 159, (byte)15); - WriteTeamLine("Kit", 1, 159, (byte)4); - - CreateScoreboards(); + WriteTeamLine("Select", 0, 159, (byte) 15); + WriteTeamLine("Kit", 1, 159, (byte) 4); + return; } - + //UHC if (game.GetType() == GameType.UHC || game.getClass().getSuperclass().equals(UHC.class)) { if (game.GetTeamList().size() > 1) { //Text - WriteTeamLine("", 0, 159, (byte)15); - WriteTeamLine("", 1, 159, (byte)4); - - for (int i=0 ; i 1 || game.GetTeamList().size() < 6) && game.GetType() != GameType.SurvivalGamesTeams) { //Display ArrayList teams = new ArrayList(); - + for (GameTeam team : game.GetTeamList()) if (team.GetVisible()) teams.add(team); - - //Positions - double space = 6; - double offset = (teams.size()-1)*space/2d; - for (int i=0 ; i teamsA = new ArrayList(); ArrayList teamsB = new ArrayList(); - - for (int i=0 ; i blockMap) + public void SetKitTeamBlocks(Location loc, int id, byte data, NautHashMap blockMap) { //Coloring - Block block = loc.clone().add( 0.5, 0, 0.5).getBlock(); + Block block = loc.clone().add(0.5, 0, 0.5).getBlock(); blockMap.put(block, block.getType()); MapUtil.QuickChangeBlockAt(block.getLocation(), id, data); - block = loc.clone().add(-0.5, 0, 0.5).getBlock(); + block = loc.clone().add(-0.5, 0, 0.5).getBlock(); blockMap.put(block, block.getType()); MapUtil.QuickChangeBlockAt(block.getLocation(), id, data); - block = loc.clone().add( 0.5, 0, -0.5).getBlock(); + block = loc.clone().add(0.5, 0, -0.5).getBlock(); blockMap.put(block, block.getType()); MapUtil.QuickChangeBlockAt(block.getLocation(), id, data); @@ -745,28 +675,28 @@ public class GameLobbyManager implements Listener MapUtil.QuickChangeBlockAt(block.getLocation(), id, data); //Top - block = loc.clone().add( 0.5, 1, 0.5).getBlock(); + block = loc.clone().add(0.5, 1, 0.5).getBlock(); blockMap.put(block, block.getType()); - MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte)5); + MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte) 5); - block = loc.clone().add(-0.5, 1, 0.5).getBlock(); + block = loc.clone().add(-0.5, 1, 0.5).getBlock(); blockMap.put(block, block.getType()); - MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte)5); + MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte) 5); - block = loc.clone().add( 0.5, 1, -0.5).getBlock(); + block = loc.clone().add(0.5, 1, -0.5).getBlock(); blockMap.put(block, block.getType()); - MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte)5); + MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte) 5); block = loc.clone().add(-0.5, 1, -0.5).getBlock(); blockMap.put(block, block.getType()); - MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte)5); + MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte) 5); //Floor - for (int x=-2 ; x<2 ; x++) + for (int x = -2; x < 2; x++) { - for (int z=-2 ; z<2 ; z++) + for (int z = -2; z < 2; z++) { - block = loc.clone().add(x + 0.5, -1, z + 0.5).getBlock(); + block = loc.clone().add(x + 0.5, -1, z + 0.5).getBlock(); blockMap.put(block, block.getType()); MapUtil.QuickChangeBlockAt(block.getLocation(), id, data); @@ -774,34 +704,26 @@ public class GameLobbyManager implements Listener } //Outline - for (int x=-3 ; x<3 ; x++) + for (int x = -3; x < 3; x++) { - for (int z=-3 ; z<3 ; z++) + for (int z = -3; z < 3; z++) { - block = loc.clone().add(x + 0.5, -1, z + 0.5).getBlock(); + block = loc.clone().add(x + 0.5, -1, z + 0.5).getBlock(); if (blockMap.containsKey(block)) continue; blockMap.put(block, block.getType()); - MapUtil.QuickChangeBlockAt(block.getLocation(), 35, (byte)15); + MapUtil.QuickChangeBlockAt(block.getLocation(), 35, (byte) 15); } } } - + public void AddKitLocation(Entity ent, Kit kit, Location loc) { _kits.put(ent, new LobbyEnt(ent, loc, kit)); } - @EventHandler - public void PlayerQuit(PlayerQuitEvent event) - { - _scoreboardMap.remove(event.getPlayer()); - _gemMap.remove(event.getPlayer()); - _kitMap.remove(event.getPlayer()); - } - @EventHandler(priority = EventPriority.LOWEST) public void DamageCancel(CustomDamageEvent event) { @@ -810,7 +732,7 @@ public class GameLobbyManager implements Listener } @EventHandler - public void Update(UpdateEvent event) + public void Update(UpdateEvent event) { if (event.getType() == UpdateType.FAST) { @@ -830,24 +752,24 @@ public class GameLobbyManager implements Listener UpdateAdvertise(); ScoreboardDisplay(event); - ScoreboardSet(event); } - + @EventHandler - public void onWeather(WeatherChangeEvent event) { - + public void onWeather(WeatherChangeEvent event) + { + if (!event.getWorld().equals(spawn.getWorld())) return; - + event.setCancelled(true); } - + @EventHandler - private void RemoveInvalidEnts(GameStateChangeEvent event) + private void RemoveInvalidEnts(GameStateChangeEvent event) { if (event.GetState() != GameState.Recruit) return; - + for (Entity ent : UtilWorld.getWorld("world").getEntities()) { if (ent instanceof Creature || ent instanceof Slime) @@ -860,19 +782,19 @@ public class GameLobbyManager implements Listener if (ent.getPassenger() != null) continue; - + ent.remove(); } } } - private void UpdateAdvertise() + private void UpdateAdvertise() { if (Manager.GetGame() == null || Manager.GetGame().GetState() != GameState.Recruit) return; - - _advertiseStage = (_advertiseStage+1)%2; - + + _advertiseStage = (_advertiseStage + 1) % 2; + if (Manager.GetGame().AdvertiseText(this, _advertiseStage)) { return; @@ -880,19 +802,19 @@ public class GameLobbyManager implements Listener if (_advertiseStage == 0) { - WriteAdvertiseLine("GET MINEPLEX ULTRA", 0, 159, (byte)4); - WriteAdvertiseLine("FOR AMAZING", 1, 159, (byte)15); - WriteAdvertiseLine("FUN TIMES", 2, 159, (byte)15); + WriteAdvertiseLine("GET MINEPLEX ULTRA", 0, 159, (byte) 4); + WriteAdvertiseLine("FOR AMAZING", 1, 159, (byte) 15); + WriteAdvertiseLine("FUN TIMES", 2, 159, (byte) 15); - WriteAdvertiseLine("www.mineplex.com", 4, 159, (byte)15); + WriteAdvertiseLine("www.mineplex.com", 4, 159, (byte) 15); } else if (_advertiseStage == 1) { - WriteAdvertiseLine("KEEP CALM", 0, 159, (byte)4); - WriteAdvertiseLine("AND", 1, 159, (byte)15); - WriteAdvertiseLine("PLAY MINEPLEX", 2, 159, (byte)4); + WriteAdvertiseLine("KEEP CALM", 0, 159, (byte) 4); + WriteAdvertiseLine("AND", 1, 159, (byte) 15); + WriteAdvertiseLine("PLAY MINEPLEX", 2, 159, (byte) 4); - WriteAdvertiseLine("www.mineplex.com", 4, 159, (byte)15); + WriteAdvertiseLine("www.mineplex.com", 4, 159, (byte) 15); } } @@ -928,9 +850,9 @@ public class GameLobbyManager implements Listener if (winnerTeam != null) { _fireworkColor = Color.GREEN; - if (winnerTeam.GetColor() == ChatColor.RED) _fireworkColor = Color.RED; - if (winnerTeam.GetColor() == ChatColor.AQUA) _fireworkColor = Color.BLUE; - if (winnerTeam.GetColor() == ChatColor.YELLOW) _fireworkColor = Color.YELLOW; + if (winnerTeam.GetColor() == ChatColor.RED) _fireworkColor = Color.RED; + if (winnerTeam.GetColor() == ChatColor.AQUA) _fireworkColor = Color.BLUE; + if (winnerTeam.GetColor() == ChatColor.YELLOW) _fireworkColor = Color.YELLOW; _fireworkStart = System.currentTimeMillis(); } @@ -941,12 +863,12 @@ public class GameLobbyManager implements Listener if (UtilTime.elapsed(_fireworkStart, 10000)) return; - UtilFirework.playFirework(spawn.clone().add(Math.random()*160-80, 30 + Math.random()*10, Math.random()*160-80), + UtilFirework.playFirework(spawn.clone().add(Math.random() * 160 - 80, 30 + Math.random() * 10, Math.random() * 160 - 80), Type.BALL_LARGE, _fireworkColor, false, false); } @EventHandler - public void Combust(EntityCombustEvent event) + public void Combust(EntityCombustEvent event) { for (LobbyEnt ent : _kits.values()) if (event.getEntity().getWorld().getUID().equals(ent.GetEnt().getWorld().getUID()) && @@ -957,21 +879,21 @@ public class GameLobbyManager implements Listener } } - public void DisplayLast(Game game) + public void DisplayLast(Game game) { //Start Fireworks RegisterFireworks(game.WinnerTeam); } - public void DisplayNext(Game game, HashMap pastTeams) + public void DisplayNext(Game game, HashMap pastTeams) { - WriteGameLine(game.GetType().GetLobbyName(), 0, 159, (byte)14); - + WriteGameLine(game.GetType().GetLobbyName(), 0, 159, (byte) 14); + if (Manager.GetGame().GetMode() == null) - WriteGameLine(" ", 1, 159, (byte)1); + WriteGameLine(" ", 1, 159, (byte) 1); else - WriteGameLine(Manager.GetGame().GetMode(), 1, 159, (byte)1); - + WriteGameLine(Manager.GetGame().GetMode(), 1, 159, (byte) 1); + DisplayWaiting(); CreateKits(game); CreateTeams(game); @@ -979,7 +901,7 @@ public class GameLobbyManager implements Listener public void DisplayWaiting() { - WriteGameLine("waiting for players", 3, 159, (byte)13); + WriteGameLine("waiting for players", 3, 159, (byte) 13); } @EventHandler @@ -988,199 +910,64 @@ public class GameLobbyManager implements Listener if (event.getType() != UpdateType.FAST) return; - if (Manager.GetGame() != null && - (Manager.GetGame().GetState() != GameState.Loading && - Manager.GetGame().GetState() != GameState.Recruit)) + if (Manager.GetGame() != null && + (Manager.GetGame().GetState() != GameState.Loading && + Manager.GetGame().GetState() != GameState.Recruit)) { for (Player player : UtilServer.getPlayers()) - player.setScoreboard(Manager.GetGame().GetScoreboard().GetScoreboard()); //XXX + player.setScoreboard(Manager.GetGame().GetScoreboard().getScoreboard()); //XXX } else { - for (Player player : UtilServer.getPlayers()) + for (Entry ent : Manager.getScoreboardManager().getScoreboards().entrySet()) { - if (!HasScoreboard(player)) + if (Bukkit.getPlayer(ent.getKey()) != null) { - CreateScoreboard(player, true); - } - else - { - player.setScoreboard(_scoreboardMap.get(player)); + Bukkit.getPlayer(ent.getKey()).setScoreboard(ent.getValue().getHandle()); } } } } - - //this is called from above - public void ScoreboardSet(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - if (Manager.GetGame() != null && !Manager.GetGame().DisplayLobbySide) - { - return; - } - - _colorTick = !_colorTick; - - int spectatorCount = 0; - - for(Player players : UtilServer.GetPlayers()) - { - if (Manager.isVanished(players)) - { - spectatorCount++; - } - } - - for (Entry entry : _scoreboardMap.entrySet()) - { - Objective objective = entry.getValue().getObjective("§l" + "Lobby"); - - if (Manager.GetGame() != null && Manager.GetGame().GetCountdown() >= 0) - { - if (Manager.GetGame().GetCountdown() > 0) - objective.setDisplayName(C.Bold + "§lStarting in " + C.cGreen + "§l" + Manager.GetGame().GetCountdown() + (Manager.GetGame().GetCountdown() == 1 ? " Second" : " Seconds")); - else if (Manager.GetGame().GetCountdown() == 0) - objective.setDisplayName(ChatColor.WHITE + "§lIn Progress..."); - } - else - { - if (Manager.GetGame() instanceof UHC && !((UHC)Manager.GetGame()).isMapLoaded()) - { - objective.setDisplayName(((UHC) Manager.GetGame()).getObjectiveName(_colorTick)); - } - else - { - objective.setDisplayName(ChatColor.GREEN + "§l" + "Waiting for Players"); - } - } - - int line = 15; - - objective.getScore(" ").setScore(line--); - - objective.getScore(C.cYellow + C.Bold + "Players").setScore(line--); - - // Remove Old - entry.getValue().resetScores(_oldPlayerCount + "/" + _oldMaxPlayerCount); - // Set new - - objective.getScore(UtilServer.getPlayers().length - spectatorCount + "/" + Manager.GetPlayerFull()).setScore(line--); - - if (Manager.GetGame() != null) - { - ChatColor teamColor = ChatColor.GRAY; - String kitName = "None"; - - if (Manager.GetGame().GetTeam(entry.getKey()) != null) - { - teamColor = Manager.GetGame().GetTeam(entry.getKey()).GetColor(); - } - - if (Manager.GetGame().GetKit(entry.getKey()) != null) - { - kitName = Manager.GetGame().GetKit(entry.getKey()).GetName() + ""; - } - - if (teamColor == null) - - //Shorten Kit Name - if (kitName.length() > 16) - kitName = kitName.substring(0, 16); - - // Remove old - //entry.getValue().resetScores(teamColor + C.Bold + "Kit"); - for(String string : entry.getValue().getEntries()) - { - if(string.endsWith("Kit")) - { - entry.getValue().resetScores(string); - } - } - entry.getValue().resetScores(_kitMap.get(entry.getKey()) + ""); - - // Set new - objective.getScore(" ").setScore(line--); - objective.getScore(teamColor + C.Bold + "Kit").setScore(line--); - objective.getScore(kitName + "").setScore(line--); - - _kitMap.put(entry.getKey(), kitName + ""); - } - - objective.getScore(" ").setScore(line--); - objective.getScore(C.cGreen + C.Bold + "Gems").setScore(line--); - - // Remove old - entry.getValue().resetScores(_gemMap.get(entry.getKey()) + " "); - // Set new - objective.getScore(Manager.GetDonation().Get(entry.getKey().getName()).getBalance(GlobalCurrency.GEM) + " ").setScore(line--); - - _gemMap.put(entry.getKey(), Manager.GetDonation().Get(entry.getKey().getName()).getBalance(GlobalCurrency.GEM)); - - //Server - objective.getScore(" ").setScore(line--); - objective.getScore(C.cAqua + C.Bold + "Server").setScore(line--); - objective.getScore(_serverName).setScore(line--); - - // ELO DIVISION - if (Manager.GetGame() != null && Manager.GetGame().EloRanking) - { - objective.getScore(" ").setScore(line--); - objective.getScore(C.cPurpleB + C.Bold + "Division").setScore(line--); - - // Remove old - entry.getValue().resetScores(_divisionMap.get(entry.getKey()) + " "); - // Set new - EloDivision ed = EloDivision.getDivision(Manager.getEloManager().getElo(entry.getKey(), Manager.GetGame().GetType().getGameId())); - objective.getScore(ed.getDisplayName() + " ").setScore(line--); - } - } - - _oldPlayerCount = UtilServer.getPlayers().length - spectatorCount; - _oldMaxPlayerCount = Manager.GetPlayerFull(); - } private String GetKitCustomName(Player player, Game game, LobbyEnt ent) { CoreClient client = Manager.GetClients().Get(player); - Donor donor = Manager.GetDonation().Get(player.getName()); + Donor donor = Manager.GetDonation().Get(player); String entityName = ent.GetKit().GetName(); if (!player.isOnline() || client == null || donor == null) return entityName; - + if (client.GetRank() == null) { System.out.println("client rank is null"); } - + if (game == null) { System.out.println("game is null"); } - + if (Manager == null) { System.out.println("Manager is null"); } - + if (Manager.GetServerConfig() == null) { System.out.println("Manager.GetServerConfig() is null"); } - - if (ent.GetKit().GetAvailability() == KitAvailability.Free || //Free - Manager.hasKitsUnlocked(player) || //YouTube - (ent.GetKit().GetAvailability() == KitAvailability.Achievement && - Manager.GetAchievement().hasCategory(player, ent.GetKit().getAchievementRequirement())) || //Achievement - donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName(game) + " " + ent.GetKit().GetName()) || //Green - Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || //STAFF - donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) - Manager.GetServerConfig().Tournament) //Tournament + + if (ent.GetKit().GetAvailability() == KitAvailability.Free || //Free + Manager.hasKitsUnlocked(player) || //YouTube + (ent.GetKit().GetAvailability() == KitAvailability.Achievement && + Manager.GetAchievement().hasCategory(player, ent.GetKit().getAchievementRequirement())) || //Achievement + donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName(game) + " " + ent.GetKit().GetName()) || //Green + Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || //STAFF + donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) + Manager.GetServerConfig().Tournament) //Tournament { entityName = ent.GetKit().GetAvailability().GetColor() + entityName; } @@ -1223,120 +1010,149 @@ public class GameLobbyManager implements Listener } } - public void AddPlayerToScoreboards(Player player, String teamName) - { - if (teamName == null) - teamName = ""; + public void AddPlayerToScoreboards(Player player, GameTeam gameTeam) + { + Rank rank = Manager.GetClients().Get(player).getRealOrDisguisedRank(); + String teamId = getTeamId(gameTeam, player); + + for (MineplexScoreboard scoreboard : Manager.getScoreboardManager().getScoreboards().values()) + { + Team team = scoreboard.getHandle().getTeam(teamId); + if (team == null) + { + team = scoreboard.getHandle().registerNewTeam(teamId); + if (gameTeam != null) + { + if (gameTeam.GetDisplaytag()) + { + team.setPrefix(gameTeam.GetColor() + C.Bold + gameTeam.GetName() + gameTeam.GetColor() + " "); + } + else + { + if (rank == Rank.ALL) + { + team.setPrefix(gameTeam.GetColor() + ""); + } + else + { + team.setPrefix(rank.getTag(true, true) + ChatColor.RESET + " " + gameTeam.GetColor()); + } + } + } + } + team.addEntry(player.getName()); + } + } + + public void RemovePlayerFromTeam(Player player, GameTeam gameTeam) + { + Rank rank = Manager.GetClients().Get(player).getRealOrDisguisedRank(); + + String teamId = getTeamId(gameTeam, player); + + for (MineplexScoreboard scoreboard : Manager.getScoreboardManager().getScoreboards().values()) + { + Team team = scoreboard.getHandle().getTeam(teamId); + if (team != null) + { + team.removeEntry(player.getName()); + } + scoreboard.getHandle().getTeam(rank.Name).addEntry(player.getName()); + } + } + + public String getTeamId(GameTeam gameTeam, Player player) + { + Rank rank = Manager.GetClients().Get(player).getRealOrDisguisedRank(); + String rankName = rank.Name; + boolean rankIsUltra = !rank.has(Rank.ULTRA) && + Manager.GetDonation().Get(player).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"); - String rankName = Manager.GetClients().Get(player).GetRank().Name; - boolean rankIsUltra = !Manager.GetClients().Get(player).GetRank().has(Rank.ULTRA) && Manager.GetDonation().Get(player.getName()).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"); - if (rankIsUltra) { rankName = Rank.ULTRA.Name; } - - String rankTeamName = rankName + teamName; - for (Scoreboard scoreboard : GetScoreboards()) + String teamId; + if (gameTeam != null && gameTeam.GetDisplaytag()) { - try + teamId = "GT" + String.valueOf(gameTeam.getTeamId()); + } + else + { + teamId = rankName; + + if (gameTeam != null && gameTeam.GetColor() != null) { - scoreboard.getTeam(rankTeamName).addPlayer(player); - } - catch (Exception e) - { - //UHC adds people to teams earlier than usual, which can case this - if (Manager.GetGame() instanceof UHC) - { - try - { - Manager.GetGame().GetScoreboard().GetScoreboard().getTeam(teamName).addPlayer(player); - System.out.println("GameLobbyManager UHC Team Assignment Success"); - break; - } - catch(Exception f) - { - System.out.println("GameLobbyManager AddPlayerToScoreboard UHC Error"); - System.out.println("[" + teamName + "] adding [" + player.getName() + "]"); - System.out.println("Team is Null [" + (Manager.GetGame().GetScoreboard().GetScoreboard().getTeam(teamName) == null) + "]"); - } - } - else - { - System.out.println("GameLobbyManager AddPlayerToScoreboard Error"); - System.out.println("[" + rankTeamName + "] adding [" + player.getName() + "]"); - System.out.println("Team is Null [" + (scoreboard.getTeam(rankTeamName) == null) + "]"); - } + teamId += "." + gameTeam.GetColor().getChar(); } } - - + return teamId; } - + @EventHandler public void disallowInventoryClick(InventoryClickEvent event) { if (Manager.GetGame() == null) return; - + if (Manager.GetGame().GetState() != GameState.Recruit) return; - + if (event.getInventory().getType() == InventoryType.CRAFTING) { event.setCancelled(true); event.getWhoClicked().closeInventory(); } } - + @EventHandler public void InventoryUpdate(UpdateEvent event) { if (!Manager.IsHotbarInventory()) return; - + if (event.getType() != UpdateType.FAST) - return; - + return; + if (Manager.GetGame() == null) return; - + if (Manager.GetGame().GetState() != GameState.Recruit && Manager.GetGame().GadgetsDisabled) return; - + for (Player player : UtilServer.getPlayers()) { if (player.getOpenInventory().getType() != InventoryType.CRAFTING) continue; - + //Cosmetic Menu Manager.getCosmeticManager().giveInterfaceItem(player); Manager.getBoosterManager().giveInterfaceItem(player); } } - + @EventHandler(priority = EventPriority.LOWEST) public void explodeBlockBreakFix(EntityExplodeEvent event) { if (Manager.GetGame() == null) return; - + if (Manager.GetGame().GetState() == GameState.Live) return; event.blockList().clear(); } - + @EventHandler(priority = EventPriority.LOWEST) public void velocityEventCancel(PlayerVelocityEvent event) { if (Manager.GetGame() == null) return; - + if (Manager.GetGame().GetState() == GameState.Live) return; - + event.setCancelled(true); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index cadc5f53c..d6403af05 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -519,7 +519,7 @@ public class GameManager implements Listener Game game = Manager.GetGame(); if (game == null) return; - game.GetScoreboard().UpdateTitle(); + game.GetScoreboard().updateTitle(); } @EventHandler(priority = EventPriority.LOWEST) //BEFORE PARSE DATA @@ -577,15 +577,6 @@ public class GameManager implements Listener game.ParseData(); } - @EventHandler(priority = EventPriority.MONITOR) - public void TeamScoreboardCreation(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Recruit) - return; - - event.GetGame().GetScoreboard().CreateTeams(); - } - public void TeamPreferenceJoin(Game game) { //Preferred Team No Longer Full @@ -832,17 +823,7 @@ public class GameManager implements Listener }, i); } } - - @EventHandler - public void disguiseClean(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Dead) - return; - Manager.GetDisguise().clearDisguises(); - } - - @EventHandler public void WorldFireworksUpdate(UpdateEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index 86d41b5be..9b632cf65 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -118,9 +118,6 @@ public class GamePlayerManager implements Listener UtilTabTitle.setHeaderAndFooter(player, Manager.GetGame() != null ? C.cGold + C.Bold + Manager.GetGame().GetType().GetName() : " ", "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop"); - - //Lobby Name - Manager.GetLobby().AddPlayerToScoreboards(player, null); //Lobby Spawn if (Manager.GetGame() == null || !Manager.GetGame().InProgress()) @@ -177,7 +174,7 @@ public class GamePlayerManager implements Listener UtilPlayer.message(player, F.main("Game", Manager.GetGame().GetName() + " is in progress, please wait for next game!")); } - player.setScoreboard(Manager.GetGame().GetScoreboard().GetScoreboard()); + player.setScoreboard(Manager.GetGame().GetScoreboard().getScoreboard()); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java index 5aa9b23c5..2b60a12da 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java @@ -178,8 +178,8 @@ public class GameRewardManager implements Listener if(Manager.GetClients().Get(player).getDisguisedAs() != null) { - changeName(player, Manager.GetClients().Get(player).GetPlayerName()); - System.out.println("Gems for " + Manager.GetClients().Get(player).GetPlayerName()); + changeName(player, Manager.GetClients().Get(player).getName()); + System.out.println("Gems for " + Manager.GetClients().Get(player).getName()); } // Award players shards equal to base gems, plus booster bonuses. @@ -196,7 +196,7 @@ public class GameRewardManager implements Listener // Gem Finder if (game.GemHunterEnabled) { - int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel(); + int gemFinder = Manager.GetAchievement().get(player, Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) { gemsToReward += (int)(baseGemsEarned * (gemFinder * 0.25)); @@ -321,7 +321,7 @@ public class GameRewardManager implements Listener //Gem Finder if (game.GemHunterEnabled) { - int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel(); + int gemFinder = Manager.GetAchievement().get(player, Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) { UtilPlayer.message(player, F.elem(C.cGreen + "+" + ((int)(earnedGems*(gemFinder * 0.25)) + " Gems")) + " for " + @@ -399,8 +399,8 @@ public class GameRewardManager implements Listener if (give) { UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " + - C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getName()).getBalance(GlobalCurrency.GEM) + totalGems) + " Gems") + C.cWhite + C.Bold + " and " + - F.elem(C.cAqua + C.Bold + (Manager.GetDonation().Get(player.getName()).getBalance(GlobalCurrency.TREASURE_SHARD) + shards) + " Treasure Shards")); + C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getUniqueId()).getBalance(GlobalCurrency.GEM) + totalGems) + " Gems") + C.cWhite + C.Bold + " and " + + F.elem(C.cAqua + C.Bold + (Manager.GetDonation().Get(player.getUniqueId()).getBalance(GlobalCurrency.TREASURE_SHARD) + shards) + " Treasure Shards")); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java index 8e6088764..21132157e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java @@ -46,9 +46,9 @@ import java.util.UUID; public class GameSpectatorManager implements Listener, IPacketHandler { // A map of a player UUID to the UUID of the entity they want to spectate - private Map _pendingSpectate = Collections.synchronizedMap(new HashMap<>()); + private final Map _pendingSpectate = Collections.synchronizedMap(new HashMap<>()); - private ArcadeManager _manager; + private final ArcadeManager _manager; public GameSpectatorManager(ArcadeManager manager) { @@ -70,11 +70,6 @@ public class GameSpectatorManager implements Listener, IPacketHandler if (!_manager.GetGame().IsAlive(player)) event.setCancelled(true); - processClick(player, event.getAction()); - } - - public void processClick(Player player, Action action) - { if (_manager.GetGame() == null) return; @@ -102,7 +97,7 @@ public class GameSpectatorManager implements Listener, IPacketHandler break; } - if (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) + if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) currentPlayer = currentPlayer - 2; else return; @@ -212,6 +207,7 @@ public class GameSpectatorManager implements Listener, IPacketHandler } } + // todo what if we cancel this event? @EventHandler(priority = EventPriority.LOW) public void dismountEntity(PlayerToggleSneakEvent event) { @@ -284,6 +280,7 @@ public class GameSpectatorManager implements Listener, IPacketHandler _pendingSpectate.put(player.getUniqueId(), target.getUniqueId()); EntityPlayer ep = ((CraftPlayer) player).getHandle(); + EntityTracker tracker = ep.u().getTracker(); EntityTrackerEntry entry = tracker.trackedEntities.get(target.getEntityId()); @@ -300,6 +297,7 @@ public class GameSpectatorManager implements Listener, IPacketHandler UtilPlayer.message(player, F.main("Game", "Sneak to stop spectating.")); _pendingSpectate.remove(player.getUniqueId()); + return; } // We still set spectating here even though it's pointless because of updateSpecEntites() above diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTournamentManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTournamentManager.java index 44dd582f0..698cc5a92 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTournamentManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTournamentManager.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.scoreboard.MineplexScoreboard; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; @@ -123,8 +124,9 @@ public class GameTournamentManager implements Listener if (!Manager.IsTournamentPoints()) return; - for (Scoreboard scoreboard : Manager.GetLobby().GetScoreboards()) + for (MineplexScoreboard mpscoreboard : Manager.getScoreboardManager().getScoreboards().values()) { + Scoreboard scoreboard = mpscoreboard.getHandle(); Objective objective = scoreboard.getObjective(DisplaySlot.BELOW_NAME); if (objective == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java index 00beb0a37..944ed3ec4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -27,6 +27,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.stream.Collectors; +import java.util.UUID; public class GameChatManager implements Listener { @@ -83,18 +84,7 @@ public class GameChatManager implements Listener if (!_manager.GetGame().IsAlive(sender)) dead = C.cGray + "Dead " + C.Reset; - Rank rank = _manager.GetClients().Get(sender).GetRank(); - String disguiseTag = ""; - if(_manager.GetClients().Get(sender).isDisguised()) - { - CoreClient cc = _manager.GetClients().Get(sender); - rank = cc.getDisguisedRank(); - - if(!cc.GetRank().has(Rank.JNR_DEV)) - { - disguiseTag = ChatColor.BLACK + " "; - } - } + Rank rank = _manager.GetClients().Get(sender).getRealOrDisguisedRank(); //Level String levelStr = ""; @@ -133,7 +123,14 @@ public class GameChatManager implements Listener event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + event.getPlayer().getName() + " " + C.cPurple + "%2$s"); - event.getRecipients().addAll(party.getMembersByUUID().stream().map(Bukkit::getPlayer).collect(Collectors.toList())); + + for (UUID member : party.getMembers()) + { + Player other = Bukkit.getPlayer(member); + + if (other != null) + event.getRecipients().add(other); + } } else { @@ -170,7 +167,7 @@ public class GameChatManager implements Listener } //Base Format - event.setFormat(disguiseTag + dead + levelStr + rankStr + _manager.GetColor(sender) + senderName + " " + C.cWhite + "%2$s"); + event.setFormat(dead + levelStr + rankStr + _manager.GetColor(sender) + senderName + " " + C.cWhite + "%2$s"); //Public/Private (Not If Player Dead) if (_manager.GetGame() != null && _manager.GetGame().GetState() == GameState.Live) @@ -189,10 +186,10 @@ public class GameChatManager implements Listener else globalMessage = true; - event.setFormat(isPriv ? disguiseTag + C.cWhiteB + "Team " + dead + levelStr + rankStr + senderName + " " + C.cWhite + "%2$s" : disguiseTag + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); + event.setFormat(isPriv ? C.cWhiteB + "Team " + dead + levelStr + rankStr + senderName + " " + C.cWhite + "%2$s" : dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); if(rankStr.equals("")) - format = isPriv ? disguiseTag + C.cWhiteB + "Team " + dead + levelStr : disguiseTag + dead + levelStr; + format = isPriv ? C.cWhiteB + "Team " + dead + levelStr : dead + levelStr; else format = event.getFormat().split(rankStr)[0]; @@ -201,10 +198,10 @@ public class GameChatManager implements Listener else { globalMessage = true; - event.setFormat(disguiseTag + dead + levelStr + rankStr + senderName + " " + C.cWhite + "%2$s"); + event.setFormat(dead + levelStr + rankStr + senderName + " " + C.cWhite + "%2$s"); if(rankStr.equals("")) - format = disguiseTag + dead + levelStr; + format = dead + levelStr; else format = event.getFormat().split(rankStr)[0]; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java index 6500f6308..8a787fc58 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java @@ -1,64 +1,49 @@ package nautilus.game.arcade.scoreboard; -import java.util.ArrayList; +import mineplex.core.common.Pair; import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilMath; +import mineplex.core.scoreboard.WritableMineplexScoreboard; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Score; import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; -public class GameScoreboard +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +public class GameScoreboard extends WritableMineplexScoreboard { - private Game Game; - - private Scoreboard _scoreboard; - private Objective _sideObjective; - - private ArrayList _elements = new ArrayList(); - private char[] _chars = "1234567890abcdefghijklmnopqrstuvwxyz".toCharArray(); - private ArrayList _previousLines = new ArrayList(); + private Game _game; private String _title; private int _shineIndex; private boolean _shineDirection = true; - - private boolean _debug = false; - + public GameScoreboard(Game game) { - Game = game; + _game = game; _title = " MINEPLEX "; - //Scoreboard - _scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); - - _sideObjective = _scoreboard.registerNewObjective("Obj"+UtilMath.r(999999999), "dummy"); - _sideObjective.setDisplaySlot(DisplaySlot.SIDEBAR); - _sideObjective.setDisplayName(C.Bold + _title); + setSidebarName(C.Bold + _title); } - public Scoreboard GetScoreboard() + public Scoreboard getScoreboard() { - return _scoreboard; + return getHandle(); } - public Objective GetObjectiveSide() - { - return _sideObjective; - } - - public void UpdateTitle() + public void updateTitle() { String out; - + if (_shineDirection) { out = C.cGold + C.Bold; @@ -67,16 +52,16 @@ public class GameScoreboard { out = C.cWhite + C.Bold; } - - for (int i=0 ; i < _title.length() ; i++) + + for (int i = 0; i < _title.length(); i++) { char c = _title.charAt(i); - + if (_shineDirection) { if (i == _shineIndex) out += C.cYellow + C.Bold; - + if (i == _shineIndex + 1) out += C.cWhite + C.Bold; } @@ -84,254 +69,102 @@ public class GameScoreboard { if (i == _shineIndex) out += C.cYellow + C.Bold; - + if (i == _shineIndex + 1) out += C.cGold + C.Bold; } - - + + out += c; } - - _sideObjective.setDisplayName(out); - + + setSidebarName(out); + _shineIndex++; - - if (_shineIndex == _title.length()*2) + + if (_shineIndex == _title.length() * 2) { _shineIndex = 0; _shineDirection = !_shineDirection; } } - public String ParseTeamName(String name) + public void setPlayerTeam(Player player, GameTeam gameTeam) { - return name.substring(0, Math.min(16, name.length())); - } + String teamId = _game.getArcadeManager().GetLobby().getTeamId(gameTeam, player); - public void CreateTeams() - { - System.out.println("Creating Scoreboard Teams."); - - - _scoreboard.registerNewTeam(ParseTeamName("SPEC")).setPrefix(ChatColor.GRAY + ""); - - //Team Groups - for (GameTeam team : Game.GetTeamList()) + if (getHandle().getTeam(teamId) == null) { - System.out.println("Scoreboard Team: " + team.GetName().toUpperCase()); - if (team.GetDisplaytag()) - { - Team group = _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())); + Team targetTeam = getHandle().registerNewTeam(teamId); - group.setPrefix(team.GetColor() + C.Bold + team.GetName() + team.GetColor() + " "); - group.setSuffix(C.Reset); + if (gameTeam.GetDisplaytag()) + { + targetTeam.setPrefix(gameTeam.GetColor() + C.Bold + gameTeam.GetName() + gameTeam.GetColor() + " "); + targetTeam.setSuffix(C.Reset); } else { - Team group = _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())); - - group.setPrefix(team.GetColor() + ""); - group.setSuffix(C.Reset); - } - } - - /* - //Base Groups - for (Rank rank : Rank.values()) - { - //_scoreboard.registerNewTeam(ParseTeamName(rank.Name + "SPEC")).setPrefix(ChatColor.GRAY + ""); - } - - //Team Groups - for (GameTeam team : Game.GetTeamList()) - { - System.out.println("Scoreboard Team: " + team.getName().toUpperCase()); - - for (Rank rank : Rank.values()) - { - _scoreboard.registerNewTeam(ParseTeamName(rank.Name + team.getName().toUpperCase())).setPrefix(team.GetColor() + ""); - } - } - */ - } - - public void SetPlayerTeam(Player player, String teamName) - { - for (Team team : _scoreboard.getTeams()) - team.removePlayer(player); - - if (teamName == null) - teamName = ""; - - String team = ParseTeamName(teamName); - - try - { - _scoreboard.getTeam(team).addPlayer(player); - } - catch (Exception e) - { - e.printStackTrace(); - System.out.println("ERROR ADDING PLAYER TO TEAM: " + team); - } - } - - public void ResetScore(String line) - { - _scoreboard.resetScores(line); - } - - /* - public void Reset() - { - for (ScoreboardElement elem : _elements) - { - for (String line : elem.getLines()) - { - ResetScore(line); + targetTeam.setPrefix(gameTeam.GetColor() + ""); + targetTeam.setSuffix(C.Reset); } } - _elements.clear(); - - _space = " "; - } - */ - - public void Write(String line) - { - _elements.add(new ScoreboardElementText(line)); + setPlayerTeam(player, teamId); } - public void WriteOrdered(String key, String line, int value, boolean prependScore) + public void setSpectating(Player player) { - if (prependScore) - line = value + " " + line; - - for (ScoreboardElement elem : _elements) + if (getHandle().getTeam("SPEC") == null) { - if (elem instanceof ScoreboardElementScores) - { - ScoreboardElementScores scores = (ScoreboardElementScores)elem; + getHandle().registerNewTeam("SPEC").setPrefix(C.cGray); + } + setPlayerTeam(player, "SPEC"); + } - if (scores.IsKey(key)) - { - scores.AddScore(line, value); - return; - } - } + private void setPlayerTeam(Player player, String teamId) + { + for (Team team : getHandle().getTeams()) + team.removeEntry(player.getName()); + + getHandle().getTeam(teamId).addEntry(player.getName()); + } + + public void writeGroup(Collection players, Function> score, boolean prependScore) + { + Map scores = new HashMap<>(); + Map names = new HashMap<>(); + + for (T player : players) + { + Pair result = score.apply(player); + if (result == null) continue; + scores.put(player, result.getRight()); + names.put(player, result.getLeft()); } - _elements.add(new ScoreboardElementScores(key, line, value, true)); + scores = sortByValue(scores); + + for (Map.Entry entry : scores.entrySet()) + { + String line = names.get(entry.getKey()); + if (prependScore) + { + line = entry.getValue() + " " + line; + } + write(line); + } } - public void WriteBlank() + private > Map sortByValue(Map map) { - _elements.add(new ScoreboardElementText(" ")); - } + List> list = new LinkedList<>(map.entrySet()); + Collections.sort(list, (o1, o2) -> (o2.getValue()).compareTo(o1.getValue())); - public void Draw() - { - if (_debug) System.out.println(); - if (_debug) System.out.println("/////////////////////////"); - - // Generate Lines - ArrayList newLines = new ArrayList(); - - for (ScoreboardElement elem : _elements) + Map result = new LinkedHashMap<>(); + for (Map.Entry entry : list) { - newLines.addAll(elem.GetLines()); + result.put(entry.getKey(), entry.getValue()); } - - int i = 0; - while (true) - { - if (i >= _chars.length) - break; - - String str = ChatColor.COLOR_CHAR + "" + _chars[i] + C.Reset; - - Score score = GetObjectiveSide().getScore(str); - - if (newLines.size() <= i) - { - if (score.isScoreSet()) - { - ResetScore(str); - } - else - { - break; - } - } - else if (i >= _previousLines.size() || !_previousLines.get(i).equals(newLines.get(i))) - { - Team team = GetScoreboard().getTeam(str); - - if (team == null) - { - team = GetScoreboard().registerNewTeam(str); - team.addEntry(str); - } - - String[] line = split(newLines.get(i)); - - team.setPrefix(line[0]); - team.setSuffix(line[1]); - - if (!score.isScoreSet()) - { - if (i == 15) - { - score.setScore(1); - } - - score.setScore(15 - i); - } - } - - i++; - } - - _previousLines = newLines; - } - - private String[] split(String line) - { - String[] strings = new String[2]; - - if (line.length() > 16) - { - String line1 = line.substring(0, 16); - String line2 = line.substring(16); - - if (line1.endsWith(ChatColor.COLOR_CHAR + "")) - { - line2 = line1.substring(15, 16) + line2; - line1 = line1.substring(0, 15); - } - - line2 = ChatColor.getLastColors(line1) + line2; - - if (line2.length() > 16) - { - line2 = line2.substring(0, 16); - } - - strings[0] = line1; - strings[1] = line2; - } - else - { - strings[0] = line; - strings[1] = ""; - } - - return strings; - } - public void Reset() - { - _elements.clear(); + return result; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElement.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElement.java deleted file mode 100644 index a7df64281..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElement.java +++ /dev/null @@ -1,8 +0,0 @@ -package nautilus.game.arcade.scoreboard; - -import java.util.ArrayList; - -public abstract class ScoreboardElement -{ - public abstract ArrayList GetLines(); -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementScores.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementScores.java deleted file mode 100644 index 02302866d..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementScores.java +++ /dev/null @@ -1,65 +0,0 @@ -package nautilus.game.arcade.scoreboard; - -import java.util.ArrayList; -import java.util.HashMap; - -public class ScoreboardElementScores extends ScoreboardElement -{ - private String _key; - - private HashMap _scores; - - private boolean _higherIsBetter; - - public ScoreboardElementScores(String key, String line, int value, boolean higherIsBetter) - { - _scores = new HashMap(); - - _key = key; - - AddScore(line, value); - - _higherIsBetter = higherIsBetter; - } - - @Override - public ArrayList GetLines() - { - ArrayList orderedScores = new ArrayList(); - - //Order Scores - while (orderedScores.size() < _scores.size()) - { - String bestKey = null; - int bestScore = 0; - - for (String key : _scores.keySet()) - { - if (orderedScores.contains(key)) - continue; - - if (bestKey == null || - (_higherIsBetter && _scores.get(key) >= bestScore) || - (!_higherIsBetter && _scores.get(key) <= bestScore)) - { - bestKey = key; - bestScore = _scores.get(key); - } - } - - orderedScores.add(bestKey); - } - - return orderedScores; - } - - public boolean IsKey(String key) - { - return _key.equals(key); - } - - public void AddScore(String line, int value) - { - _scores.put(line, value); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementText.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementText.java deleted file mode 100644 index cccb2b8fa..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementText.java +++ /dev/null @@ -1,24 +0,0 @@ -package nautilus.game.arcade.scoreboard; - -import java.util.ArrayList; - -public class ScoreboardElementText extends ScoreboardElement -{ - private String _line; - - public ScoreboardElementText(String line) - { - _line = line; - } - - @Override - public ArrayList GetLines() - { - ArrayList orderedScores = new ArrayList(); - - orderedScores.add(_line); - - return orderedScores; - } - -} diff --git a/Plugins/app.xml b/Plugins/app.xml index aa91bc8fc..77c896f20 100644 --- a/Plugins/app.xml +++ b/Plugins/app.xml @@ -37,6 +37,7 @@ com.mineplex:spigot + com.mineplex:anticheat diff --git a/Plugins/plugin.xml b/Plugins/plugin.xml index c6ed635aa..a7e80fd04 100644 --- a/Plugins/plugin.xml +++ b/Plugins/plugin.xml @@ -46,6 +46,7 @@ com.google.code.gson:gson com.mineplex:spigot + com.mineplex:anticheat From 4562b00dcb272fce1516f3e52bf6778fe8727191 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 11 Aug 2016 03:51:16 -0400 Subject: [PATCH 78/89] Repurpose MAC reports pref for GWEN reports --- .../src/mineplex/core/antihack/AntiHack.java | 15 ++------------- .../ui/ExclusivePreferencesPage.java | 17 ++++++++++++----- .../core/preferences/ui/PreferencesPage.java | 2 +- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 0a032f529..67bb54c00 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -8,6 +8,7 @@ import com.mineplex.anticheat.api.GameStartEvent; import com.mineplex.anticheat.api.MineplexLink; import com.mineplex.anticheat.api.PlayerViolationEvent; import mineplex.core.PlayerSelector; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClient; @@ -257,7 +258,7 @@ public class AntiHack extends MiniPlugin for (Player player : Bukkit.getOnlinePlayers()) { - if (_clientManager.Get(player).GetRank().has(Rank.HELPER)) + if (Managers.get(PreferencesManager.class).Get(player).ShowMacReports && _clientManager.Get(player).GetRank().has(Rank.HELPER)) { ((CraftPlayer) player).getHandle().sendMessage(component); } @@ -845,14 +846,6 @@ public class AntiHack extends MiniPlugin total += _offense.get(player).get(curType).size(); } - - //Inform - for (Player admin : UtilServer.getPlayers()) - if (_clientManager.Get(admin).GetRank().has(Rank.SNR_MODERATOR) && _preferences.Get(admin).ShowMacReports) - { - UtilPlayer.message(admin, "#" + total + ": " + C.cRed + C.Bold + player.getName() + " suspected for " + type + "."); - } - // Print (Debug) System.out.println("[Offense] #" + total + ": " + player.getName() + " received suspicion for " + type + "."); } @@ -929,10 +922,6 @@ public class AntiHack extends MiniPlugin UtilPlayer.message(player, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " GWEN > " + ChatColor.RESET + C.cGold + event.getPlayer().getName() + C.cYellow + " failed " + event.getHackType() + " VL" + event.getViolations() + ": " + event.getMessage() + ". Please investigate"); } } - else if (client.GetRank().has(Rank.SNR_MODERATOR) && _preferences.Get(player).ShowMacReports) - { - UtilPlayer.message(player, "#" + event.getViolations() + ": " + C.cRed + C.Bold + event.getPlayer().getName() + " suspected for " + event.getHackType() + "."); - } } if (event.shouldTellStaff()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java index 3dee2717c..b0b052ffa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java @@ -126,7 +126,7 @@ public class ExclusivePreferencesPage extends ShopPageBase Date: Thu, 11 Aug 2016 11:34:17 -0500 Subject: [PATCH 79/89] Add AntiSpam front end --- .../mineplex/core/common/api/ApiEndpoint.java | 21 +++++--- .../src/mineplex/core/common/api/ApiHost.java | 31 ++++++++++++ .../core/antispam/AntiSpamManager.java | 39 +++++++++++++++ .../mineplex/core/antispam/ChatPayload.java | 48 +++++++++++++++++++ .../repository/AntiSpamRepository.java | 26 ++++++++++ .../core/boosters/BoosterRepository.java | 3 +- .../src/mineplex/hub/HubManager.java | 3 ++ 7 files changed, 163 insertions(+), 8 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiHost.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antispam/ChatPayload.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antispam/repository/AntiSpamRepository.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiEndpoint.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiEndpoint.java index 06fdc0896..3b12c1d0b 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiEndpoint.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiEndpoint.java @@ -1,23 +1,30 @@ package mineplex.core.common.api; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; /** * @author Shaun Bennett */ public class ApiEndpoint { - private static final String API_HOST = "10.33.53.12"; -// private static final String API_HOST = "localhost"; -// private static final int API_PORT = 3000; - private static final int API_PORT = 7979; - private Gson _gson; private ApiWebCall _webCall; - public ApiEndpoint(String path, Gson gson) + public ApiEndpoint(ApiHost host, String path) { - String url = "http://" + API_HOST + ":" + API_PORT + path; + this(host, path, new GsonBuilder().setFieldNamingStrategy(new ApiFieldNamingStrategy()) + .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").create()); + } + + public ApiEndpoint(ApiHost host, String path, Gson gson) + { + this(host.getHost(), host.getPort(), path, gson); + } + + public ApiEndpoint(String host, int port, String path, Gson gson) + { + String url = "http://" + host + ":" + port + path; _webCall = new ApiWebCall(url, gson); _gson = gson; } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiHost.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiHost.java new file mode 100644 index 000000000..93dbf761b --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiHost.java @@ -0,0 +1,31 @@ +package mineplex.core.common.api; + +/** + * TODO: Store this in a file instead of being hardcoded + * + * @author Shaun Bennett + */ +public enum ApiHost +{ + AMPLIFIERS("10.33.53.12", 7979), + ANTISPAM("10.33.53.12", 8181); + + private String _host; + private int _port; + + ApiHost(String host, int port) + { + _host = host; + _port = port; + } + + public String getHost() + { + return _host; + } + + public int getPort() + { + return _port; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java new file mode 100644 index 000000000..3ef5d9f1c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java @@ -0,0 +1,39 @@ +package mineplex.core.antispam; + +import mineplex.core.MiniPlugin; +import mineplex.core.antispam.repository.AntiSpamRepository; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.AsyncPlayerChatEvent; + +/** + * @author Shaun Bennett + */ +public class AntiSpamManager extends MiniPlugin +{ + private final String _pluginName; + private final AntiSpamRepository _repository; + + public AntiSpamManager() + { + super("AntiSpam"); + + _pluginName = getPlugin().getClass().getSimpleName(); + _repository = new AntiSpamRepository(); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onChat(AsyncPlayerChatEvent event) + { + // Only listen to async events, as non async events are fake messages + if (event.isAsynchronous()) + { + Player player = event.getPlayer(); + String message = event.getMessage(); + ChatPayload payload = new ChatPayload(player.getName(), player.getUniqueId().toString(), message); + // Run our API call async to the chat message (prevents blocking chat message) + runAsync(() -> _repository.logMessage(_pluginName, payload)); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antispam/ChatPayload.java b/Plugins/Mineplex.Core/src/mineplex/core/antispam/ChatPayload.java new file mode 100644 index 000000000..389c4f7b5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antispam/ChatPayload.java @@ -0,0 +1,48 @@ +package mineplex.core.antispam; + +/** + * @author Shaun Bennett + */ +public class ChatPayload +{ + private String _playerName; + private String _uuid; + private String _message; + + public ChatPayload(String playerName, String uuid, String message) + { + _playerName = playerName; + _uuid = uuid; + _message = message; + } + + public String getPlayerName() + { + return _playerName; + } + + public void setPlayerName(String playerName) + { + _playerName = playerName; + } + + public String getUuid() + { + return _uuid; + } + + public void setUuid(String uuid) + { + _uuid = uuid; + } + + public String getMessage() + { + return _message; + } + + public void setMessage(String message) + { + _message = message; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antispam/repository/AntiSpamRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/antispam/repository/AntiSpamRepository.java new file mode 100644 index 000000000..42e9ddf15 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antispam/repository/AntiSpamRepository.java @@ -0,0 +1,26 @@ +package mineplex.core.antispam.repository; + +import com.google.gson.Gson; +import mineplex.core.antispam.ChatPayload; +import mineplex.core.common.api.ApiEndpoint; +import mineplex.core.common.api.ApiHost; +import mineplex.core.common.api.ApiResponse; +import mineplex.core.thread.ThreadPool; + +import java.util.Random; + +/** + * @author Shaun Bennett + */ +public class AntiSpamRepository extends ApiEndpoint +{ + public AntiSpamRepository() + { + super(ApiHost.ANTISPAM, "/chat"); + } + + public ApiResponse logMessage(String source, ChatPayload payload) + { + return getWebCall().post("/" + source, ApiResponse.class, payload); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterRepository.java index a057c4071..25e8c2c64 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterRepository.java @@ -7,6 +7,7 @@ import com.google.gson.JsonObject; import com.mojang.authlib.properties.PropertyMap; import mineplex.core.common.api.ApiEndpoint; import mineplex.core.common.api.ApiFieldNamingStrategy; +import mineplex.core.common.api.ApiHost; import mineplex.core.common.api.ApiResponse; import java.util.Arrays; @@ -23,7 +24,7 @@ public class BoosterRepository extends ApiEndpoint { public BoosterRepository() { - super("/booster", new GsonBuilder().setFieldNamingStrategy(new ApiFieldNamingStrategy()) + super(ApiHost.AMPLIFIERS, "/booster", new GsonBuilder().setFieldNamingStrategy(new ApiFieldNamingStrategy()) // .registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()) .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").create()); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 2494d3ffe..990dea9ae 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -5,6 +5,7 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; +import mineplex.core.antispam.AntiSpamManager; import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.benefit.BenefitManager; import mineplex.core.blockrestore.BlockRestore; @@ -206,6 +207,8 @@ public class HubManager extends MiniClientPlugin new SoccerManager(this, _gadgetManager); new KothManager(this, _gadgetManager); + new AntiSpamManager(); + //new TrickOrTreatManager(_plugin, this, taskManager, donationManager, clientManager); _petManager = petManager; From 33cb4db33876c705693e9df93163b1b851c76384 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 12 Aug 2016 19:52:23 +0100 Subject: [PATCH 80/89] Minestrike - Stop vanished players being assigned teams on join --- .../game/arcade/game/games/minestrike/Minestrike.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java index 862ead445..b099898c1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java @@ -1043,6 +1043,11 @@ public class Minestrike extends TeamGame { if (GetState() == GameState.Recruit || GetState() == GameState.Loading) return; + + if (Manager.isVanished(event.getPlayer())) + { + return; + } //Target Team GameTeam targetTeam = null; From c99a23d6707aecdb4647e5239d031ef1f5ace212 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sat, 13 Aug 2016 00:57:39 -0500 Subject: [PATCH 81/89] Add region and server to chat payload --- .../core/antispam/AntiSpamManager.java | 28 ++++++- .../mineplex/core/antispam/ChatPayload.java | 80 ++++++++++++++++++- 2 files changed, 105 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java index 3ef5d9f1c..d48d8f15d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java @@ -2,6 +2,7 @@ package mineplex.core.antispam; import mineplex.core.MiniPlugin; import mineplex.core.antispam.repository.AntiSpamRepository; +import mineplex.core.status.ServerStatusManager; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -13,6 +14,8 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; public class AntiSpamManager extends MiniPlugin { private final String _pluginName; + private final String _serverName; + private final String _region; private final AntiSpamRepository _repository; public AntiSpamManager() @@ -21,6 +24,18 @@ public class AntiSpamManager extends MiniPlugin _pluginName = getPlugin().getClass().getSimpleName(); _repository = new AntiSpamRepository(); + + ServerStatusManager serverStatusManager = require(ServerStatusManager.class); + if (serverStatusManager != null) + { + _serverName = serverStatusManager.getCurrentServerName(); + _region = serverStatusManager.getRegion().name(); + } + else + { + _serverName = "Unknown"; + _region = "Unknown"; + } } @EventHandler(priority = EventPriority.LOWEST) @@ -31,9 +46,18 @@ public class AntiSpamManager extends MiniPlugin { Player player = event.getPlayer(); String message = event.getMessage(); - ChatPayload payload = new ChatPayload(player.getName(), player.getUniqueId().toString(), message); + ChatPayload payload = new ChatPayload(player.getName(), player.getUniqueId().toString(), _region, _serverName, message, System.currentTimeMillis()); // Run our API call async to the chat message (prevents blocking chat message) - runAsync(() -> _repository.logMessage(_pluginName, payload)); + runAsync(() -> { + try + { + _repository.logMessage(_pluginName, payload); + } + catch (Exception ex) + { + System.out.println("Failed to send chat payload to AntiSpam repo. Ignoring!"); + } + }); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antispam/ChatPayload.java b/Plugins/Mineplex.Core/src/mineplex/core/antispam/ChatPayload.java index 389c4f7b5..bec9550c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antispam/ChatPayload.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antispam/ChatPayload.java @@ -7,13 +7,19 @@ public class ChatPayload { private String _playerName; private String _uuid; + private String _region; + private String _server; private String _message; + private long _time; - public ChatPayload(String playerName, String uuid, String message) + public ChatPayload(String playerName, String uuid, String region, String server, String message, long time) { _playerName = playerName; _uuid = uuid; + _region = region; + _server = server; _message = message; + _time = time; } public String getPlayerName() @@ -45,4 +51,76 @@ public class ChatPayload { _message = message; } + + public String getServer() + { + return _server; + } + + public void setServer(String server) + { + _server = server; + } + + public long getTime() + { + return _time; + } + + public void setTime(long time) + { + _time = time; + } + + public String getRegion() + { + return _region; + } + + public void setRegion(String region) + { + _region = region; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ChatPayload payload = (ChatPayload) o; + + if (_time != payload._time) return false; + if (!_playerName.equals(payload._playerName)) return false; + if (!_uuid.equals(payload._uuid)) return false; + if (!_region.equals(payload._region)) return false; + if (!_server.equals(payload._server)) return false; + return _message.equals(payload._message); + + } + + @Override + public int hashCode() + { + int result = _playerName.hashCode(); + result = 31 * result + _uuid.hashCode(); + result = 31 * result + _region.hashCode(); + result = 31 * result + _server.hashCode(); + result = 31 * result + _message.hashCode(); + result = 31 * result + (int) (_time ^ (_time >>> 32)); + return result; + } + + @Override + public String toString() + { + return "ChatPayload{" + + "_playerName='" + _playerName + '\'' + + ", _uuid='" + _uuid + '\'' + + ", _region='" + _region + '\'' + + ", _server='" + _server + '\'' + + ", _message='" + _message + '\'' + + ", _time=" + _time + + '}'; + } } \ No newline at end of file From 0f4f1a3582939ebf653b7255f2c84f440fdfaa37 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sat, 13 Aug 2016 01:39:56 -0500 Subject: [PATCH 82/89] Remove pointless try/catch --- .../src/mineplex/core/antispam/AntiSpamManager.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java index d48d8f15d..ce8ce600b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java @@ -48,16 +48,7 @@ public class AntiSpamManager extends MiniPlugin String message = event.getMessage(); ChatPayload payload = new ChatPayload(player.getName(), player.getUniqueId().toString(), _region, _serverName, message, System.currentTimeMillis()); // Run our API call async to the chat message (prevents blocking chat message) - runAsync(() -> { - try - { - _repository.logMessage(_pluginName, payload); - } - catch (Exception ex) - { - System.out.println("Failed to send chat payload to AntiSpam repo. Ignoring!"); - } - }); + runAsync(() -> _repository.logMessage(_pluginName, payload)); } } } From 08e65cb17eff11c1585e6d0bbc7c61c329735b2b Mon Sep 17 00:00:00 2001 From: cnr Date: Sun, 14 Aug 2016 17:31:38 -0400 Subject: [PATCH 83/89] Implement MineplexLink spectator check --- Plugins/Mineplex.Core/pom.xml | 2 +- .../Mineplex.Core/src/mineplex/core/antihack/AntiHack.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/pom.xml b/Plugins/Mineplex.Core/pom.xml index 6ab588198..81a567966 100644 --- a/Plugins/Mineplex.Core/pom.xml +++ b/Plugins/Mineplex.Core/pom.xml @@ -47,7 +47,7 @@ com.mineplex anticheat - 1.0 + 1.1 diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 67bb54c00..1f75df4e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -190,6 +190,12 @@ public class AntiHack extends MiniPlugin DisguiseBase disguise = disguiseManager.getActiveDisguise(player); return disguise != null ? disguise.getDisguiseType() : null; } + + @Override + public boolean isSpectator(Player player) + { + return UtilPlayer.isSpectator(player); + } }, this._plugin, ServicePriority.Normal); ServerCommandManager.getInstance().registerCommandType(MajorViolationCommand.class, violation -> From c66e485c9e487fd57d75c6a8dc26b225582ada2a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 13 Aug 2016 00:19:02 -0400 Subject: [PATCH 84/89] Fix arrow knockback --- .../minecraft/game/core/damage/DamageManager.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index dcaf61de3..ebb331257 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -545,13 +545,19 @@ public class DamageManager extends MiniPlugin origin = event.GetDamagerEntity(true).getLocation(); if (event.getKnockbackOrigin() != null) origin = event.getKnockbackOrigin(); - else if (event.GetProjectile() != null) - origin = event.GetProjectile().getLocation(); //Vec Vector trajectory = UtilAlg.getTrajectory2d(origin, event.GetDamageeEntity().getLocation()); trajectory.multiply(0.6 * knockback); trajectory.setY(Math.abs(trajectory.getY())); + + if (event.GetProjectile() != null && event.getKnockbackOrigin() == null) + { + trajectory = event.GetProjectile().getVelocity(); + trajectory.setY(0); + trajectory.multiply(0.37 * knockback / trajectory.length()); + trajectory.setY(0.06); + } //Apply double vel = 0.2 + trajectory.length() * 0.8; From 405f67f8b2fd3c24663f906215420ab7fb9d78ee Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 17 Aug 2016 16:36:56 -0400 Subject: [PATCH 85/89] Implement/activate Anticheat phase two - Remove anticheat guardians from Arcade - Uncomment/implement Anticheat phase two actions - Specifically: immediate ban on Kill Aura type A, VL 200. - Give moderators less-specific messages, and limit messages by severity --- .../src/mineplex/core/antihack/AntiHack.java | 286 ++++++++++-------- .../core/antihack/CheckThresholds.java | 56 ++++ .../core/antihack/actions/AntiHackAction.java | 8 +- .../core/antihack/banwave/BanWaveManager.java | 5 - .../src/nautilus/game/arcade/Arcade.java | 7 - .../nautilus/game/arcade/ArcadeManager.java | 35 --- 6 files changed, 221 insertions(+), 176 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/CheckThresholds.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 1f75df4e8..a3afe9508 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -2,14 +2,15 @@ package mineplex.core.antihack; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; +import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.AtomicDouble; import com.mineplex.anticheat.api.GameEndEvent; import com.mineplex.anticheat.api.GameStartEvent; import com.mineplex.anticheat.api.MineplexLink; import com.mineplex.anticheat.api.PlayerViolationEvent; -import mineplex.core.PlayerSelector; import mineplex.core.Managers; import mineplex.core.MiniPlugin; +import mineplex.core.PlayerSelector; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; @@ -21,15 +22,7 @@ import mineplex.core.antihack.types.Reach; import mineplex.core.antihack.types.Speed; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.*; import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.portal.Portal; @@ -41,44 +34,23 @@ import mineplex.core.punish.Punishment; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.commands.ServerCommandManager; -import net.minecraft.server.v1_8_R3.ChatClickable; -import net.minecraft.server.v1_8_R3.ChatComponentText; -import net.minecraft.server.v1_8_R3.ChatHoverable; -import net.minecraft.server.v1_8_R3.ChatModifier; -import net.minecraft.server.v1_8_R3.EnumChatFormat; -import net.minecraft.server.v1_8_R3.IChatBaseComponent; -import net.minecraft.server.v1_8_R3.MathHelper; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Location; +import net.minecraft.server.v1_8_R3.*; +import org.bukkit.*; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerToggleFlightEvent; -import org.bukkit.event.player.PlayerVelocityEvent; +import org.bukkit.event.player.*; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.ServicePriority; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitTask; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; -import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -89,7 +61,14 @@ import java.util.function.Predicate; @ReflectivelyCreateMiniPlugin public class AntiHack extends MiniPlugin { - public static final boolean IS_PHASE_TWO = false; + private static final Map _checks = ImmutableMap.of( + "Killaura (Type A)", new CheckThresholds("Kill Aura", 25, 50), + "Killaura (Type B)", new CheckThresholds("High CPS", 0, Integer.MAX_VALUE), + "Killaura (Type C)", new CheckThresholds("Reach", Integer.MAX_VALUE, Integer.MAX_VALUE), + "Killaura (Type D)", new CheckThresholds("Kill Aura", 1000, 1500), + "BadPackets", new CheckThresholds("Regen", 1000, 2000) + ); + public static final String NAME = "Chiss"; public static final String USER_HAS_BEEN_BANNED = F.main("GWEN", "%s has been banned. I am always watching"); public static final String USER_HAS_BEEN_BANNED_BANWAVE = USER_HAS_BEEN_BANNED; @@ -200,74 +179,17 @@ public class AntiHack extends MiniPlugin ServerCommandManager.getInstance().registerCommandType(MajorViolationCommand.class, violation -> { - if (!violation.getOriginatingServer().equals(this._thisServer)) - { - IChatBaseComponent component = new ChatComponentText("") - .addSibling( - new ChatComponentText("A") - .setChatModifier( - new ChatModifier() - .setColor(EnumChatFormat.AQUA) - .setRandom(true) - ) - ) - .addSibling( - new ChatComponentText(" GWEN > ") - .setChatModifier( - new ChatModifier() - .setColor(EnumChatFormat.RED) - .setBold(true) - ) - ) - .addSibling( - new ChatComponentText(violation.getPlayerName()) - .setChatModifier( - new ChatModifier() - .setColor(EnumChatFormat.GOLD) - ) - ) - .addSibling( - new ChatComponentText(" failed " + violation.getHackType() + " VL" + violation.getViolations() + " in server ") - .setChatModifier( - new ChatModifier() - .setColor(EnumChatFormat.YELLOW) - ) - ) - .addSibling( - new ChatComponentText( - violation.getOriginatingServer() - ) - .setChatModifier( - new ChatModifier() - .setColor(EnumChatFormat.YELLOW) - .setChatClickable( - new ChatClickable( - ChatClickable.EnumClickAction.RUN_COMMAND, - "/server " + violation.getOriginatingServer() - ) - ) - .setChatHoverable( - new ChatHoverable( - ChatHoverable.EnumHoverAction.SHOW_TEXT, - new ChatComponentText("Teleport to " + violation.getOriginatingServer()) - ) - ) - ) - ) - .addSibling( - new ChatComponentText(": " + violation.getMessage() + ". Please investigate") - .setChatModifier( - new ChatModifier() - .setColor(EnumChatFormat.YELLOW) - ) - ); + IChatBaseComponent component = getMinimalMessage(violation); - for (Player player : Bukkit.getOnlinePlayers()) + for (Player player : Bukkit.getOnlinePlayers()) + { + if (player.getName().equals("Spoobncoobr")) { - if (Managers.get(PreferencesManager.class).Get(player).ShowMacReports && _clientManager.Get(player).GetRank().has(Rank.HELPER)) - { - ((CraftPlayer) player).getHandle().sendMessage(component); - } + ((CraftPlayer) player).getHandle().sendMessage(getDetailedMessage(violation)); + + } else if (Managers.get(PreferencesManager.class).Get(player).ShowMacReports && _clientManager.Get(player).GetRank().has(Rank.HELPER)) + { + ((CraftPlayer) player).getHandle().sendMessage(component); } } }); @@ -355,6 +277,144 @@ public class AntiHack extends MiniPlugin require(BanWaveManager.class); } + private IChatBaseComponent getDetailedMessage(MajorViolationCommand violation) + { + return new ChatComponentText("") + .addSibling( + new ChatComponentText("A") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.AQUA) + .setRandom(true) + ) + ) + .addSibling( + new ChatComponentText(" GWEN > ") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.RED) + .setBold(true) + ) + ) + .addSibling( + new ChatComponentText(violation.getPlayerName()) + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.GOLD) + ) + ) + .addSibling( + new ChatComponentText(" failed " + violation.getHackType() + " VL" + violation.getViolations() + " in server ") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + ) + ) + .addSibling( + new ChatComponentText( + violation.getOriginatingServer() + ) + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + .setChatClickable( + new ChatClickable( + ChatClickable.EnumClickAction.RUN_COMMAND, + "/server " + violation.getOriginatingServer() + ) + ) + .setChatHoverable( + new ChatHoverable( + ChatHoverable.EnumHoverAction.SHOW_TEXT, + new ChatComponentText("Teleport to " + violation.getOriginatingServer()) + ) + ) + ) + ) + .addSibling( + new ChatComponentText(": " + violation.getMessage() + ". Please investigate!") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + ) + ); + } + + private IChatBaseComponent getMinimalMessage(MajorViolationCommand violation) + { + IChatBaseComponent component = new ChatComponentText("") + .addSibling( + new ChatComponentText("A") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.AQUA) + .setRandom(true) + ) + ) + .addSibling( + new ChatComponentText(" GWEN > ") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.RED) + .setBold(true) + ) + ) + .addSibling( + new ChatComponentText(violation.getPlayerName()) + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.GOLD) + ) + ) + .addSibling( + new ChatComponentText(" suspected of ") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + ) + ) + .addSibling(_checks.get(violation.getHackType()).format(violation.getViolations())); + + if (!violation.getOriginatingServer().equals(this._thisServer)) + { + component + .addSibling( + new ChatComponentText(" in ") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + ) + ) + .addSibling( + new ChatComponentText(violation.getOriginatingServer()) + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.AQUA) + .setChatClickable( + new ChatClickable( + ChatClickable.EnumClickAction.RUN_COMMAND, + "/server " + violation.getOriginatingServer() + ) + ) + .setChatHoverable( + new ChatHoverable( + ChatHoverable.EnumHoverAction.SHOW_TEXT, + new ChatComponentText("Teleport to " + violation.getOriginatingServer()) + ) + ) + ) + ); + } + + return component.addSibling( + new ChatComponentText(". Please investigate!") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + ) + ); + } + public void registerFilter(Predicate filter) { if (filter == null) @@ -382,9 +442,6 @@ public class AntiHack extends MiniPlugin public void runBanAnimation(Player player, Runnable after) { - if (!IS_PHASE_TWO) - return; - if (_pendingBan.add(player)) { float oldWalkSpeed = player.getWalkSpeed(); @@ -576,10 +633,7 @@ public class AntiHack extends MiniPlugin @EventHandler public void on(PlayerViolationEvent event) { - if (IS_PHASE_TWO) - { - AntiHackAction.getAction(event.getCheckClass()).handle(event); - } + AntiHackAction.getAction(event.getCheckClass()).handle(event); } public void announceBan(Player player) @@ -918,21 +972,9 @@ public class AntiHack extends MiniPlugin @EventHandler public void onHack(PlayerViolationEvent event) { - for (Player player : Bukkit.getOnlinePlayers()) - { - CoreClient client = _clientManager.Get(player); - if (event.shouldTellStaff()) - { - if (client.GetRank().has(Rank.HELPER)) - { - UtilPlayer.message(player, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " GWEN > " + ChatColor.RESET + C.cGold + event.getPlayer().getName() + C.cYellow + " failed " + event.getHackType() + " VL" + event.getViolations() + ": " + event.getMessage() + ". Please investigate"); - } - } - } - if (event.shouldTellStaff()) { - String key = event.getPlayer().getName() + "." + event.getHackType(); + String key = event.getPlayer().getName() + "." + event.getHackType() + "." + _checks.get(event.getHackType()).getSeverity(event.getViolations()).toString(); Integer pastVl = this._cooldown.getIfPresent(key); if (pastVl != null) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/CheckThresholds.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/CheckThresholds.java new file mode 100644 index 000000000..4c6b34b94 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/CheckThresholds.java @@ -0,0 +1,56 @@ +package mineplex.core.antihack; + +import net.minecraft.server.v1_8_R3.ChatComponentText; +import net.minecraft.server.v1_8_R3.ChatModifier; +import net.minecraft.server.v1_8_R3.EnumChatFormat; +import net.minecraft.server.v1_8_R3.IChatBaseComponent; + +public class CheckThresholds +{ + private final String _friendlyName; + private final int _med; + private final int _high; + + public CheckThresholds(String friendlyName, int med, int high) + { + _friendlyName = friendlyName; + _med = med; + _high = high; + } + + public IChatBaseComponent format(int violationLevel) + { + EnumChatFormat color = getSeverity(violationLevel)._color; + return new ChatComponentText(_friendlyName).setChatModifier(new ChatModifier().setColor(color)); + } + + public Severity getSeverity(int violationLevel) + { + if (violationLevel >= _high) + { + return Severity.HIGH; + + } else if (violationLevel >= _med) + { + return Severity.MEDIUM; + + } else + { + return Severity.LOW; + } + } + + public enum Severity + { + LOW(EnumChatFormat.GREEN), + MEDIUM(EnumChatFormat.GOLD), + HIGH(EnumChatFormat.RED), + ; + private final EnumChatFormat _color; + + Severity(EnumChatFormat color) + { + _color = color; + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/AntiHackAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/AntiHackAction.java index 0d09b4e80..689f57f7b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/AntiHackAction.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/AntiHackAction.java @@ -2,9 +2,6 @@ package mineplex.core.antihack.actions; import com.mineplex.anticheat.api.PlayerViolationEvent; import com.mineplex.anticheat.checks.combat.KillauraTypeA; -import com.mineplex.anticheat.checks.combat.KillauraTypeB; -import com.mineplex.anticheat.checks.combat.KillauraTypeD; -import com.mineplex.anticheat.checks.player.BadPackets; import mineplex.core.common.util.UtilServer; import org.bukkit.event.Listener; @@ -22,10 +19,7 @@ public abstract class AntiHackAction implements Listener static { - ACTIONS.put(KillauraTypeA.class, new ImmediateBanAction(60)); - ACTIONS.put(KillauraTypeB.class, new BanwaveAction(NEXT_BAN_WAVE, 50)); - ACTIONS.put(KillauraTypeD.class, new BanwaveAction(NEXT_BAN_WAVE, 550)); - ACTIONS.put(BadPackets.class, new MixedAction(new BanwaveAction(NEXT_BAN_WAVE, 80), new ImmediateBanAction(120))); + ACTIONS.put(KillauraTypeA.class, new ImmediateBanAction(200)); } private int _vl; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java index c39c476a7..8b39d9ac0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java @@ -24,11 +24,6 @@ public class BanWaveManager extends MiniPlugin @EventHandler public void onJoin(PlayerJoinEvent event) { - if (!AntiHack.IS_PHASE_TWO) - { - return; - } - runAsync(() -> { CoreClient client = require(CoreClientManager.class).Get(event.getPlayer()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index cf01b4520..303ebc9f7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -4,11 +4,9 @@ import java.io.File; import java.util.HashMap; import mineplex.core.Managers; -import mineplex.core.antihack.AntiHackGuardian; import mineplex.core.boosters.BoosterManager; import mineplex.core.thank.ThankManager; import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -144,11 +142,6 @@ public class Arcade extends JavaPlugin AntiHack antiHack = require(AntiHack.class); antiHack.setKick(false); - for (int i = 0; i < 10; i++) - { - antiHack.registerGuardian(new AntiHackGuardian(new Location(Bukkit.getWorld("world"), 0, 125, 0), 23, -23, 130, 120, 23, -23)); - } - IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); StatsManager statsManager = new StatsManager(this, _clientManager); EloManager eloManager = new EloManager(this, _clientManager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index e9782bf7e..7bb2599be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -5,8 +5,6 @@ import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; -import mineplex.core.antihack.AntiHack; -import mineplex.core.antihack.AntiHackGuardian; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.bonuses.BonusManager; @@ -99,8 +97,6 @@ import nautilus.game.arcade.shop.ArcadeShop; import net.minecraft.server.v1_8_R3.EntityLiving; import org.bukkit.*; import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Entity; @@ -1948,37 +1944,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation } } - @EventHandler - public void spawnGuardians(GameStateChangeEvent event) - { - if (event.GetState() == GameState.Live) - { - require(AntiHack.class).clearGuardians(); - - Location specLocation = GetGame().GetSpectatorLocation().add(0, 5, 0); - int maxX = (int) (specLocation.getX() + 50); - int minX = (int) (specLocation.getX() - 50); - int maxY = (int) (specLocation.getY() + 5); - int minY = (int) (specLocation.getY() - 5); - int maxZ = (int) (specLocation.getZ() + 50); - int minZ = (int) (specLocation.getZ() - 50); - - for (int i = 0; i < 10; i++) - { - require(AntiHack.class).registerGuardian(new AntiHackGuardian(specLocation, maxX, minX, maxY, minY, maxZ, minZ)); - } - } - else if (event.GetState() == GameState.Recruit) - { - require(AntiHack.class).clearGuardians(); - - for (int i = 0; i < 10; i++) - { - require(AntiHack.class).registerGuardian(new AntiHackGuardian(new Location(Bukkit.getWorld("world"), 0, 125, 0), 23, -23, 130, 120, 23, -23)); - } - } - } - public ProgressingKitManager getProgressionKitManager() { return _progressionKitManager; From 999237fe69f386f2b454836dff4e43136f974a38 Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 17 Aug 2016 23:38:08 -0400 Subject: [PATCH 86/89] Accurately report game TPS --- .../src/mineplex/core/monitor/LagMeter.java | 12 ------------ .../nautilus/game/arcade/game/games/uhc/UHC.java | 13 ------------- 2 files changed, 25 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index b4846dfc8..802b3d643 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -37,8 +37,6 @@ public class LagMeter extends MiniPlugin private boolean _timingsPasted; private long _timingsStarted; - private boolean _fakeTps = false; - private HashSet _monitoring = new HashSet(); public LagMeter(JavaPlugin plugin, CoreClientManager clientManager) @@ -122,10 +120,6 @@ public class LagMeter extends MiniPlugin public double getTicksPerSecond() { - if (_fakeTps) - { - return 20.0; - } return _ticksPerSecond; } @@ -170,10 +164,4 @@ public class LagMeter extends MiniPlugin player.sendMessage(F.main(getName(), ChatColor.GRAY + "Free-------" + ChatColor.YELLOW + (Runtime.getRuntime().freeMemory() / 1048576) + "MB")); player.sendMessage(F.main(getName(), ChatColor.GRAY + "Max--------" + ChatColor.YELLOW + (Runtime.getRuntime().maxMemory() / 1048576)) + "MB"); } - - // I'm so sorry. Blame ServerMonitor for being so strict - public void setFakeTps(boolean fakeTps) - { - this._fakeTps = fakeTps; - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index 3ddb02053..18d67e8ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -715,19 +715,6 @@ public class UHC extends TeamGame implements NCPHook } } - @EventHandler - public void toggleFakeTps(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Dead) - { - Managers.get(LagMeter.class).setFakeTps(true); - } - else - { - Managers.get(LagMeter.class).setFakeTps(false); - } - } - @EventHandler public void generateWorld(GameStateChangeEvent event) { From 78fe41a8af7c6b8358d888e312eb364c93503e40 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 18 Aug 2016 01:50:12 -0500 Subject: [PATCH 87/89] Update Anticheat ban message and duration --- .../src/mineplex/core/antihack/AntiHack.java | 12 +++++------- .../src/mineplex/core/antihack/CheckThresholds.java | 5 +++++ .../core/antihack/actions/ImmediateBanAction.java | 12 +++++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index a3afe9508..d5351e02f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -61,7 +61,7 @@ import java.util.function.Predicate; @ReflectivelyCreateMiniPlugin public class AntiHack extends MiniPlugin { - private static final Map _checks = ImmutableMap.of( + public static final Map CHECKS = ImmutableMap.of( "Killaura (Type A)", new CheckThresholds("Kill Aura", 25, 50), "Killaura (Type B)", new CheckThresholds("High CPS", 0, Integer.MAX_VALUE), "Killaura (Type C)", new CheckThresholds("Reach", Integer.MAX_VALUE, Integer.MAX_VALUE), @@ -373,7 +373,7 @@ public class AntiHack extends MiniPlugin .setColor(EnumChatFormat.YELLOW) ) ) - .addSibling(_checks.get(violation.getHackType()).format(violation.getViolations())); + .addSibling(CHECKS.get(violation.getHackType()).format(violation.getViolations())); if (!violation.getOriginatingServer().equals(this._thisServer)) { @@ -552,19 +552,17 @@ public class AntiHack extends MiniPlugin { runSync(() -> { - int totalPunishments = getPunishments(player); - int daysBanned = getDaysBanned(player); CoreClient coreClient = _clientManager.Get(player); if (coreClient.GetRank().has(Rank.TWITCH)) { - require(Punish.class).AddPunishment(coreClient.getName(), Category.Hacking, message, AntiHack.NAME, totalPunishments + 1, true, daysBanned == -1 ? -1 : TimeUnit.DAYS.toHours(daysBanned), true); + require(Punish.class).AddPunishment(coreClient.getName(), Category.Hacking, message, AntiHack.NAME, 3, true, -1, true); } else { runBanAnimation(player, () -> { - require(Punish.class).AddPunishment(coreClient.getName(), Category.Hacking, message, AntiHack.NAME, totalPunishments + 1, true, daysBanned == -1 ? -1 : TimeUnit.DAYS.toHours(daysBanned), true); + require(Punish.class).AddPunishment(coreClient.getName(), Category.Hacking, message, AntiHack.NAME, 3, true, -1, true); announceBan(player); }); } @@ -974,7 +972,7 @@ public class AntiHack extends MiniPlugin { if (event.shouldTellStaff()) { - String key = event.getPlayer().getName() + "." + event.getHackType() + "." + _checks.get(event.getHackType()).getSeverity(event.getViolations()).toString(); + String key = event.getPlayer().getName() + "." + event.getHackType() + "." + CHECKS.get(event.getHackType()).getSeverity(event.getViolations()).toString(); Integer pastVl = this._cooldown.getIfPresent(key); if (pastVl != null) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/CheckThresholds.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/CheckThresholds.java index 4c6b34b94..b00207db6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/CheckThresholds.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/CheckThresholds.java @@ -18,6 +18,11 @@ public class CheckThresholds _high = high; } + public String getFriendlyName() + { + return _friendlyName; + } + public IChatBaseComponent format(int violationLevel) { EnumChatFormat color = getSeverity(violationLevel)._color; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/ImmediateBanAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/ImmediateBanAction.java index 70f3a7609..668d82389 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/ImmediateBanAction.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/ImmediateBanAction.java @@ -3,10 +3,7 @@ package mineplex.core.antihack.actions; import com.mineplex.anticheat.api.PlayerViolationEvent; import mineplex.core.Managers; import mineplex.core.antihack.AntiHack; -import mineplex.core.punish.Category; -import mineplex.core.punish.Punish; - -import java.util.concurrent.TimeUnit; +import mineplex.core.common.util.UtilServer; class ImmediateBanAction extends AntiHackAction { @@ -20,7 +17,12 @@ class ImmediateBanAction extends AntiHackAction { if (event.getViolations() >= this.getMinVl()) { - Managers.get(AntiHack.class).doBan(event.getPlayer(), event.getMessage()); + String server = UtilServer.getServerName(); + if (server.contains("-")) + { + server = server.substring(0, server.indexOf('-')); + } + Managers.get(AntiHack.class).doBan(event.getPlayer(), "[GWEN] Hacking - " + AntiHack.CHECKS.get(event.getHackType()).getFriendlyName() + " [" + server + "]"); } } } From 08e1b765f734261b2c7e5e2993c950c8182d2608 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 18 Aug 2016 01:54:25 -0500 Subject: [PATCH 88/89] Send local Anticheat messages regardless of preference --- Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index d5351e02f..44430ffdb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -187,7 +187,7 @@ public class AntiHack extends MiniPlugin { ((CraftPlayer) player).getHandle().sendMessage(getDetailedMessage(violation)); - } else if (Managers.get(PreferencesManager.class).Get(player).ShowMacReports && _clientManager.Get(player).GetRank().has(Rank.HELPER)) + } else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || Managers.get(PreferencesManager.class).Get(player).ShowMacReports)) { ((CraftPlayer) player).getHandle().sendMessage(component); } From a79fa9cd465c3d1de8497b4ed3e97c477843fac7 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 18 Aug 2016 01:55:05 -0500 Subject: [PATCH 89/89] Update GWEN preference name to reflect its purpose --- .../core/preferences/ui/ExclusivePreferencesPage.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java index b0b052ffa..c376b2461 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java @@ -126,7 +126,7 @@ public class ExclusivePreferencesPage extends ShopPageBase