diff --git a/src/main/java/com/gamingmesh/jobs/PermissionHandler.java b/src/main/java/com/gamingmesh/jobs/PermissionHandler.java index 9c0ae5b2..77089494 100644 --- a/src/main/java/com/gamingmesh/jobs/PermissionHandler.java +++ b/src/main/java/com/gamingmesh/jobs/PermissionHandler.java @@ -19,8 +19,10 @@ package com.gamingmesh.jobs; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map.Entry; +import java.util.Set; import org.bukkit.World; import org.bukkit.entity.Player; @@ -228,13 +230,17 @@ public class PermissionHandler { // recalculate! player.recalculatePermissions(); } + + public static Set worldsRegistered = new HashSet(); public void registerPermissions() { PluginManager pm = plugin.getServer().getPluginManager(); for (World world : plugin.getServer().getWorlds()) { String worldName = world.getName().toLowerCase(); - if (pm.getPermission("jobs.world." + worldName) == null) + if (pm.getPermission("jobs.world." + worldName) == null) { pm.addPermission(new Permission("jobs.world." + worldName, PermissionDefault.TRUE)); + worldsRegistered.add(worldName); + } } for (Job job : Jobs.getJobs()) { diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java index 19424a64..2f3ecc68 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java @@ -67,6 +67,7 @@ import org.bukkit.permissions.PermissionDefault; import org.bukkit.plugin.PluginManager; import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.PermissionHandler; import com.gamingmesh.jobs.Signs.SignTopType; import com.gamingmesh.jobs.Signs.SignUtil; import com.gamingmesh.jobs.Signs.jobsSign; @@ -359,8 +360,10 @@ public class JobsListener implements Listener { public void onWorldLoad(WorldLoadEvent event) { PluginManager pm = plugin.getServer().getPluginManager(); String name = event.getWorld().getName().toLowerCase(); - if (pm.getPermission("jobs.world." + name) == null) + if (pm.getPermission("jobs.world." + name) == null && !PermissionHandler.worldsRegistered.contains(name)) { pm.addPermission(new Permission("jobs.world." + name, PermissionDefault.TRUE)); + PermissionHandler.worldsRegistered.add(name); + } } @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)