diff --git a/com/gamingmesh/jobs/.gitignore b/com/gamingmesh/jobs/.gitignore index f7cbafcd..9e3d74d3 100644 --- a/com/gamingmesh/jobs/.gitignore +++ b/com/gamingmesh/jobs/.gitignore @@ -10,3 +10,4 @@ /PlayerManager$BoostOf.class /PermissionManager.class /PermissionManager$prm.class +/PlayerManager$2.class diff --git a/com/gamingmesh/jobs/PermissionHandler.java b/com/gamingmesh/jobs/PermissionHandler.java index dfcdf61f..436e681e 100644 --- a/com/gamingmesh/jobs/PermissionHandler.java +++ b/com/gamingmesh/jobs/PermissionHandler.java @@ -35,6 +35,7 @@ import com.gamingmesh.jobs.container.JobConditions; import com.gamingmesh.jobs.container.JobPermission; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.Debug; public class PermissionHandler { private Jobs plugin; @@ -45,6 +46,7 @@ public class PermissionHandler { public void recalculatePermissions(JobsPlayer jPlayer) { +// long time = System.nanoTime(); if (jPlayer == null) return; @@ -61,9 +63,9 @@ public class PermissionHandler { this.plugin.getServer().getPluginManager().removePermission(permission); changed = true; } - + // Permissions should only apply if we have permission to use jobs in this world - if (hasWorldPermission(player, player.getWorld().getName())) { + if (hasWorldPermission2(player, player.getWorld().getName())) { List progression = jPlayer.getJobProgression(); // calculate new permissions HashMap permissions = new HashMap(); @@ -249,7 +251,27 @@ public class PermissionHandler { } return player.hasPermission("jobs.world." + world.toLowerCase()); } - + + public boolean hasWorldPermission2(Player player, String world) { + boolean foundMain = false; + boolean foundWorld = false; + for (PermissionAttachmentInfo one : player.getEffectivePermissions()) { + if (one.getPermission().equalsIgnoreCase("jobs.use")) { + foundMain = true; + if (foundWorld) + break; + } + if (one.getPermission().equalsIgnoreCase("jobs.world." + world.toLowerCase())) { + foundWorld = true; + if (foundMain) + break; + } + } + if (!foundMain || !foundWorld) + return false; + return true; + } + public boolean hasWorldPermission(JobsPlayer player, String world) { if (!Jobs.getPermissionManager().hasPermission(player, "jobs.use")) { return false; diff --git a/com/gamingmesh/jobs/commands/list/bonus.java b/com/gamingmesh/jobs/commands/list/bonus.java index 9a71d3b0..73ff9699 100644 --- a/com/gamingmesh/jobs/commands/list/bonus.java +++ b/com/gamingmesh/jobs/commands/list/bonus.java @@ -12,6 +12,7 @@ import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.stuff.ChatColor; +import com.gamingmesh.jobs.stuff.Debug; public class bonus implements Cmd { @@ -46,60 +47,37 @@ public class bonus implements Cmd { sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline")); - sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.permission", - "%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.Permission, CurrencyType.MONEY, true)), - "%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.Permission, CurrencyType.POINTS, true)), - "%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.Permission, CurrencyType.EXP, true)))); - - sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.item", - "%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.Item, CurrencyType.MONEY, true)), - "%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.Item, CurrencyType.POINTS, true)), - "%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.Item, CurrencyType.EXP, true)))); - - if (!job.getJobInfo(ActionType.KILL).isEmpty() || !job.getJobInfo(ActionType.MMKILL).isEmpty()) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.nearspawner", - "%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.NearSpawner, CurrencyType.MONEY, true)), - "%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.NearSpawner, CurrencyType.POINTS, true)), - "%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.NearSpawner, CurrencyType.EXP, true)))); - } - - if (!job.getJobInfo(ActionType.KILL).isEmpty() || !job.getJobInfo(ActionType.MMKILL).isEmpty()) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.petpay", - "%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.PetPay, CurrencyType.MONEY, true)), - "%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.PetPay, CurrencyType.POINTS, true)), - "%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.PetPay, CurrencyType.EXP, true)))); - } - - sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.global", - "%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.Global, CurrencyType.MONEY, true)), - "%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.Global, CurrencyType.POINTS, true)), - "%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.Global, CurrencyType.EXP, true)))); - - sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.dynamic", - "%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.Dynamic, CurrencyType.MONEY, true)), - "%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.Dynamic, CurrencyType.POINTS, true)), - "%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.Dynamic, CurrencyType.EXP, true)))); - - sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.area", - "%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.Area, CurrencyType.MONEY, true)), - "%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.Area, CurrencyType.POINTS, true)), - "%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.Area, CurrencyType.EXP, true)))); + printBoost(sender, boost, BoostOf.Permission); + printBoost(sender, boost, BoostOf.Item); + printBoost(sender, boost, BoostOf.NearSpawner); + printBoost(sender, boost, BoostOf.PetPay); + printBoost(sender, boost, BoostOf.Global); + printBoost(sender, boost, BoostOf.Dynamic); + printBoost(sender, boost, BoostOf.Area); if (Jobs.getMcMMOlistener().mcMMOPresent && boost.get(BoostOf.McMMO, CurrencyType.EXP) != 0D) - sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.mcmmo", - "%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.get(BoostOf.McMMO, CurrencyType.MONEY, true)), - "%points%", ChatColor.GOLD.toString() + formatText(boost.get(BoostOf.McMMO, CurrencyType.POINTS, true)), - "%exp%", ChatColor.YELLOW.toString() + formatText(boost.get(BoostOf.McMMO, CurrencyType.EXP, true)))); + printBoost(sender, boost, BoostOf.McMMO); sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.final", - "%money%", ChatColor.DARK_GREEN.toString() + formatText(boost.getFinal(CurrencyType.MONEY, true)), - "%points%", ChatColor.GOLD.toString() + formatText(boost.getFinal(CurrencyType.POINTS, true)), - "%exp%", ChatColor.YELLOW.toString() + formatText(boost.getFinal(CurrencyType.EXP, true)))); + "%money%", mc + formatText(boost.getFinal(CurrencyType.MONEY, true)), + "%points%", pc + formatText(boost.getFinal(CurrencyType.POINTS, true)), + "%exp%", ec + formatText(boost.getFinal(CurrencyType.EXP, true)))); return true; } + String mc = ChatColor.DARK_GREEN.toString(); + String pc = ChatColor.GOLD.toString(); + String ec = ChatColor.YELLOW.toString(); + + private void printBoost(CommandSender sender, Boost boost, BoostOf type) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output." + type.name().toLowerCase(), + "%money%", mc + formatText(boost.get(type, CurrencyType.MONEY, true)), + "%points%", pc + formatText(boost.get(type, CurrencyType.POINTS, true)), + "%exp%", ec + formatText(boost.get(type, CurrencyType.EXP, true)))); + } + private static String formatText(double amount) { return ((amount > 0 ? "+" : "") + amount + "%"); } diff --git a/com/gamingmesh/jobs/listeners/JobsListener.java b/com/gamingmesh/jobs/listeners/JobsListener.java index 84b183f1..8226a11b 100644 --- a/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/com/gamingmesh/jobs/listeners/JobsListener.java @@ -162,7 +162,7 @@ public class JobsListener implements Listener { Jobs.getGUIManager().GuiList.remove(player.getName()); } - @EventHandler(priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerJoin(final PlayerJoinEvent event) { // make sure plugin is enabled diff --git a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 253a9b28..23d51354 100644 --- a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -150,7 +150,7 @@ public class JobsPaymentListener implements Listener { // check if in creative if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; - + if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; @@ -267,8 +267,16 @@ public class JobsPaymentListener implements Listener { if (player.getGameMode() == GameMode.CREATIVE && !Jobs.getGCManager().payInCreative()) return; + long time = System.nanoTime(); if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; + Debug.D("time in " + (System.nanoTime() - time)); + + + time = System.nanoTime(); + if (!Jobs.getPermissionHandler().hasWorldPermission2(player, player.getLocation().getWorld().getName())) + return; + Debug.D("time in " + (System.nanoTime() - time)); BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.BREAK); FastPayment fp = Jobs.FastPayment.get(player.getName()); diff --git a/plugin.yml b/plugin.yml index 84393d11..01ee6c06 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: Jobs description: Jobs Plugin for the BukkitAPI main: com.gamingmesh.jobs.Jobs -version: 3.7.6 +version: 3.7.7 author: phrstbrn softdepend: [Vault, iConomy, MythicMobs, McMMO] commands: