1
0
mirror of https://github.com/OvercastNetwork/ProjectAres.git synced 2025-04-11 22:56:08 +02:00

Change rotation change message & enhance logic (#27)

This commit is contained in:
Javi 2017-08-01 21:14:36 +02:00 committed by GitHub
parent 53e16c4d02
commit a08b8e178e
2 changed files with 18 additions and 14 deletions

View File

@ -68,8 +68,10 @@ map.gamemode.long.mixed = Mixed
map.gamemode.long.skywars = Skywars map.gamemode.long.skywars = Skywars
map.gamemode.long.survival = Survival Games map.gamemode.long.survival = Survival Games
rotation.change.broadcast.title = Changing Rotation... rotation.change.broadcast.change = Rotation Change
rotation.change.broadcast.info = The server is automatically changing rotations to best accommodate the current player count. rotation.change.broadcast.previous = Previous: {0}
rotation.change.broadcast.current = Current: {0}
rotation.change.broadcast.info = The rotations have been changed to accommodate the number of online players.
command.match.matchInfo.title = Match command.match.matchInfo.title = Match
command.match.matchInfo.title.tip = View this match on the web command.match.matchInfo.title.tip = View this match on the web

View File

@ -41,7 +41,7 @@ public class DynamicRotationListener implements PluginFacet, Listener {
// Ignore if dynamic rotations are disabled or if there is only one rotation available // Ignore if dynamic rotations are disabled or if there is only one rotation available
if (!config.getBoolean("dynamic", false) || rotationManager.getRotations().size() <= 1) return; if (!config.getBoolean("dynamic", false) || rotationManager.getRotations().size() <= 1) return;
int playerCount = players.count(); int playerCount = players.count() + Math.round(event.getMatch().getObservingPlayers().size() / 2);
// Get appropriate rotation // Get appropriate rotation
RotationProviderInfo rotation = rotationManager.getProviders().stream() RotationProviderInfo rotation = rotationManager.getProviders().stream()
@ -52,6 +52,7 @@ public class DynamicRotationListener implements PluginFacet, Listener {
} else { } else {
RotationState rotState = rotation.provider.getRotation(rotation.name); RotationState rotState = rotation.provider.getRotation(rotation.name);
String oldRotation = rotationManager.getCurrentRotationName();
if (rotState == null) { if (rotState == null) {
logger.warning("'" + rotation.name + "' rotation provider doesn't have a rotation with it's own name"); logger.warning("'" + rotation.name + "' rotation provider doesn't have a rotation with it's own name");
} else if (!rotationManager.getCurrentRotationName().equals(rotation.name)) { } else if (!rotationManager.getCurrentRotationName().equals(rotation.name)) {
@ -59,15 +60,16 @@ public class DynamicRotationListener implements PluginFacet, Listener {
rotationManager.setCurrentRotationName(rotation.name); rotationManager.setCurrentRotationName(rotation.name);
logger.info("Changing to \"" + rotation.name + "\" rotation..."); logger.info("Changing to \"" + rotation.name + "\" rotation...");
sendRotationChangeMessage(audiences.localServer()); sendRotationChangeMessage(audiences.localServer(), oldRotation, rotation.name);
} }
} }
} }
private void sendRotationChangeMessage(Audience audience) { private void sendRotationChangeMessage(Audience audience, String previous, String current) {
audience.sendMessage(new HeaderComponent(ChatColor.RED)); audience.sendMessage(new HeaderComponent(ChatColor.AQUA, new TranslatableComponent("rotation.change.broadcast.change")));
audience.sendMessage(new Component(new TranslatableComponent("rotation.change.broadcast.title"), ChatColor.GOLD)); audience.sendMessage(new Component(new TranslatableComponent("rotation.change.broadcast.previous", ChatColor.AQUA + previous), ChatColor.DARK_AQUA));
audience.sendMessage(new Component(new TranslatableComponent("rotation.change.broadcast.info"), ChatColor.YELLOW)); audience.sendMessage(new Component(new TranslatableComponent("rotation.change.broadcast.current", ChatColor.AQUA + current), ChatColor.DARK_AQUA));
audience.sendMessage(new HeaderComponent(ChatColor.RED)); audience.sendMessage(new Component(new TranslatableComponent("rotation.change.broadcast.info"), ChatColor.WHITE));
audience.sendMessage(new HeaderComponent(ChatColor.DARK_AQUA));
} }
} }