From 295d799b507fb0d1366ef28eb25dd0761fb6f406 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sat, 30 May 2020 20:29:16 -0500 Subject: [PATCH] Add enterReplacesExits setting for greeting/farewell --- .../src/main/java/org/dynmap/MapManager.java | 32 +++++++++++++++---- .../src/main/resources/configuration.txt | 2 ++ .../src/main/resources/configuration.txt | 2 ++ .../src/main/resources/configuration.txt | 2 ++ .../src/main/resources/configuration.txt | 2 ++ .../src/main/resources/configuration.txt | 2 ++ .../src/main/resources/configuration.txt | 2 ++ .../src/main/resources/configuration.txt | 2 ++ .../src/main/resources/configuration.txt | 2 ++ spigot/src/main/resources/configuration.txt | 2 ++ 10 files changed, 43 insertions(+), 7 deletions(-) diff --git a/DynmapCore/src/main/java/org/dynmap/MapManager.java b/DynmapCore/src/main/java/org/dynmap/MapManager.java index fe279b09..d1c690b2 100644 --- a/DynmapCore/src/main/java/org/dynmap/MapManager.java +++ b/DynmapCore/src/main/java/org/dynmap/MapManager.java @@ -83,17 +83,23 @@ public class MapManager { private static final int DEFAULT_TITLE_STAY = 70; // 70 ticks = 3 1/2 second private static final int DEFAULT_TITLE_FADEOUT = 20; // 20 ticks = 1 second private static final boolean DEFAULT_ENTEREXIT_USETITLE = true; + private static final boolean DEFAULT_ENTEREPLACESEXITS = false; private int enterexitperiod = DEFAULT_ENTEREXIT_PERIOD; // Enter/exit processing period private int titleFadeIn = DEFAULT_TITLE_FADEIN; private int titleStay = DEFAULT_TITLE_STAY; private int titleFadeOut = DEFAULT_TITLE_FADEOUT; private boolean enterexitUseTitle = DEFAULT_ENTEREXIT_USETITLE; + private boolean enterReplacesExits = DEFAULT_ENTEREPLACESEXITS; private HashMap> entersetstate = new HashMap>(); + private static class TextQueueRec { + EnterExitText txt; + boolean isEnter; + } private static class SendQueueRec { DynmapPlayer player; - ArrayList queue = new ArrayList(); + ArrayList queue = new ArrayList(); int tickdelay; }; private HashMap entersetsendqueue = new HashMap(); @@ -970,7 +976,7 @@ public class MapManager { }, 0); } - private void enqueueMessage(UUID uuid, DynmapPlayer player, EnterExitText txt) { + private void enqueueMessage(UUID uuid, DynmapPlayer player, EnterExitText txt, boolean isEnter) { SendQueueRec rec = entersetsendqueue.get(uuid); if (rec == null) { rec = new SendQueueRec(); @@ -978,7 +984,18 @@ public class MapManager { rec.tickdelay = 0; entersetsendqueue.put(uuid, rec); } - rec.queue.add(txt); + TextQueueRec txtrec = new TextQueueRec(); + txtrec.isEnter = isEnter; + txtrec.txt = txt; + rec.queue.add(txtrec); + // If enter replaces exits, and we just added enter, purge exits + if (enterReplacesExits && isEnter) { + ArrayList newlst = new ArrayList(); + for (TextQueueRec r : rec.queue) { + if (r.isEnter) newlst.add(r); // Keep the enter records + } + rec.queue = newlst; + } } private class DoUserMoveProcessing implements Runnable { @@ -999,7 +1016,7 @@ public class MapManager { for (EnterExitMarker m : oldset) { EnterExitText txt = m.getFarewellText(); if ((txt != null) && (newset.contains(m) == false)) { - enqueueMessage(puuid, player, txt); + enqueueMessage(puuid, player, txt, false); } } } @@ -1007,7 +1024,7 @@ public class MapManager { for (EnterExitMarker m : newset) { EnterExitText txt = m.getGreetingText(); if ((txt != null) && ((oldset == null) || (oldset.contains(m) == false))) { - enqueueMessage(puuid, player, txt); + enqueueMessage(puuid, player, txt, true); } } newstate.put(puuid, newset); @@ -1026,8 +1043,8 @@ public class MapManager { rec.tickdelay = 0; // If something to send, send it if (rec.queue.size() > 0) { - EnterExitText txt = rec.queue.remove(0); - sendPlayerEnterExit(rec.player, txt); // And send it + TextQueueRec txt = rec.queue.remove(0); + sendPlayerEnterExit(rec.player, txt.txt); // And send it rec.tickdelay = 50 * (titleFadeIn + 10); // Delay by fade in time plus 1/2 second } else { // Else, if we are empty and exhausted delay, remove it @@ -1127,6 +1144,7 @@ public class MapManager { titleStay = configuration.getInteger("titleStay", DEFAULT_TITLE_STAY); titleFadeOut = configuration.getInteger("titleFadeOut", DEFAULT_TITLE_FADEOUT); enterexitUseTitle = configuration.getBoolean("enterexitUseTitle", DEFAULT_ENTEREXIT_USETITLE); + enterReplacesExits = configuration.getBoolean("enterReplacesExits", DEFAULT_ENTEREPLACESEXITS); // Load the save pending job period savependingperiod = configuration.getInteger("save-pending-period", 900); if ((savependingperiod > 0) && (savependingperiod < 60)) savependingperiod = 60; diff --git a/forge-1.10.2/src/main/resources/configuration.txt b/forge-1.10.2/src/main/resources/configuration.txt index 11df4bd9..c3773f15 100644 --- a/forge-1.10.2/src/main/resources/configuration.txt +++ b/forge-1.10.2/src/main/resources/configuration.txt @@ -444,6 +444,8 @@ soft-ref-cache: true #titleFadeOut: 20 # Enter/exit messages use on screen titles (true - default), if false chat messages are sent instead #enterexitUseTitle: true +# Set true if new enter messages should supercede pending exit messages (vs being queued in order), default false +#enterReplacesExits: true # Set to true to enable verbose startup messages - can help with debugging map configuration problems # Set to false for a much quieter startup log diff --git a/forge-1.11.2/src/main/resources/configuration.txt b/forge-1.11.2/src/main/resources/configuration.txt index 11df4bd9..c3773f15 100644 --- a/forge-1.11.2/src/main/resources/configuration.txt +++ b/forge-1.11.2/src/main/resources/configuration.txt @@ -444,6 +444,8 @@ soft-ref-cache: true #titleFadeOut: 20 # Enter/exit messages use on screen titles (true - default), if false chat messages are sent instead #enterexitUseTitle: true +# Set true if new enter messages should supercede pending exit messages (vs being queued in order), default false +#enterReplacesExits: true # Set to true to enable verbose startup messages - can help with debugging map configuration problems # Set to false for a much quieter startup log diff --git a/forge-1.12.2/src/main/resources/configuration.txt b/forge-1.12.2/src/main/resources/configuration.txt index 11df4bd9..c3773f15 100644 --- a/forge-1.12.2/src/main/resources/configuration.txt +++ b/forge-1.12.2/src/main/resources/configuration.txt @@ -444,6 +444,8 @@ soft-ref-cache: true #titleFadeOut: 20 # Enter/exit messages use on screen titles (true - default), if false chat messages are sent instead #enterexitUseTitle: true +# Set true if new enter messages should supercede pending exit messages (vs being queued in order), default false +#enterReplacesExits: true # Set to true to enable verbose startup messages - can help with debugging map configuration problems # Set to false for a much quieter startup log diff --git a/forge-1.13.2/src/main/resources/configuration.txt b/forge-1.13.2/src/main/resources/configuration.txt index 11df4bd9..c3773f15 100644 --- a/forge-1.13.2/src/main/resources/configuration.txt +++ b/forge-1.13.2/src/main/resources/configuration.txt @@ -444,6 +444,8 @@ soft-ref-cache: true #titleFadeOut: 20 # Enter/exit messages use on screen titles (true - default), if false chat messages are sent instead #enterexitUseTitle: true +# Set true if new enter messages should supercede pending exit messages (vs being queued in order), default false +#enterReplacesExits: true # Set to true to enable verbose startup messages - can help with debugging map configuration problems # Set to false for a much quieter startup log diff --git a/forge-1.14.4/src/main/resources/configuration.txt b/forge-1.14.4/src/main/resources/configuration.txt index 11df4bd9..c3773f15 100644 --- a/forge-1.14.4/src/main/resources/configuration.txt +++ b/forge-1.14.4/src/main/resources/configuration.txt @@ -444,6 +444,8 @@ soft-ref-cache: true #titleFadeOut: 20 # Enter/exit messages use on screen titles (true - default), if false chat messages are sent instead #enterexitUseTitle: true +# Set true if new enter messages should supercede pending exit messages (vs being queued in order), default false +#enterReplacesExits: true # Set to true to enable verbose startup messages - can help with debugging map configuration problems # Set to false for a much quieter startup log diff --git a/forge-1.15.2/src/main/resources/configuration.txt b/forge-1.15.2/src/main/resources/configuration.txt index 11df4bd9..c3773f15 100644 --- a/forge-1.15.2/src/main/resources/configuration.txt +++ b/forge-1.15.2/src/main/resources/configuration.txt @@ -444,6 +444,8 @@ soft-ref-cache: true #titleFadeOut: 20 # Enter/exit messages use on screen titles (true - default), if false chat messages are sent instead #enterexitUseTitle: true +# Set true if new enter messages should supercede pending exit messages (vs being queued in order), default false +#enterReplacesExits: true # Set to true to enable verbose startup messages - can help with debugging map configuration problems # Set to false for a much quieter startup log diff --git a/forge-1.8.9/src/main/resources/configuration.txt b/forge-1.8.9/src/main/resources/configuration.txt index 11df4bd9..c3773f15 100644 --- a/forge-1.8.9/src/main/resources/configuration.txt +++ b/forge-1.8.9/src/main/resources/configuration.txt @@ -444,6 +444,8 @@ soft-ref-cache: true #titleFadeOut: 20 # Enter/exit messages use on screen titles (true - default), if false chat messages are sent instead #enterexitUseTitle: true +# Set true if new enter messages should supercede pending exit messages (vs being queued in order), default false +#enterReplacesExits: true # Set to true to enable verbose startup messages - can help with debugging map configuration problems # Set to false for a much quieter startup log diff --git a/forge-1.9.4/src/main/resources/configuration.txt b/forge-1.9.4/src/main/resources/configuration.txt index 11df4bd9..c3773f15 100644 --- a/forge-1.9.4/src/main/resources/configuration.txt +++ b/forge-1.9.4/src/main/resources/configuration.txt @@ -444,6 +444,8 @@ soft-ref-cache: true #titleFadeOut: 20 # Enter/exit messages use on screen titles (true - default), if false chat messages are sent instead #enterexitUseTitle: true +# Set true if new enter messages should supercede pending exit messages (vs being queued in order), default false +#enterReplacesExits: true # Set to true to enable verbose startup messages - can help with debugging map configuration problems # Set to false for a much quieter startup log diff --git a/spigot/src/main/resources/configuration.txt b/spigot/src/main/resources/configuration.txt index f9dd54a0..177a3e43 100644 --- a/spigot/src/main/resources/configuration.txt +++ b/spigot/src/main/resources/configuration.txt @@ -471,6 +471,8 @@ soft-ref-cache: true #titleFadeOut: 20 # Enter/exit messages use on screen titles (true - default), if false chat messages are sent instead #enterexitUseTitle: true +# Set true if new enter messages should supercede pending exit messages (vs being queued in order), default false +#enterReplacesExits: true # Set to true to enable verbose startup messages - can help with debugging map configuration problems # Set to false for a much quieter startup log