Make dynamic rotations work again, add option to disable them in config, and show activation player counts in /rotations
This commit is contained in:
parent
427515a94b
commit
a50b29d625
|
@ -19,6 +19,7 @@ command.map.mapInfo.folder = Folder
|
|||
command.map.currentRotation.title = Current Rotation
|
||||
|
||||
command.map.rotationList.title = Loaded Rotations
|
||||
command.map.rotationList.activatesWith = (activates with {0} players)
|
||||
|
||||
map.genre.objectives = Objectives
|
||||
map.genre.deathmatch = Deathmatch
|
||||
|
|
|
@ -32,6 +32,7 @@ import tc.oc.commons.bukkit.nick.UsernameRenderer;
|
|||
import tc.oc.commons.core.chat.Audience;
|
||||
import tc.oc.commons.core.chat.Component;
|
||||
import tc.oc.commons.core.chat.Components;
|
||||
import tc.oc.pgm.Config;
|
||||
import tc.oc.pgm.PGM;
|
||||
import tc.oc.pgm.PGMTranslations;
|
||||
import tc.oc.pgm.ffa.FreeForAllModule;
|
||||
|
@ -238,7 +239,8 @@ public class MapCommands {
|
|||
|
||||
new PrettyPaginatedResult<String>(PGMTranslations.get().t("command.map.rotationList.title", sender)) {
|
||||
@Override public String format(String rotationName, int index) {
|
||||
return (index % 2 == 0 ? ChatColor.AQUA : ChatColor.DARK_AQUA) + rotationName;
|
||||
int activation = Config.getConfiguration().getInt("rotation.providers.file." + rotationName + ".count");
|
||||
return (index % 2 == 0 ? ChatColor.AQUA : ChatColor.DARK_AQUA) + rotationName + (activation > 0 ? ChatColor.GRAY + " " + PGMTranslations.get().t("command.map.rotationList.activatesWith", sender, ChatColor.RED + "" + activation + ChatColor.GRAY) : "");
|
||||
}
|
||||
}.display(new BukkitWrappedCommandSender(sender), Lists.newArrayList(rotations.keySet()), page);
|
||||
}
|
||||
|
|
|
@ -11,33 +11,31 @@ import tc.oc.pgm.Config;
|
|||
import tc.oc.pgm.PGM;
|
||||
import tc.oc.pgm.cycle.CycleMatchModule;
|
||||
import tc.oc.pgm.events.MatchEndEvent;
|
||||
import tc.oc.pgm.match.Match;
|
||||
|
||||
public class DynamicRotationChangeListener implements Listener {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(RotationCategory.MEDIUM.toString().toLowerCase());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMatchEnd(MatchEndEvent event) {
|
||||
RotationManager rotationManager = PGM.getMatchManager().getRotationManager();
|
||||
|
||||
// Ignore if there is only one rotation available
|
||||
if (rotationManager.getRotations().size() == 1) return;
|
||||
if (rotationManager.getRotations().size() == 1 || !Config.getConfiguration().getBoolean("rotation.dynamic")) return;
|
||||
|
||||
// Number of players we can assume is active
|
||||
int participatingPlayers = event.getMatch().getServer().getOnlinePlayers().size();
|
||||
|
||||
// Get appropriate rotation
|
||||
RotationCategory appr = getAppropriateRotationCategory(participatingPlayers, rotationManager);
|
||||
if (appr != null && rotationManager.getRotation(appr.toString().toLowerCase()) != rotationManager.getRotation()) {
|
||||
|
||||
if (appr != null && !rotationManager.getCurrentRotationName().equals(appr.toString().toLowerCase())) {
|
||||
rotationManager.setRotation(rotationManager.getRotation(appr.toString().toLowerCase()));
|
||||
CycleMatchModule cmm = event.getMatch().needMatchModule(CycleMatchModule.class);
|
||||
cmm.startCountdown(cmm.getConfig().countdown());
|
||||
|
||||
event.getMatch().sendMessage(new TextComponent(ChatColor.RED + "" + ChatColor.STRIKETHROUGH + "---------------------------------------------------"));
|
||||
event.getMatch().sendMessage(new Component(new TranslatableComponent("rotation.change.broadcast.title"), ChatColor.GOLD));
|
||||
event.getMatch().sendMessage(new Component(new TranslatableComponent("rotation.change.broadcast.info"), ChatColor.YELLOW));
|
||||
event.getMatch().sendMessage(new TextComponent(ChatColor.RED + "" + ChatColor.STRIKETHROUGH + "---------------------------------------------------"));
|
||||
PGM.get().getLogger().info("[Dynamic Rotations] Changing to \"" + appr.toString().toLowerCase() + "\" rotation...");
|
||||
sendRotationChangeMessage(event.getMatch());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,4 +56,11 @@ public class DynamicRotationChangeListener implements Listener {
|
|||
|
||||
return RotationCategory.MINI;
|
||||
}
|
||||
|
||||
private void sendRotationChangeMessage(Match match) {
|
||||
match.sendMessage(new TextComponent(ChatColor.RED + "" + ChatColor.STRIKETHROUGH + "---------------------------------------------------"));
|
||||
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 + "---------------------------------------------------"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue