diff options
| author | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2023-08-21 00:05:24 +0800 |
|---|---|---|
| committer | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2023-08-21 00:10:30 +0800 |
| commit | 4dbcd98640bf3c50fbd0961cb66d33c57ac4a6d7 (patch) | |
| tree | dca5e50b1741e39b0e1c2b6919ff7506eed987b1 /src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util | |
| parent | 82421e8ffe95290973209c11116597c2965dedd9 (diff) | |
| download | Skyblocker-4dbcd98640bf3c50fbd0961cb66d33c57ac4a6d7.tar.gz Skyblocker-4dbcd98640bf3c50fbd0961cb66d33c57ac4a6d7.tar.bz2 Skyblocker-4dbcd98640bf3c50fbd0961cb66d33c57ac4a6d7.zip | |
Refactor code
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util')
| -rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java | 4 | ||||
| -rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java | 74 |
2 files changed, 31 insertions, 47 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java index 30cc242e..7b35bcce 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java @@ -94,7 +94,7 @@ public class PlayerListMgr { return null; } String str = txt.getString().trim(); - if (str.length() == 0) { + if (str.isEmpty()) { return null; } return str; @@ -144,7 +144,7 @@ public class PlayerListMgr { } // Avoid returning an empty component - Rift advertisements needed this - if (newText.getString().length() == 0) { + if (newText.getString().isEmpty()) { return null; } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java index e6aa0336..11c9d860 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java @@ -7,7 +7,7 @@ import me.xmrvizzy.skyblocker.utils.Utils; */ public class PlayerLocator { - public static enum Location { + public enum Location { DUNGEON("dungeon"), GUEST_ISLAND("guest_island"), HOME_ISLAND("home_island"), @@ -31,7 +31,7 @@ public class PlayerLocator { public final String internal; - private Location(String i) { + Location(String i) { // as used internally by the mod, e.g. in the json this.internal = i; } @@ -44,60 +44,44 @@ public class PlayerLocator { return Location.UNKNOWN; } - String areaDesciptor = PlayerListMgr.strAt(41); + String areaDescriptor = PlayerListMgr.strAt(41); - if (areaDesciptor == null || areaDesciptor.length() < 6) { + if (areaDescriptor == null || areaDescriptor.length() < 6) { return Location.UNKNOWN; } - if (areaDesciptor.startsWith("Dungeon")) { + if (areaDescriptor.startsWith("Dungeon")) { return Location.DUNGEON; } - switch (areaDesciptor.substring(6)) { - case "Private Island": + return switch (areaDescriptor.substring(6)) { + case "Private Island" -> { String islandType = PlayerListMgr.strAt(44); if (islandType == null) { - return Location.UNKNOWN; + yield Location.UNKNOWN; } else if (islandType.endsWith("Guest")) { - return Location.GUEST_ISLAND; + yield Location.GUEST_ISLAND; } else { - return Location.HOME_ISLAND; + yield Location.HOME_ISLAND; } - case "Crimson Isle": - return Location.CRIMSON_ISLE; - case "Dungeon Hub": - return Location.DUNGEON_HUB; - case "The Farming Islands": - return Location.FARMING_ISLAND; - case "The Park": - return Location.PARK; - case "Dwarven Mines": - return Location.DWARVEN_MINES; - case "Crystal Hollows": - return Location.CRYSTAL_HOLLOWS; - case "The End": - return Location.END; - case "Gold Mine": - return Location.GOLD_MINE; - case "Deep Caverns": - return Location.DEEP_CAVERNS; - case "Hub": - return Location.HUB; - case "Spider's Den": - return Location.SPIDER_DEN; - case "Jerry's Workshop": - return Location.JERRY; - case "Garden": - return Location.GARDEN; - case "Instanced": - return Location.INSTANCED; - case "The Rift": - return Location.THE_RIFT; - case "Dark Auction": - return Location.DARK_AUCTION; - default: - return Location.UNKNOWN; - } + } + case "Crimson Isle" -> Location.CRIMSON_ISLE; + case "Dungeon Hub" -> Location.DUNGEON_HUB; + case "The Farming Islands" -> Location.FARMING_ISLAND; + case "The Park" -> Location.PARK; + case "Dwarven Mines" -> Location.DWARVEN_MINES; + case "Crystal Hollows" -> Location.CRYSTAL_HOLLOWS; + case "The End" -> Location.END; + case "Gold Mine" -> Location.GOLD_MINE; + case "Deep Caverns" -> Location.DEEP_CAVERNS; + case "Hub" -> Location.HUB; + case "Spider's Den" -> Location.SPIDER_DEN; + case "Jerry's Workshop" -> Location.JERRY; + case "Garden" -> Location.GARDEN; + case "Instanced" -> Location.INSTANCED; + case "The Rift" -> Location.THE_RIFT; + case "Dark Auction" -> Location.DARK_AUCTION; + default -> Location.UNKNOWN; + }; } } |
