1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

Version Dependent

All tested and working on Spigot 1.16.5 and 1.20.1.
This commit is contained in:
FireML 2023-08-30 03:47:42 +01:00
parent 2fab19974c
commit d7cd601723
3 changed files with 42 additions and 20 deletions

View File

@ -97,6 +97,7 @@ import com.gamingmesh.jobs.listeners.JobsListener;
import com.gamingmesh.jobs.listeners.JobsPayment14Listener; import com.gamingmesh.jobs.listeners.JobsPayment14Listener;
import com.gamingmesh.jobs.listeners.JobsPaymentListener; import com.gamingmesh.jobs.listeners.JobsPaymentListener;
import com.gamingmesh.jobs.listeners.PistonProtectionListener; import com.gamingmesh.jobs.listeners.PistonProtectionListener;
import com.gamingmesh.jobs.listeners.JobsPayment16Listener;
import com.gamingmesh.jobs.selection.SelectionManager; import com.gamingmesh.jobs.selection.SelectionManager;
import com.gamingmesh.jobs.stuff.Loging; import com.gamingmesh.jobs.stuff.Loging;
import com.gamingmesh.jobs.stuff.TabComplete; import com.gamingmesh.jobs.stuff.TabComplete;
@ -794,6 +795,9 @@ public final class Jobs extends JavaPlugin {
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) { if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
pm.registerEvents(new JobsPayment14Listener(), getInstance()); pm.registerEvents(new JobsPayment14Listener(), getInstance());
} }
if (Version.isCurrentEqualOrHigher(Version.v1_16_R3)) {
pm.registerEvents(new JobsPayment16Listener(), getInstance());
}
if (getGCManager().useBlockProtection) { if (getGCManager().useBlockProtection) {
pm.registerEvents(new PistonProtectionListener(), getInstance()); pm.registerEvents(new PistonProtectionListener(), getInstance());

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

@ -1985,24 +1985,4 @@ public final class JobsPaymentListener implements Listener {
fp.setTime(System.currentTimeMillis() + 45); 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));
}
} }