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:
parent
d7ace9a073
commit
f3d301ddc9
|
|
@ -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 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 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_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 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
|
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_survivalAutoNatureRestoration = config.getBoolean("GriefPrevention.Claims.Expiration.AutomaticNatureRestoration.SurvivalWorlds", false);
|
||||||
this.config_claims_maxClaimsPerPlayer = config.getInt("GriefPrevention.Claims.MaximumNumberOfClaimsPerPlayer", 0);
|
this.config_claims_maxClaimsPerPlayer = config.getInt("GriefPrevention.Claims.MaximumNumberOfClaimsPerPlayer", 0);
|
||||||
this.config_claims_respectWorldGuard = config.getBoolean("GriefPrevention.Claims.CreationRequiresWorldGuardBuildPermission", true);
|
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_enabled = config.getBoolean("GriefPrevention.Spam.Enabled", true);
|
||||||
this.config_spam_loginCooldownSeconds = config.getInt("GriefPrevention.Spam.LoginCooldownSeconds", 60);
|
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.");
|
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.Expiration.AutomaticNatureRestoration.SurvivalWorlds", this.config_claims_survivalAutoNatureRestoration);
|
||||||
outConfig.set("GriefPrevention.Claims.MaximumNumberOfClaimsPerPlayer", this.config_claims_maxClaimsPerPlayer);
|
outConfig.set("GriefPrevention.Claims.MaximumNumberOfClaimsPerPlayer", this.config_claims_maxClaimsPerPlayer);
|
||||||
outConfig.set("GriefPrevention.Claims.CreationRequiresWorldGuardBuildPermission", this.config_claims_respectWorldGuard);
|
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.Enabled", this.config_spam_enabled);
|
||||||
outConfig.set("GriefPrevention.Spam.LoginCooldownSeconds", this.config_spam_loginCooldownSeconds);
|
outConfig.set("GriefPrevention.Spam.LoginCooldownSeconds", this.config_spam_loginCooldownSeconds);
|
||||||
|
|
|
||||||
|
|
@ -812,34 +812,37 @@ class PlayerEventHandler implements Listener
|
||||||
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, task, 100L);
|
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
|
//FEATURE: if the player teleporting doesn't have permission to build a nether portal and none already exists at the destination, cancel the teleportation
|
||||||
Location destination = event.getTo();
|
if(GriefPrevention.instance.config_claims_portalsRequirePermission)
|
||||||
if(event.useTravelAgent())
|
|
||||||
{
|
{
|
||||||
if(event.getPortalTravelAgent().getCanCreatePortal())
|
Location destination = event.getTo();
|
||||||
|
if(event.useTravelAgent())
|
||||||
{
|
{
|
||||||
//hypothetically find where the portal would be created if it were
|
if(event.getPortalTravelAgent().getCanCreatePortal())
|
||||||
TravelAgent agent = event.getPortalTravelAgent();
|
{
|
||||||
agent.setCanCreatePortal(false);
|
//hypothetically find where the portal would be created if it were
|
||||||
destination = agent.findOrCreate(destination);
|
TravelAgent agent = event.getPortalTravelAgent();
|
||||||
agent.setCanCreatePortal(true);
|
agent.setCanCreatePortal(false);
|
||||||
|
destination = agent.findOrCreate(destination);
|
||||||
|
agent.setCanCreatePortal(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//if not able to create a portal, we don't have to do anything here
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//if not able to create a portal, we don't have to do anything here
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//if creating a new portal
|
//if creating a new portal
|
||||||
if(destination.getBlock().getType() != Material.PORTAL)
|
if(destination.getBlock().getType() != Material.PORTAL)
|
||||||
{
|
|
||||||
//check for a land claim and the player's permission that land claim
|
|
||||||
Claim claim = this.dataStore.getClaimAt(destination, false, null);
|
|
||||||
if(claim != null && claim.allowBuild(player, Material.PORTAL) != null)
|
|
||||||
{
|
{
|
||||||
//cancel and inform about the reason
|
//check for a land claim and the player's permission that land claim
|
||||||
event.setCancelled(true);
|
Claim claim = this.dataStore.getClaimAt(destination, false, null);
|
||||||
GriefPrevention.sendMessage(player, TextMode.Err, Messages.NoBuildPortalPermission, claim.getOwnerName());
|
if(claim != null && claim.allowBuild(player, Material.PORTAL) != null)
|
||||||
|
{
|
||||||
|
//cancel and inform about the reason
|
||||||
|
event.setCancelled(true);
|
||||||
|
GriefPrevention.sendMessage(player, TextMode.Err, Messages.NoBuildPortalPermission, claim.getOwnerName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user