Made limiting tree growth opt-in.
It can be expensive for some servers and trees growing aren't a /major/ griefing issue, so this feature defaults to off.
This commit is contained in:
parent
b4bdec450d
commit
9510bc7415
|
|
@ -741,5 +741,46 @@ public class BlockEventHandler implements Listener
|
||||||
|
|
||||||
//everything else is NOT OK
|
//everything else is NOT OK
|
||||||
dispenseEvent.setCancelled(true);
|
dispenseEvent.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onTreeGrow (StructureGrowEvent growEvent)
|
||||||
|
{
|
||||||
|
//only take these potentially expensive steps if configured to do so
|
||||||
|
if(!GriefPrevention.instance.config_limitTreeGrowth) return;
|
||||||
|
|
||||||
|
Location rootLocation = growEvent.getLocation();
|
||||||
|
Claim rootClaim = this.dataStore.getClaimAt(rootLocation, false, null);
|
||||||
|
String rootOwnerName = null;
|
||||||
|
|
||||||
|
//who owns the spreading block, if anyone?
|
||||||
|
if(rootClaim != null)
|
||||||
|
{
|
||||||
|
//tree growth in subdivisions is dependent on who owns the top level claim
|
||||||
|
if(rootClaim.parent != null) rootClaim = rootClaim.parent;
|
||||||
|
|
||||||
|
//if an administrative claim, just let the tree grow where it wants
|
||||||
|
if(rootClaim.isAdminClaim()) return;
|
||||||
|
|
||||||
|
//otherwise, note the owner of the claim
|
||||||
|
rootOwnerName = rootClaim.getOwnerName();
|
||||||
|
}
|
||||||
|
|
||||||
|
//for each block growing
|
||||||
|
for(int i = 0; i < growEvent.getBlocks().size(); i++)
|
||||||
|
{
|
||||||
|
BlockState block = growEvent.getBlocks().get(i);
|
||||||
|
Claim blockClaim = this.dataStore.getClaimAt(block.getLocation(), false, rootClaim);
|
||||||
|
|
||||||
|
//if it's growing into a claim
|
||||||
|
if(blockClaim != null)
|
||||||
|
{
|
||||||
|
//if there's no owner for the new tree, or the owner for the new tree is different from the owner of the claim
|
||||||
|
if(rootOwnerName == null || !rootOwnerName.equals(blockClaim.getOwnerName()))
|
||||||
|
{
|
||||||
|
growEvent.getBlocks().remove(i--);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,8 @@ public class GriefPrevention extends JavaPlugin
|
||||||
|
|
||||||
public HashMap<String, Integer> config_seaLevelOverride; //override for sea level, because bukkit doesn't report the right value for all situations
|
public HashMap<String, Integer> config_seaLevelOverride; //override for sea level, because bukkit doesn't report the right value for all situations
|
||||||
|
|
||||||
|
public boolean config_limitTreeGrowth; //whether trees should be prevented from growing into a claim from outside
|
||||||
|
|
||||||
//reference to the economy plugin, if economy integration is enabled
|
//reference to the economy plugin, if economy integration is enabled
|
||||||
public static Economy economy = null;
|
public static Economy economy = null;
|
||||||
|
|
||||||
|
|
@ -351,6 +353,7 @@ public class GriefPrevention extends JavaPlugin
|
||||||
this.config_blockSurfaceOtherExplosions = config.getBoolean("GriefPrevention.BlockSurfaceOtherExplosions", true);
|
this.config_blockSurfaceOtherExplosions = config.getBoolean("GriefPrevention.BlockSurfaceOtherExplosions", true);
|
||||||
this.config_blockWildernessWaterBuckets = config.getBoolean("GriefPrevention.LimitSurfaceWaterBuckets", true);
|
this.config_blockWildernessWaterBuckets = config.getBoolean("GriefPrevention.LimitSurfaceWaterBuckets", true);
|
||||||
this.config_blockSkyTrees = config.getBoolean("GriefPrevention.LimitSkyTrees", true);
|
this.config_blockSkyTrees = config.getBoolean("GriefPrevention.LimitSkyTrees", true);
|
||||||
|
this.config_limitTreeGrowth = config.getBoolean("GriefPrevention.LimitTreeGrowth", false);
|
||||||
|
|
||||||
this.config_fireSpreads = config.getBoolean("GriefPrevention.FireSpreads", false);
|
this.config_fireSpreads = config.getBoolean("GriefPrevention.FireSpreads", false);
|
||||||
this.config_fireDestroys = config.getBoolean("GriefPrevention.FireDestroys", false);
|
this.config_fireDestroys = config.getBoolean("GriefPrevention.FireDestroys", false);
|
||||||
|
|
@ -597,6 +600,7 @@ public class GriefPrevention extends JavaPlugin
|
||||||
outConfig.set("GriefPrevention.BlockSurfaceOtherExplosions", this.config_blockSurfaceOtherExplosions);
|
outConfig.set("GriefPrevention.BlockSurfaceOtherExplosions", this.config_blockSurfaceOtherExplosions);
|
||||||
outConfig.set("GriefPrevention.LimitSurfaceWaterBuckets", this.config_blockWildernessWaterBuckets);
|
outConfig.set("GriefPrevention.LimitSurfaceWaterBuckets", this.config_blockWildernessWaterBuckets);
|
||||||
outConfig.set("GriefPrevention.LimitSkyTrees", this.config_blockSkyTrees);
|
outConfig.set("GriefPrevention.LimitSkyTrees", this.config_blockSkyTrees);
|
||||||
|
outConfig.set("GriefPrevention.LimitTreeGrowth", this.config_limitTreeGrowth);
|
||||||
|
|
||||||
outConfig.set("GriefPrevention.FireSpreads", this.config_fireSpreads);
|
outConfig.set("GriefPrevention.FireSpreads", this.config_fireSpreads);
|
||||||
outConfig.set("GriefPrevention.FireDestroys", this.config_fireDestroys);
|
outConfig.set("GriefPrevention.FireDestroys", this.config_fireDestroys);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user