5.3
This commit is contained in:
@@ -704,6 +704,9 @@ public class Claim
|
||||
//admin claims aren't restricted
|
||||
if(this.isAdminClaim()) return null;
|
||||
|
||||
//don't apply this rule to very large claims
|
||||
if(this.getArea() > 10000) return null;
|
||||
|
||||
//determine maximum allowable entity count, based on claim size
|
||||
int maxEntities = this.getArea() / 50;
|
||||
if(maxEntities == 0) return GriefPrevention.instance.dataStore.getMessage(Messages.ClaimTooSmallForEntities);
|
||||
|
||||
@@ -297,7 +297,7 @@ class EntityEventHandler implements Listener
|
||||
}
|
||||
|
||||
//when an entity is damaged
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onEntityDamage (EntityDamageEvent event)
|
||||
{
|
||||
//only actually interested in entities damaging entities (ignoring environmental damage)
|
||||
|
||||
@@ -117,12 +117,17 @@ public class GriefPrevention extends JavaPlugin
|
||||
|
||||
public boolean config_addItemsToClaimedChests; //whether players may add items to claimed chests by left-clicking them
|
||||
public boolean config_eavesdrop; //whether whispered messages will be visible to administrators
|
||||
public ArrayList<String> config_eavesdrop_whisperCommands; //list of whisper commands to eavesdrop on
|
||||
|
||||
public boolean config_smartBan; //whether to ban accounts which very likely owned by a banned player
|
||||
|
||||
public boolean config_endermenMoveBlocks; //whether or not endermen may move blocks around
|
||||
public boolean config_creaturesTrampleCrops; //whether or not non-player entities may trample crops
|
||||
|
||||
public List<Integer> config_mods_accessTrustIds; //list of block IDs which should require /accesstrust for player interaction
|
||||
public List<Integer> config_mods_containerTrustIds; //list of block IDs which should require /containertrust for player interaction
|
||||
public List<String> config_mods_ignoreClaimsAccounts; //list of player names which ALWAYS ignore claims
|
||||
|
||||
//reference to the economy plugin, if economy integration is enabled
|
||||
public static Economy economy = null;
|
||||
|
||||
@@ -260,12 +265,22 @@ public class GriefPrevention extends JavaPlugin
|
||||
|
||||
this.config_addItemsToClaimedChests = config.getBoolean("GriefPrevention.AddItemsToClaimedChests", true);
|
||||
this.config_eavesdrop = config.getBoolean("GriefPrevention.EavesdropEnabled", false);
|
||||
String whisperCommandsToMonitor = config.getString("GriefPrevention.WhisperCommands", "/tell;/pm;/r");
|
||||
|
||||
this.config_smartBan = config.getBoolean("GriefPrevention.SmartBan", true);
|
||||
|
||||
this.config_endermenMoveBlocks = config.getBoolean("GriefPrevention.EndermenMoveBlocks", false);
|
||||
this.config_creaturesTrampleCrops = config.getBoolean("GriefPrevention.CreaturesTrampleCrops", false);
|
||||
|
||||
this.config_mods_accessTrustIds = config.getIntegerList("GriefPrevention.Mods.BlockIdsRequiringAccessTrust");
|
||||
if(this.config_mods_accessTrustIds == null) this.config_mods_accessTrustIds = new ArrayList<Integer>();
|
||||
|
||||
this.config_mods_accessTrustIds = config.getIntegerList("GriefPrevention.Mods.BlockIdsRequiringContainerTrust");
|
||||
if(this.config_mods_containerTrustIds == null) this.config_mods_containerTrustIds = new ArrayList<Integer>();
|
||||
|
||||
this.config_mods_ignoreClaimsAccounts = config.getStringList("GriefPrevention.Mods.PlayersIgnoringAllClaims");
|
||||
if(this.config_mods_ignoreClaimsAccounts == null) this.config_mods_ignoreClaimsAccounts = new ArrayList<String>();
|
||||
|
||||
//default for claim investigation tool
|
||||
String investigationToolMaterialName = Material.STICK.name();
|
||||
|
||||
@@ -420,6 +435,7 @@ public class GriefPrevention extends JavaPlugin
|
||||
config.set("GriefPrevention.AddItemsToClaimedChests", this.config_addItemsToClaimedChests);
|
||||
|
||||
config.set("GriefPrevention.EavesdropEnabled", this.config_eavesdrop);
|
||||
config.set("GriefPrevention.WhisperCommands", whisperCommandsToMonitor);
|
||||
config.set("GriefPrevention.SmartBan", this.config_smartBan);
|
||||
|
||||
config.set("GriefPrevention.Siege.Worlds", siegeEnabledWorldNames);
|
||||
@@ -432,6 +448,10 @@ public class GriefPrevention extends JavaPlugin
|
||||
config.set("GriefPrevention.Database.UserName", databaseUserName);
|
||||
config.set("GriefPrevention.Database.Password", databasePassword);
|
||||
|
||||
config.set("GriefPrevention.Mods.BlockIdsRequiringAccessTrust", this.config_mods_accessTrustIds);
|
||||
config.set("GriefPrevention.Mods.BlockIdsRequiringContainerTrust", this.config_mods_containerTrustIds);
|
||||
config.set("GriefPrevention.Mods.PlayersIgnoringAllClaims", this.config_mods_ignoreClaimsAccounts);
|
||||
|
||||
try
|
||||
{
|
||||
config.save(DataStore.configFilePath);
|
||||
@@ -449,6 +469,14 @@ public class GriefPrevention extends JavaPlugin
|
||||
this.config_spam_monitorSlashCommands.add(commands[i].trim());
|
||||
}
|
||||
|
||||
//try to parse the list of commands which should be monitored for spam
|
||||
this.config_eavesdrop_whisperCommands = new ArrayList<String>();
|
||||
commands = whisperCommandsToMonitor.split(";");
|
||||
for(int i = 0; i < commands.length; i++)
|
||||
{
|
||||
this.config_eavesdrop_whisperCommands.add(commands[i].trim());
|
||||
}
|
||||
|
||||
//when datastore initializes, it loads player and claim data, and posts some stats to the log
|
||||
if(databaseUrl.length() > 0)
|
||||
{
|
||||
@@ -2080,8 +2108,8 @@ public class GriefPrevention extends JavaPlugin
|
||||
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
|
||||
Claim claim = this.dataStore.getClaimAt(location, false, playerData.lastClaim);
|
||||
|
||||
//exception: administrators in ignore claims mode
|
||||
if(playerData.ignoreClaims) return null;
|
||||
//exception: administrators in ignore claims mode and special player accounts created by server mods
|
||||
if(playerData.ignoreClaims || GriefPrevention.instance.config_mods_ignoreClaimsAccounts.contains(player.getName())) return null;
|
||||
|
||||
//wilderness rules
|
||||
if(claim == null)
|
||||
@@ -2120,8 +2148,8 @@ public class GriefPrevention extends JavaPlugin
|
||||
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
|
||||
Claim claim = this.dataStore.getClaimAt(location, false, playerData.lastClaim);
|
||||
|
||||
//exception: administrators in ignore claims mode
|
||||
if(playerData.ignoreClaims) return null;
|
||||
//exception: administrators in ignore claims mode, and special player accounts created by server mods
|
||||
if(playerData.ignoreClaims || GriefPrevention.instance.config_mods_ignoreClaimsAccounts.contains(player.getName())) return null;
|
||||
|
||||
//wilderness rules
|
||||
if(claim == null)
|
||||
|
||||
@@ -308,22 +308,20 @@ class PlayerEventHandler implements Listener
|
||||
return false;
|
||||
}
|
||||
|
||||
//when a player uses a slash command, monitor for spam
|
||||
//when a player uses a slash command...
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
void onPlayerCommandPreprocess (PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if(!GriefPrevention.instance.config_spam_enabled) return;
|
||||
|
||||
//if the slash command used is in the list of monitored commands, treat it like a chat message (see above)
|
||||
String [] args = event.getMessage().split(" ");
|
||||
if(GriefPrevention.instance.config_spam_monitorSlashCommands.contains(args[0])) this.onPlayerChat(event);
|
||||
|
||||
if(GriefPrevention.instance.config_eavesdrop && args[0].equalsIgnoreCase("/tell") && !event.getPlayer().hasPermission("griefprevention.eavesdrop") && args.length > 2)
|
||||
//if eavesdrop enabled, eavesdrop
|
||||
String command = args[0].toLowerCase();
|
||||
if(GriefPrevention.instance.config_eavesdrop && GriefPrevention.instance.config_eavesdrop_whisperCommands.contains(command) && !event.getPlayer().hasPermission("griefprevention.eavesdrop") && args.length > 1)
|
||||
{
|
||||
StringBuilder logMessageBuilder = new StringBuilder();
|
||||
logMessageBuilder.append("[").append(event.getPlayer().getName()).append(" > ").append(args[1]).append("] ");
|
||||
logMessageBuilder.append("[[").append(event.getPlayer().getName()).append("]] ");
|
||||
|
||||
for(int i = 2; i < args.length; i++)
|
||||
for(int i = 1; i < args.length; i++)
|
||||
{
|
||||
logMessageBuilder.append(args[i]).append(" ");
|
||||
}
|
||||
@@ -342,6 +340,12 @@ class PlayerEventHandler implements Listener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if anti spam enabled, check for spam
|
||||
if(!GriefPrevention.instance.config_spam_enabled) return;
|
||||
|
||||
//if the slash command used is in the list of monitored commands, treat it like a chat message (see above)
|
||||
if(GriefPrevention.instance.config_spam_monitorSlashCommands.contains(args[0])) this.onPlayerChat(event);
|
||||
}
|
||||
|
||||
//when a player attempts to join the server...
|
||||
@@ -878,7 +882,8 @@ class PlayerEventHandler implements Listener
|
||||
clickedBlockType == Material.BREWING_STAND ||
|
||||
clickedBlockType == Material.WORKBENCH ||
|
||||
clickedBlockType == Material.JUKEBOX ||
|
||||
clickedBlockType == Material.ENCHANTMENT_TABLE)))
|
||||
clickedBlockType == Material.ENCHANTMENT_TABLE ||
|
||||
GriefPrevention.instance.config_mods_containerTrustIds.contains(clickedBlock.getTypeId()))))
|
||||
{
|
||||
//block container use while under siege, so players can't hide items from attackers
|
||||
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
|
||||
@@ -936,7 +941,7 @@ class PlayerEventHandler implements Listener
|
||||
}
|
||||
|
||||
//otherwise apply rules for buttons and switches
|
||||
else if(GriefPrevention.instance.config_claims_preventButtonsSwitches && (clickedBlockType == null || clickedBlockType == Material.STONE_BUTTON || clickedBlockType == Material.LEVER))
|
||||
else if(GriefPrevention.instance.config_claims_preventButtonsSwitches && (clickedBlockType == null || clickedBlockType == Material.STONE_BUTTON || clickedBlockType == Material.LEVER || GriefPrevention.instance.config_mods_accessTrustIds.contains(clickedBlock.getTypeId())))
|
||||
{
|
||||
Claim claim = this.dataStore.getClaimAt(clickedBlock.getLocation(), false, null);
|
||||
if(claim != null)
|
||||
|
||||
Reference in New Issue
Block a user