Redesigned per-world claim mode configuration.
Much easier to understand and customize, especially for server owners who are new to GP and have both survival and creative worlds. Also, a performance improvement - when claim creation is disabled in a world, GP will not protect any existing claims in that world.
This commit is contained in:
parent
c0520880ff
commit
ca6024e151
|
|
@ -187,6 +187,9 @@ public class BlockEventHandler implements Listener
|
|||
}
|
||||
}
|
||||
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(placeEvent.getBlock().getWorld())) return;
|
||||
|
||||
//make sure the player is allowed to build at the location
|
||||
String noBuildReason = GriefPrevention.instance.allowBuild(player, block.getLocation());
|
||||
if(noBuildReason != null)
|
||||
|
|
@ -373,6 +376,9 @@ public class BlockEventHandler implements Listener
|
|||
//pushing down is ALWAYS safe
|
||||
if(event.getDirection() == BlockFace.DOWN) return;
|
||||
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(event.getBlock().getWorld())) return;
|
||||
|
||||
Block pistonBlock = event.getBlock();
|
||||
List<Block> blocks = event.getBlocks();
|
||||
|
||||
|
|
@ -498,6 +504,9 @@ public class BlockEventHandler implements Listener
|
|||
//if pulling "air", always safe
|
||||
if(event.getRetractLocation().getBlock().getType() == Material.AIR) return;
|
||||
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(event.getBlock().getWorld())) return;
|
||||
|
||||
//if pistons limited to only pulling blocks which are in the same claim the piston is in
|
||||
if(GriefPrevention.instance.config_pistonsInClaimsOnly)
|
||||
{
|
||||
|
|
@ -569,6 +578,9 @@ public class BlockEventHandler implements Listener
|
|||
return;
|
||||
}
|
||||
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(spreadEvent.getBlock().getWorld())) return;
|
||||
|
||||
//never spread into a claimed area, regardless of settings
|
||||
if(this.dataStore.getClaimAt(spreadEvent.getBlock().getLocation(), false, null) != null)
|
||||
{
|
||||
|
|
@ -619,6 +631,9 @@ public class BlockEventHandler implements Listener
|
|||
return;
|
||||
}
|
||||
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(burnEvent.getBlock().getWorld())) return;
|
||||
|
||||
//never burn claimed blocks, regardless of settings
|
||||
if(this.dataStore.getClaimAt(burnEvent.getBlock().getLocation(), false, null) != null)
|
||||
{
|
||||
|
|
@ -632,8 +647,8 @@ public class BlockEventHandler implements Listener
|
|||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onBlockFromTo (BlockFromToEvent spreadEvent)
|
||||
{
|
||||
//don't track fluid movement in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.config_claims_enabledWorlds.contains(spreadEvent.getBlock().getWorld())) return;
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(spreadEvent.getBlock().getWorld())) return;
|
||||
|
||||
//always allow fluids to flow straight down
|
||||
if(spreadEvent.getFace() == BlockFace.DOWN) return;
|
||||
|
|
@ -681,6 +696,9 @@ public class BlockEventHandler implements Listener
|
|||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onDispense(BlockDispenseEvent dispenseEvent)
|
||||
{
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(dispenseEvent.getBlock().getWorld())) return;
|
||||
|
||||
//from where?
|
||||
Block fromBlock = dispenseEvent.getBlock();
|
||||
Dispenser dispenser = new Dispenser(fromBlock.getType(), fromBlock.getData());
|
||||
|
|
@ -714,6 +732,9 @@ public class BlockEventHandler implements Listener
|
|||
//only take these potentially expensive steps if configured to do so
|
||||
if(!GriefPrevention.instance.config_limitTreeGrowth) return;
|
||||
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(growEvent.getWorld())) return;
|
||||
|
||||
Location rootLocation = growEvent.getLocation();
|
||||
Claim rootClaim = this.dataStore.getClaimAt(rootLocation, false, null);
|
||||
String rootOwnerName = null;
|
||||
|
|
|
|||
8
src/me/ryanhamshire/GriefPrevention/ClaimsMode.java
Normal file
8
src/me/ryanhamshire/GriefPrevention/ClaimsMode.java
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package me.ryanhamshire.GriefPrevention;
|
||||
|
||||
public enum ClaimsMode
|
||||
{
|
||||
Survival,
|
||||
Creative,
|
||||
Disabled
|
||||
}
|
||||
|
|
@ -512,7 +512,7 @@ public abstract class DataStore
|
|||
}
|
||||
|
||||
//creative mode claims always go to bedrock
|
||||
if(GriefPrevention.instance.config_claims_enabledCreativeWorlds.contains(world))
|
||||
if(GriefPrevention.instance.config_claims_worldModes.get(world) == ClaimsMode.Creative)
|
||||
{
|
||||
smally = 2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,14 @@ class EntityCleanupTask implements Runnable
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
ArrayList<World> worlds = GriefPrevention.instance.config_claims_enabledCreativeWorlds;
|
||||
ArrayList<World> worlds = new ArrayList<World>();
|
||||
for(World world : GriefPrevention.instance.getServer().getWorlds())
|
||||
{
|
||||
if(GriefPrevention.instance.config_claims_worldModes.get(world) == ClaimsMode.Creative)
|
||||
{
|
||||
worlds.add(world);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < worlds.size(); i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class EntityEventHandler implements Listener
|
|||
}
|
||||
|
||||
//don't allow the wither to break blocks, when the wither is determined, too expensive to constantly check for claimed blocks
|
||||
else if(event.getEntityType() == EntityType.WITHER && GriefPrevention.instance.config_claims_enabledWorlds.contains(event.getBlock().getWorld()))
|
||||
else if(event.getEntityType() == EntityType.WITHER && GriefPrevention.instance.config_claims_worldModes.get(event.getBlock().getWorld()) != ClaimsMode.Disabled)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ class EntityEventHandler implements Listener
|
|||
|
||||
//FEATURE: explosions don't destroy blocks when they explode near or above sea level in standard worlds
|
||||
boolean isCreeper = (explodeEvent.getEntity() != null && explodeEvent.getEntity() instanceof Creeper);
|
||||
if( location.getWorld().getEnvironment() == Environment.NORMAL && GriefPrevention.instance.config_claims_enabledWorlds.contains(location.getWorld()) && ((isCreeper && GriefPrevention.instance.config_blockSurfaceCreeperExplosions) || (!isCreeper && GriefPrevention.instance.config_blockSurfaceOtherExplosions)))
|
||||
if( location.getWorld().getEnvironment() == Environment.NORMAL && GriefPrevention.instance.claimsEnabledForWorld(location.getWorld()) && ((isCreeper && GriefPrevention.instance.config_blockSurfaceCreeperExplosions) || (!isCreeper && GriefPrevention.instance.config_blockSurfaceOtherExplosions)))
|
||||
{
|
||||
for(int i = 0; i < blocks.size(); i++)
|
||||
{
|
||||
|
|
@ -224,6 +224,9 @@ class EntityEventHandler implements Listener
|
|||
{
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(entity.getWorld())) return;
|
||||
|
||||
//special rule for creative worlds: killed entities don't drop items or experience orbs
|
||||
if(GriefPrevention.instance.creativeRulesApply(entity.getLocation()))
|
||||
{
|
||||
|
|
@ -272,6 +275,9 @@ class EntityEventHandler implements Listener
|
|||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onHangingBreak(HangingBreakEvent event)
|
||||
{
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(event.getEntity().getWorld())) return;
|
||||
|
||||
//FEATURE: claimed paintings are protected from breakage
|
||||
|
||||
//explosions don't destroy hangings
|
||||
|
|
@ -314,6 +320,9 @@ class EntityEventHandler implements Listener
|
|||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onPaintingPlace(HangingPlaceEvent event)
|
||||
{
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(event.getBlock().getWorld())) return;
|
||||
|
||||
//FEATURE: similar to above, placing a painting requires build permission in the claim
|
||||
|
||||
//if the player doesn't have permission, don't allow the placement
|
||||
|
|
@ -454,6 +463,9 @@ class EntityEventHandler implements Listener
|
|||
//if theft protection is enabled
|
||||
if(event instanceof EntityDamageByEntityEvent)
|
||||
{
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(event.getEntity().getWorld())) return;
|
||||
|
||||
//if the damaged entity is a claimed item frame, the damager needs to be a player with container trust in the claim
|
||||
if(subEvent.getEntityType() == EntityType.ITEM_FRAME)
|
||||
{
|
||||
|
|
@ -561,6 +573,9 @@ class EntityEventHandler implements Listener
|
|||
//all of this is anti theft code
|
||||
if(!GriefPrevention.instance.config_claims_preventTheft) return;
|
||||
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(event.getVehicle().getWorld())) return;
|
||||
|
||||
//determine which player is attacking, if any
|
||||
Player attacker = null;
|
||||
Entity damageSource = event.getAttacker();
|
||||
|
|
|
|||
|
|
@ -63,8 +63,9 @@ public class GriefPrevention extends JavaPlugin
|
|||
public DataStore dataStore;
|
||||
|
||||
//configuration variables, loaded/saved from a config.yml
|
||||
public ArrayList<World> config_claims_enabledWorlds; //list of worlds where players can create GriefPrevention claims
|
||||
public ArrayList<World> config_claims_enabledCreativeWorlds; //list of worlds where additional creative mode anti-grief rules apply
|
||||
|
||||
//claim mode for each world
|
||||
public ConcurrentHashMap<World, ClaimsMode> config_claims_worldModes = new ConcurrentHashMap<World, ClaimsMode>();
|
||||
|
||||
public boolean config_claims_preventTheft; //whether containers and crafting blocks are protectable
|
||||
public boolean config_claims_protectCreatures; //whether claimed animals may be injured by players without permission
|
||||
|
|
@ -178,69 +179,100 @@ public class GriefPrevention extends JavaPlugin
|
|||
|
||||
//read configuration settings (note defaults)
|
||||
|
||||
//default for claims worlds list
|
||||
ArrayList<String> defaultClaimsWorldNames = new ArrayList<String>();
|
||||
//get (deprecated node) claims world names from the config file
|
||||
List<World> worlds = this.getServer().getWorlds();
|
||||
for(int i = 0; i < worlds.size(); i++)
|
||||
{
|
||||
defaultClaimsWorldNames.add(worlds.get(i).getName());
|
||||
}
|
||||
|
||||
//get claims world names from the config file
|
||||
List<String> claimsEnabledWorldNames = config.getStringList("GriefPrevention.Claims.Worlds");
|
||||
if(claimsEnabledWorldNames == null || claimsEnabledWorldNames.size() == 0)
|
||||
{
|
||||
claimsEnabledWorldNames = defaultClaimsWorldNames;
|
||||
}
|
||||
List<String> deprecated_claimsEnabledWorldNames = config.getStringList("GriefPrevention.Claims.Worlds");
|
||||
|
||||
//validate that list
|
||||
this.config_claims_enabledWorlds = new ArrayList<World>();
|
||||
for(int i = 0; i < claimsEnabledWorldNames.size(); i++)
|
||||
for(int i = 0; i < deprecated_claimsEnabledWorldNames.size(); i++)
|
||||
{
|
||||
String worldName = claimsEnabledWorldNames.get(i);
|
||||
String worldName = deprecated_claimsEnabledWorldNames.get(i);
|
||||
World world = this.getServer().getWorld(worldName);
|
||||
if(world == null)
|
||||
{
|
||||
AddLogEntry("Error: Claims Configuration: There's no world named \"" + worldName + "\". Please update your config.yml.");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.config_claims_enabledWorlds.add(world);
|
||||
deprecated_claimsEnabledWorldNames.remove(i--);
|
||||
}
|
||||
}
|
||||
|
||||
//default creative claim world names
|
||||
List<String> defaultCreativeWorldNames = new ArrayList<String>();
|
||||
|
||||
//if default game mode for the server is creative, creative rules will apply to all worlds unless the config specifies otherwise
|
||||
if(this.getServer().getDefaultGameMode() == GameMode.CREATIVE)
|
||||
{
|
||||
for(int i = 0; i < defaultClaimsWorldNames.size(); i++)
|
||||
{
|
||||
defaultCreativeWorldNames.add(defaultClaimsWorldNames.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
//get creative world names from the config file
|
||||
List<String> creativeClaimsEnabledWorldNames = config.getStringList("GriefPrevention.Claims.CreativeRulesWorlds");
|
||||
if(creativeClaimsEnabledWorldNames == null || creativeClaimsEnabledWorldNames.size() == 0)
|
||||
{
|
||||
creativeClaimsEnabledWorldNames = defaultCreativeWorldNames;
|
||||
}
|
||||
//get (deprecated node) creative world names from the config file
|
||||
List<String> deprecated_creativeClaimsEnabledWorldNames = config.getStringList("GriefPrevention.Claims.CreativeRulesWorlds");
|
||||
|
||||
//validate that list
|
||||
this.config_claims_enabledCreativeWorlds = new ArrayList<World>();
|
||||
for(int i = 0; i < creativeClaimsEnabledWorldNames.size(); i++)
|
||||
for(int i = 0; i < deprecated_creativeClaimsEnabledWorldNames.size(); i++)
|
||||
{
|
||||
String worldName = creativeClaimsEnabledWorldNames.get(i);
|
||||
String worldName = deprecated_creativeClaimsEnabledWorldNames.get(i);
|
||||
World world = this.getServer().getWorld(worldName);
|
||||
if(world == null)
|
||||
{
|
||||
AddLogEntry("Error: Claims Configuration: There's no world named \"" + worldName + "\". Please update your config.yml.");
|
||||
deprecated_claimsEnabledWorldNames.remove(i--);
|
||||
}
|
||||
}
|
||||
|
||||
//decide claim mode for each world
|
||||
for(World world : worlds)
|
||||
{
|
||||
//is it specified in the config file?
|
||||
String configSetting = config.getString("GriefPrevention.Claims.Mode." + world.getName());
|
||||
if(configSetting != null)
|
||||
{
|
||||
ClaimsMode claimsMode = this.configStringToClaimsMode(configSetting);
|
||||
if(claimsMode != null)
|
||||
{
|
||||
this.config_claims_worldModes.put(world, claimsMode);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.config_claims_enabledCreativeWorlds.add(world);
|
||||
GriefPrevention.AddLogEntry("Error: Invalid claim mode \"" + configSetting + "\". Options are Survival, Creative, and Disabled.");
|
||||
this.config_claims_worldModes.put(world, ClaimsMode.Creative);
|
||||
}
|
||||
}
|
||||
|
||||
//was it specified in a deprecated config node?
|
||||
if(deprecated_creativeClaimsEnabledWorldNames.contains(world.getName()))
|
||||
{
|
||||
this.config_claims_worldModes.put(world, ClaimsMode.Creative);
|
||||
}
|
||||
|
||||
else if(deprecated_claimsEnabledWorldNames.contains(world.getName()))
|
||||
{
|
||||
this.config_claims_worldModes.put(world, ClaimsMode.Survival);
|
||||
}
|
||||
|
||||
//does the world's name indicate its purpose?
|
||||
else if(world.getName().toLowerCase().contains("survival"))
|
||||
{
|
||||
this.config_claims_worldModes.put(world, ClaimsMode.Survival);
|
||||
}
|
||||
|
||||
else if(world.getName().toLowerCase().contains("creative"))
|
||||
{
|
||||
this.config_claims_worldModes.put(world, ClaimsMode.Creative);
|
||||
}
|
||||
|
||||
//decide a default based on server type and world type
|
||||
else if(this.getServer().getDefaultGameMode() == GameMode.CREATIVE)
|
||||
{
|
||||
this.config_claims_worldModes.put(world, ClaimsMode.Creative);
|
||||
}
|
||||
|
||||
else if(world.getEnvironment() == Environment.NORMAL)
|
||||
{
|
||||
this.config_claims_worldModes.put(world, ClaimsMode.Survival);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
this.config_claims_worldModes.put(world, ClaimsMode.Disabled);
|
||||
}
|
||||
|
||||
//if the setting WOULD be disabled but this is a server upgrading from the old config format,
|
||||
//then default to survival mode for safety's sake (to protect any admin claims which may
|
||||
//have been created there)
|
||||
if(this.config_claims_worldModes.get(world) == ClaimsMode.Disabled &&
|
||||
deprecated_claimsEnabledWorldNames.size() > 0)
|
||||
{
|
||||
this.config_claims_worldModes.put(world, ClaimsMode.Survival);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -303,19 +335,10 @@ public class GriefPrevention extends JavaPlugin
|
|||
this.config_claims_minSize = config.getInt("GriefPrevention.Claims.MinimumSize", 10);
|
||||
this.config_claims_maxDepth = config.getInt("GriefPrevention.Claims.MaximumDepth", 0);
|
||||
this.config_claims_trappedCooldownHours = config.getInt("GriefPrevention.Claims.TrappedCommandCooldownHours", 8);
|
||||
|
||||
this.config_claims_chestClaimExpirationDays = config.getInt("GriefPrevention.Claims.Expiration.ChestClaimDays", 7);
|
||||
outConfig.set("GriefPrevention.Claims.Expiration.ChestClaimDays", this.config_claims_chestClaimExpirationDays);
|
||||
|
||||
this.config_claims_unusedClaimExpirationDays = config.getInt("GriefPrevention.Claims.Expiration.UnusedClaimDays", 14);
|
||||
outConfig.set("GriefPrevention.Claims.Expiration.UnusedClaimDays", this.config_claims_unusedClaimExpirationDays);
|
||||
|
||||
this.config_claims_expirationDays = config.getInt("GriefPrevention.Claims.Expiration.AllClaimDays", 0);
|
||||
outConfig.set("GriefPrevention.Claims.Expiration.AllClaimDays", this.config_claims_expirationDays);
|
||||
|
||||
this.config_claims_survivalAutoNatureRestoration = config.getBoolean("GriefPrevention.Claims.Expiration.AutomaticNatureRestoration.SurvivalWorlds", false);
|
||||
outConfig.set("GriefPrevention.Claims.Expiration.AutomaticNatureRestoration.SurvivalWorlds", this.config_claims_survivalAutoNatureRestoration);
|
||||
|
||||
this.config_spam_enabled = config.getBoolean("GriefPrevention.Spam.Enabled", true);
|
||||
this.config_spam_loginCooldownSeconds = config.getInt("GriefPrevention.Spam.LoginCooldownSeconds", 60);
|
||||
this.config_spam_warningMessage = config.getString("GriefPrevention.Spam.WarningMessage", "Please reduce your noise level. Spammers will be banned.");
|
||||
|
|
@ -534,8 +557,14 @@ public class GriefPrevention extends JavaPlugin
|
|||
String databaseUserName = config.getString("GriefPrevention.Database.UserName", "");
|
||||
String databasePassword = config.getString("GriefPrevention.Database.Password", "");
|
||||
|
||||
outConfig.set("GriefPrevention.Claims.Worlds", claimsEnabledWorldNames);
|
||||
outConfig.set("GriefPrevention.Claims.CreativeRulesWorlds", creativeClaimsEnabledWorldNames);
|
||||
//claims mode by world
|
||||
for(World world : this.config_claims_worldModes.keySet())
|
||||
{
|
||||
outConfig.set(
|
||||
"GriefPrevention.Claims.Mode." + world.getName(),
|
||||
this.config_claims_worldModes.get(world).name());
|
||||
}
|
||||
|
||||
outConfig.set("GriefPrevention.Claims.PreventTheft", this.config_claims_preventTheft);
|
||||
outConfig.set("GriefPrevention.Claims.ProtectCreatures", this.config_claims_protectCreatures);
|
||||
outConfig.set("GriefPrevention.Claims.PreventButtonsSwitches", this.config_claims_preventButtonsSwitches);
|
||||
|
|
@ -555,6 +584,10 @@ public class GriefPrevention extends JavaPlugin
|
|||
outConfig.set("GriefPrevention.Claims.TrappedCommandCooldownHours", this.config_claims_trappedCooldownHours);
|
||||
outConfig.set("GriefPrevention.Claims.InvestigationTool", this.config_claims_investigationTool.name());
|
||||
outConfig.set("GriefPrevention.Claims.ModificationTool", this.config_claims_modificationTool.name());
|
||||
outConfig.set("GriefPrevention.Claims.Expiration.ChestClaimDays", this.config_claims_chestClaimExpirationDays);
|
||||
outConfig.set("GriefPrevention.Claims.Expiration.UnusedClaimDays", this.config_claims_unusedClaimExpirationDays);
|
||||
outConfig.set("GriefPrevention.Claims.Expiration.AllClaimDays", this.config_claims_expirationDays);
|
||||
outConfig.set("GriefPrevention.Claims.Expiration.AutomaticNatureRestoration.SurvivalWorlds", this.config_claims_survivalAutoNatureRestoration);
|
||||
|
||||
outConfig.set("GriefPrevention.Spam.Enabled", this.config_spam_enabled);
|
||||
outConfig.set("GriefPrevention.Spam.LoginCooldownSeconds", this.config_spam_loginCooldownSeconds);
|
||||
|
|
@ -775,6 +808,26 @@ public class GriefPrevention extends JavaPlugin
|
|||
AddLogEntry("Boot finished.");
|
||||
}
|
||||
|
||||
private ClaimsMode configStringToClaimsMode(String configSetting)
|
||||
{
|
||||
if(configSetting.equalsIgnoreCase("Survival"))
|
||||
{
|
||||
return ClaimsMode.Survival;
|
||||
}
|
||||
else if(configSetting.equalsIgnoreCase("Creative"))
|
||||
{
|
||||
return ClaimsMode.Creative;
|
||||
}
|
||||
else if(configSetting.equalsIgnoreCase("Disabled"))
|
||||
{
|
||||
return ClaimsMode.Disabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//handles slash commands
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
|
||||
|
||||
|
|
@ -2275,12 +2328,6 @@ public class GriefPrevention extends JavaPlugin
|
|||
GriefPrevention.sendMessage(player, TextMode.Success, Messages.PvPImmunityStart);
|
||||
}
|
||||
|
||||
//checks whether players can create claims in a world
|
||||
public boolean claimsEnabledForWorld(World world)
|
||||
{
|
||||
return this.config_claims_enabledWorlds.contains(world);
|
||||
}
|
||||
|
||||
//checks whether players siege in a world
|
||||
public boolean siegeEnabledForWorld(World world)
|
||||
{
|
||||
|
|
@ -2556,10 +2603,16 @@ public class GriefPrevention extends JavaPlugin
|
|||
}
|
||||
}
|
||||
|
||||
//checks whether players can create claims in a world
|
||||
public boolean claimsEnabledForWorld(World world)
|
||||
{
|
||||
return this.config_claims_worldModes.get(world) != ClaimsMode.Disabled;
|
||||
}
|
||||
|
||||
//determines whether creative anti-grief rules apply at a location
|
||||
boolean creativeRulesApply(Location location)
|
||||
{
|
||||
return this.config_claims_enabledCreativeWorlds.contains(location.getWorld());
|
||||
return this.config_claims_worldModes.get((location.getWorld())) == ClaimsMode.Creative;
|
||||
}
|
||||
|
||||
public String allowBuild(Player player, Location location)
|
||||
|
|
|
|||
|
|
@ -755,6 +755,9 @@ class PlayerEventHandler implements Listener
|
|||
{
|
||||
Player player = event.getPlayer();
|
||||
Entity entity = event.getRightClicked();
|
||||
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(entity.getWorld())) return;
|
||||
|
||||
PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
|
||||
|
||||
//don't allow interaction with item frames in claimed areas without build permission
|
||||
|
|
@ -912,6 +915,8 @@ class PlayerEventHandler implements Listener
|
|||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onPlayerBedEnter (PlayerBedEnterEvent bedEvent)
|
||||
{
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(bedEvent.getBed().getWorld())) return;
|
||||
|
||||
if(!GriefPrevention.instance.config_claims_preventButtonsSwitches) return;
|
||||
|
||||
Player player = bedEvent.getPlayer();
|
||||
|
|
@ -937,6 +942,8 @@ class PlayerEventHandler implements Listener
|
|||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onPlayerBucketEmpty (PlayerBucketEmptyEvent bucketEvent)
|
||||
{
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(bucketEvent.getBlockClicked().getWorld())) return;
|
||||
|
||||
Player player = bucketEvent.getPlayer();
|
||||
Block block = bucketEvent.getBlockClicked().getRelative(bucketEvent.getBlockFace());
|
||||
int minLavaDistance = 10;
|
||||
|
|
@ -959,7 +966,7 @@ class PlayerEventHandler implements Listener
|
|||
}
|
||||
|
||||
//otherwise no wilderness dumping (unless underground) in worlds where claims are enabled
|
||||
else if(GriefPrevention.instance.config_claims_enabledWorlds.contains(block.getWorld()))
|
||||
else if(GriefPrevention.instance.claimsEnabledForWorld(block.getWorld()))
|
||||
{
|
||||
if(block.getY() >= GriefPrevention.instance.getSeaLevel(block.getWorld()) - 5 && !player.hasPermission("griefprevention.lava"))
|
||||
{
|
||||
|
|
@ -1000,6 +1007,8 @@ class PlayerEventHandler implements Listener
|
|||
Player player = bucketEvent.getPlayer();
|
||||
Block block = bucketEvent.getBlockClicked();
|
||||
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(block.getWorld())) return;
|
||||
|
||||
//make sure the player is allowed to build at the location
|
||||
String noBuildReason = GriefPrevention.instance.allowBuild(player, block.getLocation());
|
||||
if(noBuildReason != null)
|
||||
|
|
@ -1738,7 +1747,7 @@ class PlayerEventHandler implements Listener
|
|||
if(lastShovelLocation == null)
|
||||
{
|
||||
//if claims are not enabled in this world and it's not an administrative claim, display an error message and stop
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(player.getWorld()) && playerData.shovelMode != ShovelMode.Admin)
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(player.getWorld()))
|
||||
{
|
||||
GriefPrevention.sendMessage(player, TextMode.Err, Messages.ClaimsDisabledWorld);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user