From c53563e7d1edc78862605b1f44248673901c54c2 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Thu, 28 Mar 2013 02:17:38 -0400 Subject: [PATCH] More work GJ didn't ask me to do --- .../nossr50/datatypes/skills/SkillType.java | 39 ++++++++++++------- .../gmail/nossr50/listeners/SelfListener.java | 20 ++++++++++ src/main/java/com/gmail/nossr50/mcMMO.java | 3 ++ .../util/skills/ParticleEffectUtils.java | 5 +++ 4 files changed, 52 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/listeners/SelfListener.java 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 9a2146aca..36f458ca9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java @@ -1,5 +1,7 @@ package com.gmail.nossr50.datatypes.skills; +import org.bukkit.Color; + import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; @@ -20,32 +22,35 @@ import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.StringUtils; public enum SkillType { - ACROBATICS(AcrobaticsManager.class), - ARCHERY(ArcheryManager.class), - AXES(AxesManager.class, AbilityType.SKULL_SPLITTER, ToolType.AXE), - EXCAVATION(ExcavationManager.class, AbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL), - FISHING(FishingManager.class), - HERBALISM(HerbalismManager.class, AbilityType.GREEN_TERRA, ToolType.HOE), - MINING(MiningManager.class, AbilityType.SUPER_BREAKER, ToolType.PICKAXE), - REPAIR(RepairManager.class), - SMELTING(SmeltingManager.class), - SWORDS(SwordsManager.class, AbilityType.SERRATED_STRIKES, ToolType.SWORD), - TAMING(TamingManager.class), - UNARMED(UnarmedManager.class, AbilityType.BERSERK, ToolType.FISTS), - WOODCUTTING(WoodcuttingManager.class, AbilityType.TREE_FELLER, ToolType.AXE); + ACROBATICS(AcrobaticsManager.class, Color.WHITE), + ARCHERY(ArcheryManager.class, Color.MAROON), + AXES(AxesManager.class, Color.AQUA, AbilityType.SKULL_SPLITTER, ToolType.AXE), + EXCAVATION(ExcavationManager.class, Color.fromRGB(139, 69, 19), AbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL), + FISHING(FishingManager.class, Color.NAVY), + HERBALISM(HerbalismManager.class, Color.GREEN, AbilityType.GREEN_TERRA, ToolType.HOE), + MINING(MiningManager.class, Color.GRAY, AbilityType.SUPER_BREAKER, ToolType.PICKAXE), + REPAIR(RepairManager.class, Color.SILVER), + SMELTING(SmeltingManager.class, Color.YELLOW), + SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), AbilityType.SERRATED_STRIKES, ToolType.SWORD), + TAMING(TamingManager.class, Color.PURPLE), + UNARMED(UnarmedManager.class, Color.BLACK, AbilityType.BERSERK, ToolType.FISTS), + WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, AbilityType.TREE_FELLER, ToolType.AXE); private Class managerClass; + private Color runescapeColor; private AbilityType ability; private ToolType tool; - private SkillType(Class managerClass) { + private SkillType(Class managerClass, Color runescapeColor) { this.managerClass = managerClass; + this.runescapeColor = runescapeColor; ability = null; tool = null; } - private SkillType(Class managerClass, AbilityType ability, ToolType tool) { + private SkillType(Class managerClass, Color runescapeColor, AbilityType ability, ToolType tool) { this.managerClass = managerClass; + this.runescapeColor = runescapeColor; this.ability = ability; this.tool = tool; } @@ -116,4 +121,8 @@ public enum SkillType { return false; } } + + public Color getRunescapeModeColor() { + return runescapeColor; + } } diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java new file mode 100644 index 000000000..aeb1343a8 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -0,0 +1,20 @@ +package com.gmail.nossr50.listeners; + +import java.util.Calendar; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; + +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) + public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) { + Calendar today = Calendar.getInstance(); + if (today.get(Calendar.MONTH) == Calendar.APRIL && today.get(Calendar.DAY_OF_MONTH) == 1) { + ParticleEffectUtils.runescapeModeCelebration(event.getPlayer(), event.getSkill()); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 0af3fe9f4..5f600a119 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -29,6 +29,7 @@ import com.gmail.nossr50.listeners.BlockListener; import com.gmail.nossr50.listeners.EntityListener; import com.gmail.nossr50.listeners.InventoryListener; import com.gmail.nossr50.listeners.PlayerListener; +import com.gmail.nossr50.listeners.SelfListener; import com.gmail.nossr50.listeners.WorldListener; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.metrics.MetricsManager; @@ -59,6 +60,7 @@ public class mcMMO extends JavaPlugin { private final BlockListener blockListener = new BlockListener(this); private final EntityListener entityListener = new EntityListener(this); private final InventoryListener inventoryListener = new InventoryListener(this); + private final SelfListener selfListener = new SelfListener(); private final WorldListener worldListener = new WorldListener(); private HashMap tntTracker = new HashMap(); @@ -351,6 +353,7 @@ public class mcMMO extends JavaPlugin { pluginManager.registerEvents(blockListener, this); pluginManager.registerEvents(entityListener, this); pluginManager.registerEvents(inventoryListener, this); + pluginManager.registerEvents(selfListener, this); pluginManager.registerEvents(worldListener, this); } 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 37d5fc4f6..d377b47ff 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java @@ -15,6 +15,7 @@ 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 { @@ -73,6 +74,10 @@ public final class ParticleEffectUtils { fireworkParticleShower(player, Color.RED); } + public static void runescapeModeCelebration(Player player, SkillType skill) { + fireworkParticleShower(player, skill.getRunescapeModeColor()); + } + private static void fireworkParticleShower(Player player, Color color) { Location location = player.getLocation(); location.setY(location.getY() - 1.0);