From bbc83a6c77f959d9bb329bf7c73beb5f2f62631f Mon Sep 17 00:00:00 2001 From: Zrips Date: Wed, 15 Nov 2023 12:43:45 +0200 Subject: [PATCH] Fix for fishing action not taking into consideration blacklisted world --- pom.xml | 2 +- src/main/java/com/gamingmesh/jobs/Jobs.java | 5 ++-- .../com/gamingmesh/jobs/container/Job.java | 28 ++++++++++++++----- .../jobs/listeners/JobsPaymentListener.java | 5 ++-- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 0dae35d4..9fbe1035 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 Jobs jobs - 5.2.1.1 + 5.2.1.2 Jobs http://maven.apache.org diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index e6f55167..d92e59df 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -1008,7 +1008,7 @@ public final class Jobs extends JavaPlugin { // no job if (numjobs == 0) { - if (noneJob == null || noneJob.isWorldBlackListed(block) || noneJob.isWorldBlackListed(block, ent) || noneJob.isWorldBlackListed(victim)) + if (noneJob == null || noneJob.isWorldBlackListed(block, ent, victim)) return; JobInfo jobinfo = noneJob.getJobInfo(info, 1); @@ -1106,8 +1106,7 @@ public final class Jobs extends JavaPlugin { } else { List expiredJobs = new ArrayList<>(); for (JobProgression prog : progression) { - if (prog.getJob().isWorldBlackListed(block) || prog.getJob().isWorldBlackListed(block, ent) - || prog.getJob().isWorldBlackListed(victim)) + if (prog.getJob().isWorldBlackListed(block, ent, victim)) continue; if (jPlayer.isLeftTimeEnded(prog.getJob())) { diff --git a/src/main/java/com/gamingmesh/jobs/container/Job.java b/src/main/java/com/gamingmesh/jobs/container/Job.java index 08ac41fc..5e43322a 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Job.java +++ b/src/main/java/com/gamingmesh/jobs/container/Job.java @@ -31,9 +31,12 @@ import java.util.function.BiPredicate; import com.gamingmesh.jobs.actions.EnchantActionInfo; import com.gamingmesh.jobs.stuff.Util; + +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -652,21 +655,32 @@ public class Job { } public boolean isWorldBlackListed(Entity ent) { - return isWorldBlackListed(null, ent); + return isWorldBlackListed(null, ent, null); } public boolean isWorldBlackListed(Block block) { - return isWorldBlackListed(block, null); + return isWorldBlackListed(block, null, null); } + @Deprecated public boolean isWorldBlackListed(Block block, Entity ent) { + return isWorldBlackListed(block, ent, null); + } + + public boolean isWorldBlackListed(Block block, Entity ent, LivingEntity lent) { + if (block != null) + return isWorldBlackListed(block.getWorld()); + if (ent != null) + return isWorldBlackListed(ent.getWorld()); + if (lent != null) + return isWorldBlackListed(lent.getWorld()); + return false; + } + + public boolean isWorldBlackListed(World world) { if (worldBlacklist.isEmpty()) return reversedWorldBlacklist; - - if (block != null) - return worldBlacklist.contains(block.getWorld().getName()) != reversedWorldBlacklist; - - return ent != null && worldBlacklist.contains(ent.getWorld().getName()) != reversedWorldBlacklist; + return world != null && worldBlacklist.contains(world.getName()) != reversedWorldBlacklist; } public boolean isReversedWorldBlacklist() { diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 49fa25b3..de6d02cf 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -528,7 +528,7 @@ public final class JobsPaymentListener implements Listener { if (!payIfCreative(player)) return; - if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) + if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getWorld().getName())) return; // check if player is riding @@ -550,8 +550,7 @@ public final class JobsPaymentListener implements Listener { } } - Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), - new ItemActionInfo(((Item) event.getCaught()).getItemStack(), ActionType.FISH)); + Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new ItemActionInfo(((Item) event.getCaught()).getItemStack(), ActionType.FISH), event.getCaught()); } }