Added connecting clients as a factor for status snapshot.

Added online check for DonationManager rewarding local info.
This commit is contained in:
Jonathan Williams 2014-12-14 02:32:52 -05:00
parent 5b67e2182a
commit 9fb2231d76
3 changed files with 19 additions and 9 deletions

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

@ -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();