diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index c0d34f1..dedaae0 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -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); diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index 7fe5c75..46f6b97 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -812,34 +812,37 @@ 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 - Location destination = event.getTo(); - if(event.useTravelAgent()) + if(GriefPrevention.instance.config_claims_portalsRequirePermission) { - if(event.getPortalTravelAgent().getCanCreatePortal()) + Location destination = event.getTo(); + if(event.useTravelAgent()) { - //hypothetically find where the portal would be created if it were - TravelAgent agent = event.getPortalTravelAgent(); - agent.setCanCreatePortal(false); - destination = agent.findOrCreate(destination); - agent.setCanCreatePortal(true); + if(event.getPortalTravelAgent().getCanCreatePortal()) + { + //hypothetically find where the portal would be created if it were + TravelAgent agent = event.getPortalTravelAgent(); + 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(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) + //if creating a new portal + if(destination.getBlock().getType() != Material.PORTAL) { - //cancel and inform about the reason - event.setCancelled(true); - GriefPrevention.sendMessage(player, TextMode.Err, Messages.NoBuildPortalPermission, claim.getOwnerName()); + //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 + event.setCancelled(true); + GriefPrevention.sendMessage(player, TextMode.Err, Messages.NoBuildPortalPermission, claim.getOwnerName()); + } } } }