Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex

This commit is contained in:
Chiss 2014-12-15 12:26:25 +11:00
commit d0f8a6a063
12 changed files with 56 additions and 90 deletions

Binary file not shown.

View File

@ -95,8 +95,6 @@ public class LobbyBalancer implements Listener, Runnable
if (timeSpentInLock > 50)
System.out.println("[==] TIMING [==] Locked loading servers for " + timeSpentInLock + "ms");
_lobbyIndex = 0;
}
}
}

View File

@ -48,7 +48,8 @@ public class CoreClientManager extends MiniPlugin
private Object _clientLock = new Object();
private static int _connectingClients = 0;
private static int _clientsConnecting = 0;
private static int _clientsProcessing = 0;
public CoreClientManager(JavaPlugin plugin, String webServer)
{
@ -120,11 +121,17 @@ public class CoreClientManager extends MiniPlugin
return _clientList.get(player.getName());
}
}
public int getPlayerCountIncludingConnecting()
{
return Bukkit.getOnlinePlayers().size() + _clientsConnecting;
}
@EventHandler(priority = EventPriority.LOWEST)
public void AsyncLogin(AsyncPlayerPreLoginEvent event)
{
while (_connectingClients >= 5)
_clientsConnecting++;
while (_clientsProcessing >= 5)
{
try
{
@ -136,7 +143,7 @@ public class CoreClientManager extends MiniPlugin
}
}
_connectingClients++;
_clientsProcessing++;
try
{
@ -152,7 +159,8 @@ public class CoreClientManager extends MiniPlugin
}
finally
{
_connectingClients--;
_clientsProcessing--;
_clientsConnecting--;
}
if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().Has(Rank.MODERATOR))

View File

