Merge remote-tracking branch 'origin/master'

This commit is contained in:
Shaun Bennett 2014-10-27 20:25:47 -05:00
commit 9819b6c10a
18 changed files with 107 additions and 63 deletions

View File

@ -48,6 +48,8 @@ public class CoreClientManager extends MiniPlugin
private Object _clientLock = new Object(); private Object _clientLock = new Object();
private static int _connectingClients = 0;
public CoreClientManager(JavaPlugin plugin, String webServer) public CoreClientManager(JavaPlugin plugin, String webServer)
{ {
super("Client Manager", plugin); super("Client Manager", plugin);
@ -122,6 +124,20 @@ public class CoreClientManager extends MiniPlugin
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void AsyncLogin(AsyncPlayerPreLoginEvent event) public void AsyncLogin(AsyncPlayerPreLoginEvent event)
{ {
while (_connectingClients >= 5)
{
try
{
Thread.sleep(25);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
_connectingClients++;
try try
{ {
LoadClient(Add(event.getName()), event.getUniqueId(), event.getAddress().getHostAddress()); LoadClient(Add(event.getName()), event.getUniqueId(), event.getAddress().getHostAddress());
@ -134,6 +150,10 @@ public class CoreClientManager extends MiniPlugin
System.out.println(exception.getMessage()); System.out.println(exception.getMessage());
} }
finally
{
_connectingClients--;
}
if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().Has(Rank.MODERATOR)) if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().Has(Rank.MODERATOR))
{ {

View File

@ -83,11 +83,14 @@ public class Npc
public void returnToPost() 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() public boolean isReturning()
@ -95,13 +98,16 @@ public class Npc
return _returning; return _returning;
} }
public void clearGoals(Entity entity) public void clearGoals()
{ {
_returning = false; if (_entity instanceof CraftCreature)
{
_returning = false;
Location entityLocation = entity.getLocation(); Location entityLocation = _entity.getLocation();
EntityCreature ec = ((CraftCreature) entity).getHandle(); EntityCreature ec = ((CraftCreature) _entity).getHandle();
ec.getNavigation().a(entityLocation.getX(), entityLocation.getY(), entityLocation.getZ(), .8f); ec.getNavigation().a(entityLocation.getX(), entityLocation.getY(), entityLocation.getZ(), .8f);
}
} }
public NpcManager getNpcManager() public NpcManager getNpcManager()

View File

@ -451,15 +451,15 @@ public class NpcManager extends MiniPlugin
entity.setVelocity(new Vector(0, 0, 0)); entity.setVelocity(new Vector(0, 0, 0));
npc.setFailedAttempts(0); npc.setFailedAttempts(0);
} }
else if (!npc.isInRadius(entity.getLocation())) else if (!npc.isInRadius(entity.getLocation()) && npc.getEntity() instanceof CraftCreature)
{ {
npc.returnToPost(); npc.returnToPost();
npc.incrementFailedAttempts(); npc.incrementFailedAttempts();
} }
else else if (npc.getEntity() instanceof CraftCreature)
{ {
if (npc.isReturning()) if (npc.isReturning())
npc.clearGoals(entity); npc.clearGoals();
npc.setFailedAttempts(0); npc.setFailedAttempts(0);
} }

View File

@ -3,27 +3,19 @@ package mineplex.core.portal;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Map.Entry;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.portal.Commands.*; import mineplex.core.portal.Commands.*;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.serverdata.Region; import mineplex.serverdata.Region;
import mineplex.serverdata.ServerCommandManager; import mineplex.serverdata.ServerCommandManager;
import mineplex.serverdata.ServerManager; import mineplex.serverdata.ServerManager;
@ -38,8 +30,6 @@ public class Portal extends MiniPlugin
private HashSet<String> _connectingPlayers = new HashSet<String>(); private HashSet<String> _connectingPlayers = new HashSet<String>();
private Region _region; private Region _region;
private boolean _retrieve = true;
private String _serverName;
public Portal(JavaPlugin plugin, String serverName) public Portal(JavaPlugin plugin, String serverName)
{ {
@ -47,13 +37,12 @@ public class Portal extends MiniPlugin
instance = this; instance = this;
this._serverName = serverName;
this._region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU; this._region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord"); Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord");
// Register the server command type for future use // 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) public void SendAllPlayers(String serverName)

View File

@ -36,5 +36,4 @@ public class TransferCommand extends ServerCommand
Portal.getInstance().SendPlayerToServer(player, transfer.getServerName()); Portal.getInstance().SendPlayerToServer(player, transfer.getServerName());
} }
} }
} }

View File

@ -245,7 +245,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> 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 @Override
public void Clicked(Player player) public void Clicked(Player player)

View File

