From d98ce0037d8d720f62e53a3c7e9c321801b0f5cc Mon Sep 17 00:00:00 2001 From: ItsNature Date: Wed, 20 May 2026 22:00:57 +0200 Subject: [PATCH] Various additions to the Waypoint Module --- .../apollo/module/waypoint/Waypoint.java | 42 +++++ .../module/waypoint/WaypointModule.java | 18 ++ .../module/waypoint/WaypointTextStyle.java | 116 ++++++++++++ .../module/waypoint/WaypointModuleImpl.java | 141 ++++++++++++++- docs/developers/lightweight/protobuf.mdx | 6 +- docs/developers/modules/waypoint.mdx | 171 ++++++++++++++++++ .../api/listener/ApolloPlayerApiListener.java | 1 - .../api/module/WaypointApiExample.java | 28 +++ .../example/command/WaypointCommand.java | 10 +- .../example/module/impl/WaypointExample.java | 2 + .../json/module/WaypointJsonExample.java | 21 +++ .../proto/module/WaypointProtoExample.java | 19 ++ gradle/libs.versions.toml | 2 +- 13 files changed, 562 insertions(+), 15 deletions(-) create mode 100644 api/src/main/java/com/lunarclient/apollo/module/waypoint/WaypointTextStyle.java diff --git a/api/src/main/java/com/lunarclient/apollo/module/waypoint/Waypoint.java b/api/src/main/java/com/lunarclient/apollo/module/waypoint/Waypoint.java index 39c534b3..57a1d4db 100644 --- a/api/src/main/java/com/lunarclient/apollo/module/waypoint/Waypoint.java +++ b/api/src/main/java/com/lunarclient/apollo/module/waypoint/Waypoint.java @@ -27,6 +27,7 @@ import java.awt.Color; import lombok.Builder; import lombok.Getter; +import org.jetbrains.annotations.Nullable; /** * Represents a waypoint which can be shown on the client. @@ -82,4 +83,45 @@ public final class Waypoint { */ boolean hidden; + /** + * Whether the beacon beam for this waypoint is drawn. + * + * @since 1.2.7 + */ + @Builder.Default + boolean showBeam = true; + + /** + * Whether the in-world block outline highlight at the waypoint location is drawn. + * + * @since 1.2.7 + */ + @Builder.Default + boolean highlightBlock = true; + + /** + * Line width of the block highlight outline when {@link #highlightBlock} is enabled. + * + *

Accepts {@code 1.5F} to {@code 7.5F}. Leaving the + * field at its default of {@code 0.0F} is treated as a + * fallback to the player's own configured line width.

+ * + * @since 1.2.7 + */ + @Builder.Default + float highlightBlockLineWidth = 0.0F; + + /** + * Label and HUD text overrides applied to this waypoint. + * + *

Set to a built {@link WaypointTextStyle} to drive the + * client's text rendering from the server; leave {@code null} to + * defer to the Lunar waypoint mod's own settings.

+ * + * @return the text style, or {@code null} when no override is sent + * @since 1.2.7 + */ + @Builder.Default + @Nullable WaypointTextStyle textStyle = null; + } diff --git a/api/src/main/java/com/lunarclient/apollo/module/waypoint/WaypointModule.java b/api/src/main/java/com/lunarclient/apollo/module/waypoint/WaypointModule.java index 176adab5..9b278d1b 100644 --- a/api/src/main/java/com/lunarclient/apollo/module/waypoint/WaypointModule.java +++ b/api/src/main/java/com/lunarclient/apollo/module/waypoint/WaypointModule.java @@ -127,4 +127,22 @@ public boolean isClientNotify() { */ public abstract void resetWaypoints(Recipients recipients); + /** + * Shows a {@link Waypoint} for the {@link Recipients} that was previously hidden. + * + * @param recipients the recipients that are receiving the packet + * @param waypointName the waypoint name + * @since 1.2.7 + */ + public abstract void showWaypoint(Recipients recipients, String waypointName); + + /** + * Hides a {@link Waypoint} for the {@link Recipients} without removing it. + * + * @param recipients the recipients that are receiving the packet + * @param waypointName the waypoint name + * @since 1.2.7 + */ + public abstract void hideWaypoint(Recipients recipients, String waypointName); + } diff --git a/api/src/main/java/com/lunarclient/apollo/module/waypoint/WaypointTextStyle.java b/api/src/main/java/com/lunarclient/apollo/module/waypoint/WaypointTextStyle.java new file mode 100644 index 00000000..f34be6c8 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/waypoint/WaypointTextStyle.java @@ -0,0 +1,116 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2026 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.module.waypoint; + +import lombok.Builder; +import lombok.Getter; + +/** + * Overrides for a waypoint's on-screen label, icons and distance HUD on the Lunar client. + * + * @since 1.2.7 + */ +@Getter +@Builder +public final class WaypointTextStyle { + + /** + * Whether the waypoint label (text and box) is drawn at all. + * + * @since 1.2.7 + */ + @Builder.Default + boolean showText = true; + + /** + * Restricts the waypoint label drawing to when the player is looking roughly toward the waypoint. + * + * @since 1.2.7 + */ + @Builder.Default + boolean onlyShowTextWhenLookingNear = false; + + /** + * Whether the waypoint icons are drawn. + * + * @since 1.2.7 + */ + @Builder.Default + boolean showIcons = false; + + /** + * The waypoint scale applied to the label icon. + * + *

Accepts {@code 0.1F} to {@code 3.0F}

+ * + * @since 1.2.7 + */ + @Builder.Default + float textIconScale = 1.5F; + + /** + * The waypoint scale applied to the main label text. + * + *

Accepts {@code 0.1F} to {@code 2.0F}

+ * + * @since 1.2.7 + */ + @Builder.Default + float labelScale = 1.0F; + + /** + * The waypoint padding of the label background box. + * + *

Accepts {@code 1.0F} to {@code 8.0F}

+ * + * @since 1.2.7 + */ + @Builder.Default + float boxPadding = 4.0F; + + /** + * Whether a border is drawn around the label background box. + * + * @since 1.2.7 + */ + @Builder.Default + boolean boxBorders = true; + + /** + * Whether a shadow is drawn behind the label text. + * + * @since 1.2.7 + */ + @Builder.Default + boolean textShadow = false; + + /** + * Whether the distance from the player to the waypoint is shown next to the label. + * + * @since 1.2.7 + */ + @Builder.Default + boolean showDistance = true; + +} diff --git a/common/src/main/java/com/lunarclient/apollo/module/waypoint/WaypointModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/waypoint/WaypointModuleImpl.java index 608563cc..03844a1f 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/waypoint/WaypointModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/waypoint/WaypointModuleImpl.java @@ -31,8 +31,10 @@ import com.lunarclient.apollo.player.ApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.waypoint.v1.DisplayWaypointMessage; +import com.lunarclient.apollo.waypoint.v1.HideWaypointMessage; import com.lunarclient.apollo.waypoint.v1.RemoveWaypointMessage; import com.lunarclient.apollo.waypoint.v1.ResetWaypointsMessage; +import com.lunarclient.apollo.waypoint.v1.ShowWaypointMessage; import java.awt.Color; import java.lang.reflect.Type; import java.util.Arrays; @@ -43,6 +45,8 @@ import org.spongepowered.configurate.serialize.SerializationException; import org.spongepowered.configurate.serialize.TypeSerializer; +import static com.lunarclient.apollo.util.Ranges.checkRange; + /** * Provides the waypoints module. * @@ -87,6 +91,24 @@ public void resetWaypoints(@NonNull Recipients recipients) { recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); } + @Override + public void showWaypoint(@NonNull Recipients recipients, @NonNull String waypointName) { + ShowWaypointMessage message = ShowWaypointMessage.newBuilder() + .setName(waypointName) + .build(); + + recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + } + + @Override + public void hideWaypoint(@NonNull Recipients recipients, @NonNull String waypointName) { + HideWaypointMessage message = HideWaypointMessage.newBuilder() + .setName(waypointName) + .build(); + + recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + } + private void onPlayerRegister(ApolloRegisterPlayerEvent event) { ApolloPlayer player = event.getPlayer(); List waypoints = this.getOptions().get(player, WaypointModule.DEFAULT_WAYPOINTS); @@ -99,31 +121,74 @@ private void onPlayerRegister(ApolloRegisterPlayerEvent event) { } private DisplayWaypointMessage toProtobuf(Waypoint waypoint) { - return DisplayWaypointMessage.newBuilder() + DisplayWaypointMessage.Builder builder = DisplayWaypointMessage.newBuilder() .setName(waypoint.getName()) .setLocation(NetworkTypes.toProtobuf(waypoint.getLocation())) .setColor(NetworkTypes.toProtobuf(waypoint.getColor())) .setPreventRemoval(waypoint.isPreventRemoval()) .setHidden(waypoint.isHidden()) + .setShowBeam(waypoint.isShowBeam()) + .setHighlightBlock(waypoint.isHighlightBlock()); + + float highlightBlockLineWidth = waypoint.getHighlightBlockLineWidth(); + if (highlightBlockLineWidth != 0.0F) { + builder.setHighlightBlockLineWidth(checkRange(highlightBlockLineWidth, 1.5F, 7.5F, "Waypoint#highlightBlockLineWidth")); + } + + WaypointTextStyle style = waypoint.getTextStyle(); + if (style != null) { + builder.setStyle(this.toProtobuf(style)); + } + + return builder.build(); + } + + private com.lunarclient.apollo.waypoint.v1.WaypointTextStyle toProtobuf(WaypointTextStyle style) { + return com.lunarclient.apollo.waypoint.v1.WaypointTextStyle.newBuilder() + .setShowText(style.isShowText()) + .setOnlyShowTextWhenLookingNear(style.isOnlyShowTextWhenLookingNear()) + .setShowIcons(style.isShowIcons()) + .setTextIconScale(checkRange(style.getTextIconScale(), 0.1F, 3.0F, "WaypointTextStyle#textIconScale")) + .setLabelScale(checkRange(style.getLabelScale(), 0.1F, 2.0F, "WaypointTextStyle#labelScale")) + .setBoxPadding(checkRange(style.getBoxPadding(), 1.0F, 8.0F, "WaypointTextStyle#boxPadding")) + .setBoxBorders(style.isBoxBorders()) + .setTextShadow(style.isTextShadow()) + .setShowDistance(style.isShowDistance()) .build(); } private static final class WaypointSerializer implements TypeSerializer { @Override public Waypoint deserialize(Type type, ConfigurationNode node) throws SerializationException { - return Waypoint.builder() + Waypoint.WaypointBuilder builder = Waypoint.builder() .name(this.virtualNode(node, "name").getString()) .location(ApolloBlockLocation.builder() .world(this.virtualNode(node, "location", "world").getString()) .x(this.virtualNode(node, "location", "x").getInt()) .y(this.virtualNode(node, "location", "y").getInt()) .z(this.virtualNode(node, "location", "z").getInt()) - .build() - ) - .color(Color.decode(this.virtualNode(node, "color").getString("#FFFFFF"))) - .preventRemoval(this.virtualNode(node, "prevent-removal").getBoolean()) - .hidden(this.virtualNode(node, "hidden").getBoolean()) - .build(); + .build()) + .color(Color.decode(node.node("color").getString("#FFFFFF"))) + .preventRemoval(node.node("prevent-removal").getBoolean()) + .hidden(node.node("hidden").getBoolean()); + + if (node.hasChild("show-beam")) { + builder.showBeam(node.node("show-beam").getBoolean(true)); + } + + if (node.hasChild("highlight-block")) { + builder.highlightBlock(node.node("highlight-block").getBoolean(true)); + } + + if (node.hasChild("highlight-block-line-width")) { + builder.highlightBlockLineWidth((float) node.node("highlight-block-line-width").getDouble(4.0D)); + } + + if (node.hasChild("style")) { + builder.textStyle(this.readStyle(node.node("style"))); + } + + return builder.build(); } @Override @@ -141,6 +206,66 @@ public void serialize(Type type, @Nullable Waypoint waypoint, ConfigurationNode node.node("color").set(String.format("#%06X", (0xFFFFFF & waypoint.getColor().getRGB()))); node.node("prevent-removal").set(waypoint.isPreventRemoval()); node.node("hidden").set(waypoint.isHidden()); + node.node("show-beam").set(waypoint.isShowBeam()); + node.node("highlight-block").set(waypoint.isHighlightBlock()); + node.node("highlight-block-line-width").set(waypoint.getHighlightBlockLineWidth()); + + if (waypoint.getTextStyle() != null) { + this.writeStyle(node.node("style"), waypoint.getTextStyle()); + } + } + + private WaypointTextStyle readStyle(ConfigurationNode node) { + WaypointTextStyle.WaypointTextStyleBuilder builder = WaypointTextStyle.builder(); + if (node.hasChild("show-text")) { + builder.showText(node.node("show-text").getBoolean(true)); + } + + if (node.hasChild("only-show-text-when-looking-near")) { + builder.onlyShowTextWhenLookingNear(node.node("only-show-text-when-looking-near").getBoolean(false)); + } + + if (node.hasChild("show-icons")) { + builder.showIcons(node.node("show-icons").getBoolean(false)); + } + + if (node.hasChild("text-icon-scale")) { + builder.textIconScale(node.node("text-icon-scale").getFloat(1.5F)); + } + + if (node.hasChild("label-scale")) { + builder.labelScale(node.node("label-scale").getFloat(1.0F)); + } + + if (node.hasChild("box-padding")) { + builder.boxPadding(node.node("box-padding").getFloat(4.0F)); + } + + if (node.hasChild("box-borders")) { + builder.boxBorders(node.node("box-borders").getBoolean(true)); + } + + if (node.hasChild("text-shadow")) { + builder.textShadow(node.node("text-shadow").getBoolean(false)); + } + + if (node.hasChild("show-distance")) { + builder.showDistance(node.node("show-distance").getBoolean(true)); + } + + return builder.build(); + } + + private void writeStyle(ConfigurationNode node, WaypointTextStyle style) throws SerializationException { + node.node("show-text").set(style.isShowText()); + node.node("only-show-text-when-looking-near").set(style.isOnlyShowTextWhenLookingNear()); + node.node("show-icons").set(style.isShowIcons()); + node.node("text-icon-scale").set(style.getTextIconScale()); + node.node("label-scale").set(style.getLabelScale()); + node.node("box-padding").set(style.getBoxPadding()); + node.node("box-borders").set(style.isBoxBorders()); + node.node("text-shadow").set(style.isTextShadow()); + node.node("show-distance").set(style.isShowDistance()); } private ConfigurationNode virtualNode(ConfigurationNode source, Object... path) throws SerializationException { diff --git a/docs/developers/lightweight/protobuf.mdx b/docs/developers/lightweight/protobuf.mdx index c1129b9d..0d43206e 100644 --- a/docs/developers/lightweight/protobuf.mdx +++ b/docs/developers/lightweight/protobuf.mdx @@ -26,7 +26,7 @@ Available fields for each message, including their types, are available on the B com.lunarclient apollo-protos - 0.1.6 + 0.1.7 ``` @@ -41,7 +41,7 @@ Available fields for each message, including their types, are available on the B } dependencies { - api 'com.lunarclient:apollo-protos:0.1.6' + api 'com.lunarclient:apollo-protos:0.1.7' } ``` @@ -55,7 +55,7 @@ Available fields for each message, including their types, are available on the B } dependencies { - api("com.lunarclient:apollo-protos:0.1.6") + api("com.lunarclient:apollo-protos:0.1.7") } ``` diff --git a/docs/developers/modules/waypoint.mdx b/docs/developers/modules/waypoint.mdx index 6a541b60..d693cd68 100644 --- a/docs/developers/modules/waypoint.mdx +++ b/docs/developers/modules/waypoint.mdx @@ -12,6 +12,9 @@ The waypoint module allows you to interact with the Waypoints mod in Lunar Clien - Supply a custom name for the waypoint. - Control the ability to remove the waypoint. (They will always have the option to disable the waypoint, even if you prevent it from being deleted client-side.) - Control if the waypoint is set to be hidden by default. + - Toggle the beam and the block outline highlight. + - Override the on-screen label, icons, scaling, padding, borders, text shadow and distance HUD per waypoint. + - Show or hide an existing waypoint without removing it. ![Waypoint Module Example](/modules/waypoint/overview.png#center) @@ -57,6 +60,38 @@ public void displayWaypointExample(Player viewer) { } ``` +### Displaying a Waypoint with Text Style + +Attach a `WaypointTextStyle` to override the on-screen label, icons, scaling and distance HUD on a per-waypoint basis. Any field you leave at its default keeps deferring to the player's own Waypoints mod settings — see the [`Waypoint` Options](#waypoint-options) section below for the full list and accepted ranges. + +```java +public void displayWaypointWithTextStyle(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + this.waypointModule.displayWaypoint(apolloPlayer, Waypoint.builder() + .name("POI") + .location(ApolloBlockLocation.builder() + .world("world") + .x(-500) + .y(100) + .z(-500) + .build() + ) + .color(Color.GREEN) + .preventRemoval(false) + .hidden(false) + .textStyle(WaypointTextStyle.builder() + .showIcons(true) + .labelScale(0.5F) + .textIconScale(0.7F) + .build()) + .build() + ); + }); +} +``` + ### Removing a Waypoint ```java @@ -66,6 +101,22 @@ public void removeWaypointExample(Player viewer) { } ``` +### Showing or Hiding an Existing Waypoint + +Use these to toggle visibility of a waypoint already sent to the client, without removing it. + +```java +public void showWaypointExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.waypointModule.showWaypoint(apolloPlayer, "KoTH")); +} + +public void hideWaypointExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.waypointModule.hideWaypoint(apolloPlayer, "KoTH")); +} +``` + ### Resetting all Waypoints ```java @@ -143,6 +194,41 @@ Custom colors can be created from any RGB values using `new Color(int red, int g .hidden(false) ``` +`.showBeam(Boolean)` whether the beacon beam for this waypoint is drawn. Defaults to `true`. + +```java +.showBeam(true) +``` + +`.highlightBlock(Boolean)` whether the in-world block outline highlight at the waypoint location is drawn. Defaults to `true`. + +```java +.highlightBlock(true) +``` + +`.highlightBlockLineWidth(float)` line width of the block highlight outline when `highlightBlock` is enabled. Accepts `1.5F` to `7.5F`. Leaving the field at its default of `0.0F` is treated as a fallback to the player's own configured line width. + +```java +.highlightBlockLineWidth(5.0F) +``` + +`.textStyle(WaypointTextStyle)` overrides for the on-screen label, icons and distance HUD. Leave unset (or `null`) to defer entirely to the player's own Waypoints mod settings. + +```java +.textStyle(WaypointTextStyle.builder() + .showText(true) + .onlyShowTextWhenLookingNear(false) + .showIcons(false) + .textIconScale(1.5F) // 0.1F to 3.0F + .labelScale(1.0F) // 0.1F to 2.0F + .boxPadding(4.0F) // 1.0F to 8.0F + .boxBorders(true) + .textShadow(false) + .showDistance(true) + .build() +) +``` + @@ -171,6 +257,27 @@ public void displayWaypointExample(Player viewer) { } ``` +**Displaying a Waypoint with Text Style** + +```java +public void displayWaypointWithTextStyle(Player viewer) { + DisplayWaypointMessage message = DisplayWaypointMessage.newBuilder() + .setName("POI") + .setLocation(ProtobufUtil.createBlockLocationProto(new Location(viewer.getWorld(), -500, 100, -500))) + .setColor(ProtobufUtil.createColorProto(Color.GREEN)) + .setPreventRemoval(false) + .setHidden(false) + .setStyle(WaypointTextStyle.newBuilder() + .setShowIcons(true) + .setLabelScale(0.5F) + .setTextIconScale(0.7F) + .build()) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + **Removing a Waypoint** ```java @@ -183,6 +290,26 @@ public void removeWaypointExample(Player viewer) { } ``` +**Showing or Hiding an Existing Waypoint** + +```java +public void showWaypointExample(Player viewer) { + ShowWaypointMessage message = ShowWaypointMessage.newBuilder() + .setName("KoTH") + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} + +public void hideWaypointExample(Player viewer) { + HideWaypointMessage message = HideWaypointMessage.newBuilder() + .setName("KoTH") + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + **Resetting all Waypoints** ```java @@ -222,6 +349,30 @@ public void displayWaypointExample(Player viewer) { } ``` +**Displaying a Waypoint with Text Style** + +```java +public void displayWaypointWithTextStyle(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.waypoint.v1.DisplayWaypointMessage"); + message.addProperty("name", "POI"); + message.add("location", JsonUtil.createBlockLocationObject( + new Location(Bukkit.getWorld("world"), -500, 100, -500) + )); + message.add("color", JsonUtil.createColorObject(Color.GREEN)); + message.addProperty("prevent_removal", false); + message.addProperty("hidden", false); + + JsonObject style = new JsonObject(); + style.addProperty("show_icons", true); + style.addProperty("label_scale", 0.5F); + style.addProperty("text_icon_scale", 0.7F); + message.add("style", style); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + **Removing a Waypoint** ```java @@ -234,6 +385,26 @@ public void removeWaypointExample(Player viewer) { } ``` +**Showing or Hiding an Existing Waypoint** + +```java +public void showWaypointExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.waypoint.v1.ShowWaypointMessage"); + message.addProperty("name", "KoTH"); + + JsonPacketUtil.sendPacket(viewer, message); +} + +public void hideWaypointExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.waypoint.v1.HideWaypointMessage"); + message.addProperty("name", "KoTH"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + **Resetting all Waypoints** ```java diff --git a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/listener/ApolloPlayerApiListener.java b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/listener/ApolloPlayerApiListener.java index 58b7d4ed..d0cb1938 100644 --- a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/listener/ApolloPlayerApiListener.java +++ b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/listener/ApolloPlayerApiListener.java @@ -64,7 +64,6 @@ private void onApolloRegister(ApolloRegisterPlayerEvent event) { this.example.getBeamExample().displayBeamExample(player); this.example.getBorderExample().displayBorderExample(player); - this.example.getWaypointExample().displayWaypointExample(player); CooldownExample cooldownExample = this.example.getCooldownExample(); cooldownExample.displayCooldownItemExample(player); diff --git a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/WaypointApiExample.java b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/WaypointApiExample.java index 2e7225c0..7396e9c1 100644 --- a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/WaypointApiExample.java +++ b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/WaypointApiExample.java @@ -28,6 +28,7 @@ import com.lunarclient.apollo.example.module.impl.WaypointExample; import com.lunarclient.apollo.module.waypoint.Waypoint; import com.lunarclient.apollo.module.waypoint.WaypointModule; +import com.lunarclient.apollo.module.waypoint.WaypointTextStyle; import com.lunarclient.apollo.player.ApolloPlayer; import java.awt.Color; import java.util.Optional; @@ -59,6 +60,33 @@ public void displayWaypointExample(Player viewer) { }); } + @Override + public void displayWaypointWithTextStyle(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + this.waypointModule.displayWaypoint(apolloPlayer, Waypoint.builder() + .name("POI") + .location(ApolloBlockLocation.builder() + .world("world") // The world the waypoint should display in + .x(-500) + .y(100) + .z(-500) + .build() + ) + .color(Color.GREEN) + .preventRemoval(false) // If the player can delete the waypoint + .hidden(false) + .textStyle(WaypointTextStyle.builder() + .showIcons(true) + .labelScale(0.5F) + .textIconScale(0.7F) + .build()) + .build() + ); + }); + } + @Override public void removeWaypointExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); diff --git a/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/command/WaypointCommand.java b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/command/WaypointCommand.java index 6970074c..4a24460b 100644 --- a/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/command/WaypointCommand.java +++ b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/command/WaypointCommand.java @@ -43,7 +43,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command Player player = (Player) sender; if (args.length != 1) { - player.sendMessage("Usage: /waypoint "); + player.sendMessage("Usage: /waypoint "); return true; } @@ -56,6 +56,12 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command break; } + case "displaywithstyle": { + waypointExample.displayWaypointWithTextStyle(player); + player.sendMessage("Displaying waypoint with style...."); + break; + } + case "remove": { waypointExample.removeWaypointExample(player); player.sendMessage("Removing waypoint...."); @@ -68,7 +74,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } default: { - player.sendMessage("Usage: /waypoint "); + player.sendMessage("Usage: /waypoint "); break; } } diff --git a/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/module/impl/WaypointExample.java b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/module/impl/WaypointExample.java index 86ae902e..3450ad4f 100644 --- a/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/module/impl/WaypointExample.java +++ b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/module/impl/WaypointExample.java @@ -30,6 +30,8 @@ public abstract class WaypointExample extends ApolloModuleExample { public abstract void displayWaypointExample(Player viewer); + public abstract void displayWaypointWithTextStyle(Player viewer); + public abstract void removeWaypointExample(Player viewer); public abstract void resetWaypointsExample(Player viewer); diff --git a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/WaypointJsonExample.java b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/WaypointJsonExample.java index a0a2f64c..84f46b9b 100644 --- a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/WaypointJsonExample.java +++ b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/WaypointJsonExample.java @@ -49,6 +49,27 @@ public void displayWaypointExample(Player viewer) { JsonPacketUtil.sendPacket(viewer, message); } + @Override + public void displayWaypointWithTextStyle(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.waypoint.v1.DisplayWaypointMessage"); + message.addProperty("name", "POI"); + message.add("location", JsonUtil.createBlockLocationObject( + new Location(Bukkit.getWorld("world"), -500, 100, -500) + )); + message.add("color", JsonUtil.createColorObject(Color.GREEN)); + message.addProperty("prevent_removal", false); + message.addProperty("hidden", false); + + JsonObject style = new JsonObject(); + style.addProperty("show_icons", true); + style.addProperty("label_scale", 0.5F); + style.addProperty("text_icon_scale", 0.7F); + message.add("style", style); + + JsonPacketUtil.sendPacket(viewer, message); + } + @Override public void removeWaypointExample(Player viewer) { JsonObject message = new JsonObject(); diff --git a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/WaypointProtoExample.java b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/WaypointProtoExample.java index af0ad9e7..21918b8c 100644 --- a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/WaypointProtoExample.java +++ b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/WaypointProtoExample.java @@ -29,6 +29,7 @@ import com.lunarclient.apollo.waypoint.v1.DisplayWaypointMessage; import com.lunarclient.apollo.waypoint.v1.RemoveWaypointMessage; import com.lunarclient.apollo.waypoint.v1.ResetWaypointsMessage; +import com.lunarclient.apollo.waypoint.v1.WaypointTextStyle; import java.awt.Color; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -48,6 +49,24 @@ public void displayWaypointExample(Player viewer) { ProtobufPacketUtil.sendPacket(viewer, message); } + @Override + public void displayWaypointWithTextStyle(Player viewer) { + DisplayWaypointMessage message = DisplayWaypointMessage.newBuilder() + .setName("POI") + .setLocation(ProtobufUtil.createBlockLocationProto(new Location(viewer.getWorld(), -500, 100, -500))) + .setColor(ProtobufUtil.createColorProto(Color.GREEN)) + .setPreventRemoval(false) + .setHidden(false) + .setStyle(WaypointTextStyle.newBuilder() + .setShowIcons(true) + .setLabelScale(0.5F) + .setTextIconScale(0.7F) + .build()) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + @Override public void removeWaypointExample(Player viewer) { RemoveWaypointMessage message = RemoveWaypointMessage.newBuilder() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cb68d5c4..f2b33187 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ geantyref = "1.3.11" idea = "1.1.7" jetbrains = "24.0.1" lombok = "1.18.38" -protobuf = "0.1.6" +protobuf = "0.1.7" gson = "2.10.1" shadow = "9.4.1" spotless = "8.4.0"