diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 12dbf69a..f264fa9a 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.listeners.PlayerSignEdit1_20Listeners; import com.gamingmesh.jobs.selection.SelectionManager; import com.gamingmesh.jobs.stuff.Loging; @@ -795,6 +796,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 (Version.isCurrentEqualOrHigher(Version.v1_20_R1)) { pm.registerEvents(new PlayerSignEdit1_20Listeners(), getInstance()); diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index 6a097d5d..22cbc821 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -617,6 +617,7 @@ public class ConfigManager { case BREW: case BREAK: case STRIPLOGS: + case BUCKET: case COLLECT: material = CMIMaterial.get(myKey + (subType)); @@ -723,7 +724,7 @@ public class ConfigManager { } id = material.getId(); - } else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK) { + } else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK || actionType == ActionType.BUCKET) { // check entities CMIEntityType entity = CMIEntityType.getByName(myKey); diff --git a/src/main/java/com/gamingmesh/jobs/container/ActionType.java b/src/main/java/com/gamingmesh/jobs/container/ActionType.java index 0b9a1a9d..08019512 100644 --- a/src/main/java/com/gamingmesh/jobs/container/ActionType.java +++ b/src/main/java/com/gamingmesh/jobs/container/ActionType.java @@ -41,7 +41,8 @@ public enum ActionType { EAT("Eat"), CUSTOMKILL("custom-kill"), COLLECT("Collect"), - BAKE("Bake"); + BAKE("Bake"), + BUCKET("Bucket"); private String name; 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 30f247c3..aeca72d0 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -77,6 +77,7 @@ import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerShearEntityEvent; +import org.bukkit.event.player.PlayerBucketEntityEvent; import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.EnchantingInventory;