diff options
author | Lulonaut <lulonaut@tutanota.de> | 2022-11-12 13:13:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-12 13:13:05 +0100 |
commit | 9d0d62d66698f1d3833e7335ba81d059233709c1 (patch) | |
tree | b3240f4fe9fb38ef36b84690f8c508a4e2af4e88 | |
parent | 5f521c98519a636e6139113887cdc2e223300333 (diff) | |
download | NotEnoughUpdates-9d0d62d66698f1d3833e7335ba81d059233709c1.tar.gz NotEnoughUpdates-9d0d62d66698f1d3833e7335ba81d059233709c1.tar.bz2 NotEnoughUpdates-9d0d62d66698f1d3833e7335ba81d059233709c1.zip |
Show slayer overlay in "None" location (#437)
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java | 8 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java | 27 |
2 files changed, 28 insertions, 7 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java index 00e13016..72879bf9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java @@ -66,11 +66,15 @@ public class SlayerOverlay extends TextOverlay { } private boolean shouldUpdate() { - if (!NotEnoughUpdates.INSTANCE.config.slayerOverlay.onlyShowWhenRelevant || SBInfo.getInstance().stranded) + if (!NotEnoughUpdates.INSTANCE.config.slayerOverlay.onlyShowWhenRelevant || SBInfo.getInstance().stranded) { return true; - //Ignore if on stranded + } + String scoreboardLocation = SBInfo.getInstance().location; String locrawLocation = SBInfo.getInstance().getLocation(); + if ("None".equals(scoreboardLocation)) { + scoreboardLocation = SBInfo.getInstance().getLastScoreboardLocation(); + } //In case something is broken still show the overlay if (locrawLocation == null || scoreboardLocation == null) return true; switch (SBInfo.getInstance().slayer) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java index b8e8312d..ec7ec404 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -78,6 +78,7 @@ public class SBInfo { public IChatComponent header; public String location = ""; + public String lastLocation = ""; public String date = ""; public String time = ""; public String objective = ""; @@ -279,11 +280,26 @@ public class SBInfo { } public void setLocation(String location) { - location = location == null ? location :location.intern(); - if (!Objects.equals(this.mode, location)) { - MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(location, this.mode)); + location = location == null ? location : location.intern(); + if (!Objects.equals(mode, location)) { + MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(location, mode)); } - this.mode = location; + mode = location; + } + + /** + * @return the current location as displayed on the scoreboard + */ + public String getScoreboardLocation() { + return location; + } + + /** + * @return the previous location as displayed on the scoreboard + * @see #getScoreboardLocation() + */ + public String getLastScoreboardLocation() { + return lastLocation; } private static final String profilePrefix = "\u00a7r\u00a7e\u00a7lProfile: \u00a7r\u00a7a"; @@ -426,8 +442,9 @@ public class SBInfo { String l = Utils.cleanColour(line).replaceAll("[^A-Za-z0-9() ]", "").trim(); if (!l.equals(location)) { new ScoreboardLocationChangeListener(location, l); + lastLocation = location; + location = l; } - location = l; break; } } |