Perf: Check for creative world mode.
This commit is contained in:
parent
cfe61ef945
commit
faccc26572
|
|
@ -84,6 +84,7 @@ public class GriefPrevention extends JavaPlugin
|
||||||
|
|
||||||
//claim mode for each world
|
//claim mode for each world
|
||||||
public ConcurrentHashMap<World, ClaimsMode> config_claims_worldModes;
|
public ConcurrentHashMap<World, ClaimsMode> config_claims_worldModes;
|
||||||
|
private boolean config_creativeWorldsExist; //note on whether there are any creative mode worlds, to save cpu cycles on a common hash lookup
|
||||||
|
|
||||||
public boolean config_claims_preventTheft; //whether containers and crafting blocks are protectable
|
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
|
public boolean config_claims_protectCreatures; //whether claimed animals may be injured by players without permission
|
||||||
|
|
@ -427,6 +428,7 @@ public class GriefPrevention extends JavaPlugin
|
||||||
|
|
||||||
//decide claim mode for each world
|
//decide claim mode for each world
|
||||||
this.config_claims_worldModes = new ConcurrentHashMap<World, ClaimsMode>();
|
this.config_claims_worldModes = new ConcurrentHashMap<World, ClaimsMode>();
|
||||||
|
this.config_creativeWorldsExist = false;
|
||||||
for(World world : worlds)
|
for(World world : worlds)
|
||||||
{
|
{
|
||||||
//is it specified in the config file?
|
//is it specified in the config file?
|
||||||
|
|
@ -437,12 +439,14 @@ public class GriefPrevention extends JavaPlugin
|
||||||
if(claimsMode != null)
|
if(claimsMode != null)
|
||||||
{
|
{
|
||||||
this.config_claims_worldModes.put(world, claimsMode);
|
this.config_claims_worldModes.put(world, claimsMode);
|
||||||
|
if(claimsMode == ClaimsMode.Creative) this.config_creativeWorldsExist = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GriefPrevention.AddLogEntry("Error: Invalid claim mode \"" + configSetting + "\". Options are Survival, Creative, and Disabled.");
|
GriefPrevention.AddLogEntry("Error: Invalid claim mode \"" + configSetting + "\". Options are Survival, Creative, and Disabled.");
|
||||||
this.config_claims_worldModes.put(world, ClaimsMode.Creative);
|
this.config_claims_worldModes.put(world, ClaimsMode.Creative);
|
||||||
|
this.config_creativeWorldsExist = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -450,6 +454,7 @@ public class GriefPrevention extends JavaPlugin
|
||||||
if(deprecated_creativeClaimsEnabledWorldNames.contains(world.getName()))
|
if(deprecated_creativeClaimsEnabledWorldNames.contains(world.getName()))
|
||||||
{
|
{
|
||||||
this.config_claims_worldModes.put(world, ClaimsMode.Creative);
|
this.config_claims_worldModes.put(world, ClaimsMode.Creative);
|
||||||
|
this.config_creativeWorldsExist = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(deprecated_claimsEnabledWorldNames.contains(world.getName()))
|
else if(deprecated_claimsEnabledWorldNames.contains(world.getName()))
|
||||||
|
|
@ -466,12 +471,14 @@ public class GriefPrevention extends JavaPlugin
|
||||||
else if(world.getName().toLowerCase().contains("creative"))
|
else if(world.getName().toLowerCase().contains("creative"))
|
||||||
{
|
{
|
||||||
this.config_claims_worldModes.put(world, ClaimsMode.Creative);
|
this.config_claims_worldModes.put(world, ClaimsMode.Creative);
|
||||||
|
this.config_creativeWorldsExist = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//decide a default based on server type and world type
|
//decide a default based on server type and world type
|
||||||
else if(this.getServer().getDefaultGameMode() == GameMode.CREATIVE)
|
else if(this.getServer().getDefaultGameMode() == GameMode.CREATIVE)
|
||||||
{
|
{
|
||||||
this.config_claims_worldModes.put(world, ClaimsMode.Creative);
|
this.config_claims_worldModes.put(world, ClaimsMode.Creative);
|
||||||
|
this.config_creativeWorldsExist = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(world.getEnvironment() == Environment.NORMAL)
|
else if(world.getEnvironment() == Environment.NORMAL)
|
||||||
|
|
@ -3194,7 +3201,9 @@ public class GriefPrevention extends JavaPlugin
|
||||||
//determines whether creative anti-grief rules apply at a location
|
//determines whether creative anti-grief rules apply at a location
|
||||||
boolean creativeRulesApply(Location location)
|
boolean creativeRulesApply(Location location)
|
||||||
{
|
{
|
||||||
return this.config_claims_worldModes.get((location.getWorld())) == ClaimsMode.Creative;
|
if(!this.config_creativeWorldsExist) return false;
|
||||||
|
|
||||||
|
return this.config_claims_worldModes.get((location.getWorld())) == ClaimsMode.Creative;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String allowBuild(Player player, Location location)
|
public String allowBuild(Player player, Location location)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user