diff options
| author | Fluboxer <36457056+Fluboxer@users.noreply.github.com> | 2025-04-26 04:13:10 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-25 21:13:10 -0400 |
| commit | 39fbee480a7cdea8ebcc7585e5dce60ccb8ca5d7 (patch) | |
| tree | 4adf5d5431f9c9272a8a096e404e542741a9ded5 /src | |
| parent | 6ebe9fffba90f6adba1ee77097376e78bdd57ada (diff) | |
| download | Skyblocker-39fbee480a7cdea8ebcc7585e5dce60ccb8ca5d7.tar.gz Skyblocker-39fbee480a7cdea8ebcc7585e5dce60ccb8ca5d7.tar.bz2 Skyblocker-39fbee480a7cdea8ebcc7585e5dce60ccb8ca5d7.zip | |
Update chat cords parsing to support common "X Y Z" format (#1222)
* Now it can parse X Y Z cords instead of X: Z: Y: cords only
* while we are at it, why doesn't it tell you what it wants to add as waypoint before you agree to let it do so?
* added another format, made it use translatable strings. Since I'm already here - adjusted Russian translation for waypoints
* Made feedback message slightly less ugly by hiding "|" if no area is specified. Also made waypoint vanish within 6 blocks
Diffstat (limited to 'src')
4 files changed, 16 insertions, 9 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatPositionShare.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatPositionShare.java index 031161a4..7daeb998 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatPositionShare.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatPositionShare.java @@ -27,11 +27,12 @@ import java.util.regex.Pattern; public class ChatPositionShare { private static final Logger LOGGER = LoggerFactory.getLogger(ChatPositionShare.class); - - private static final Pattern GENERIC_COORDS_PATTERN = Pattern.compile("x: (?<x>-?[0-9]+), y: (?<y>[0-9]+), z: (?<z>-?[0-9]+)"); + private static final Pattern SIMPLE_COORDS_PATTERN = Pattern.compile("(?<x>-?[0-9]+) (?<y>[0-9]+) (?<z>-?[0-9]+)"); + private static final Pattern SIMPLE_COMMA_COORDS_PATTERN = Pattern.compile("(?<x>-?[0-9]+), (?<y>[0-9]+), (?<z>-?[0-9]+)"); + private static final Pattern GENERIC_COORDS_PATTERN = Pattern.compile("x: (?<x>-?[0-9]+), y: (?<y>[0-9]+), z: (?<z>-?[0-9]+)"); private static final Pattern SKYBLOCKER_COORDS_PATTERN = Pattern.compile("x: (?<x>-?[0-9]+), y: (?<y>[0-9]+), z: (?<z>-?[0-9]+)(?: \\| (?<area>[^|]+))"); private static final Pattern SKYHANNI_DIANA_PATTERN = Pattern.compile("A MINOS INQUISITOR has spawned near \\[(?<area>[^]]*)] at Coords (?<x>-?[0-9]+) (?<y>[0-9]+) (?<z>-?[0-9]+)"); - private static final List<Pattern> PATTERNS = List.of(SKYBLOCKER_COORDS_PATTERN, SKYHANNI_DIANA_PATTERN, GENERIC_COORDS_PATTERN); + private static final List<Pattern> PATTERNS = List.of(SKYBLOCKER_COORDS_PATTERN, SKYHANNI_DIANA_PATTERN, GENERIC_COORDS_PATTERN, SIMPLE_COMMA_COORDS_PATTERN, SIMPLE_COORDS_PATTERN); @Init public static void init() { @@ -71,7 +72,7 @@ public class ChatPositionShare { private static void requestWaypoint(String x, String y, String z, @NotNull String area) { String command = "/skyblocker waypoints individual " + x + " " + y + " " + z + " " + area; - MutableText requestMessage = Constants.PREFIX.get().append(Text.translatable("skyblocker.config.chat.waypoints.display").formatted(Formatting.AQUA) + MutableText requestMessage = Constants.PREFIX.get().append(Text.translatable("skyblocker.config.chat.waypoints.display", x, y, z).formatted(Formatting.AQUA) .styled(style -> style .withHoverEvent(new HoverEvent.ShowText(Text.translatable("skyblocker.config.chat.waypoints.display"))) .withClickEvent(new ClickEvent.RunCommand(command.trim())) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/IndividualWaypoint.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/IndividualWaypoint.java index b493c241..f214abc5 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/IndividualWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/IndividualWaypoint.java @@ -67,7 +67,12 @@ public class IndividualWaypoint extends NamedWaypoint { private static int setWaypoint(Consumer<Text> feedback, int x, int y, int z, String area) { setWaypoint(x, y, z, area); - feedback.accept(Constants.PREFIX.get().append(Text.translatable("skyblocker.config.chat.waypoints.displayed", x, y, z, area))); + if (area != null && !area.isEmpty()) { + area = "| " + area; + feedback.accept(Constants.PREFIX.get().append(Text.translatable("skyblocker.config.chat.waypoints.displayed", x, y, z, area))); + } else { + feedback.accept(Constants.PREFIX.get().append(Text.translatable("skyblocker.config.chat.waypoints.displayed", x, y, z, ""))); + } return Command.SINGLE_SUCCESS; } @@ -86,7 +91,7 @@ public class IndividualWaypoint extends NamedWaypoint { } private static void onTick(MinecraftClient client) { - if (waypoint != null && client.player != null && client.player.squaredDistanceTo(waypoint.centerPos) <= 8) { + if (waypoint != null && client.player != null && client.player.squaredDistanceTo(waypoint.centerPos) <= 36) { waypoint = null; } } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 054b9af1..a0b95f5d 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -525,8 +525,8 @@ "skyblocker.config.chat.chatRules.screen.ruleScreen.sounds.pling": "Pling", "skyblocker.config.chat.chatRules.screen.ruleScreen.sounds.zombie": "Zombie", "skyblocker.config.chat.chatRules.screen.ruleScreen.true": "True", - "skyblocker.config.chat.waypoints.display": "[Click to Display Waypoint]", - "skyblocker.config.chat.waypoints.displayed": "Displayed temporary waypoint at x: %d, y: %d, z: %d | %s", + "skyblocker.config.chat.waypoints.display": "[Click to Display Waypoint at x: %d y: %d z: %d]", + "skyblocker.config.chat.waypoints.displayed": "Displayed temporary waypoint at x: %d y: %d z: %d %s", "skyblocker.config.chat.confirmationPromptHelper": "Chat Confirmation Prompt Helper", "skyblocker.config.chat.confirmationPromptHelper.@Tooltip": "Upon receiving a yes or no prompt in chat, you can click anywhere on the screen within 60 seconds to accept the prompt.\n\nAn example of this is Trevor the Trapper's tasks.", diff --git a/src/main/resources/assets/skyblocker/lang/ru_ru.json b/src/main/resources/assets/skyblocker/lang/ru_ru.json index cc446cdf..6c55529b 100644 --- a/src/main/resources/assets/skyblocker/lang/ru_ru.json +++ b/src/main/resources/assets/skyblocker/lang/ru_ru.json @@ -874,7 +874,8 @@ "skyblocker.config.helpers.itemPrice.enableItemPriceLookup.@Tooltip": "Ищет выбранный предмет на Базаре или Аукционе при нажатии F6.", "skyblocker.config.helpers.itemPrice.itemPriceLookupFailed": "Не удалость найти предмент на Базаре и Аукционе", "skyblocker.config.slayer.highlightMinis.@Tooltip[0]": "\nВыключено: Не подсвечивать Slayer мини боссов.", - "skyblocker.config.chat.waypoints.display": "[Показывать метки]", + "skyblocker.config.chat.waypoints.display": "[Показывать метки по координатам x: %d y: %d z: %d]", + "skyblocker.config.chat.waypoints.displayed": "Отображена временная метка по координатам x: %d y: %d z: %d %s", "skyblocker.config.eventNotifications.@Tooltip[1]": "Порядок не важен. Если хотите отключить уведомления, просто очистите список.", "skyblocker.config.quickNav.button.tooltip.@Tooltip": "Подсказка, отображаемая при наведении курсора на кнопку.\n\nВы можете использовать текстовый формат json.\nОтсутствие значения приведет к тому, что подсказка не будет отображаться.", "skyblocker.config.debug.debugWebSockets": "Включить Отладочные Сообщения Websocket", |
