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:
parent
53e16c4d02
commit
a08b8e178e
@ -68,8 +68,10 @@ map.gamemode.long.mixed = Mixed
|
||||
map.gamemode.long.skywars = Skywars
|
||||
map.gamemode.long.survival = Survival Games
|
||||
|
||||
rotation.change.broadcast.title = Changing Rotation...
|
||||
rotation.change.broadcast.info = The server is automatically changing rotations to best accommodate the current player count.
|
||||
rotation.change.broadcast.change = Rotation Change
|
||||
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.tip = View this match on the web
|
||||
|
@ -41,7 +41,7 @@ public class DynamicRotationListener implements PluginFacet, Listener {
|
||||
// Ignore if dynamic rotations are disabled or if there is only one rotation available
|
||||
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
|
||||
RotationProviderInfo rotation = rotationManager.getProviders().stream()
|
||||
@ -52,6 +52,7 @@ public class DynamicRotationListener implements PluginFacet, Listener {
|
||||
} else {
|
||||
RotationState rotState = rotation.provider.getRotation(rotation.name);
|
||||
|
||||
String oldRotation = rotationManager.getCurrentRotationName();
|
||||
if (rotState == null) {
|
||||
logger.warning("'" + rotation.name + "' rotation provider doesn't have a rotation with it's own name");
|
||||
} else if (!rotationManager.getCurrentRotationName().equals(rotation.name)) {
|
||||
@ -59,15 +60,16 @@ public class DynamicRotationListener implements PluginFacet, Listener {
|
||||
rotationManager.setCurrentRotationName(rotation.name);
|
||||
|
||||
logger.info("Changing to \"" + rotation.name + "\" rotation...");
|
||||
sendRotationChangeMessage(audiences.localServer());
|
||||
sendRotationChangeMessage(audiences.localServer(), oldRotation, rotation.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendRotationChangeMessage(Audience audience) {
|
||||
audience.sendMessage(new HeaderComponent(ChatColor.RED));
|
||||
audience.sendMessage(new Component(new TranslatableComponent("rotation.change.broadcast.title"), ChatColor.GOLD));
|
||||
audience.sendMessage(new Component(new TranslatableComponent("rotation.change.broadcast.info"), ChatColor.YELLOW));
|
||||
audience.sendMessage(new HeaderComponent(ChatColor.RED));
|
||||
private void sendRotationChangeMessage(Audience audience, String previous, String current) {
|
||||
audience.sendMessage(new HeaderComponent(ChatColor.AQUA, new TranslatableComponent("rotation.change.broadcast.change")));
|
||||
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.current", ChatColor.AQUA + current), ChatColor.DARK_AQUA));
|
||||
audience.sendMessage(new Component(new TranslatableComponent("rotation.change.broadcast.info"), ChatColor.WHITE));
|
||||
audience.sendMessage(new HeaderComponent(ChatColor.DARK_AQUA));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user