diff --git a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index a48a4536b..89af0d05c 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -84,7 +84,11 @@ public class FishingCommand extends SkillCommand { // MASTER ANGLER if (canMasterAngler) { double rawBiteChance = 1.0 / (isStorming ? 300 : 500); - Location location = (mcMMOPlayer.getHookLocation() != null) ? mcMMOPlayer.getHookLocation() : player.getLocation(); + Location location = mcMMOPlayer.getFishingManager().getHookLocation(); + + if (location == null) { + location = player.getLocation(); + } Biome biome = location.getBlock().getBiome(); diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index c3695df6d..bb6452081 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -6,7 +6,6 @@ import java.util.Set; import org.bukkit.GameMode; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -37,7 +36,6 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; -import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.swords.SwordsManager; @@ -77,14 +75,8 @@ public class McMMOPlayer { private boolean displaySkillNotifications = true; private boolean abilityUse = true; - private boolean placedRepairAnvil; - private int lastRepairClick; - private boolean placedSalvageAnvil; - private int lastSalvageClick; private boolean godMode; - private Location hookLocation; - private final Map abilityMode = new HashMap(); private final Map abilityInformed = new HashMap(); @@ -434,68 +426,6 @@ public class McMMOPlayer { databaseATS = System.currentTimeMillis(); } - /* - * Repair Anvil Placement - */ - - public boolean getPlacedAnvil(Material anvilType) { - if (anvilType == Repair.repairAnvilMaterial) { - return placedRepairAnvil; - } - - if (anvilType == Repair.salvageAnvilMaterial) { - return placedSalvageAnvil; - } - - return true; - } - - public void togglePlacedAnvil(Material anvilType) { - if (anvilType == Repair.repairAnvilMaterial) { - placedRepairAnvil = !placedRepairAnvil; - } - - if (anvilType == Repair.salvageAnvilMaterial) { - placedSalvageAnvil = !placedSalvageAnvil; - } - } - - /* - * Repair Anvil Usage - */ - - public int getLastAnvilUse(Material anvilType) { - if (anvilType == Repair.repairAnvilMaterial) { - return lastRepairClick; - } - - if (anvilType == Repair.salvageAnvilMaterial) { - return lastSalvageClick; - } - - return 0; - } - - public void setLastAnvilUse(Material anvilType, int value) { - if (anvilType == Repair.repairAnvilMaterial) { - lastRepairClick = value; - } - - if (anvilType == Repair.salvageAnvilMaterial) { - lastSalvageClick = value; - } - } - - public void actualizeLastAnvilUse(Material anvilType) { - if (anvilType == Repair.repairAnvilMaterial) { - lastRepairClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); - } - - if (anvilType == Repair.salvageAnvilMaterial) { - lastSalvageClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); - } - } - /* * God Mode */ @@ -508,18 +438,6 @@ public class McMMOPlayer { godMode = !godMode; } - /* - * Fishing: Master Angler - */ - - public Location getHookLocation() { - return hookLocation; - } - - public void setHookLocation(Location hookLocation) { - this.hookLocation = hookLocation; - } - /* * Skill notifications */ diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 51b7f6122..693898f39 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -465,7 +465,7 @@ public class PlayerListener implements Listener { // Cancel repairing an enchanted item if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) { - mcMMOPlayer.setLastAnvilUse(Repair.repairAnvilMaterial, 0); + repairManager.setLastAnvilUse(Repair.repairAnvilMaterial, 0); player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name"))); } } @@ -475,7 +475,7 @@ public class PlayerListener implements Listener { // Cancel salvaging an enchanted item if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) { - mcMMOPlayer.setLastAnvilUse(Repair.salvageAnvilMaterial, 0); + repairManager.setLastAnvilUse(Repair.salvageAnvilMaterial, 0); player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name"))); } } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 608713f8a..590404ad3 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -67,6 +67,7 @@ public class FishingManager extends SkillManager { private long fishingTimestamp = 0L; private Location fishingTarget; private Item fishingCatch; + private Location hookLocation; public FishingManager(McMMOPlayer mcMMOPlayer) { super(mcMMOPlayer, SkillType.FISHING); @@ -281,7 +282,7 @@ public class FishingManager extends SkillManager { Biome biome = location.getBlock().getBiome(); double biteChance = hook.getBiteChance(); - mcMMOPlayer.setHookLocation(location); + hookLocation = location; if (biome == Biome.RIVER || biome == Biome.OCEAN) { biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier(); @@ -362,6 +363,10 @@ public class FishingManager extends SkillManager { return experience * getVanillaXpMultiplier(); } + public Location getHookLocation() { + return hookLocation; + } + /** * Handle the Shake ability * diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java index 0818eddd2..28976a04e 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -25,10 +25,14 @@ import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; public class RepairManager extends SkillManager { + private boolean placedRepairAnvil; + private int lastRepairClick; + private boolean placedSalvageAnvil; + private int lastSalvageClick; + public RepairManager(McMMOPlayer mcMMOPlayer) { super(mcMMOPlayer, SkillType.REPAIR); } @@ -41,14 +45,14 @@ public class RepairManager extends SkillManager { public void placedAnvilCheck(Material anvilType) { Player player = getPlayer(); - if (mcMMOPlayer.getPlacedAnvil(anvilType)) { + if (getPlacedAnvil(anvilType)) { return; } player.sendMessage(Repair.getAnvilMessage(anvilType)); player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - mcMMOPlayer.togglePlacedAnvil(anvilType); + togglePlacedAnvil(anvilType); } public void handleRepair(ItemStack item) { @@ -176,8 +180,7 @@ public class RepairManager extends SkillManager { */ public boolean checkConfirmation(Material anvilType, boolean actualize) { Player player = getPlayer(); - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - long lastUse = mcMMOPlayer.getLastAnvilUse(anvilType); + long lastUse = getLastAnvilUse(anvilType); if (!SkillUtils.cooldownExpired(lastUse, 3) || !Config.getInstance().getRepairConfirmRequired()) { return true; @@ -187,7 +190,7 @@ public class RepairManager extends SkillManager { return false; } - mcMMOPlayer.actualizeLastAnvilUse(anvilType); + actualizeLastAnvilUse(anvilType); if (anvilType == Repair.repairAnvilMaterial) { player.sendMessage(LocaleLoader.getString("Skills.ConfirmOrCancel", LocaleLoader.getString("Repair.Pretty.Name"))); @@ -348,4 +351,66 @@ public class RepairManager extends SkillManager { player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); } } + + /* + * Repair Anvil Placement + */ + + public boolean getPlacedAnvil(Material anvilType) { + if (anvilType == Repair.repairAnvilMaterial) { + return placedRepairAnvil; + } + + if (anvilType == Repair.salvageAnvilMaterial) { + return placedSalvageAnvil; + } + + return true; + } + + public void togglePlacedAnvil(Material anvilType) { + if (anvilType == Repair.repairAnvilMaterial) { + placedRepairAnvil = !placedRepairAnvil; + } + + if (anvilType == Repair.salvageAnvilMaterial) { + placedSalvageAnvil = !placedSalvageAnvil; + } + } + + /* + * Repair Anvil Usage + */ + + public int getLastAnvilUse(Material anvilType) { + if (anvilType == Repair.repairAnvilMaterial) { + return lastRepairClick; + } + + if (anvilType == Repair.salvageAnvilMaterial) { + return lastSalvageClick; + } + + return 0; + } + + public void setLastAnvilUse(Material anvilType, int value) { + if (anvilType == Repair.repairAnvilMaterial) { + lastRepairClick = value; + } + + if (anvilType == Repair.salvageAnvilMaterial) { + lastSalvageClick = value; + } + } + + public void actualizeLastAnvilUse(Material anvilType) { + if (anvilType == Repair.repairAnvilMaterial) { + lastRepairClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); + } + + if (anvilType == Repair.salvageAnvilMaterial) { + lastSalvageClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); + } + } }