From 345b6cde423d5b9a41a7be2cfdd2f67ff50b3ca4 Mon Sep 17 00:00:00 2001 From: javipepe Date: Sun, 26 Mar 2017 14:58:56 +0200 Subject: [PATCH] Some clean-up on dynamic rotations code :sparkles: --- .../pgm/rotation/DynamicRotationChangeListener.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/PGM/src/main/java/tc/oc/pgm/rotation/DynamicRotationChangeListener.java b/PGM/src/main/java/tc/oc/pgm/rotation/DynamicRotationChangeListener.java index d6ce58c..2f61045 100644 --- a/PGM/src/main/java/tc/oc/pgm/rotation/DynamicRotationChangeListener.java +++ b/PGM/src/main/java/tc/oc/pgm/rotation/DynamicRotationChangeListener.java @@ -6,6 +6,7 @@ import net.md_5.bungee.api.chat.TranslatableComponent; import org.bukkit.configuration.Configuration; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import tc.oc.commons.bukkit.chat.HeaderComponent; import tc.oc.commons.core.chat.Component; import tc.oc.pgm.Config; import tc.oc.pgm.PGM; @@ -20,14 +21,14 @@ public class DynamicRotationChangeListener implements Listener { public void onMatchEnd(MatchEndEvent event) { RotationManager rotationManager = PGM.getMatchManager().getRotationManager(); - // Ignore if there is only one rotation available - if (rotationManager.getRotations().size() == 1 || !Config.getConfiguration().getBoolean("rotation.dynamic")) return; + // Ignore if dynamic rotations are disabled or if there is only one rotation available + if (!Config.getConfiguration().getBoolean("rotation.dynamic") || rotationManager.getRotations().size() == 1) return; // Number of players we can assume is active - int participatingPlayers = event.getMatch().getServer().getOnlinePlayers().size(); + int playersOnline = event.getMatch().getServer().getOnlinePlayers().size(); // Get appropriate rotation - RotationCategory appr = getAppropriateRotationCategory(participatingPlayers, rotationManager); + RotationCategory appr = getAppropriateRotationCategory(playersOnline, rotationManager); if (appr != null && !rotationManager.getCurrentRotationName().equals(appr.toString().toLowerCase())) { rotationManager.setRotation(rotationManager.getRotation(appr.toString().toLowerCase())); @@ -58,9 +59,9 @@ public class DynamicRotationChangeListener implements Listener { } private void sendRotationChangeMessage(Match match) { - match.sendMessage(new TextComponent(ChatColor.RED + "" + ChatColor.STRIKETHROUGH + "---------------------------------------------------")); + match.sendMessage(new HeaderComponent(ChatColor.RED)); match.sendMessage(new Component(new TranslatableComponent("rotation.change.broadcast.title"), ChatColor.GOLD)); match.sendMessage(new Component(new TranslatableComponent("rotation.change.broadcast.info"), ChatColor.YELLOW)); - match.sendMessage(new TextComponent(ChatColor.RED + "" + ChatColor.STRIKETHROUGH + "---------------------------------------------------")); + match.sendMessage(new HeaderComponent(ChatColor.RED)); } }