Improve death message spam blocker.
Can't mitigate by logging out and back in. Made blockage less obvious to spammer. Increased default cooldown to two minutes.
This commit is contained in:
parent
65f122aa95
commit
a97d5c191a
|
|
@ -567,7 +567,7 @@ public class GriefPrevention extends JavaPlugin
|
|||
this.config_spam_banMessage = config.getString("GriefPrevention.Spam.BanMessage", "Banned for spam.");
|
||||
String slashCommandsToMonitor = config.getString("GriefPrevention.Spam.MonitorSlashCommands", "/me;/global;/local");
|
||||
slashCommandsToMonitor = config.getString("GriefPrevention.Spam.ChatSlashCommands", slashCommandsToMonitor);
|
||||
this.config_spam_deathMessageCooldownSeconds = config.getInt("GriefPrevention.Spam.DeathMessageCooldownSeconds", 60);
|
||||
this.config_spam_deathMessageCooldownSeconds = config.getInt("GriefPrevention.Spam.DeathMessageCooldownSeconds", 120);
|
||||
|
||||
this.config_pvp_protectFreshSpawns = config.getBoolean("GriefPrevention.PvP.ProtectFreshSpawns", true);
|
||||
this.config_pvp_punishLogout = config.getBoolean("GriefPrevention.PvP.PunishLogout", true);
|
||||
|
|
|
|||
|
|
@ -78,9 +78,6 @@ public class PlayerData
|
|||
//whether this player was recently warned about building outside land claims
|
||||
boolean warnedAboutBuildingOutsideClaims = false;
|
||||
|
||||
//timestamp of last death, for use in preventing death message spam
|
||||
long lastDeathTimeStamp = 0;
|
||||
|
||||
//timestamp when last siege ended (where this player was the defender)
|
||||
long lastSiegeEndTimeStamp = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import java.util.Arrays;
|
|||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
|
@ -931,20 +932,24 @@ class PlayerEventHandler implements Listener
|
|||
}
|
||||
|
||||
//when a player dies...
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
private HashMap<UUID, Long> deathTimestamps = new HashMap<UUID, Long>();
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
void onPlayerDeath(PlayerDeathEvent event)
|
||||
{
|
||||
//FEATURE: prevent death message spam by implementing a "cooldown period" for death messages
|
||||
PlayerData playerData = this.dataStore.getPlayerData(event.getEntity().getUniqueId());
|
||||
Player player = event.getEntity();
|
||||
Long lastDeathTime = this.deathTimestamps.get(player.getUniqueId());
|
||||
long now = Calendar.getInstance().getTimeInMillis();
|
||||
if(now - playerData.lastDeathTimeStamp < GriefPrevention.instance.config_spam_deathMessageCooldownSeconds * 1000)
|
||||
if(lastDeathTime != null && now - lastDeathTime < GriefPrevention.instance.config_spam_deathMessageCooldownSeconds * 1000)
|
||||
{
|
||||
event.setDeathMessage("");
|
||||
player.sendMessage(event.getDeathMessage()); //let the player assume his death message was broadcasted to everyone
|
||||
event.setDeathMessage("");
|
||||
}
|
||||
|
||||
playerData.lastDeathTimeStamp = now;
|
||||
this.deathTimestamps.put(player.getUniqueId(), now);
|
||||
|
||||
//these are related to locking dropped items on death to prevent theft
|
||||
PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId());
|
||||
playerData.dropsAreUnlocked = false;
|
||||
playerData.receivedDropUnlockAdvertisement = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user