From f80008bc5a471a688db8dc03ae8a8c3e2ff001ee Mon Sep 17 00:00:00 2001 From: Mads Boddum Date: Thu, 13 Oct 2016 04:24:42 +0200 Subject: [PATCH] Cloned players now go on leave --- src/services/faction/FactionService.java | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/services/faction/FactionService.java b/src/services/faction/FactionService.java index 06ccbac3..97a7381b 100644 --- a/src/services/faction/FactionService.java +++ b/src/services/faction/FactionService.java @@ -53,18 +53,14 @@ import utilities.ThreadUtilities; public final class FactionService extends Service { - private ScheduledExecutorService executor; - private Map> statusChangers; + private final ScheduledExecutorService executor; + private final Map> statusChangers; public FactionService() { - registerForIntent(FactionIntent.TYPE); - } - - @Override - public boolean initialize() { statusChangers = new HashMap<>(); executor = Executors.newSingleThreadScheduledExecutor(ThreadUtilities.newThreadFactory("faction-service")); - return super.initialize(); + + registerForIntent(FactionIntent.TYPE); } @Override @@ -76,10 +72,8 @@ public final class FactionService extends Service { @Override public boolean terminate() { - if (executor != null) { - // If some were in the middle of switching, finish the switches immediately - executor.shutdownNow().forEach(runnable -> runnable.run()); - } + // If some were in the middle of switching, finish the switches immediately + executor.shutdownNow().forEach(runnable -> runnable.run()); return super.terminate(); } @@ -216,11 +210,11 @@ public final class FactionService extends Service { } else { // Their new status does not equal the one we want - apply the new one - changeStatus(target, oldStatus, newStatus); + target.setPvpStatus(newStatus); } } else { // They're not currently waiting to switch to a new status - change now - changeStatus(target, oldStatus, newStatus); + target.setPvpStatus(newStatus); } }