From 8c5cc006c8a94555ac8ff1ba159465cb6755e6cd Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 26 Jul 2023 13:40:32 +0200 Subject: add support for sendcoords with description --- .../features/commands/SendCoordinatedCommand.kt | 18 +++++++++++++----- .../skyhanni/features/misc/PatcherSendCoordinates.kt | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt index c9055976a..8cc303fcf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt @@ -15,14 +15,22 @@ class SendCoordinatedCommand { val message = packet.message.lowercase() if (message == "/sendcoords") { event.isCanceled = true - val location = LocationUtils.playerLocation() - val x = location.x.toInt() - val y = location.y.toInt() - val z = location.z.toInt() - LorenzUtils.sendMessageToServer("x: $x, y: $y, z: $z") + LorenzUtils.sendMessageToServer(getCoordinates()) + } else if (message.startsWith("/sendcoords ")) { + event.isCanceled = true + val description = message.split(" ").drop(1).joinToString(" ") + LorenzUtils.sendMessageToServer("${getCoordinates()} $description") } } } + private fun getCoordinates(): String { + val location = LocationUtils.playerLocation() + val x = location.x.toInt() + val y = location.y.toInt() + val z = location.z.toInt() + return "x: $x, y: $y, z: $z" + } + } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt index 195f1b06c..520957830 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt @@ -30,11 +30,19 @@ class PatcherSendCoordinates { val message = event.message.removeColor() pattern.matchMatcher(message) { - val playerName = group("playerName").split(" ").last() - val x = group("x").trim().toInt() - val y = group("y").trim().toInt() - val z = group("z").trim().toInt() - patcherBeacon.add(PatcherBeacon(LorenzVec(x, y, z), playerName, System.currentTimeMillis() / 1000)) + var description = group("playerName").split(" ").last() + val x = group("x").toInt() + val y = group("y").toInt() + + val end = group("z") + val z = if (end.contains(" ")) { + val split = end.split(" ") + val extra = split.drop(1).joinToString(" ") + description += " " + extra + + split.first().toInt() + } else end.toInt() + patcherBeacon.add(PatcherBeacon(LorenzVec(x, y, z), description, System.currentTimeMillis() / 1000)) logger.log("got patcher coords and username") } } -- cgit