From f2ed36bcb67dc22be15c2bf16d31a078c86fef95 Mon Sep 17 00:00:00 2001 From: Geoff Yoerger Date: Mon, 4 Dec 2017 07:58:00 -0600 Subject: [PATCH] Don't dynamically change rotations when a mutation is queued --- PGM/src/main/java/tc/oc/pgm/mutation/MutationQueue.java | 4 ++++ .../java/tc/oc/pgm/rotation/DynamicRotationListener.java | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/PGM/src/main/java/tc/oc/pgm/mutation/MutationQueue.java b/PGM/src/main/java/tc/oc/pgm/mutation/MutationQueue.java index 1cc2fe4..295702b 100644 --- a/PGM/src/main/java/tc/oc/pgm/mutation/MutationQueue.java +++ b/PGM/src/main/java/tc/oc/pgm/mutation/MutationQueue.java @@ -34,6 +34,10 @@ public class MutationQueue { public ListenableFuture clear() { return force(Collections.emptyList()); } + + public boolean isEmpty() { + return minecraftService.getLocalServer().queued_mutations().isEmpty(); + } public ListenableFuture removeAll(final Collection mutations) { Collection removed = mutations(); diff --git a/PGM/src/main/java/tc/oc/pgm/rotation/DynamicRotationListener.java b/PGM/src/main/java/tc/oc/pgm/rotation/DynamicRotationListener.java index 76b5be9..e16df85 100644 --- a/PGM/src/main/java/tc/oc/pgm/rotation/DynamicRotationListener.java +++ b/PGM/src/main/java/tc/oc/pgm/rotation/DynamicRotationListener.java @@ -17,6 +17,7 @@ import tc.oc.commons.core.logging.Loggers; import tc.oc.commons.core.plugin.PluginFacet; import tc.oc.pgm.PGM; import tc.oc.pgm.events.MatchEndEvent; +import tc.oc.pgm.mutation.MutationQueue; import java.util.logging.Logger; @@ -26,12 +27,14 @@ public class DynamicRotationListener implements PluginFacet, Listener { private final Audiences audiences; private final OnlinePlayers players; private final ConfigurationSection config; + private final MutationQueue mutationQueue; - @Inject DynamicRotationListener(Loggers loggers, Audiences audiences, OnlinePlayers players, Configuration config) { + @Inject DynamicRotationListener(Loggers loggers, Audiences audiences, OnlinePlayers players, Configuration config, MutationQueue mutationQueue) { this.logger = loggers.get(getClass()); this.audiences = audiences; this.players = players; this.config = config.getConfigurationSection("rotation"); + this.mutationQueue = mutationQueue; } @EventHandler(priority = EventPriority.MONITOR) @@ -40,6 +43,9 @@ 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; + + // If a mutation was set for the next map, don't change it yet. + if (mutationQueue.isEmpty()) return; int playerCount = players.count() + Math.round(event.getMatch().getObservingPlayers().size() / 2);