mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Added timeout check to nonuke, so lag doesn't ban people.
This commit is contained in:
parent
5c8f98089e
commit
b94efb525f
@ -1,5 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Heartbeat;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
|
||||
@ -74,16 +75,24 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
playerdata.incrementBlockDestroyCount();
|
||||
if (playerdata.getBlockDestroyCount() > TotalFreedomMod.nukeMonitorCountBreak)
|
||||
Long lastRan = TFM_Heartbeat.getLastRan();
|
||||
if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
||||
TFM_Util.autoEject(p, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||
TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
|
||||
}
|
||||
else
|
||||
{
|
||||
playerdata.incrementBlockDestroyCount();
|
||||
if (playerdata.getBlockDestroyCount() > TotalFreedomMod.nukeMonitorCountBreak)
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
||||
TFM_Util.autoEject(p, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||
|
||||
playerdata.resetBlockDestroyCount();
|
||||
playerdata.resetBlockDestroyCount();
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,16 +151,24 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
playerdata.incrementBlockPlaceCount();
|
||||
if (playerdata.getBlockPlaceCount() > TotalFreedomMod.nukeMonitorCountPlace)
|
||||
Long lastRan = TFM_Heartbeat.getLastRan();
|
||||
if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " is placing blocks too fast!", ChatColor.RED);
|
||||
TFM_Util.autoEject(p, "You are placing blocks too fast.");
|
||||
TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
|
||||
}
|
||||
else
|
||||
{
|
||||
playerdata.incrementBlockPlaceCount();
|
||||
if (playerdata.getBlockPlaceCount() > TotalFreedomMod.nukeMonitorCountPlace)
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " is placing blocks too fast!", ChatColor.RED);
|
||||
TFM_Util.autoEject(p, "You are placing blocks too fast.");
|
||||
|
||||
playerdata.resetBlockPlaceCount();
|
||||
playerdata.resetBlockPlaceCount();
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ public class TFM_Heartbeat extends BukkitRunnable
|
||||
{
|
||||
private final TotalFreedomMod plugin;
|
||||
private final Server server;
|
||||
private static Long lastRan = null;
|
||||
|
||||
public TFM_Heartbeat(TotalFreedomMod instance)
|
||||
{
|
||||
@ -16,9 +17,16 @@ public class TFM_Heartbeat extends BukkitRunnable
|
||||
this.server = plugin.getServer();
|
||||
}
|
||||
|
||||
public static Long getLastRan()
|
||||
{
|
||||
return lastRan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
lastRan = System.currentTimeMillis();
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
|
Loading…
Reference in New Issue
Block a user