@ -2,6 +2,7 @@ package mineplex.core.donation;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -83,7 +84,7 @@ public class DonationManager extends MiniPlugin
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final UUID uuid, final String packageName, final boolean coinPurchase, final int cost, boolean oneTimePurchase)
{
Donor donor = Get(name);
final Donor donor = Bukkit.getPlayerExact(name) != null ? Get(name) : null;
if (donor != null)
{
@ -102,8 +103,6 @@ public class DonationManager extends MiniPlugin
{
if (response == TransactionResponse.Success)
{
Donor donor = Get(name);
if (donor != null)
{
donor.AddUnknownSalesPackagesOwned(packageName);

View File

@ -40,7 +40,8 @@ public class PetFactory
_pets.put(EntityType.CHICKEN, new Pet("Chicken", EntityType.CHICKEN, 7000));
_pets.put(EntityType.WOLF, new Pet("Dog", EntityType.WOLF, 8000));
_pets.put(EntityType.OCELOT, new Pet("Cat", EntityType.OCELOT, 6000));
_pets.put(EntityType.MUSHROOM_COW, new Pet("Mooshroom", EntityType.MUSHROOM_COW, 5000));
_pets.put(EntityType.MUSHROOM_COW, new Pet("Mooshroom", EntityType.MUSHROOM_COW, 5000));
//_pets.put(EntityType.WITHER, new Pet("Widder", EntityType.SHEEP, 5));
List<PetSalesToken> petTokens = new ArrayList<PetSalesToken>();

View File

@ -1,6 +1,5 @@
package mineplex.core.pet;
import java.lang.reflect.Field;
import java.util.Iterator;
import java.util.Map.Entry;
@ -15,35 +14,25 @@ import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import net.minecraft.server.v1_7_R4.EntityCreature;
import net.minecraft.server.v1_7_R4.EntityHuman;
import net.minecraft.server.v1_7_R4.EntityInsentient;
import net.minecraft.server.v1_7_R4.EntitySnowman;
import net.minecraft.server.v1_7_R4.Navigation;
import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer;
import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround;
import net.minecraft.server.v1_7_R4.PathfinderGoalSelector;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftSnowman;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Creature;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowman;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.EntityBlockFormEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -59,6 +48,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
private static Object _petOwnerSynch = new Object();
private static Object _petRenameSynch = new Object();
private DisguiseManager _disguiseManager;
private mineplex.core.creature.Creature _creatureModule;
private PetRepository _repository;
private PetFactory _petFactory;
@ -66,18 +56,16 @@ public class PetManager extends MiniClientPlugin<PetClient>
private NautHashMap<String, Creature> _activePetOwners;
private NautHashMap<String, Integer> _failedAttempts;
private Field _goalSelector;
private Field _targetSelector;
private NautHashMap<String, EntityType> _petOwnerQueue = new NautHashMap<String, EntityType>();
private NautHashMap<String, String> _petRenameQueue = new NautHashMap<String, String>();
public PetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, mineplex.core.creature.Creature creatureModule, BlockRestore restore, String webAddress)
public PetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, DisguiseManager disguiseManager, mineplex.core.creature.Creature creatureModule, BlockRestore restore, String webAddress)
{
super("Pet Manager", plugin);
_creatureModule = creatureModule;
_disguiseManager = disguiseManager;
_repository = new PetRepository(webAddress);
_petFactory = new PetFactory(_repository);
_blockRestore = restore;
@ -168,11 +156,21 @@ public class PetManager extends MiniClientPlugin<PetClient>
pet.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 0));
UtilEnt.silence(pet, true);
}
if (pet instanceof Villager)
else if (pet instanceof Villager)
{
((Villager) pet).setBaby();
((Villager) pet).setAgeLock(true);
}
/*
else if (pet instanceof Sheep)
{
DisguiseWither disguise = new DisguiseWither(pet);
disguise.s(350);
_disguiseManager.disguise(disguise);
UtilEnt.silence(pet, true);
}
*/
_activePetOwners.put(player.getName(), pet);
_failedAttempts.put(player.getName(), 0);
@ -183,7 +181,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
((Ageable)pet).setAgeLock(true);
}
ClearPetGoals(pet);
UtilEnt.Vegetate(pet);
}
public Creature GetPet(Player player)
@ -329,43 +327,6 @@ public class PetManager extends MiniClientPlugin<PetClient>
}
}
}
private void ClearPetGoals(Creature pet)
{
try
{
_goalSelector = EntityInsentient.class.getDeclaredField("goalSelector");
_goalSelector.setAccessible(true);
_targetSelector = EntityInsentient.class.getDeclaredField("targetSelector");
_targetSelector.setAccessible(true);
EntityCreature creature = ((CraftCreature)pet).getHandle();
PathfinderGoalSelector goalSelector = new PathfinderGoalSelector(((CraftWorld)pet.getWorld()).getHandle().methodProfiler);
goalSelector.a(0, new PathfinderGoalLookAtPlayer(creature, EntityHuman.class, 6.0F));
goalSelector.a(1, new PathfinderGoalRandomLookaround(creature));
_goalSelector.set(creature, goalSelector);
_targetSelector.set(creature, new PathfinderGoalSelector(((CraftWorld)pet.getWorld()).getHandle().methodProfiler));
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
}
catch (SecurityException e)
{
e.printStackTrace();
}
}
@EventHandler
public void OnClientWebResponse(ClientWebResponseEvent event)
@ -406,16 +367,4 @@ public class PetManager extends MiniClientPlugin<PetClient>
for (Player player : UtilServer.getPlayers())
RemovePet(player, true);
}
// @EventHandler
// public void snowmanTrailClean(EntityBlockFormEvent event)
// {
// if (event.isCancelled())
// return;
//
// if (event.getEntity() instanceof Snowman)
// {
// _blockRestore.Add(event.getBlock(), 78, (byte)0, 0, (byte)0, 6000);
// }
// }
}

View File

