From 9e006ebe8911aa53987f6a959c0ed6de0213c9bd Mon Sep 17 00:00:00 2001 From: montlikadani Date: Thu, 26 Mar 2020 09:12:39 +0100 Subject: [PATCH] Improved baking action doesn't pay enough when items are on another block - Removed some deprecated methods --- src/main/java/com/gamingmesh/jobs/Jobs.java | 59 +------------------ .../jobs/listeners/JobsPayment14Listener.java | 16 ++--- 2 files changed, 10 insertions(+), 65 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index ec0761f0..53ea9fd7 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -28,12 +28,6 @@ import com.gamingmesh.jobs.Placeholders.NewPlaceholderAPIHook; import com.gamingmesh.jobs.Placeholders.Placeholder; import com.gamingmesh.jobs.Placeholders.PlaceholderAPIHook; import com.gamingmesh.jobs.hooks.HookManager; -import com.gamingmesh.jobs.hooks.McMMO.McMMOManager; -import com.gamingmesh.jobs.hooks.MyPet.MyPetManager; -import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobInterface; -import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobs2; -import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobs4; -import com.gamingmesh.jobs.hooks.WorldGuard.WorldGuardManager; import com.gamingmesh.jobs.Signs.SignUtil; import com.gamingmesh.jobs.api.JobsExpGainEvent; import com.gamingmesh.jobs.api.JobsPrePaymentEvent; @@ -93,15 +87,6 @@ public class Jobs extends JavaPlugin { private static PistonProtectionListener PistonProtectionListener = null; - @Deprecated - private static McMMOManager McMMOManager = null; - @Deprecated - private static MythicMobInterface MythicManager = null; - @Deprecated - private static MyPetManager myPetManager = null; - @Deprecated - private static WorldGuardManager worldGuardManager = null; - private static ConfigManager configManager = null; private static GeneralConfigManager GconfigManager = null; @@ -136,28 +121,12 @@ public class Jobs extends JavaPlugin { private static PointsData pointsDatabase = null; - @Deprecated - public static McMMOManager getMcMMOManager() { - if (McMMOManager == null) - McMMOManager = new McMMOManager(); - return McMMOManager; - } - public static PistonProtectionListener getPistonProtectionListener() { if (PistonProtectionListener == null) PistonProtectionListener = new PistonProtectionListener(); return PistonProtectionListener; } - @Deprecated - public static MyPetManager getMyPetManager() { - if (myPetManager == null && getInstance().getServer().getPluginManager().getPlugin("MyPet") != null) { - myPetManager = new MyPetManager(); - } - - return myPetManager; - } - private Placeholder Placeholder; private boolean PlaceholderAPIEnabled = false; @@ -191,32 +160,6 @@ public class Jobs extends JavaPlugin { return true; } - @Deprecated - public static WorldGuardManager getWorldGuardManager() { - return worldGuardManager; - } - - @Deprecated - public void setMythicManager() { - try { - Class.forName("net.elseland.xikage.MythicMobs.API.MythicMobsAPI"); - MythicManager = new MythicMobs2(this); - } catch (ClassNotFoundException e) { - try { - Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper"); - MythicManager = new MythicMobs4(this); - } catch (ClassNotFoundException ex) { - } - } - if (MythicManager != null) - consoleMsg("&e[Jobs] MythicMobs detected."); - } - - @Deprecated - public static MythicMobInterface getMythicManager() { - return MythicManager; - } - public static Loging getLoging() { if (loging == null) loging = new Loging(); @@ -488,7 +431,7 @@ public class Jobs extends JavaPlugin { } public static Job getJob(int id) { - return getJobsIds().get(id); + return jobsIds.get(id); } public boolean isPlaceholderAPIEnabled() { diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment14Listener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment14Listener.java index 7baf3c92..eab032b2 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment14Listener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment14Listener.java @@ -3,6 +3,7 @@ package com.gamingmesh.jobs.listeners; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import org.bukkit.block.Campfire; import org.bukkit.entity.Player; @@ -20,7 +21,7 @@ import com.gamingmesh.jobs.container.PlayerCamp; public class JobsPayment14Listener implements Listener { - private Map campPlayers = new HashMap<>(); + private final Map campPlayers = new HashMap<>(); @EventHandler(priority = EventPriority.LOW) public void onCook(BlockCookEvent event) { @@ -36,22 +37,23 @@ public class JobsPayment14Listener implements Listener { if (!(event.getBlock().getState() instanceof Campfire)) return; - for (Iterator> it = campPlayers.entrySet().iterator(); it.hasNext();) { - Map.Entry camps = it.next(); + for (Iterator> it = campPlayers.entrySet().iterator(); it.hasNext();) { + Entry camps = it.next(); if (camps == null) { continue; } - if (!camps.getValue().getBlock().getLocation().equals(event.getBlock().getLocation())) { + PlayerCamp camp = camps.getKey(); + if (!camp.getBlock().getLocation().equals(event.getBlock().getLocation())) { continue; } - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(camps.getKey()); + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(camps.getValue()); if (jPlayer == null) return; Jobs.action(jPlayer, new ItemActionInfo(event.getSource(), ActionType.BAKE)); - if (camps.getValue().getItem().equals(event.getSource())) { + if (camp.getItem().equals(event.getSource())) { it.remove(); } } @@ -79,6 +81,6 @@ public class JobsPayment14Listener implements Listener { if (!JobsPaymentListener.payIfCreative(p)) return; - campPlayers.put(p, new PlayerCamp(ev.getItem(), click)); + campPlayers.put(new PlayerCamp(ev.getItem(), click), p); } }