1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

McMMO fishing treasure support

This commit is contained in:
Zrips 2020-07-07 16:09:04 +03:00
parent 41e3b30d67
commit adce7558d2
3 changed files with 78 additions and 2 deletions

View File

@ -14,8 +14,10 @@ import com.gamingmesh.jobs.actions.ItemActionInfo;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
public class McMMO1_X_listener implements Listener {
@ -26,6 +28,42 @@ public class McMMO1_X_listener implements Listener {
this.plugin = plugin;
}
@EventHandler
public void onFishingTreasure(McMMOPlayerFishingTreasureEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Player player = event.getPlayer();
//disabling plugin in world
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())
return;
if (!JobsPaymentListener.payForItemDurabilityLoss(player))
return;
if (event.getTreasure() == null)
return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return;
Jobs.action(jPlayer, new ItemActionInfo(event.getTreasure(), ActionType.FISH));
}
@EventHandler
public void OnItemrepair(McMMOPlayerRepairCheckEvent event) {
// make sure plugin is enabled

View File

@ -14,8 +14,10 @@ import com.gamingmesh.jobs.actions.ItemActionInfo;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
public class McMMO2_X_listener implements Listener {
@ -26,6 +28,42 @@ public class McMMO2_X_listener implements Listener {
this.plugin = plugin;
}
@EventHandler
public void onFishingTreasure(McMMOPlayerFishingTreasureEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Player player = event.getPlayer();
//disabling plugin in world
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())
return;
if (!JobsPaymentListener.payForItemDurabilityLoss(player))
return;
if (event.getTreasure() == null)
return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return;
Jobs.action(jPlayer, new ItemActionInfo(event.getTreasure(), ActionType.FISH));
}
@EventHandler
public void OnItemrepair(McMMOPlayerRepairCheckEvent event) {
// make sure plugin is enabled

View File

@ -1833,7 +1833,7 @@ public class JobsPaymentListener implements Listener {
Jobs.action(jPlayer, new ExploreActionInfo(String.valueOf(respond.getCount()), ActionType.EXPLORE));
}
static boolean payIfCreative(Player player) {
public static boolean payIfCreative(Player player) {
if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative() && !player.hasPermission("jobs.paycreative"))
return false;
@ -1841,7 +1841,7 @@ public class JobsPaymentListener implements Listener {
}
// Prevent item durability loss
private static boolean payForItemDurabilityLoss(Player p) {
public static boolean payForItemDurabilityLoss(Player p) {
if (Jobs.getGCManager().payItemDurabilityLoss)
return true;