From d7cd60172312db97dd46b5bf8c82585e77628834 Mon Sep 17 00:00:00 2001 From: FireML <106587317+FireML@users.noreply.github.com> Date: Wed, 30 Aug 2023 03:47:42 +0100 Subject: [PATCH] Version Dependent All tested and working on Spigot 1.16.5 and 1.20.1. --- src/main/java/com/gamingmesh/jobs/Jobs.java | 4 ++ .../jobs/listeners/JobsPayment16Listener.java | 38 +++++++++++++++++++ .../jobs/listeners/JobsPaymentListener.java | 20 ---------- 3 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/gamingmesh/jobs/listeners/JobsPayment16Listener.java diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index e9971e3f..55a8c183 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -97,6 +97,7 @@ import com.gamingmesh.jobs.listeners.JobsListener; import com.gamingmesh.jobs.listeners.JobsPayment14Listener; import com.gamingmesh.jobs.listeners.JobsPaymentListener; import com.gamingmesh.jobs.listeners.PistonProtectionListener; +import com.gamingmesh.jobs.listeners.JobsPayment16Listener; import com.gamingmesh.jobs.selection.SelectionManager; import com.gamingmesh.jobs.stuff.Loging; import com.gamingmesh.jobs.stuff.TabComplete; @@ -794,6 +795,9 @@ public final class Jobs extends JavaPlugin { if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) { pm.registerEvents(new JobsPayment14Listener(), getInstance()); } + if (Version.isCurrentEqualOrHigher(Version.v1_16_R3)) { + pm.registerEvents(new JobsPayment16Listener(), getInstance()); + } if (getGCManager().useBlockProtection) { pm.registerEvents(new PistonProtectionListener(), getInstance()); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment16Listener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment16Listener.java new file mode 100644 index 00000000..b49e7319 --- /dev/null +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment16Listener.java @@ -0,0 +1,38 @@ +package com.gamingmesh.jobs.listeners; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.actions.EntityActionInfo; +import com.gamingmesh.jobs.container.ActionType; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerBucketEntityEvent; + +public class JobsPayment16Listener implements Listener { + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onEntityBucketed(PlayerBucketEntityEvent event) { + Player player = event.getPlayer(); + + if (!Jobs.getGCManager().canPerformActionInWorld(player.getWorld())) { + return; + } + + // check if in creative + if (!JobsPaymentListener.payIfCreative(player)) { + return; + } + + if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) { + return; + } + + // check if player is riding + if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle() && !player.getVehicle().getType().equals(EntityType.BOAT)) { + return; + } + + Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new EntityActionInfo(event.getEntity(), ActionType.BUCKET)); + } +} diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index f34ca05e..b55614fc 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -1985,24 +1985,4 @@ public final class JobsPaymentListener implements Listener { fp.setTime(System.currentTimeMillis() + 45); } } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onEntityBucketed(PlayerBucketEntityEvent event) { - Player player = event.getPlayer(); - - if (!Jobs.getGCManager().canPerformActionInWorld(player.getWorld())) - return; - - // check if in creative - if (!payIfCreative(player)) - return; - - if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) - return; - - // check if player is riding - if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle() && !player.getVehicle().getType().equals(EntityType.BOAT)) - return; - - Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new EntityActionInfo(event.getEntity(), ActionType.BUCKET)); - } }