@ -2,10 +2,12 @@ package mineplex.minecraft.game.core.combat;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.minecraft.game.core.damage.DamageChange;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; 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<DamageChange> mod)
{ {
if (source == null) if (source == null)
source = "-"; source = "-";
GetDamage().addFirst(new CombatDamage(source, dmg)); GetDamage().addFirst(new CombatDamage(source, dmg, mod));
LastDamage = System.currentTimeMillis(); LastDamage = System.currentTimeMillis();
} }

View File

@ -1,16 +1,23 @@
package mineplex.minecraft.game.core.combat; package mineplex.minecraft.game.core.combat;
import java.util.ArrayList;
import java.util.List;
import mineplex.minecraft.game.core.damage.DamageChange;
public class CombatDamage public class CombatDamage
{ {
private String _name; private String _name;
private double _dmg; private double _dmg;
private long _time; private long _time;
private List<DamageChange> _mod = new ArrayList<>();
public CombatDamage(String name, double dmg) public CombatDamage(String name, double dmg, List<DamageChange> mod)
{ {
_name = name; _name = name;
_dmg = dmg; _dmg = dmg;
_time = System.currentTimeMillis(); _time = System.currentTimeMillis();
_mod = mod;
} }
public String GetName() public String GetName()
@ -27,4 +34,9 @@ public class CombatDamage
{ {
return _time; return _time;
} }
public List<DamageChange> getDamageMod()
{
return _mod;
}
} }

View File

@ -3,9 +3,11 @@ package mineplex.minecraft.game.core.combat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.minecraft.game.core.damage.DamageChange;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -45,12 +47,12 @@ public class CombatLog
} }
public void Attacked(String damagerName, double damage, public void Attacked(String damagerName, double damage,
LivingEntity damagerEnt, String attackName) LivingEntity damagerEnt, String attackName, List<DamageChange> mod)
{ {
// Add Attacked // Add Attacked
CombatComponent comp = GetEnemy(damagerName, damagerEnt); CombatComponent comp = GetEnemy(damagerName, damagerEnt);
comp.AddDamage(attackName, damage); comp.AddDamage(attackName, damage, mod);
// Set Last // Set Last
LastDamager = comp; LastDamager = comp;

View File

@ -84,7 +84,7 @@ public class CombatManager extends MiniPlugin
Get(damagee).Attacked( Get(damagee).Attacked(
UtilEnt.getName(damagerEnt), UtilEnt.getName(damagerEnt),
event.getDamage(), damagerEnt, event.getDamage(), damagerEnt,
event.getCause() + ""); event.getCause() + "", null);
} }
// Damager is WORLD // Damager is WORLD
else else
@ -181,7 +181,7 @@ public class CombatManager extends MiniPlugin
} }
Get(damagee).Attacked(source, 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( Get(event.GetDamageePlayer()).Attacked(
UtilEnt.getName(event.GetDamagerEntity(true)), UtilEnt.getName(event.GetDamagerEntity(true)),
(int) event.GetDamage(), event.GetDamagerEntity(true), (int) event.GetDamage(), event.GetDamagerEntity(true),
reason); reason, event.GetDamageMod());
} }
// Damager is WORLD // Damager is WORLD
else else
@ -331,7 +331,7 @@ public class CombatManager extends MiniPlugin
reason = event.GetReason(); reason = event.GetReason();
Get(event.GetDamageePlayer()).Attacked(source, Get(event.GetDamageePlayer()).Attacked(source,
(int) event.GetDamage(), null, reason); (int) event.GetDamage(), null, reason, event.GetDamageMod());
} }
} }

View File

