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

Merge pull request #1583 from FireML/bucket-entity-action

Bucketing Entities Action
This commit is contained in:
Zrips 2023-08-30 11:48:00 +03:00 committed by GitHub
commit 5667544626
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 2 deletions

View File

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

View File

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

View File

@ -41,7 +41,8 @@ public enum ActionType {
EAT("Eat"),
CUSTOMKILL("custom-kill"),
COLLECT("Collect"),
BAKE("Bake");
BAKE("Bake"),
BUCKET("Bucket");
private String name;

View File

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

View File

@ -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;