diff --git a/src/main/java/com/gmail/nossr50/api/AbilityAPI.java b/src/main/java/com/gmail/nossr50/api/AbilityAPI.java index dde4b0769..e3ac1e5a7 100644 --- a/src/main/java/com/gmail/nossr50/api/AbilityAPI.java +++ b/src/main/java/com/gmail/nossr50/api/AbilityAPI.java @@ -84,6 +84,6 @@ // } // // public static boolean isBleeding(LivingEntity entity) { -// return BleedTimerTask.isBleeding(entity); +// return pluginRef.getBleedTimerTask().isBleeding(entity); // } //} 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 f95a2f649..fa5aae660 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -12,7 +12,6 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.AbilityDisableTask; -import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.runnables.skills.ToolLowerTask; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; @@ -1011,7 +1010,7 @@ public class McMMOPlayer { public void logout(boolean syncSave) { Player thisPlayer = getPlayer(); resetAbilityMode(); - BleedTimerTask.bleedOut(thisPlayer); + pluginRef.getBleedTimerTask().bleedOut(thisPlayer); if (syncSave) { getProfile().save(true); diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedContainer.java b/src/main/java/com/gmail/nossr50/datatypes/skills/BleedContainer.java similarity index 92% rename from src/main/java/com/gmail/nossr50/runnables/skills/BleedContainer.java rename to src/main/java/com/gmail/nossr50/datatypes/skills/BleedContainer.java index fc0a335a6..ec42d1849 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedContainer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/BleedContainer.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.runnables.skills; +package com.gmail.nossr50.datatypes.skills; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index dc1469ed2..b8cc64735 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -89,6 +89,9 @@ public class mcMMO extends JavaPlugin { private CommandTools commandTools; private TextComponentFactory textComponentFactory; + /* Never-Ending tasks */ + private BleedTimerTask bleedTimerTask; + /* File Paths */ private String mainDirectory; private String localesDirectory; @@ -164,7 +167,7 @@ public class mcMMO extends JavaPlugin { formulaManager = new FormulaManager(); for (Player player : getServer().getOnlinePlayers()) { - new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(this, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + new PlayerProfileLoadingTask(this, player).runTaskLaterAsynchronously(this, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading } debug("Version " + getDescription().getVersion() + " is enabled!"); @@ -597,7 +600,8 @@ public class mcMMO extends JavaPlugin { new CleanBackupFilesTask(this).runTaskAsynchronously(this); // Bleed timer (Runs every 0.5 seconds) - new BleedTimerTask().runTaskTimer(this, Misc.TICK_CONVERSION_FACTOR, (Misc.TICK_CONVERSION_FACTOR / 2)); + bleedTimerTask = new BleedTimerTask(this); + pluginRef.getBleedTimerTask().runTaskTimer(this, Misc.TICK_CONVERSION_FACTOR, (Misc.TICK_CONVERSION_FACTOR / 2)); // Old & Powerless User remover long purgeIntervalTicks = getConfigManager().getConfigDatabase().getConfigSectionCleaning().getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR; @@ -614,18 +618,18 @@ public class mcMMO extends JavaPlugin { long kickIntervalTicks = getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR; if (kickIntervalTicks == 0) { - new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. + new PartyAutoKickTask(this).runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. } else if (kickIntervalTicks > 0) { - new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks); + new PartyAutoKickTask(this).runTaskTimer(this, kickIntervalTicks, kickIntervalTicks); } } // Update power level tag scoreboards - new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR); + new PowerLevelUpdatingTask(this).runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR); // Clear the registered XP data so players can earn XP again if (getConfigManager().getConfigLeveling().getConfigLevelingDiminishedReturns().isDiminishedReturnsEnabled()) { - new ClearRegisteredXPGainTask().runTaskTimer(this, 60, 60); + new ClearRegisteredXPGainTask(this).runTaskTimer(this, 60, 60); } if (configManager.getConfigNotifications().getConfigNotificationGeneral().isPlayerTips()) { @@ -726,4 +730,8 @@ public class mcMMO extends JavaPlugin { public TextComponentFactory getTextComponentFactory() { return textComponentFactory; } + + public BleedTimerTask getBleedTimerTask() { + return bleedTimerTask; + } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java index a044df3ef..48d9bcc6e 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java @@ -3,13 +3,16 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; +import com.gmail.nossr50.mcMMO; import org.bukkit.scheduler.BukkitRunnable; public class AbilityCooldownTask extends BukkitRunnable { - private McMMOPlayer mcMMOPlayer; - private SuperAbilityType ability; + private final mcMMO pluginRef; + private final McMMOPlayer mcMMOPlayer; + private final SuperAbilityType ability; - public AbilityCooldownTask(McMMOPlayer mcMMOPlayer, SuperAbilityType ability) { + public AbilityCooldownTask(mcMMO pluginRef, McMMOPlayer mcMMOPlayer, SuperAbilityType ability) { + this.pluginRef = pluginRef; this.mcMMOPlayer = mcMMOPlayer; this.ability = ability; } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java index 06af3b4b8..1b6db0835 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.SkillUtils; @@ -12,10 +13,12 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; public class AbilityDisableTask extends BukkitRunnable { + private final mcMMO pluginRef; private McMMOPlayer mcMMOPlayer; private SuperAbilityType ability; - public AbilityDisableTask(McMMOPlayer mcMMOPlayer, SuperAbilityType ability) { + public AbilityDisableTask(mcMMO pluginRef, McMMOPlayer mcMMOPlayer, SuperAbilityType ability) { + this.pluginRef = pluginRef; this.mcMMOPlayer = mcMMOPlayer; this.ability = ability; } @@ -54,7 +57,7 @@ public class AbilityDisableTask extends BukkitRunnable { SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff()); - new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(pluginRef, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR); + new AbilityCooldownTask(pluginRef, mcMMOPlayer, ability).runTaskLater(pluginRef, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR); } private void resendChunkRadiusAt(Player player) { diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java index d7aee1718..0a3e0df6b 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java @@ -7,6 +7,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import org.bukkit.entity.LivingEntity; import org.bukkit.scheduler.BukkitRunnable; +//TODO: Why is this a task? Investigate later. public class AwardCombatXpTask extends BukkitRunnable { private McMMOPlayer mcMMOPlayer; private double baseXp; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index 755ab10fb..f593b285a 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -1,6 +1,8 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; +import com.gmail.nossr50.datatypes.skills.BleedContainer; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.sounds.SoundManager; @@ -16,17 +18,22 @@ import java.util.Map; import java.util.Map.Entry; public class BleedTimerTask extends BukkitRunnable { - private static Map bleedList = new HashMap<>(); + private final mcMMO pluginRef; + private Map bleedList; - public static BleedContainer copyContainer(BleedContainer container) { + public BleedTimerTask(mcMMO pluginRef) { + this.pluginRef = pluginRef; + bleedList = new HashMap<>(); + } + + private BleedContainer copyContainer(BleedContainer container) { LivingEntity target = container.target; LivingEntity source = container.damageSource; int bleedTicks = container.bleedTicks; int bleedRank = container.bleedRank; int toolTier = container.toolTier; - BleedContainer newContainer = new BleedContainer(target, bleedTicks, bleedRank, toolTier, source); - return newContainer; + return new BleedContainer(target, bleedTicks, bleedRank, toolTier, source); } /** @@ -34,7 +41,7 @@ public class BleedTimerTask extends BukkitRunnable { * * @param entity LivingEntity to bleed out */ - public static void bleedOut(LivingEntity entity) { + public void bleedOut(LivingEntity entity) { /* * Don't remove anything from the list outside of run() */ @@ -50,7 +57,7 @@ public class BleedTimerTask extends BukkitRunnable { * @param entity LivingEntity to add * @param ticks Number of bleeding ticks */ - public static void add(LivingEntity entity, LivingEntity attacker, int ticks, int bleedRank, int toolTier) { + public void add(LivingEntity entity, LivingEntity attacker, int ticks, int bleedRank, int toolTier) { if (toolTier < 4) ticks = Math.max(1, (ticks / 3)); @@ -58,7 +65,7 @@ public class BleedTimerTask extends BukkitRunnable { bleedList.put(entity, newBleedContainer); } - public static boolean isBleeding(LivingEntity entity) { + public boolean isBleeding(LivingEntity entity) { return bleedList.containsKey(entity); } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java index cf9654b26..e19ba9eb5 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java @@ -6,9 +6,9 @@ import com.gmail.nossr50.util.experience.ExperienceBarManager; import org.bukkit.scheduler.BukkitRunnable; public class ExperienceBarHideTask extends BukkitRunnable { - public final McMMOPlayer mcMMOPlayer; - public final PrimarySkillType primarySkillType; - public final ExperienceBarManager experienceBarManagerRef; + private final McMMOPlayer mcMMOPlayer; + private final PrimarySkillType primarySkillType; + private final ExperienceBarManager experienceBarManagerRef; public ExperienceBarHideTask(ExperienceBarManager experienceBarManagerRef, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType) { this.experienceBarManagerRef = experienceBarManagerRef; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java index 38f5eb84d..102c9b0b7 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java @@ -4,7 +4,7 @@ import org.bukkit.block.BlockState; import org.bukkit.scheduler.BukkitRunnable; public class HerbalismBlockUpdaterTask extends BukkitRunnable { - private BlockState blockState; + private final BlockState blockState; public HerbalismBlockUpdaterTask(BlockState blockState) { this.blockState = blockState; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java index 6aa47b6ea..355921bc9 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java @@ -2,25 +2,25 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SubSkillType; +import com.gmail.nossr50.mcMMO; import org.bukkit.scheduler.BukkitRunnable; public class SkillUnlockNotificationTask extends BukkitRunnable { - private McMMOPlayer mcMMOPlayer; - private SubSkillType subSkillType; - private int rank; + private final mcMMO pluginRef; + private final McMMOPlayer mcMMOPlayer; + private final SubSkillType subSkillType; /** * Notify a player about a newly unlocked subskill * * @param mcMMOPlayer target player * @param subSkillType the subskill that they just unlocked - * @param rank the rank of the subskill */ - public SkillUnlockNotificationTask(McMMOPlayer mcMMOPlayer, SubSkillType subSkillType, int rank) { + public SkillUnlockNotificationTask(mcMMO pluginRef, McMMOPlayer mcMMOPlayer, SubSkillType subSkillType) { + this.pluginRef = pluginRef; this.mcMMOPlayer = mcMMOPlayer; this.subSkillType = subSkillType; - this.rank = rank; } /** diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java index bbd505e81..73885b6c4 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java @@ -3,13 +3,16 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.ToolType; +import com.gmail.nossr50.mcMMO; import org.bukkit.scheduler.BukkitRunnable; public class ToolLowerTask extends BukkitRunnable { - private McMMOPlayer mcMMOPlayer; - private ToolType tool; + private final mcMMO pluginRef; + private final McMMOPlayer mcMMOPlayer; + private final ToolType tool; - public ToolLowerTask(McMMOPlayer mcMMOPlayer, ToolType tool) { + public ToolLowerTask(mcMMO pluginRef, McMMOPlayer mcMMOPlayer, ToolType tool) { + this.pluginRef = pluginRef; this.mcMMOPlayer = mcMMOPlayer; this.tool = tool; } diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManager.java b/src/main/java/com/gmail/nossr50/skills/SkillManager.java index 81649f4ea..133fdc608 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillManager.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillManager.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainSource; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.mcMMO; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -11,8 +12,10 @@ import org.bukkit.entity.Player; public abstract class SkillManager { protected McMMOPlayer mcMMOPlayer; protected PrimarySkillType skill; + protected final mcMMO pluginRef; - public SkillManager(McMMOPlayer mcMMOPlayer, PrimarySkillType skill) { + public SkillManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer, PrimarySkillType skill) { + this.pluginRef = pluginRef; this.mcMMOPlayer = mcMMOPlayer; this.skill = skill; } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index 1dabffa79..995422745 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -25,8 +26,8 @@ public class AcrobaticsManager extends SkillManager { private long rollXPIntervalLengthen = (1000 * 10); //10 Seconds private LimitedSizeList fallLocationMap; - public AcrobaticsManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.ACROBATICS); + public AcrobaticsManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.ACROBATICS); rollXPInterval = (1000 * pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().getRollXPGainCooldownSeconds()); //Save some memory if exploit prevention is off diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java index 7453665fd..4ec003bc6 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java @@ -2,12 +2,13 @@ package com.gmail.nossr50.skills.alchemy; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; public class AlchemyManager extends SkillManager { - public AlchemyManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.ALCHEMY); + public AlchemyManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.ALCHEMY); } // diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 611c44284..a3bca77de 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -20,8 +21,8 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; public class ArcheryManager extends SkillManager { - public ArcheryManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.ARCHERY); + public ArcheryManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.ARCHERY); } public boolean canDaze(LivingEntity target) { diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java index 9bed07d93..8dc658a37 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java @@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.ToolType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Permissions; @@ -19,8 +20,8 @@ import org.bukkit.inventory.ItemStack; import java.util.Map; public class AxesManager extends SkillManager { - public AxesManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.AXES); + public AxesManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.AXES); } public boolean canUseAxeMastery() { diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java index 5c60a1785..0d1b9d184 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java @@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -20,8 +21,8 @@ import org.bukkit.entity.Player; import java.util.List; public class ExcavationManager extends SkillManager { - public ExcavationManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.EXCAVATION); + public ExcavationManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.EXCAVATION); } /** 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 ce23a0600..a55db9077 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -14,6 +14,7 @@ import com.gmail.nossr50.datatypes.treasure.Rarity; import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.ItemUtils; @@ -57,8 +58,8 @@ public class FishingManager extends SkillManager { private int fishCaughtCounter; private int overFishCount; - public FishingManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.FISHING); + public FishingManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.FISHING); fishCaughtCounter = 1; } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index e6cc22cc7..6c1015229 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -10,6 +10,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.datatypes.treasure.HylianTreasure; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.*; @@ -31,8 +32,8 @@ import java.util.List; public class HerbalismManager extends SkillManager { - public HerbalismManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.HERBALISM); + public HerbalismManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.HERBALISM); } public boolean canBlockCheck() { diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index e950f1c1f..6bdad6fd4 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -7,6 +7,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.AbilityCooldownTask; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.BlockUtils; @@ -27,8 +28,8 @@ import java.util.ArrayList; import java.util.List; public class MiningManager extends SkillManager { - public MiningManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.MINING); + public MiningManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.MINING); } public static double getOreBonus(int rank) { 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 41374a180..acf631bc7 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -25,8 +26,8 @@ public class RepairManager extends SkillManager { private boolean placedAnvil; private int lastClick; - public RepairManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.REPAIR); + public RepairManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.REPAIR); } /** diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java index 27e9d6e76..944fabc11 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; import com.gmail.nossr50.util.Misc; @@ -29,8 +30,8 @@ public class SalvageManager extends SkillManager { private boolean placedAnvil; private int lastClick; - public SalvageManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.SALVAGE); + public SalvageManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.SALVAGE); } /** diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index 9307c6759..45914b08d 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.experience.XPGainSource; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.random.RandomChanceUtil; @@ -15,8 +16,8 @@ import org.bukkit.event.inventory.FurnaceBurnEvent; import org.bukkit.inventory.ItemStack; public class SmeltingManager extends SkillManager { - public SmeltingManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.SMELTING); + public SmeltingManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.SMELTING); } /*public boolean canUseFluxMining(BlockState blockState) { diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index 51cecac61..dda15b31e 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -6,7 +6,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.ToolType; -import com.gmail.nossr50.runnables.skills.BleedTimerTask; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Permissions; @@ -23,8 +23,8 @@ import org.bukkit.inventory.ItemStack; import java.util.Map; public class SwordsManager extends SkillManager { - public SwordsManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.SWORDS); + public SwordsManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.SWORDS); } public boolean canActivateAbility() { @@ -69,12 +69,12 @@ public class SwordsManager extends SkillManager { return; if (pluginRef.getNotificationManager().doesPlayerUseNotifications(defender)) { - if (!BleedTimerTask.isBleeding(defender)) + if (!pluginRef.getBleedTimerTask().isBleeding(defender)) pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Started"); } } - BleedTimerTask.add(target, getPlayer(), getRuptureBleedTicks(), RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE), getToolTier(getPlayer().getInventory().getItemInMainHand())); + pluginRef.getBleedTimerTask().add(target, getPlayer(), getRuptureBleedTicks(), RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE), getToolTier(getPlayer().getInventory().getItemInMainHand())); if (mcMMOPlayer.useChatNotifications()) { pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding"); diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index e2923eb59..d9d51508a 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -9,7 +9,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.events.fake.FakeEntityTameEvent; -import com.gmail.nossr50.runnables.skills.BleedTimerTask; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -31,8 +31,8 @@ import java.util.List; public class TamingManager extends SkillManager { private static HashMap> summonedEntities = new HashMap<>(); - public TamingManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.TAMING); + public TamingManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.TAMING); } protected static void addToTracker(LivingEntity livingEntity) { @@ -138,7 +138,7 @@ public class TamingManager extends SkillManager { return 0; } - BleedTimerTask.add(target, getPlayer(), Taming.getInstance().getGoreBleedTicks(), 1, 2); + pluginRef.getBleedTimerTask().add(target, getPlayer(), Taming.getInstance().getGoreBleedTicks(), 1, 2); if (target instanceof Player) { pluginRef.getNotificationManager().sendPlayerInformation((Player) target, NotificationType.SUBSKILL_MESSAGE, "Combat.StruckByGore"); diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index af68776c3..88bb3d63a 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -7,6 +7,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.ToolType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; @@ -23,8 +24,8 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public class UnarmedManager extends SkillManager { - public UnarmedManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.UNARMED); + public UnarmedManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.UNARMED); } public boolean canActivateAbility() { diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index dbf062c3e..56e215c12 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.ItemUtils; @@ -26,8 +27,8 @@ import java.util.Set; public class WoodcuttingManager extends SkillManager { - public WoodcuttingManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, PrimarySkillType.WOODCUTTING); + public WoodcuttingManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + super(pluginRef, mcMMOPlayer, PrimarySkillType.WOODCUTTING); } public boolean canUseLeafBlower(ItemStack heldItem) { diff --git a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java index bd30b2fe1..47d1ada6c 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java @@ -44,7 +44,7 @@ public class RankUtils { //The players level is the exact level requirement for this skill if (newLevel == innerMap.get(playerRankInSkill)) { - SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType, newLevel); + SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType); skillUnlockNotificationTask.runTaskLater(plugin, (count * 100));