diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 92fb4215d..94034eee6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -48,6 +48,8 @@ public class CoreClientManager extends MiniPlugin private Object _clientLock = new Object(); + private static int _connectingClients = 0; + public CoreClientManager(JavaPlugin plugin, String webServer) { super("Client Manager", plugin); @@ -122,6 +124,20 @@ public class CoreClientManager extends MiniPlugin @EventHandler(priority = EventPriority.LOWEST) public void AsyncLogin(AsyncPlayerPreLoginEvent event) { + while (_connectingClients >= 5) + { + try + { + Thread.sleep(25); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + _connectingClients++; + try { LoadClient(Add(event.getName()), event.getUniqueId(), event.getAddress().getHostAddress()); @@ -134,6 +150,10 @@ public class CoreClientManager extends MiniPlugin System.out.println(exception.getMessage()); } + finally + { + _connectingClients--; + } if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().Has(Rank.MODERATOR)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java index 01590e771..a8b3a2a78 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java @@ -83,11 +83,14 @@ public class Npc public void returnToPost() { - EntityCreature ec = ((CraftCreature) _entity).getHandle(); + if (_entity instanceof CraftCreature) + { + EntityCreature ec = ((CraftCreature) _entity).getHandle(); - ec.getNavigation().a(getLocation().getX(), getLocation().getY(), getLocation().getZ(), .8f); + ec.getNavigation().a(getLocation().getX(), getLocation().getY(), getLocation().getZ(), .8f); - _returning = true; + _returning = true; + } } public boolean isReturning() @@ -95,13 +98,16 @@ public class Npc return _returning; } - public void clearGoals(Entity entity) + public void clearGoals() { - _returning = false; + if (_entity instanceof CraftCreature) + { + _returning = false; - Location entityLocation = entity.getLocation(); - EntityCreature ec = ((CraftCreature) entity).getHandle(); - ec.getNavigation().a(entityLocation.getX(), entityLocation.getY(), entityLocation.getZ(), .8f); + Location entityLocation = _entity.getLocation(); + EntityCreature ec = ((CraftCreature) _entity).getHandle(); + ec.getNavigation().a(entityLocation.getX(), entityLocation.getY(), entityLocation.getZ(), .8f); + } } public NpcManager getNpcManager() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index c19a91e0c..87e12d7e7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -451,15 +451,15 @@ public class NpcManager extends MiniPlugin entity.setVelocity(new Vector(0, 0, 0)); npc.setFailedAttempts(0); } - else if (!npc.isInRadius(entity.getLocation())) + else if (!npc.isInRadius(entity.getLocation()) && npc.getEntity() instanceof CraftCreature) { npc.returnToPost(); npc.incrementFailedAttempts(); } - else + else if (npc.getEntity() instanceof CraftCreature) { if (npc.isReturning()) - npc.clearGoals(entity); + npc.clearGoals(); npc.setFailedAttempts(0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 0da30b552..28496a9b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -3,27 +3,19 @@ package mineplex.core.portal; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.util.Collection; import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.entity.Player; -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.Callback; import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilPlayer; import mineplex.core.portal.Commands.*; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.Region; import mineplex.serverdata.ServerCommandManager; import mineplex.serverdata.ServerManager; @@ -38,8 +30,6 @@ public class Portal extends MiniPlugin private HashSet _connectingPlayers = new HashSet(); private Region _region; - private boolean _retrieve = true; - private String _serverName; public Portal(JavaPlugin plugin, String serverName) { @@ -47,13 +37,12 @@ public class Portal extends MiniPlugin instance = this; - this._serverName = serverName; this._region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU; Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord"); // Register the server command type for future use - ServerCommandManager.getInstance().registerCommandType(TransferCommand.class); + ServerCommandManager.getInstance().registerCommandType(TransferCommand.class.getSimpleName(), TransferCommand.class); } public void SendAllPlayers(String serverName) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/TransferCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/TransferCommand.java index 1c1a70ada..928dd8819 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/TransferCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/TransferCommand.java @@ -36,5 +36,4 @@ public class TransferCommand extends ServerCommand Portal.getInstance().SendPlayerToServer(player, transfer.getServerName()); } } - } 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 ba35f2d1c..bfe67e8bf 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -245,7 +245,7 @@ public class ServerNpcPage extends ShopPageBase im } } - AddButton(40, new ShopItem(Material.GOLD_BLOCK, C.cAqua + yellowCount++ + " Games In Progress", new String[]{MESSAGE_SPECTATE}, yellowCount > 64 ? 1 : yellowCount, false), new SingleButton() + AddButton(40, new ShopItem(Material.GOLD_BLOCK, C.cAqua + yellowCount + " Game" + (yellowCount == 1 ? "" : "s") + " In Progress", new String[]{MESSAGE_SPECTATE}, yellowCount > 64 ? 1 : yellowCount, false), new SingleButton() { @Override public void Clicked(Player player) 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 55c0eed5c..6dda3daa5 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 @@ -2,10 +2,12 @@ package mineplex.minecraft.game.core.combat; import java.util.HashMap; import java.util.LinkedList; +import java.util.List; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.minecraft.game.core.damage.DamageChange; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -32,12 +34,12 @@ public class CombatComponent } } - public void AddDamage(String source, double dmg) + public void AddDamage(String source, double dmg, List mod) { if (source == null) source = "-"; - GetDamage().addFirst(new CombatDamage(source, dmg)); + GetDamage().addFirst(new CombatDamage(source, dmg, mod)); LastDamage = System.currentTimeMillis(); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatDamage.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatDamage.java index 8634b8e8b..c0dedb230 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatDamage.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatDamage.java @@ -1,16 +1,23 @@ package mineplex.minecraft.game.core.combat; +import java.util.ArrayList; +import java.util.List; + +import mineplex.minecraft.game.core.damage.DamageChange; + public class CombatDamage { private String _name; private double _dmg; private long _time; + private List _mod = new ArrayList<>(); - public CombatDamage(String name, double dmg) + public CombatDamage(String name, double dmg, List mod) { _name = name; _dmg = dmg; _time = System.currentTimeMillis(); + _mod = mod; } public String GetName() @@ -27,4 +34,9 @@ public class CombatDamage { return _time; } + + public List getDamageMod() + { + return _mod; + } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java index 370d13997..e6630c8fe 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java @@ -3,9 +3,11 @@ package mineplex.minecraft.game.core.combat; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; +import java.util.List; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; +import mineplex.minecraft.game.core.damage.DamageChange; import org.bukkit.ChatColor; import org.bukkit.entity.LivingEntity; @@ -45,12 +47,12 @@ public class CombatLog } public void Attacked(String damagerName, double damage, - LivingEntity damagerEnt, String attackName) + LivingEntity damagerEnt, String attackName, List mod) { // Add Attacked CombatComponent comp = GetEnemy(damagerName, damagerEnt); - comp.AddDamage(attackName, damage); + comp.AddDamage(attackName, damage, mod); // Set Last LastDamager = comp; 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 86363fc9d..ef5fd3b0e 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 @@ -84,7 +84,7 @@ public class CombatManager extends MiniPlugin Get(damagee).Attacked( UtilEnt.getName(damagerEnt), event.getDamage(), damagerEnt, - event.getCause() + ""); + event.getCause() + "", null); } // Damager is WORLD else @@ -181,7 +181,7 @@ public class CombatManager extends MiniPlugin } Get(damagee).Attacked(source, - event.getDamage(), null, reason); + event.getDamage(), null, reason, null); } } @@ -231,7 +231,7 @@ public class CombatManager extends MiniPlugin Get(event.GetDamageePlayer()).Attacked( UtilEnt.getName(event.GetDamagerEntity(true)), (int) event.GetDamage(), event.GetDamagerEntity(true), - reason); + reason, event.GetDamageMod()); } // Damager is WORLD else @@ -331,7 +331,7 @@ public class CombatManager extends MiniPlugin reason = event.GetReason(); Get(event.GetDamageePlayer()).Attacked(source, - (int) event.GetDamage(), null, reason); + (int) event.GetDamage(), null, reason, event.GetDamageMod()); } } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java index 7e7ffa669..841705967 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java @@ -2,7 +2,6 @@ package mineplex.serverdata; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerCommandListener.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerCommandListener.java index e763feba5..946ecc80d 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerCommandListener.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerCommandListener.java @@ -17,7 +17,7 @@ public class ServerCommandListener extends JedisPubSub { try { - String commandType = message.split(":")[1]; + String commandType = channelName.split(":")[1]; ServerCommandManager.getInstance().handleCommand(commandType, message); } catch (Exception exception) diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerCommandManager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerCommandManager.java index 9f3542113..8bc85c3e0 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerCommandManager.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerCommandManager.java @@ -16,7 +16,7 @@ public class ServerCommandManager public final String SERVER_COMMANDS_CHANNEL = "commands.server"; private JedisPool _jedisPool; - private Map> commandTypes; + private Map> _commandTypes; /** * Private class constructor to prevent non-singleton instances. @@ -25,7 +25,7 @@ public class ServerCommandManager { this._jedisPool = new JedisPool(new JedisPoolConfig(), ServerManager.DEFAULT_REDIS_HOST, ServerManager.DEFAULT_REDIS_PORT); - this.commandTypes = new HashMap>(); + this._commandTypes = new HashMap>(); initialize(); } @@ -71,7 +71,7 @@ public class ServerCommandManager try { - String commandType = serverCommand.getClass().toString(); + String commandType = serverCommand.getClass().getSimpleName(); String serializedCommand = Utility.serialize(serverCommand); jedis.publish(SERVER_COMMANDS_CHANNEL + ":" + commandType, serializedCommand); } @@ -92,15 +92,15 @@ public class ServerCommandManager */ public void handleCommand(String commandType, String serializedCommand) { - if (commandTypes.containsKey(commandType)) + if (_commandTypes.containsKey(commandType)) { - ServerCommand serverCommand = Utility.deserialize(serializedCommand, commandTypes.get(commandType)); + ServerCommand serverCommand = Utility.deserialize(serializedCommand, _commandTypes.get(commandType)); - if (serverCommand.isTargetServer("THIS SERVER NAME HERE")) // TODO: Find server name ref - { + //if (serverCommand.isTargetServer("THIS SERVER NAME HERE")) // TODO: Find server name ref + //{ // TODO: Run synchronously? serverCommand.run(); // Run the server command - } + //} } } @@ -108,13 +108,11 @@ public class ServerCommandManager * Register a new type of {@link ServerCommand}. * @param commandType - the {@link ServerCommand} type to register. */ - public void registerCommandType(Class commandType) + public void registerCommandType(String commandName, Class commandType) { - String commandName = commandType.toString(); - - if (!commandTypes.containsKey(commandName)) + if (!_commandTypes.containsKey(commandName)) { - commandTypes.put(commandName, commandType); + _commandTypes.put(commandName, commandType); } } diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index 6e46c726c..8dcff5f07 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -169,7 +169,7 @@ public class ServerMonitor if (onlineServers.contains(entry.getKey())) iterator.remove(); - else if (System.currentTimeMillis() - entry.getValue().getValue() > 20000) + else if (System.currentTimeMillis() - entry.getValue().getValue() > 30000) { String serverName = entry.getKey(); String serverAddress = entry.getValue().getKey(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java index 64b6c6d99..095d3e381 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java @@ -26,7 +26,7 @@ public class KitSheepPig extends Kit { public KitSheepPig(ArcadeManager manager) { - super(manager, "'Pig'", KitAvailability.Gem, 5000, + super(manager, "Pig", KitAvailability.Gem, 5000, new String[] { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomber.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomber.java index 1aacd9982..5f5cd35e2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomber.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomber.java @@ -175,7 +175,7 @@ public class PerkBomber extends Perk @EventHandler public void ExplosionPrime(ExplosionPrimeEvent event) { - Player player = _tntMap.remove(event.getEntity()); + Player player = _tntMap.get(event.getEntity()); if (player != null) { for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 14)) @@ -185,7 +185,7 @@ public class PerkBomber extends Perk } } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { Player player = _tntMap.remove(event.getEntity()); @@ -198,16 +198,9 @@ public class PerkBomber extends Perk if (block.getType() == Material.DIAMOND_ORE) { + Bukkit.getPluginManager().callEvent(new BomberExplodeDiamondBlock(player, block)); + block.breakNaturally(); it.remove(); - - if (Math.random() < event.getYield()) - { - block.breakNaturally(); - - Bukkit.getPluginManager().callEvent(new BomberExplodeDiamondBlock(player, block)); - } - else - block.setType(Material.AIR); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KaboomStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KaboomStatTracker.java index 38f4dc114..7f4387d6b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KaboomStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KaboomStatTracker.java @@ -24,7 +24,7 @@ public class KaboomStatTracker extends StatTracker { for (Player player : event.getDamagedPlayers()) { - if (!player.isDead()) + if (player.getHealth() != player.getMaxHealth()) return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillReasonStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillReasonStatTracker.java index 2d89ce679..291951292 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillReasonStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillReasonStatTracker.java @@ -5,7 +5,10 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.CombatDamage; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.DamageChange; import nautilus.game.arcade.game.Game; public class KillReasonStatTracker extends StatTracker @@ -49,6 +52,27 @@ public class KillReasonStatTracker extends StatTracker if (event.GetLog().GetLastDamager() != null && event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().contains(getReason())) addStat(killer, getStatName(), 1, false, false); + else + { + for (CombatComponent component : event.GetLog().GetAttackers()) + { + for (CombatDamage damage : component.GetDamage()) + { + if (damage.getDamageMod() != null) + { + for (DamageChange mod : damage.getDamageMod()) + { + if (mod.GetReason() != null && mod.GetReason().contains(getReason())) + { + addStat(killer, getStatName(), 1, false, false); + + return; + } + } + } + } + } + } } public String getStatName()