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 bb6452081..20fba0a1c 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -55,13 +55,6 @@ public class McMMOPlayer { private Player player; private PlayerProfile profile; - /* - * Since SkillManager isn't a "polymorphic type" we may prefer to have one field for each of our - * class inheriting from SkillManager. This would also prevent the need for casting. - * However, by using the map and the loop in the constructor - * we make sure that all class inheriting from SkillManager are instanced. - * Which solution is better, I let you decide. - bm01 - */ private final Map skillManagers = new HashMap(); private Party party; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java index 63abe8791..3f49ad2c1 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java @@ -27,6 +27,7 @@ import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.google.common.collect.ImmutableList; @@ -179,10 +180,6 @@ public enum SkillType { } } - public Color getRunescapeModeColor() { - return runescapeColor; - } - public static SkillType byAbility(AbilityType ability) { for (SkillType type : values()) { if (type.getAbility() == ability) { @@ -200,4 +197,8 @@ public enum SkillType { public boolean getPermissions(Player player) { return Permissions.skillEnabled(player, this); } + + public void celebrateLevelUp(Player player) { + ParticleEffectUtils.fireworkParticleShower(player, runescapeColor); + } } diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index 76479f112..52d51751d 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -1,13 +1,11 @@ package com.gmail.nossr50.listeners; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent; -import com.gmail.nossr50.util.skills.ParticleEffectUtils; public class SelfListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -16,17 +14,8 @@ public class SelfListener implements Listener { return; } - int tier = Config.getInstance().getLevelUpEffectsTier(); - - if (tier <= 0) { - return; - } - - Player player = event.getPlayer(); - float skillValue = event.getSkillLevel(); - - if ((skillValue % tier) == 0) { - ParticleEffectUtils.runescapeModeCelebration(player, event.getSkill()); + if ((event.getSkillLevel() % Config.getInstance().getLevelUpEffectsTier()) == 0) { + event.getSkill().celebrateLevelUp(event.getPlayer()); } } } diff --git a/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java index b2140ced7..93eb751a0 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java @@ -16,7 +16,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.meta.FireworkMeta; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.skills.SkillType; public final class ParticleEffectUtils { @@ -80,11 +79,7 @@ public final class ParticleEffectUtils { } } - public static void runescapeModeCelebration(Player player, SkillType skill) { - fireworkParticleShower(player, skill.getRunescapeModeColor()); - } - - private static void fireworkParticleShower(Player player, Color color) { + public static void fireworkParticleShower(Player player, Color color) { Location location = player.getLocation(); location.setY(location.getY() + (player.isInsideVehicle() ? 1.0 : -1.0)); location.setPitch(-90);