diff options
Diffstat (limited to 'src/main/java/de/hysky')
5 files changed, 37 insertions, 36 deletions
diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index ebb85b36..e334ef86 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -166,7 +166,6 @@ public class SkyblockerMod implements ClientModInitializer { Scheduler.INSTANCE.scheduleCyclic(BackpackPreview::tick, 50); Scheduler.INSTANCE.scheduleCyclic(DwarvenHud::update, 40); Scheduler.INSTANCE.scheduleCyclic(CrystalsHud::update, 40); - Scheduler.INSTANCE.scheduleCyclic(CrystalsLocationsManager::update, 40); Scheduler.INSTANCE.scheduleCyclic(PlayerListMgr::updateList, 20); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java index f113561f..79e81ad0 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java @@ -17,14 +17,14 @@ import org.joml.Vector2i; import org.joml.Vector2ic; import java.awt.*; -import java.util.Arrays; +import java.util.List; import java.util.Map; public class CrystalsHud { private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); protected static final Identifier MAP_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/crystals_map.png"); private static final Identifier MAP_ICON = new Identifier("textures/map/map_icons.png"); - private static final String[] SMALL_LOCATIONS = { "Fairy Grotto", "King Yolkar", "Corleone", "Odawa", "Key Guardian" }; + private static final List<String> SMALL_LOCATIONS = List.of("Fairy Grotto", "King Yolkar", "Corleone", "Odawa", "Key Guardian"); public static boolean visible = false; @@ -80,8 +80,8 @@ public class CrystalsHud { Vector2ic renderPos = transformLocation(waypoint.pos.getX(), waypoint.pos.getZ()); int locationSize = SkyblockerConfigManager.get().locations.dwarvenMines.crystalsHud.locationSize; - if (Arrays.asList(SMALL_LOCATIONS).contains(waypoint.name.getString())) {//if small location half the location size - locationSize = locationSize / 2; + if (SMALL_LOCATIONS.contains(waypoint.name.getString())) {//if small location half the location size + locationSize /= 2; } //fill square of size locationSize around the coordinates of the location diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java index 0a4e4518..f43574ab 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java @@ -9,6 +9,7 @@ import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.scheduler.Scheduler; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; @@ -47,12 +48,13 @@ public class CrystalsLocationsManager { /** * A look-up table to convert between location names and waypoint in the {@link CrystalsWaypoint.Category} values. */ - protected static final Map<String, CrystalsWaypoint.Category> WAYPOINT_LOCATIONS = Arrays.stream(CrystalsWaypoint.Category.values()).collect(Collectors.toMap(CrystalsWaypoint.Category::toString, Function.identity())); + private static final Map<String, CrystalsWaypoint.Category> WAYPOINT_LOCATIONS = Arrays.stream(CrystalsWaypoint.Category.values()).collect(Collectors.toMap(CrystalsWaypoint.Category::toString, Function.identity())); private static final Pattern TEXT_CWORDS_PATTERN = Pattern.compile("([0-9][0-9][0-9]) ([0-9][0-9][0-9]?) ([0-9][0-9][0-9])"); protected static Map<String, CrystalsWaypoint> activeWaypoints = new HashMap<>(); public static void init() { + Scheduler.INSTANCE.scheduleCyclic(CrystalsLocationsManager::update, 40); WorldRenderEvents.AFTER_TRANSLUCENT.register(CrystalsLocationsManager::render); ClientReceiveMessageEvents.GAME.register(CrystalsLocationsManager::extractLocationFromMessage); ClientCommandRegistrationCallback.EVENT.register(CrystalsLocationsManager::registerWaypointLocationCommands); @@ -83,7 +85,7 @@ public class CrystalsLocationsManager { for (String waypointLocation : WAYPOINT_LOCATIONS.keySet()) { if (value.toLowerCase().contains(waypointLocation.toLowerCase())) { //todo be more lenient //all data found to create waypoint - addCustomWaypoint(Text.of(waypointLocation),blockPos); + addCustomWaypoint(waypointLocation, blockPos); return; } } @@ -144,7 +146,7 @@ public class CrystalsLocationsManager { BlockPos blockPos = location.toAbsoluteBlockPos(new ServerCommandSource(null, source.getPosition(), source.getRotation(), null, 0, null, null, null, null)); if (WAYPOINT_LOCATIONS.containsKey(place)) { - addCustomWaypoint(Text.of(place), blockPos); + addCustomWaypoint(place, blockPos); //tell the client it has done this if (CLIENT.player == null || CLIENT.getNetworkHandler() == null) { @@ -158,10 +160,10 @@ public class CrystalsLocationsManager { } - private static void addCustomWaypoint( Text waypointName, BlockPos pos) { - CrystalsWaypoint.Category category = WAYPOINT_LOCATIONS.get(waypointName.getString()); - CrystalsWaypoint waypoint = new CrystalsWaypoint(category, waypointName, pos); - activeWaypoints.put(waypointName.getString(), waypoint); + private static void addCustomWaypoint(String waypointName, BlockPos pos) { + CrystalsWaypoint.Category category = WAYPOINT_LOCATIONS.get(waypointName); + CrystalsWaypoint waypoint = new CrystalsWaypoint(category, Text.literal(waypointName), pos); + activeWaypoints.put(waypointName, waypoint); } public static void render(WorldRenderContext context) { @@ -184,12 +186,12 @@ public class CrystalsLocationsManager { } //get if the player is in the crystals - String location = Utils.getIslandArea().replace("⏣ ", ""); + String location = Utils.getIslandArea().substring(2); //if new location and needs waypoint add waypoint if (!location.equals("Unknown") && WAYPOINT_LOCATIONS.containsKey(location) && !activeWaypoints.containsKey(location)) { //add waypoint at player location BlockPos playerLocation = CLIENT.player.getBlockPos(); - addCustomWaypoint(Text.of(location), playerLocation); + addCustomWaypoint(location, playerLocation); } } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java index 8eb15935..58abd980 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java @@ -11,6 +11,7 @@ import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallba import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.network.PlayerListEntry; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -42,7 +43,7 @@ public class DwarvenHud { "First Event", "(?:Ruby|Amber|Sapphire|Jade|Amethyst|Topaz) Gemstone Collector", "(?:Amber|Sapphire|Jade|Amethyst|Topaz) Crystal Hunter", - "Chest Looter").map(s -> Pattern.compile("^.*(" + s + "): (\\d+\\.?\\d*%|DONE)")) + "Chest Looter").map(s -> Pattern.compile("(" + s + "): (\\d+\\.?\\d*%|DONE)")) .collect(Collectors.toList()); public static final Pattern MITHRIL_PATTERN = Pattern.compile("Mithril Powder: [0-9,]+"); public static final Pattern GEMSTONE_PATTERN = Pattern.compile("Gemstone Powder: [0-9,]+"); @@ -164,27 +165,28 @@ public class DwarvenHud { commissionList = new ArrayList<>(); - client.getNetworkHandler().getPlayerList().forEach(playerListEntry -> { - if (playerListEntry.getDisplayName() != null) { - //find commissions - for (Pattern pattern : COMMISSIONS) { - Matcher matcher = pattern.matcher(playerListEntry.getDisplayName().getString()); - if (matcher.find()) { - commissionList.add(new Commission(matcher.group(1), matcher.group(2))); - } - - } - //find powder - Matcher mithrilMatcher = MITHRIL_PATTERN.matcher(playerListEntry.getDisplayName().getString()); - if (mithrilMatcher.find()){ - mithrilPowder = mithrilMatcher.group(0).split(": ")[1]; - } - Matcher gemstoneMatcher = GEMSTONE_PATTERN.matcher(playerListEntry.getDisplayName().getString()); - if (gemstoneMatcher.find()){ - gemStonePowder = gemstoneMatcher.group(0).split(": ")[1]; + for (PlayerListEntry playerListEntry : client.getNetworkHandler().getPlayerList()) { + if (playerListEntry.getDisplayName() == null) { + continue; + } + //find commissions + String name = playerListEntry.getDisplayName().getString().strip(); + for (Pattern pattern : COMMISSIONS) { + Matcher matcher = pattern.matcher(name); + if (matcher.matches()) { + commissionList.add(new Commission(matcher.group(1), matcher.group(2))); } } - }); + //find powder + Matcher mithrilMatcher = MITHRIL_PATTERN.matcher(name); + if (mithrilMatcher.matches()) { + mithrilPowder = mithrilMatcher.group(0).split(": ")[1]; + } + Matcher gemstoneMatcher = GEMSTONE_PATTERN.matcher(name); + if (gemstoneMatcher.matches()) { + gemStonePowder = gemstoneMatcher.group(0).split(": ")[1]; + } + } } // steamroller tactics to get visibility from outside classes (HudCommsWidget) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/BackpackPreview.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/BackpackPreview.java index af2a062b..37de58e6 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/BackpackPreview.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/BackpackPreview.java @@ -24,7 +24,6 @@ import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.util.Objects; @@ -55,7 +54,6 @@ public class BackpackPreview { } public static void tick() { - Utils.update(); // force update isOnSkyblock to prevent crash on disconnect if (Utils.isOnSkyblock()) { // save all dirty storages saveStorages(); |