@ -9,6 +9,7 @@ import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.Callback;
import mineplex.core.monitor.LagMeter;
import mineplex.core.updater.UpdateType;
@ -26,6 +27,7 @@ public class ServerStatusManager extends MiniPlugin
public final int DEFAULT_SERVER_TIMEOUT = 15;
private ServerRepository _repository;
private CoreClientManager _clientManager;
private LagMeter _lagMeter;
private String _name;
@ -35,11 +37,12 @@ public class ServerStatusManager extends MiniPlugin
private long _startUpDate;
public ServerStatusManager(JavaPlugin plugin, LagMeter lagMeter)
public ServerStatusManager(JavaPlugin plugin, CoreClientManager clientManager, LagMeter lagMeter)
{
super("Server Status Manager", plugin);
_startUpDate = Utility.currentTimeSeconds();
_clientManager = clientManager;
_lagMeter = lagMeter;
if (new File("IgnoreUpdates.dat").exists())
@ -143,7 +146,7 @@ public class ServerStatusManager extends MiniPlugin
GetPluginManager().callEvent(event);
String motd = event.getMotd();
int playerCount = Bukkit.getOnlinePlayers().size();
int playerCount = _clientManager.getPlayerCountIncludingConnecting();
int maxPlayerCount = event.getMaxPlayers();
int tps = (int) _lagMeter.getTicksPerSecond();
String address = Bukkit.getServer().getIp().isEmpty() ? "localhost" : Bukkit.getServer().getIp();

View File

@ -66,7 +66,7 @@ public class Clans extends JavaPlugin
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
new MessageManager(this, _clientManager, preferenceManager);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, _clientManager));
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
new Spawn(this, serverStatusManager.getCurrentServerName());
Teleport teleport = new Teleport(this);
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());

View File

@ -85,21 +85,21 @@ public class Hub extends JavaPlugin implements IRelation
new ServerConfiguration(this);
//Other Modules
PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager);
preferenceManager.GiveItem = true;
new MessageManager(this, clientManager, preferenceManager);
Creature creature = new Creature(this);
NpcManager npcManager = new NpcManager(this, creature);
PetManager petManager = new PetManager(this, clientManager, donationManager, creature, blockRestore, webServerAddress);
PetManager petManager = new PetManager(this, clientManager, donationManager, disguiseManager, creature, blockRestore, webServerAddress);
PollManager pollManager = new PollManager(this, clientManager, donationManager);
//Main Modules
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager));
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager);
PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
StatsManager statsManager = new StatsManager(this, clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager);
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this));

View File

@ -40,11 +40,12 @@ public class ServerMonitor
private static Logger _logger = Logger.getLogger("ServerMonitor");
private static int _totalPlayers = 0;
private static Region _region;
public static void main (String args[])
{
Region region = !new File("eu.dat").exists() ? Region.US : Region.EU;
_repository = ServerManager.getServerRepository(region); // Fetches and connects to server repo
_region = !new File("eu.dat").exists() ? Region.US : Region.EU;
_repository = ServerManager.getServerRepository(_region); // Fetches and connects to server repo
File logFile = new File("monitor.log");
@ -281,7 +282,14 @@ public class ServerMonitor
}
else if (serverGroup.getName().equalsIgnoreCase("Halloween"))
{
if (serverGroup.getServers().size() > 250)
if (serverGroup.getServers().size() > (_region == Region.US ? 300 : 100))
{
serversToAdd = 0;
}
}
else if (serverGroup.getName().equalsIgnoreCase("Christmas"))
{
if (serverGroup.getServers().size() > (_region == Region.US ? 300 : 100))
{
serversToAdd = 0;
}

View File

@ -48,7 +48,7 @@ public class StaffServer extends JavaPlugin
new Punish(this, webServerAddress, clientManager);
new NpcManager(this, new Creature(this));
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager));
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager);
preferenceManager.GiveItem = false;

View File

@ -90,7 +90,7 @@ public class Arcade extends JavaPlugin
new MessageManager(this, _clientManager, preferenceManager);
Creature creature = new Creature(this);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, _clientManager));
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
new Spawn(this, serverStatusManager.getCurrentServerName());
Teleport teleport = new Teleport(this);
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
@ -112,7 +112,7 @@ public class Arcade extends JavaPlugin
//Inventory
InventoryManager inventoryManager = new InventoryManager(this, _clientManager);
PetManager petManager = new PetManager(this, _clientManager, _donationManager, creature, blockRestore, webServerAddress);
PetManager petManager = new PetManager(this, _clientManager, _donationManager, 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);
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null);