Move this to the skill itself.

This commit is contained in:
GJ 2013-10-28 16:32:40 -04:00
parent 9b3ae5c729
commit cc2c9eb21d
4 changed files with 8 additions and 30 deletions

View File

@ -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<SkillType, SkillManager> skillManagers = new HashMap<SkillType, SkillManager>();
private Party party;

View File

@ -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);
}
}

View File

@ -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());
}
}
}

View File

@ -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);