Added automatic timings report in the event of lag.

Added more exception handling around LoadingWindow
This commit is contained in:
Jonathan Williams 2015-09-11 22:50:53 -07:00
parent 4bb100b6be
commit 2380b9041d
2 changed files with 61 additions and 14 deletions

View File

@ -151,21 +151,47 @@ public class LoadingWindow implements Runnable, Listener {
{
Player player = Bukkit.getPlayer(_playersUUID);
if (player == null || player.getOpenInventory() == null || player.getOpenInventory().getTopInventory() == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (_inv != null && !player.getOpenInventory().getTopInventory().equals(_inv))) {
end();
return;
}
if (_inv == null) {
_inv = Bukkit.createInventory(null, _size, _title);
try
{
if (player == null || player.getOpenInventory() == null || player.getOpenInventory().getTopInventory() == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (!player.getOpenInventory().getTopInventory().equals(_inv)))
{
end();
return;
}
setBackGround();
setLoadingBarItems();
UtilPlayer.swapToInventory(player, _inv);
Bukkit.getPluginManager().registerEvents(this, _plugin);
} else
setLoadingBarItems();
_ticker++;
if (_inv == null)
{
_inv = Bukkit.createInventory(null, _size, _title);
setBackGround();
setLoadingBarItems();
UtilPlayer.swapToInventory(player, _inv);
Bukkit.getPluginManager().registerEvents(this, _plugin);
}
else
setLoadingBarItems();
}
catch (Exception exception)
{
try
{
System.out.println("player ? " + (player == null));
System.out.println("player.getOpenInventory() ? " + (player.getOpenInventory() == null));
System.out.println("player.getOpenInventory().getTopInventory() ? " + (player.getOpenInventory().getTopInventory() == null));
System.out.println("_inv ? " + (_inv == null));
exception.printStackTrace();
}
catch (Exception exception2)
{
exception.printStackTrace();
}
end();
}
finally
{
_ticker++;
}
}
public void end() {

View File

@ -9,7 +9,9 @@ import mineplex.core.common.util.F;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -28,6 +30,10 @@ public class LagMeter extends MiniPlugin
private long _lastTick = 0;
private boolean _timingsRunning;
private boolean _timingsPasted;
private long _timingsStarted;
private HashSet<Player> _monitoring = new HashSet<Player>();
public LagMeter(JavaPlugin plugin, CoreClientManager clientManager)
@ -87,6 +93,21 @@ public class LagMeter extends MiniPlugin
_lastRun = now;
_count++;
if (_timingsRunning)
{
if (_ticksPerSecond > 15 || System.currentTimeMillis() - _timingsStarted > 60000)
{
getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings paste");
_timingsRunning = false;
}
}
else if (_ticksPerSecond < 10)
{
_timingsRunning = true;
_timingsStarted = System.currentTimeMillis();
getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings on");
}
}
public double getTicksPerSecond()