Better new player detection for creative mode.

Should help MineChat users in creative mode.
This commit is contained in:
ryanhamshire 2015-10-12 15:55:03 -07:00
parent 77a4a30432
commit 875303faf7
2 changed files with 14 additions and 3 deletions

View File

@ -35,6 +35,7 @@ import java.util.regex.Pattern;
import me.ryanhamshire.GriefPrevention.DataStore.NoTransferException; import me.ryanhamshire.GriefPrevention.DataStore.NoTransferException;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.Achievement;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -3041,4 +3042,14 @@ public class GriefPrevention extends JavaPlugin
if(configSetting != null) return configSetting; if(configSetting != null) return configSetting;
return world.getPVP(); return world.getPVP();
} }
public static boolean isNewToServer(Player player)
{
if(player.hasAchievement(Achievement.MINE_WOOD)) return false;
PlayerData playerData = instance.dataStore.getPlayerData(player.getUniqueId());
if(playerData.getClaims().size() > 0) return false;
return true;
}
} }

View File

@ -151,7 +151,7 @@ class PlayerEventHandler implements Listener
recipients.add(player); recipients.add(player);
//if player not new warn for the first infraction per play session. //if player not new warn for the first infraction per play session.
if(player.hasAchievement(Achievement.MINE_WOOD)) if(!GriefPrevention.isNewToServer(player))
{ {
PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()); PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId());
if(!playerData.profanityWarned) if(!playerData.profanityWarned)
@ -690,7 +690,7 @@ class PlayerEventHandler implements Listener
this.lastLoginThisServerSessionMap.put(playerID, nowDate); this.lastLoginThisServerSessionMap.put(playerID, nowDate);
//if newish, prevent chat until he's moved a bit to prove he's not a bot //if newish, prevent chat until he's moved a bit to prove he's not a bot
if(!player.hasAchievement(Achievement.MINE_WOOD)) if(GriefPrevention.isNewToServer(player))
{ {
playerData.noChatLocation = player.getLocation(); playerData.noChatLocation = player.getLocation();
} }
@ -920,7 +920,7 @@ class PlayerEventHandler implements Listener
this.dataStore.clearCachedPlayerData(playerID); this.dataStore.clearCachedPlayerData(playerID);
//reduce count of players with that player's IP address //reduce count of players with that player's IP address
if(GriefPrevention.instance.config_ipLimit > 0 && !player.hasAchievement(Achievement.MINE_WOOD)) if(GriefPrevention.instance.config_ipLimit > 0 && GriefPrevention.isNewToServer(player))
{ {
InetAddress ipAddress = playerData.ipAddress; InetAddress ipAddress = playerData.ipAddress;
if(ipAddress != null) if(ipAddress != null)