Perf: Nether portal restrictions are now optional.

Defaults to off.  The cost of determining if and where a nether portal
will be generated when a player steps through a portal is very high, and
this "grief" is both very difficult to execute and opportunistic.  Also,
it's arguably a gift rather than an attack.
This commit is contained in:
ryanhamshire 2015-01-29 19:50:34 -08:00
parent d7ace9a073
commit f3d301ddc9
2 changed files with 30 additions and 23 deletions

View File

@ -82,6 +82,7 @@ public class GriefPrevention extends JavaPlugin
public boolean config_claims_enderPearlsRequireAccessTrust; //whether teleporting into a claim with a pearl requires access trust
public int config_claims_maxClaimsPerPlayer; //maximum number of claims per player
public boolean config_claims_respectWorldGuard; //whether claim creations requires WG build permission in creation area
public boolean config_claims_portalsRequirePermission; //whether nether portals require permission to generate. defaults to off for performance reasons
public int config_claims_initialBlocks; //the number of claim blocks a new player starts with
public double config_claims_abandonReturnRatio; //the portion of claim blocks returned to a player when a claim is abandoned
@ -494,6 +495,8 @@ public class GriefPrevention extends JavaPlugin
this.config_claims_survivalAutoNatureRestoration = config.getBoolean("GriefPrevention.Claims.Expiration.AutomaticNatureRestoration.SurvivalWorlds", false);
this.config_claims_maxClaimsPerPlayer = config.getInt("GriefPrevention.Claims.MaximumNumberOfClaimsPerPlayer", 0);
this.config_claims_respectWorldGuard = config.getBoolean("GriefPrevention.Claims.CreationRequiresWorldGuardBuildPermission", true);
this.config_claims_portalsRequirePermission = config.getBoolean("GriefPrevention.Claims.PortalGenerationRequiresPermission", false);
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.");
@ -704,6 +707,7 @@ public class GriefPrevention extends JavaPlugin
outConfig.set("GriefPrevention.Claims.Expiration.AutomaticNatureRestoration.SurvivalWorlds", this.config_claims_survivalAutoNatureRestoration);
outConfig.set("GriefPrevention.Claims.MaximumNumberOfClaimsPerPlayer", this.config_claims_maxClaimsPerPlayer);
outConfig.set("GriefPrevention.Claims.CreationRequiresWorldGuardBuildPermission", this.config_claims_respectWorldGuard);
outConfig.set("GriefPrevention.Claims.PortalGenerationRequiresPermission", this.config_claims_portalsRequirePermission);
outConfig.set("GriefPrevention.Spam.Enabled", this.config_spam_enabled);
outConfig.set("GriefPrevention.Spam.LoginCooldownSeconds", this.config_spam_loginCooldownSeconds);

View File

@ -812,6 +812,8 @@ class PlayerEventHandler implements Listener
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, task, 100L);
//FEATURE: if the player teleporting doesn't have permission to build a nether portal and none already exists at the destination, cancel the teleportation
if(GriefPrevention.instance.config_claims_portalsRequirePermission)
{
Location destination = event.getTo();
if(event.useTravelAgent())
{
@ -844,6 +846,7 @@ class PlayerEventHandler implements Listener
}
}
}
}
//when a player teleports
@EventHandler(priority = EventPriority.LOWEST)