@ -2,7 +2,6 @@ package mineplex.serverdata;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -17,7 +17,7 @@ public class ServerCommandListener extends JedisPubSub
{ {
try try
{ {
String commandType = message.split(":")[1]; String commandType = channelName.split(":")[1];
ServerCommandManager.getInstance().handleCommand(commandType, message); ServerCommandManager.getInstance().handleCommand(commandType, message);
} }
catch (Exception exception) catch (Exception exception)

View File

@ -16,7 +16,7 @@ public class ServerCommandManager
public final String SERVER_COMMANDS_CHANNEL = "commands.server"; public final String SERVER_COMMANDS_CHANNEL = "commands.server";
private JedisPool _jedisPool; private JedisPool _jedisPool;
private Map<String, Class<? extends ServerCommand>> commandTypes; private Map<String, Class<? extends ServerCommand>> _commandTypes;
/** /**
* Private class constructor to prevent non-singleton instances. * 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, this._jedisPool = new JedisPool(new JedisPoolConfig(), ServerManager.DEFAULT_REDIS_HOST,
ServerManager.DEFAULT_REDIS_PORT); ServerManager.DEFAULT_REDIS_PORT);
this.commandTypes = new HashMap<String, Class<? extends ServerCommand>>(); this._commandTypes = new HashMap<String, Class<? extends ServerCommand>>();
initialize(); initialize();
} }
@ -71,7 +71,7 @@ public class ServerCommandManager
try try
{ {
String commandType = serverCommand.getClass().toString(); String commandType = serverCommand.getClass().getSimpleName();
String serializedCommand = Utility.serialize(serverCommand); String serializedCommand = Utility.serialize(serverCommand);
jedis.publish(SERVER_COMMANDS_CHANNEL + ":" + commandType, serializedCommand); jedis.publish(SERVER_COMMANDS_CHANNEL + ":" + commandType, serializedCommand);
} }
@ -92,15 +92,15 @@ public class ServerCommandManager
*/ */
public void handleCommand(String commandType, String serializedCommand) 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? // TODO: Run synchronously?
serverCommand.run(); // Run the server command serverCommand.run(); // Run the server command
} //}
} }
} }
@ -108,13 +108,11 @@ public class ServerCommandManager
* Register a new type of {@link ServerCommand}. * Register a new type of {@link ServerCommand}.
* @param commandType - the {@link ServerCommand} type to register. * @param commandType - the {@link ServerCommand} type to register.
*/ */
public void registerCommandType(Class<? extends ServerCommand> commandType) public void registerCommandType(String commandName, Class<? extends ServerCommand> commandType)
{ {
String commandName = commandType.toString(); if (!_commandTypes.containsKey(commandName))
if (!commandTypes.containsKey(commandName))
{ {
commandTypes.put(commandName, commandType); _commandTypes.put(commandName, commandType);
} }
} }

View File

@ -169,7 +169,7 @@ public class ServerMonitor
if (onlineServers.contains(entry.getKey())) if (onlineServers.contains(entry.getKey()))
iterator.remove(); iterator.remove();
else if (System.currentTimeMillis() - entry.getValue().getValue() > 20000) else if (System.currentTimeMillis() - entry.getValue().getValue() > 30000)
{ {
String serverName = entry.getKey(); String serverName = entry.getKey();
String serverAddress = entry.getValue().getKey(); String serverAddress = entry.getValue().getKey();

View File

@ -26,7 +26,7 @@ public class KitSheepPig extends Kit
{ {
public KitSheepPig(ArcadeManager manager) public KitSheepPig(ArcadeManager manager)
{ {
super(manager, "'Pig'", KitAvailability.Gem, 5000, super(manager, "Pig", KitAvailability.Gem, 5000,
new String[] new String[]
{ {

View File

@ -175,7 +175,7 @@ public class PerkBomber extends Perk
@EventHandler @EventHandler
public void ExplosionPrime(ExplosionPrimeEvent event) public void ExplosionPrime(ExplosionPrimeEvent event)
{ {
Player player = _tntMap.remove(event.getEntity()); Player player = _tntMap.get(event.getEntity());
if (player != null) if (player != null)
{ {
for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 14)) 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) public void onEntityExplode(EntityExplodeEvent event)
{ {
Player player = _tntMap.remove(event.getEntity()); Player player = _tntMap.remove(event.getEntity());
@ -198,16 +198,9 @@ public class PerkBomber extends Perk
if (block.getType() == Material.DIAMOND_ORE) if (block.getType() == Material.DIAMOND_ORE)
{ {
Bukkit.getPluginManager().callEvent(new BomberExplodeDiamondBlock(player, block));
block.breakNaturally();
it.remove(); it.remove();
if (Math.random() < event.getYield())
{
block.breakNaturally();
Bukkit.getPluginManager().callEvent(new BomberExplodeDiamondBlock(player, block));
}
else
block.setType(Material.AIR);
} }
} }
} }

View File

@ -24,7 +24,7 @@ public class KaboomStatTracker extends StatTracker<MineStrike>
{ {
for (Player player : event.getDamagedPlayers()) for (Player player : event.getDamagedPlayers())
{ {
if (!player.isDead()) if (player.getHealth() != player.getMaxHealth())
return; return;
} }

View File

@ -5,7 +5,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import mineplex.core.common.util.UtilPlayer; 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.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.DamageChange;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
public class KillReasonStatTracker extends StatTracker<Game> public class KillReasonStatTracker extends StatTracker<Game>
@ -49,6 +52,27 @@ public class KillReasonStatTracker extends StatTracker<Game>
if (event.GetLog().GetLastDamager() != null && event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().contains(getReason())) if (event.GetLog().GetLastDamager() != null && event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().contains(getReason()))
addStat(killer, getStatName(), 1, false, false); 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() public String getStatName()