1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-29 04:18:07 +01:00

Fix for fishing action not taking into consideration blacklisted world

This commit is contained in:
Zrips 2023-11-15 12:43:45 +02:00
parent 957669cb7a
commit bbc83a6c77
4 changed files with 26 additions and 14 deletions

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>Jobs</groupId>
<artifactId>jobs</artifactId>
<version>5.2.1.1</version>
<version>5.2.1.2</version>
<name>Jobs</name>
<url>http://maven.apache.org</url>

View File

@ -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<Job> 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())) {

View File

@ -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() {

View File

@ -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());
}
}