From 734815c58db4c60679932293a89ea6e9ea7c197a Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 4 Feb 2014 08:34:17 -0500 Subject: [PATCH] No reason to have our scoreboard stuff in a different listener. --- .../nossr50/listeners/PlayerListener.java | 3 ++ .../listeners/ScoreboardsListener.java | 39 ------------------- .../gmail/nossr50/listeners/SelfListener.java | 22 ++++++++++- src/main/java/com/gmail/nossr50/mcMMO.java | 2 - 4 files changed, 24 insertions(+), 42 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/listeners/ScoreboardsListener.java diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 3ffa87a1e..d076c631c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.listeners; +import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; @@ -353,6 +354,7 @@ public class PlayerListener implements Listener { BleedTimerTask.bleedOut(player); mcMMOPlayer.getProfile().save(); UserManager.remove(player.getName()); + ScoreboardManager.teardownPlayer(player); } /** @@ -373,6 +375,7 @@ public class PlayerListener implements Listener { } UserManager.addUser(player).actualizeRespawnATS(); + ScoreboardManager.setupPlayer(player); if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) { Motd.displayAll(player); diff --git a/src/main/java/com/gmail/nossr50/listeners/ScoreboardsListener.java b/src/main/java/com/gmail/nossr50/listeners/ScoreboardsListener.java deleted file mode 100644 index 2156e170a..000000000 --- a/src/main/java/com/gmail/nossr50/listeners/ScoreboardsListener.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.gmail.nossr50.listeners; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent; -import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent; -import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent; -import com.gmail.nossr50.util.scoreboards.ScoreboardManager; - -public class ScoreboardsListener implements Listener { - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerJoin(PlayerJoinEvent event) { - ScoreboardManager.setupPlayer(event.getPlayer()); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerQuit(PlayerQuitEvent event) { - ScoreboardManager.teardownPlayer(event.getPlayer()); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) { - ScoreboardManager.handleLevelUp(event.getPlayer(), event.getSkill()); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerXp(McMMOPlayerXpGainEvent event) { - ScoreboardManager.handleXp(event.getPlayer(), event.getSkill()); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onAbility(McMMOPlayerAbilityActivateEvent event) { - ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill()); - } -} diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index 52d51751d..fb34385ab 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -1,5 +1,10 @@ package com.gmail.nossr50.listeners; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent; +import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent; +import com.gmail.nossr50.util.scoreboards.ScoreboardManager; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -10,12 +15,27 @@ import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent; public class SelfListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) { + Player player = event.getPlayer(); + SkillType skill = event.getSkill(); + + ScoreboardManager.handleLevelUp(player, skill); + if (!Config.getInstance().getLevelUpEffectsEnabled()) { return; } if ((event.getSkillLevel() % Config.getInstance().getLevelUpEffectsTier()) == 0) { - event.getSkill().celebrateLevelUp(event.getPlayer()); + skill.celebrateLevelUp(player); } } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerXp(McMMOPlayerXpGainEvent event) { + ScoreboardManager.handleXp(event.getPlayer(), event.getSkill()); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onAbility(McMMOPlayerAbilityActivateEvent event) { + ScoreboardManager.cooldownUpdate(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 9ecee0c3d..e6b949171 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -28,7 +28,6 @@ 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.ScoreboardsListener; import com.gmail.nossr50.listeners.SelfListener; import com.gmail.nossr50.listeners.WorldListener; import com.gmail.nossr50.locale.LocaleLoader; @@ -441,7 +440,6 @@ public class mcMMO extends JavaPlugin { pluginManager.registerEvents(new EntityListener(this), this); pluginManager.registerEvents(new InventoryListener(this), this); pluginManager.registerEvents(new SelfListener(), this); - pluginManager.registerEvents(new ScoreboardsListener(), this); pluginManager.registerEvents(new WorldListener(this), this); }