Only send frostwalker message every 10 seconds

This commit is contained in:
Kakifrucht 2016-06-12 01:49:33 +02:00 committed by Trent Hensler
parent a7aeb26fd0
commit 5721473a16
3 changed files with 21 additions and 1 deletions

View File

@ -41,6 +41,10 @@ public interface FPlayer extends EconomyParticipator {
public void setAutoLeave(boolean autoLeave); public void setAutoLeave(boolean autoLeave);
public long getLastFrostwalkerMessage();
public void setLastFrostwalkerMessage();
public void setMonitorJoins(boolean monitor); public void setMonitorJoins(boolean monitor);
public boolean isMonitoringJoins(); public boolean isMonitoringJoins();

View File

@ -139,8 +139,15 @@ public class FactionsBlockListener implements Listener {
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
Location location = event.getBlock().getLocation(); Location location = event.getBlock().getLocation();
// only notify every 10 seconds
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
boolean justCheck = fPlayer.getLastFrostwalkerMessage() + 10000 > System.currentTimeMillis();
if (!justCheck) {
fPlayer.setLastFrostwalkerMessage();
}
// Check if they have build permissions here. If not, block this from happening. // Check if they have build permissions here. If not, block this from happening.
if (!playerCanBuildDestroyBlock(player, location, "frost walk", false)) { if (!playerCanBuildDestroyBlock(player, location, "frost walk", justCheck)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -65,6 +65,7 @@ public abstract class MemoryFPlayer implements FPlayer {
protected transient boolean autoSafeZoneEnabled; protected transient boolean autoSafeZoneEnabled;
protected transient boolean autoWarZoneEnabled; protected transient boolean autoWarZoneEnabled;
protected transient boolean loginPvpDisabled; protected transient boolean loginPvpDisabled;
protected transient long lastFrostwalkerMessage;
public void login() { public void login() {
@ -134,6 +135,14 @@ public abstract class MemoryFPlayer implements FPlayer {
P.p.debug(name + " set autoLeave to " + willLeave); P.p.debug(name + " set autoLeave to " + willLeave);
} }
public long getLastFrostwalkerMessage() {
return this.lastFrostwalkerMessage;
}
public void setLastFrostwalkerMessage() {
this.lastFrostwalkerMessage = System.currentTimeMillis();
}
public Faction getAutoClaimFor() { public Faction getAutoClaimFor() {
return autoClaimFor; return autoClaimFor;
} }