diff --git a/api/src/bukkit/java/com/lunarclient/apollo/BukkitApollo.java b/api/src/bukkit/java/com/lunarclient/apollo/BukkitApollo.java index 00a61609..441518d7 100644 --- a/api/src/bukkit/java/com/lunarclient/apollo/BukkitApollo.java +++ b/api/src/bukkit/java/com/lunarclient/apollo/BukkitApollo.java @@ -30,12 +30,11 @@ import com.lunarclient.apollo.player.ApolloPlayer; import com.lunarclient.apollo.player.ApolloPlayerManager; import com.lunarclient.apollo.recipients.Recipients; +import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Optional; import java.util.UUID; import java.util.function.Consumer; -import java.util.stream.Collectors; import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -81,11 +80,12 @@ public static void runForPlayer(@NonNull UUID playerUuid, @NonNull Consumer players) { ApolloPlayerManager playerManager = Apollo.getPlayerManager(); - List apolloPlayers = players.stream() - .map(player -> playerManager.getPlayer(player.getUniqueId())) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); + List apolloPlayers = new ArrayList<>(players.size()); + + for (Player player : players) { + playerManager.getPlayer(player.getUniqueId()) + .ifPresent(apolloPlayers::add); + } return Recipients.of(apolloPlayers); } diff --git a/api/src/bungee/java/com/lunarclient/apollo/BungeeApollo.java b/api/src/bungee/java/com/lunarclient/apollo/BungeeApollo.java index 45e35767..88267231 100644 --- a/api/src/bungee/java/com/lunarclient/apollo/BungeeApollo.java +++ b/api/src/bungee/java/com/lunarclient/apollo/BungeeApollo.java @@ -26,12 +26,11 @@ import com.lunarclient.apollo.player.ApolloPlayer; import com.lunarclient.apollo.player.ApolloPlayerManager; import com.lunarclient.apollo.recipients.Recipients; +import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Optional; import java.util.UUID; import java.util.function.Consumer; -import java.util.stream.Collectors; import lombok.NonNull; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -74,11 +73,12 @@ public static void runForPlayer(@NonNull UUID playerUuid, @NonNull Consumer players) { ApolloPlayerManager playerManager = Apollo.getPlayerManager(); - List apolloPlayers = players.stream() - .map(player -> playerManager.getPlayer(player.getUniqueId())) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); + List apolloPlayers = new ArrayList<>(players.size()); + + for (ProxiedPlayer player : players) { + playerManager.getPlayer(player.getUniqueId()) + .ifPresent(apolloPlayers::add); + } return Recipients.of(apolloPlayers); } diff --git a/api/src/folia/java/com/lunarclient/apollo/FoliaApollo.java b/api/src/folia/java/com/lunarclient/apollo/FoliaApollo.java index 8d19ab2e..3eb2f436 100644 --- a/api/src/folia/java/com/lunarclient/apollo/FoliaApollo.java +++ b/api/src/folia/java/com/lunarclient/apollo/FoliaApollo.java @@ -30,12 +30,11 @@ import com.lunarclient.apollo.player.ApolloPlayer; import com.lunarclient.apollo.player.ApolloPlayerManager; import com.lunarclient.apollo.recipients.Recipients; +import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Optional; import java.util.UUID; import java.util.function.Consumer; -import java.util.stream.Collectors; import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -81,11 +80,12 @@ public static void runForPlayer(@NonNull UUID playerUuid, @NonNull Consumer players) { ApolloPlayerManager playerManager = Apollo.getPlayerManager(); - List apolloPlayers = players.stream() - .map(player -> playerManager.getPlayer(player.getUniqueId())) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); + List apolloPlayers = new ArrayList<>(players.size()); + + for (Player player : players) { + playerManager.getPlayer(player.getUniqueId()) + .ifPresent(apolloPlayers::add); + } return Recipients.of(apolloPlayers); } diff --git a/api/src/main/java/com/lunarclient/apollo/event/EventBus.java b/api/src/main/java/com/lunarclient/apollo/event/EventBus.java index 5309fc57..5803227c 100644 --- a/api/src/main/java/com/lunarclient/apollo/event/EventBus.java +++ b/api/src/main/java/com/lunarclient/apollo/event/EventBus.java @@ -26,6 +26,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -96,7 +97,8 @@ public void unregister(@NonNull Object instance) { for (Method method : this.getEventMethods(instance)) { List> listeners = this.events.get(method.getParameterTypes()[0]); if (listeners != null) { - listeners.removeIf(consumer -> consumer instanceof ReflectiveConsumer && ((ReflectiveConsumer) consumer).getInstance() == instance); + listeners.removeIf(consumer -> consumer instanceof ReflectiveConsumer + && ((ReflectiveConsumer) consumer).getInstance() == instance); } } } @@ -127,17 +129,24 @@ public boolean unregister(@NonNull Class event, @NonNull Co @SuppressWarnings("unchecked") public EventResult post(@NonNull T event) { CopyOnWriteArrayList> consumers = this.events.get(event.getClass()); - List throwables = new ArrayList<>(); - if (consumers != null) { - for (Consumer consumer : consumers) { - try { - ((Consumer) consumer).accept(event); - } catch (Throwable throwable) { - throwables.add(throwable); + if (consumers == null || consumers.isEmpty()) { + return new EventResult<>(event, Collections.emptyList()); + } + + List throwables = null; + for (Consumer consumer : consumers) { + try { + ((Consumer) consumer).accept(event); + } catch (Throwable throwable) { + if (throwables == null) { + throwables = new ArrayList<>(); } + + throwables.add(throwable); } } - return new EventResult<>(event, throwables); + + return new EventResult<>(event, throwables == null ? Collections.emptyList() : throwables); } private List getEventMethods(Object instance) { diff --git a/api/src/main/java/com/lunarclient/apollo/mods/Mods.java b/api/src/main/java/com/lunarclient/apollo/mods/Mods.java index 01b90406..344016d6 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/Mods.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/Mods.java @@ -26,6 +26,7 @@ import com.lunarclient.apollo.mods.impl.Mod2dItems; import com.lunarclient.apollo.mods.impl.Mod3dSkins; import com.lunarclient.apollo.mods.impl.ModArmorstatus; +import com.lunarclient.apollo.mods.impl.ModAttackIndicator; import com.lunarclient.apollo.mods.impl.ModAudioSubtitles; import com.lunarclient.apollo.mods.impl.ModAutoTextActions; import com.lunarclient.apollo.mods.impl.ModAutoTextHotkey; @@ -49,6 +50,7 @@ import com.lunarclient.apollo.mods.impl.ModFps; import com.lunarclient.apollo.mods.impl.ModFreelook; import com.lunarclient.apollo.mods.impl.ModGlintColorizer; +import com.lunarclient.apollo.mods.impl.ModGuiScale; import com.lunarclient.apollo.mods.impl.ModHitColor; import com.lunarclient.apollo.mods.impl.ModHitbox; import com.lunarclient.apollo.mods.impl.ModHorseStats; @@ -145,6 +147,7 @@ public final class Mods { ModCoordinates.class, ModDayCounter.class, ModCrosshair.class, + ModAttackIndicator.class, ModPotionEffects.class, ModDirectionHud.class, ModWaypoints.class, @@ -219,9 +222,10 @@ public final class Mods { ModKillSounds.class, ModInventoryMod.class, ModF3Display.class, + ModGuiScale.class, ModRadio.class, - ModUhcOverlay.class, ModSba.class, + ModUhcOverlay.class, ModNeu.class ); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModArmorstatus.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModArmorstatus.java index eaea4670..795eb6b9 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModArmorstatus.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModArmorstatus.java @@ -125,6 +125,40 @@ public final class ModArmorstatus { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption BACKGROUND = SimpleOption.builder() + .node("armorstatus", "background").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption BORDER = SimpleOption.builder() + .node("armorstatus", "border").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final NumberOption BORDER_THICKNESS = NumberOption.number() + .node("armorstatus", "border-thickness").type(TypeToken.get(Float.class)) + .min(0.5F).max(3.0F) + .defaultValue(0.5F) + .notifyClient() + .build(); + /** * No documentation available. * @@ -169,6 +203,28 @@ public final class ModArmorstatus { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption BACKGROUND_COLOR = SimpleOption.builder() + .node("armorstatus", "background-color").type(TypeToken.get(Color.class)) + .defaultValue(new Color(0, 0, 0, 111)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("armorstatus", "border-color").type(TypeToken.get(Color.class)) + .defaultValue(new Color(0, 0, 0, 159)) + .notifyClient() + .build(); + /** * No documentation available. * diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModAttackIndicator.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModAttackIndicator.java new file mode 100644 index 00000000..876e47f1 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModAttackIndicator.java @@ -0,0 +1,389 @@ +/* + * 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.mods.impl; + +import com.lunarclient.apollo.option.NumberOption; +import com.lunarclient.apollo.option.SimpleOption; +import io.leangen.geantyref.TypeToken; +import java.awt.Color; + +/** + * Allows you to customize the crosshair attack indicator. + * + * @since 1.2.8 + */ +public final class ModAttackIndicator { + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption ENABLED = SimpleOption.builder() + .node("attack-indicator", "enabled").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption HORIZONTAL = SimpleOption.builder() + .node("attack-indicator", "horizontal").type(TypeToken.get(Boolean.class)) + .defaultValue(true) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final NumberOption SCALE = NumberOption.number() + .node("attack-indicator", "scale").type(TypeToken.get(Float.class)) + .min(0.25F).max(5.0F) + .defaultValue(1.0F) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption SHOW_IN_HUD_EDITOR = SimpleOption.builder() + .node("attack-indicator", "show-in-hud-editor").type(TypeToken.get(Boolean.class)) + .defaultValue(true) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption ALWAYS_SHOW = SimpleOption.builder() + .node("attack-indicator", "always-show").type(TypeToken.get(Boolean.class)) + .defaultValue(true) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption RENDER_ICON = SimpleOption.builder() + .node("attack-indicator", "render-icon").type(TypeToken.get(Boolean.class)) + .defaultValue(true) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption BACKGROUND = SimpleOption.builder() + .node("attack-indicator", "background").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption BACKGROUND_COLOR = SimpleOption.builder() + .node("attack-indicator", "background-color").type(TypeToken.get(Color.class)) + .defaultValue(new Color(0, 0, 0, 111)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption BORDER = SimpleOption.builder() + .node("attack-indicator", "border").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final NumberOption BORDER_THICKNESS = NumberOption.number() + .node("attack-indicator", "border-thickness").type(TypeToken.get(Float.class)) + .min(0.5F).max(3.0F) + .defaultValue(0.5F) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("attack-indicator", "border-color").type(TypeToken.get(Color.class)) + .defaultValue(new Color(0, 0, 0, 159)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption VANILLA_BLENDING = SimpleOption.builder() + .node("attack-indicator", "vanilla-blending").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption DYNAMIC_COLOR = SimpleOption.builder() + .node("attack-indicator", "dynamic-color").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption COLOR_LOW = SimpleOption.builder() + .node("attack-indicator", "color-low").type(TypeToken.get(Color.class)) + .defaultValue(new Color(255, 0, 0)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption COLOR_HIGH = SimpleOption.builder() + .node("attack-indicator", "color-high").type(TypeToken.get(Color.class)) + .defaultValue(new Color(0, 255, 0)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption COLOR = SimpleOption.builder() + .node("attack-indicator", "color").type(TypeToken.get(Color.class)) + .defaultValue(new Color(255, 255, 255)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption SWORDS = SimpleOption.builder() + .node("attack-indicator", "swords").type(TypeToken.get(Boolean.class)) + .defaultValue(true) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption AXES = SimpleOption.builder() + .node("attack-indicator", "axes").type(TypeToken.get(Boolean.class)) + .defaultValue(true) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption PICKAXES = SimpleOption.builder() + .node("attack-indicator", "pickaxes").type(TypeToken.get(Boolean.class)) + .defaultValue(true) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption SHOVEL = SimpleOption.builder() + .node("attack-indicator", "shovel").type(TypeToken.get(Boolean.class)) + .defaultValue(true) + .notifyClient() + .build(); + + /** + * Show the generic attack swing cooldown when switching items (includes hand). + * + * @since 1.2.8 + */ + public static final SimpleOption NON_WEAPONS = SimpleOption.builder() + .comment("Show the generic attack swing cooldown when switching items (includes hand)") + .node("attack-indicator", "non-weapons").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * Play a ding when the weapon cooldowns are done. + * + * @since 1.2.8 + */ + public static final SimpleOption ATTACK_INDICATOR_PLAY_SOUND_VANILLA = SimpleOption.builder() + .comment("Play a ding when the weapon cooldowns are done") + .node("attack-indicator", "attack-indicator-play-sound-vanilla").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption SLEEP = SimpleOption.builder() + .node("attack-indicator", "sleep").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption BLOCK_BREAKING = SimpleOption.builder() + .node("attack-indicator", "block-breaking").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption ENDER_PEARL = SimpleOption.builder() + .node("attack-indicator", "ender-pearl").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption CHORUS_FRUIT = SimpleOption.builder() + .node("attack-indicator", "chorus-fruit").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption BOWS = SimpleOption.builder() + .node("attack-indicator", "bows").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption SHIELDS = SimpleOption.builder() + .node("attack-indicator", "shields").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * Foods & Potions. + * + * @since 1.2.8 + */ + public static final SimpleOption CONSUMABLES = SimpleOption.builder() + .comment("Foods & Potions") + .node("attack-indicator", "consumables").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * Show capacity of storage items (bundles, shulker boxes). + * + * @since 1.2.8 + */ + public static final SimpleOption STORAGE = SimpleOption.builder() + .comment("Show capacity of storage items (bundles, shulker boxes)") + .node("attack-indicator", "storage").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * Play a ding when the cooldowns/indicators are done (excluding Sleep Progress, Block Breaking, Consumables and Storage Items). + * + * @since 1.2.8 + */ + public static final SimpleOption ATTACK_INDICATOR_PLAY_SOUND_CUSTOM = SimpleOption.builder() + .comment("Play a ding when the cooldowns/indicators are done (excluding Sleep Progress, Block Breaking, Consumables and Storage Items)") + .node("attack-indicator", "attack-indicator-play-sound-custom").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + private ModAttackIndicator() { + } + +} diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModCrosshair.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModCrosshair.java index 2895204b..e322cd73 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModCrosshair.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModCrosshair.java @@ -46,6 +46,17 @@ public final class ModCrosshair { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption SHOW_IN_F5 = SimpleOption.builder() + .node("crosshair", "show-in-f5").type(TypeToken.get(Boolean.class)) + .defaultValue(true) + .notifyClient() + .build(); + /** * No documentation available. * diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModGuiScale.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModGuiScale.java new file mode 100644 index 00000000..e1974321 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModGuiScale.java @@ -0,0 +1,75 @@ +/* + * 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.mods.impl; + +import com.lunarclient.apollo.option.NumberOption; +import com.lunarclient.apollo.option.SimpleOption; +import io.leangen.geantyref.TypeToken; + +/** + * Allows you to set a custom GUI scale different from the Minecraft settings. + * + * @since 1.2.8 + */ +public final class ModGuiScale { + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final SimpleOption ENABLED = SimpleOption.builder() + .node("gui-scale", "enabled").type(TypeToken.get(Boolean.class)) + .defaultValue(false) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final NumberOption HOTBAR_SCALE = NumberOption.number() + .node("gui-scale", "hotbar-scale").type(TypeToken.get(Float.class)) + .min(0.25F).max(2.0F) + .defaultValue(1.0F) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.2.8 + */ + public static final NumberOption INVENTORY_SCALE = NumberOption.number() + .node("gui-scale", "inventory-scale").type(TypeToken.get(Integer.class)) + .min(1).max(5) + .defaultValue(2) + .notifyClient() + .build(); + + private ModGuiScale() { + } + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/combat/CombatModule.java b/api/src/main/java/com/lunarclient/apollo/module/combat/CombatModule.java index 76288ec0..01104cd5 100644 --- a/api/src/main/java/com/lunarclient/apollo/module/combat/CombatModule.java +++ b/api/src/main/java/com/lunarclient/apollo/module/combat/CombatModule.java @@ -40,16 +40,55 @@ public final class CombatModule extends ApolloModule { /** * Whether the player gets a hit delay for a missed hit. * + *

Enabling this option may cause compatibility issues with anti-cheats.

+ * * @since 1.0.4 */ public static final SimpleOption DISABLE_MISS_PENALTY = Option.builder() - .comment("Set to 'true' to remove the miss penalty on all versions 1.8 and above, otherwise 'false'.") + .comment( + "Set to 'true' to remove the miss penalty on all versions 1.8 and above, otherwise 'false'.", + "Enabling this option may cause compatibility issues with anti-cheats." + ) .node("disable-miss-penalty").type(TypeToken.get(Boolean.class)) .defaultValue(false).notifyClient().build(); + /** + * Whether the player gets a hit delay for a missed hit while + * targeting a block. Applies to all versions 1.8 and above. + * + *

Enabling this option may cause compatibility issues with anti-cheats.

+ * + * @since 1.2.8 + */ + public static final SimpleOption DISABLE_BLOCK_MISS_PENALTY = Option.builder() + .comment( + "Set to 'true' to remove the miss penalty when targeting a block on all versions 1.8 and above, otherwise 'false'.", + "Enabling this option may cause compatibility issues with anti-cheats." + ) + .node("disable-block-miss-penalty").type(TypeToken.get(Boolean.class)) + .defaultValue(false).notifyClient().build(); + + /** + * Whether the player can dig and use an item at the same time, + * like in 1.7. Applies to all versions 1.8 and above. + * + *

Enabling this option may cause compatibility issues with anti-cheats.

+ * + * @since 1.2.8 + */ + public static final SimpleOption ALLOW_DIG_AND_USE = Option.builder() + .comment( + "Set to 'true' to allow digging and using an item at the same time on all versions 1.8 and above, otherwise 'false'.", + "Enabling this option may cause compatibility issues with anti-cheats." + ) + .node("allow-dig-and-use").type(TypeToken.get(Boolean.class)) + .defaultValue(false).notifyClient().build(); + CombatModule() { this.registerOptions( - CombatModule.DISABLE_MISS_PENALTY + CombatModule.DISABLE_MISS_PENALTY, + CombatModule.DISABLE_BLOCK_MISS_PENALTY, + CombatModule.ALLOW_DIG_AND_USE ); } diff --git a/api/src/main/java/com/lunarclient/apollo/module/marker/Marker.java b/api/src/main/java/com/lunarclient/apollo/module/marker/Marker.java new file mode 100644 index 00000000..1343d512 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/marker/Marker.java @@ -0,0 +1,168 @@ +/* + * 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.marker; + +import com.lunarclient.apollo.common.location.ApolloLocation; +import com.lunarclient.apollo.module.marker.display.MarkerFlag; +import com.lunarclient.apollo.module.marker.target.BlockMarkerTarget; +import com.lunarclient.apollo.module.marker.target.EntityMarkerTarget; +import com.lunarclient.apollo.module.marker.target.ItemMarkerTarget; +import com.lunarclient.apollo.module.marker.target.MarkerTarget; +import com.lunarclient.apollo.module.marker.target.PlayerMarkerTarget; +import java.awt.Color; +import java.time.Duration; +import java.util.UUID; +import lombok.Builder; +import lombok.Getter; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Represents a marker which can be shown on the client. + * + * @since 1.2.8 + */ +@Getter +@Builder +public final class Marker { + + /** + * Returns the marker {@link String} id. + * + * @return the marker id + * @since 1.2.8 + */ + @NotNull String id; + + /** + * Returns the marker {@link ApolloLocation}. + * + * @return the marker location + * @since 1.2.8 + */ + @NotNull ApolloLocation location; + + /** + * Returns the marker owner's {@link UUID}. + * + *

Used to show the owner head.

+ * + * @return the owner uuid + * @since 1.2.8 + */ + @NotNull UUID ownerId; + + /** + * Returns the marker owner's {@link String} name. + * + * @return the owner name + * @since 1.2.8 + */ + @NotNull String ownerName; + + /** + * Returns the {@link MarkerFlag} (icon shape and base color) of this marker. + * + * @return the marker flag + * @since 1.2.8 + */ + @NotNull MarkerFlag flag; + + /** + * Returns the {@link Color} override for this marker's {@link #flag}. + * + *

Leave {@code null} to use the player's own configured color for the + * selected flag.

+ * + * @return the flag color override, or {@code null} to defer to the player's setting + * @since 1.2.8 + */ + @Builder.Default + @Nullable Color color = null; + + /** + * Returns the {@link MarkerTarget} describing what this marker marks. + * + *

Drives the description icon and text shown on the client. One of + * {@link ItemMarkerTarget}, {@link BlockMarkerTarget}, {@link EntityMarkerTarget} + * or {@link PlayerMarkerTarget}.

+ * + * @return the marker target + * @since 1.2.8 + */ + @NotNull MarkerTarget target; + + /** + * Returns the {@link Duration} the marker remains visible. + * + *

Leave {@code null} to defer to the player's configured marker + * duration.

+ * + * @return the duration, or {@code null} to defer to the player's setting + * @since 1.2.8 + */ + @Builder.Default + @Nullable Duration duration = null; + + /** + * Returns whether a popup notification is shown when this marker first appears. + * + * @return whether an in-game notification is shown + * @since 1.2.8 + */ + @Builder.Default + boolean inGameNotification = false; + + /** + * Returns whether a chat message is sent when this marker first appears. + * + * @return whether an in-game chat message is sent + * @since 1.2.8 + */ + @Builder.Default + boolean chatNotify = false; + + /** + * Returns whether the player can middle-click to remove this marker. + * + * @return the middle-click removal state + * @since 1.2.8 + */ + @Builder.Default + boolean middleClickRemove = true; + + /** + * Returns the {@link MarkerStyle} overrides applied to this marker. + * + *

Set to a built {@link MarkerStyle} to drive the marker's appearance + * from the server; leave {@code null} to defer entirely to the player's + * own Markers mod settings.

+ * + * @return the style overrides, or {@code null} when no override is sent + * @since 1.2.8 + */ + @Builder.Default + @Nullable MarkerStyle style = null; + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/marker/MarkerModule.java b/api/src/main/java/com/lunarclient/apollo/module/marker/MarkerModule.java new file mode 100644 index 00000000..54d048ca --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/marker/MarkerModule.java @@ -0,0 +1,75 @@ +/* + * 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.marker; + +import com.lunarclient.apollo.module.ApolloModule; +import com.lunarclient.apollo.module.ModuleDefinition; +import com.lunarclient.apollo.recipients.Recipients; +import org.jetbrains.annotations.ApiStatus; + +/** + * Represents the marker module. + * + * @since 1.2.8 + */ +@ApiStatus.NonExtendable +@ModuleDefinition(id = "marker", name = "Marker") +public abstract class MarkerModule extends ApolloModule { + + /** + * Displays the {@link Marker} to the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param marker the marker + * @since 1.2.8 + */ + public abstract void displayMarker(Recipients recipients, Marker marker); + + /** + * Removes the {@link Marker} from the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param markerId the marker id + * @since 1.2.8 + */ + public abstract void removeMarker(Recipients recipients, String markerId); + + /** + * Removes the {@link Marker} from the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param marker the marker + * @since 1.2.8 + */ + public abstract void removeMarker(Recipients recipients, Marker marker); + + /** + * Resets all {@link Marker}s for the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @since 1.2.8 + */ + public abstract void resetMarkers(Recipients recipients); + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/marker/MarkerStyle.java b/api/src/main/java/com/lunarclient/apollo/module/marker/MarkerStyle.java new file mode 100644 index 00000000..aa96514b --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/marker/MarkerStyle.java @@ -0,0 +1,138 @@ +/* + * 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.marker; + +import com.lunarclient.apollo.module.marker.display.MarkerDescriptionDisplay; +import com.lunarclient.apollo.module.marker.display.MarkerDisplayCondition; +import com.lunarclient.apollo.module.marker.display.MarkerOwnerDisplay; +import lombok.Builder; +import lombok.Getter; +import org.jetbrains.annotations.NotNull; + +/** + * Overrides for a marker's appearance, owner/description display and text on the Lunar client. + * + * @since 1.2.8 + */ +@Getter +@Builder +public final class MarkerStyle { + + /** + * The scale applied to the marker. + * + *

Accepts {@code 0.5F} to {@code 2.0F}.

+ * + * @since 1.2.8 + */ + @Builder.Default + float scale = 1.0F; + + /** + * Whether the marker plays its hover animations. + * + * @since 1.2.8 + */ + @Builder.Default + boolean animateMarkerOnHover = true; + + /** + * Whether the marker uses the compact single-row layout. + * + *

When {@code true}, {@link #ownerDisplay}, {@link #descriptionDisplay} and + * {@link #ownerSuffix} are ignored; the compact layout always uses the owner head, + * description icon and shows no suffix.

+ * + * @since 1.2.8 + */ + @Builder.Default + boolean compactMode = false; + + /** + * Whether a shadow is drawn behind the marker's text. + * + * @since 1.2.8 + */ + @Builder.Default + boolean textShadow = true; + + /** + * The suffix appended after the owner name. + * + *

Set to an empty {@link String} to show no suffix.

+ * + * @since 1.2.8 + */ + @Builder.Default + @NotNull String ownerSuffix = "'s Marker"; + + /** + * How the marker's owner is displayed. + * + * @since 1.2.8 + */ + @Builder.Default + @NotNull MarkerOwnerDisplay ownerDisplay = MarkerOwnerDisplay.HEAD; + + /** + * When the marker's owner is shown. + * + * @since 1.2.8 + */ + @Builder.Default + @NotNull MarkerDisplayCondition showOwner = MarkerDisplayCondition.ALWAYS; + + /** + * When the marker's coordinates are shown. + * + * @since 1.2.8 + */ + @Builder.Default + @NotNull MarkerDisplayCondition showCoordinates = MarkerDisplayCondition.NEVER; + + /** + * When the distance from the player to the marker is shown. + * + * @since 1.2.8 + */ + @Builder.Default + @NotNull MarkerDisplayCondition showDistance = MarkerDisplayCondition.HOVER; + + /** + * When the marker's description (what was marked) is shown. + * + * @since 1.2.8 + */ + @Builder.Default + @NotNull MarkerDisplayCondition showDescription = MarkerDisplayCondition.HOVER; + + /** + * How the marker's description is displayed. + * + * @since 1.2.8 + */ + @Builder.Default + @NotNull MarkerDescriptionDisplay descriptionDisplay = MarkerDescriptionDisplay.ICON; + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/marker/display/MarkerDescriptionDisplay.java b/api/src/main/java/com/lunarclient/apollo/module/marker/display/MarkerDescriptionDisplay.java new file mode 100644 index 00000000..9800bb52 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/marker/display/MarkerDescriptionDisplay.java @@ -0,0 +1,35 @@ +/* + * 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.marker.display; + +/** + * Represents how a marker's description (what was marked) is displayed. + * + * @since 1.2.8 + */ +public enum MarkerDescriptionDisplay { + ICON, + TEXT + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/marker/display/MarkerDisplayCondition.java b/api/src/main/java/com/lunarclient/apollo/module/marker/display/MarkerDisplayCondition.java new file mode 100644 index 00000000..3ea829a0 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/marker/display/MarkerDisplayCondition.java @@ -0,0 +1,36 @@ +/* + * 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.marker.display; + +/** + * Represents when part of a marker (owner, description, coordinates, distance) is shown. + * + * @since 1.2.8 + */ +public enum MarkerDisplayCondition { + NEVER, + HOVER, + ALWAYS + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/marker/display/MarkerFlag.java b/api/src/main/java/com/lunarclient/apollo/module/marker/display/MarkerFlag.java new file mode 100644 index 00000000..44a3ac8d --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/marker/display/MarkerFlag.java @@ -0,0 +1,37 @@ +/* + * 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.marker.display; + +/** + * Represents a marker flag. + * + * @since 1.2.8 + */ +public enum MarkerFlag { + NORMAL, + DANGER, + INFO, + INTEREST + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/marker/display/MarkerOwnerDisplay.java b/api/src/main/java/com/lunarclient/apollo/module/marker/display/MarkerOwnerDisplay.java new file mode 100644 index 00000000..f90c467f --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/marker/display/MarkerOwnerDisplay.java @@ -0,0 +1,35 @@ +/* + * 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.marker.display; + +/** + * Represents how a marker's owner is displayed. + * + * @since 1.2.8 + */ +public enum MarkerOwnerDisplay { + HEAD, + NAME + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/marker/target/BlockMarkerTarget.java b/api/src/main/java/com/lunarclient/apollo/module/marker/target/BlockMarkerTarget.java new file mode 100644 index 00000000..d17234dd --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/marker/target/BlockMarkerTarget.java @@ -0,0 +1,48 @@ +/* + * 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.marker.target; + +import com.lunarclient.apollo.common.icon.ItemStackIcon; +import com.lunarclient.apollo.module.marker.Marker; +import lombok.Builder; +import lombok.Getter; + +/** + * Represents a {@link Marker} that marks a block. + * + * @since 1.2.8 + */ +@Getter +@Builder +public class BlockMarkerTarget extends MarkerTarget { + + /** + * Returns the {@link ItemStackIcon} of the marked block. + * + * @return the item stack icon + * @since 1.2.8 + */ + ItemStackIcon itemStack; + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/marker/target/EntityMarkerTarget.java b/api/src/main/java/com/lunarclient/apollo/module/marker/target/EntityMarkerTarget.java new file mode 100644 index 00000000..bce76c00 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/marker/target/EntityMarkerTarget.java @@ -0,0 +1,47 @@ +/* + * 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.marker.target; + +import com.lunarclient.apollo.module.marker.Marker; +import lombok.Builder; +import lombok.Getter; + +/** + * Represents a {@link Marker} that marks an entity. + * + * @since 1.2.8 + */ +@Getter +@Builder +public class EntityMarkerTarget extends MarkerTarget { + + /** + * Returns the marked entity type's registry name. + * + * @return the entity type registry name, e.g. {@code minecraft:zombie} + * @since 1.2.8 + */ + String entityType; + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/marker/target/ItemMarkerTarget.java b/api/src/main/java/com/lunarclient/apollo/module/marker/target/ItemMarkerTarget.java new file mode 100644 index 00000000..3b1bd20a --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/marker/target/ItemMarkerTarget.java @@ -0,0 +1,48 @@ +/* + * 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.marker.target; + +import com.lunarclient.apollo.common.icon.ItemStackIcon; +import com.lunarclient.apollo.module.marker.Marker; +import lombok.Builder; +import lombok.Getter; + +/** + * Represents a {@link Marker} that marks an item. + * + * @since 1.2.8 + */ +@Getter +@Builder +public class ItemMarkerTarget extends MarkerTarget { + + /** + * Returns the {@link ItemStackIcon} of the marked item. + * + * @return the item stack icon + * @since 1.2.8 + */ + ItemStackIcon itemStack; + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/marker/target/MarkerTarget.java b/api/src/main/java/com/lunarclient/apollo/module/marker/target/MarkerTarget.java new file mode 100644 index 00000000..133e2ef8 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/marker/target/MarkerTarget.java @@ -0,0 +1,39 @@ +/* + * 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.marker.target; + +import com.lunarclient.apollo.module.marker.Marker; + +/** + * The abstract base class for what a {@link Marker} marks, which drives the description icon + * and text shown on the client. + * + *

Use one of {@link ItemMarkerTarget}, {@link BlockMarkerTarget}, {@link EntityMarkerTarget} + * or {@link PlayerMarkerTarget}.

+ * + * @since 1.2.8 + */ +public abstract class MarkerTarget { + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/marker/target/PlayerMarkerTarget.java b/api/src/main/java/com/lunarclient/apollo/module/marker/target/PlayerMarkerTarget.java new file mode 100644 index 00000000..cb069d8e --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/marker/target/PlayerMarkerTarget.java @@ -0,0 +1,56 @@ +/* + * 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.marker.target; + +import com.lunarclient.apollo.module.marker.Marker; +import java.util.UUID; +import lombok.Builder; +import lombok.Getter; + +/** + * Represents a {@link Marker} that marks a player. + * + * @since 1.2.8 + */ +@Getter +@Builder +public class PlayerMarkerTarget extends MarkerTarget { + + /** + * Returns the marked player's {@link UUID}. + * + * @return the player uuid + * @since 1.2.8 + */ + UUID playerId; + + /** + * Returns the marked player's {@link String} name. + * + * @return the player name + * @since 1.2.8 + */ + String playerName; + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/serverlink/ServerLinkModule.java b/api/src/main/java/com/lunarclient/apollo/module/serverlink/ServerLinkModule.java index f3010c97..e319cc42 100644 --- a/api/src/main/java/com/lunarclient/apollo/module/serverlink/ServerLinkModule.java +++ b/api/src/main/java/com/lunarclient/apollo/module/serverlink/ServerLinkModule.java @@ -26,7 +26,12 @@ import com.lunarclient.apollo.common.icon.ResourceLocationIcon; import com.lunarclient.apollo.module.ApolloModule; import com.lunarclient.apollo.module.ModuleDefinition; +import com.lunarclient.apollo.module.serverlink.pausemenu.LegacyServerLinkPlacement; +import com.lunarclient.apollo.module.serverlink.pausemenu.ModernServerLinkPlacement; +import com.lunarclient.apollo.option.EnumOption; +import com.lunarclient.apollo.option.Option; import com.lunarclient.apollo.recipients.Recipients; +import io.leangen.geantyref.TypeToken; import java.util.List; import org.jetbrains.annotations.ApiStatus; @@ -42,6 +47,49 @@ @ModuleDefinition(id = "server_link", name = "Server Link") public abstract class ServerLinkModule extends ApolloModule { + /** + * Controls where the server links button is placed in the pause menu + * (1.7-1.12), where it is added on a new line by default. + * + * @since 1.2.8 + */ + public static final EnumOption LEGACY_BUTTON_PLACEMENT = Option.enumerator() + .comment( + "Where the server links button appears in the pause menu (1.7-1.12), added on a new line by default.", + " 'NEW_ROW' adds a dedicated row.", + " 'REPLACE_ACHIEVEMENTS' reuses the achievements button.", + " 'REPLACE_STATISTICS' reuses the statistics button." + ) + .node("legacy-button-placement").type(TypeToken.get(LegacyServerLinkPlacement.class)) + .defaultValue(LegacyServerLinkPlacement.NEW_ROW).notifyClient().build(); + + /** + * Controls where the server links button is placed in the pause menu + * (1.16.1+), where it replaces the existing report bugs button by default. + * + *

On 1.21 and above the server links button is handled natively and this + * option has no effect.

+ * + * @since 1.2.8 + */ + public static final EnumOption MODERN_BUTTON_PLACEMENT = Option.enumerator() + .comment( + "Where the server links button appears in the pause menu (1.16.1+), replaces the existing report bugs button by default.", + " 'REPLACE_REPORT_BUGS' reuses the report bugs button.", + " 'REPLACE_ACHIEVEMENTS' reuses the advancements button.", + " 'REPLACE_STATISTICS' reuses the statistics button.", + "Has no effect on 1.21+ (handled natively)." + ) + .node("modern-button-placement").type(TypeToken.get(ModernServerLinkPlacement.class)) + .defaultValue(ModernServerLinkPlacement.REPLACE_REPORT_BUGS).notifyClient().build(); + + ServerLinkModule() { + this.registerOptions( + ServerLinkModule.LEGACY_BUTTON_PLACEMENT, + ServerLinkModule.MODERN_BUTTON_PLACEMENT + ); + } + /** * Overrides the server link menu title image for the {@link Recipients}. * diff --git a/api/src/main/java/com/lunarclient/apollo/module/serverlink/pausemenu/LegacyServerLinkPlacement.java b/api/src/main/java/com/lunarclient/apollo/module/serverlink/pausemenu/LegacyServerLinkPlacement.java new file mode 100644 index 00000000..c3e98dc1 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/serverlink/pausemenu/LegacyServerLinkPlacement.java @@ -0,0 +1,56 @@ +/* + * 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.serverlink.pausemenu; + +/** + * Represents where the server links button is placed in the pause menu + * (1.7-1.12), where it is added on a new line by default. + * + * @since 1.2.8 + */ +public enum LegacyServerLinkPlacement { + + /** + * Adds the server links button on a dedicated new row, shifting the + * remaining buttons down. + * + * @since 1.2.8 + */ + NEW_ROW, + + /** + * Replaces the vanilla achievements button with the server links button. + * + * @since 1.2.8 + */ + REPLACE_ACHIEVEMENTS, + + /** + * Replaces the vanilla statistics button with the server links button. + * + * @since 1.2.8 + */ + REPLACE_STATISTICS + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/serverlink/pausemenu/ModernServerLinkPlacement.java b/api/src/main/java/com/lunarclient/apollo/module/serverlink/pausemenu/ModernServerLinkPlacement.java new file mode 100644 index 00000000..4a83bdbc --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/serverlink/pausemenu/ModernServerLinkPlacement.java @@ -0,0 +1,58 @@ +/* + * 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.serverlink.pausemenu; + +/** + * Represents where the server links button is placed in the pause menu + * (1.16.1+), where it replaces the existing report bugs button by default. + * + *

On 1.21 and above the server links button is handled natively and this + * option has no effect.

+ * + * @since 1.2.8 + */ +public enum ModernServerLinkPlacement { + + /** + * Replaces the report bugs button with the server links button. + * + * @since 1.2.8 + */ + REPLACE_REPORT_BUGS, + + /** + * Replaces the vanilla advancements button with the server links button. + * + * @since 1.2.8 + */ + REPLACE_ACHIEVEMENTS, + + /** + * Replaces the vanilla statistics button with the server links button. + * + * @since 1.2.8 + */ + REPLACE_STATISTICS + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModule.java b/api/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModule.java index ed1d9999..75c648d6 100644 --- a/api/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModule.java +++ b/api/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModule.java @@ -47,6 +47,16 @@ public abstract class StaffModModule extends ApolloModule { */ public abstract void enableStaffMods(Recipients recipients, List mods); + /** + * Enables the {@link StaffMod}s for the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param mods the staff mods + * @param enabledByDefault whether the staff mods should be enabled by default on the client + * @since 1.2.8 + */ + public abstract void enableStaffMods(Recipients recipients, List mods, boolean enabledByDefault); + /** * Disables the {@link StaffMod}s from the {@link Recipients}. * @@ -64,6 +74,15 @@ public abstract class StaffModModule extends ApolloModule { */ public abstract void enableAllStaffMods(Recipients recipients); + /** + * Enables all {@link StaffMod}s for the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param enabledByDefault whether the staff mods should be enabled by default on the client + * @since 1.2.8 + */ + public abstract void enableAllStaffMods(Recipients recipients, boolean enabledByDefault); + /** * Disables all {@link StaffMod}s from the {@link Recipients}. * diff --git a/api/src/main/java/com/lunarclient/apollo/option/Option.java b/api/src/main/java/com/lunarclient/apollo/option/Option.java index 24d61baf..f88affef 100644 --- a/api/src/main/java/com/lunarclient/apollo/option/Option.java +++ b/api/src/main/java/com/lunarclient/apollo/option/Option.java @@ -130,6 +130,15 @@ public static > EnumOption.EnumOptionBuilder enumerator() { */ boolean notify; + /** + * Returns the option key. + * + * @return the key string + * @since 1.2.8 + */ + @EqualsAndHashCode.Exclude + String key; + Option(M builder) { this.path = requireNonNull(builder.node, "node"); this.typeToken = requireNonNull(builder.typeToken, "typeToken"); @@ -137,16 +146,8 @@ public static > EnumOption.EnumOptionBuilder enumerator() { this.comment = builder.comment; this.defaultValue = builder.defaultValue; this.notify = builder.notify; - } - /** - * Returns the key as a joined {@link String}. - * - * @return the key string - * @since 1.0.0 - */ - public String getKey() { - return String.join(".", this.getPath()); + this.key = String.join(".", this.path); } @Override diff --git a/api/src/main/java/com/lunarclient/apollo/option/OptionBuilder.java b/api/src/main/java/com/lunarclient/apollo/option/OptionBuilder.java index d1e46378..55770daa 100644 --- a/api/src/main/java/com/lunarclient/apollo/option/OptionBuilder.java +++ b/api/src/main/java/com/lunarclient/apollo/option/OptionBuilder.java @@ -86,6 +86,22 @@ public M comment(@Nullable String comment) { return (M) this; } + /** + * Sets the option comment to the provided lines, joined with a newline, and + * returns this builder. + * + *

Each provided line is rendered as its own comment line in the + * configuration.

+ * + * @param lines the comment lines + * @return this builder + * @since 1.2.8 + */ + public M comment(@NonNull String... lines) { + this.comment = String.join("\n", lines); + return (M) this; + } + /** * Sets the option default value to the provided {@code T} value and * returns this builder. diff --git a/api/src/minestom/java/com/lunarclient/apollo/MinestomApollo.java b/api/src/minestom/java/com/lunarclient/apollo/MinestomApollo.java index 14144d2d..f80c8d60 100644 --- a/api/src/minestom/java/com/lunarclient/apollo/MinestomApollo.java +++ b/api/src/minestom/java/com/lunarclient/apollo/MinestomApollo.java @@ -27,12 +27,11 @@ import com.lunarclient.apollo.player.ApolloPlayer; import com.lunarclient.apollo.player.ApolloPlayerManager; import com.lunarclient.apollo.recipients.Recipients; +import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Optional; import java.util.UUID; import java.util.function.Consumer; -import java.util.stream.Collectors; import lombok.NonNull; import net.minestom.server.entity.Entity; import net.minestom.server.entity.Player; @@ -76,11 +75,12 @@ public static void runForPlayer(@NonNull UUID playerUuid, @NonNull Consumer players) { ApolloPlayerManager playerManager = Apollo.getPlayerManager(); - List apolloPlayers = players.stream() - .map(player -> playerManager.getPlayer(player.getUuid())) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); + List apolloPlayers = new ArrayList<>(players.size()); + + for (Player player : players) { + playerManager.getPlayer(player.getUuid()) + .ifPresent(apolloPlayers::add); + } return Recipients.of(apolloPlayers); } diff --git a/api/src/velocity/java/com/lunarclient/apollo/VelocityApollo.java b/api/src/velocity/java/com/lunarclient/apollo/VelocityApollo.java index f88992ed..dbd1cdad 100644 --- a/api/src/velocity/java/com/lunarclient/apollo/VelocityApollo.java +++ b/api/src/velocity/java/com/lunarclient/apollo/VelocityApollo.java @@ -27,12 +27,11 @@ import com.lunarclient.apollo.player.ApolloPlayerManager; import com.lunarclient.apollo.recipients.Recipients; import com.velocitypowered.api.proxy.Player; +import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Optional; import java.util.UUID; import java.util.function.Consumer; -import java.util.stream.Collectors; import lombok.NonNull; /** @@ -75,11 +74,12 @@ public static void runForPlayer(@NonNull UUID playerUuid, @NonNull Consumer players) { ApolloPlayerManager playerManager = Apollo.getPlayerManager(); - List apolloPlayers = players.stream() - .map(player -> playerManager.getPlayer(player.getUniqueId())) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); + List apolloPlayers = new ArrayList<>(players.size()); + + for (Player player : players) { + playerManager.getPlayer(player.getUniqueId()) + .ifPresent(apolloPlayers::add); + } return Recipients.of(apolloPlayers); } diff --git a/common/src/main/java/com/lunarclient/apollo/module/beam/BeamModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/beam/BeamModuleImpl.java index 7353eb98..ba4c4b38 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/beam/BeamModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/beam/BeamModuleImpl.java @@ -23,11 +23,11 @@ */ package com.lunarclient.apollo.module.beam; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.beam.v1.DisplayBeaconBeamMessage; import com.lunarclient.apollo.beam.v1.RemoveBeaconBeamMessage; import com.lunarclient.apollo.beam.v1.ResetBeaconBeamsMessage; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import lombok.NonNull; @@ -46,7 +46,7 @@ public void displayBeam(@NonNull Recipients recipients, @NonNull Beam beam) { .setColor(NetworkTypes.toProtobuf(beam.getColor())) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -55,7 +55,7 @@ public void removeBeam(@NonNull Recipients recipients, @NonNull String beamId) { .setId(beamId) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -66,7 +66,7 @@ public void removeBeam(@NonNull Recipients recipients, @NonNull Beam beam) { @Override public void resetBeams(@NonNull Recipients recipients) { ResetBeaconBeamsMessage message = ResetBeaconBeamsMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/border/BorderModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/border/BorderModuleImpl.java index d4677ec0..dd6dd6f1 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/border/BorderModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/border/BorderModuleImpl.java @@ -23,11 +23,11 @@ */ package com.lunarclient.apollo.module.border; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.border.v1.DisplayBorderMessage; import com.lunarclient.apollo.border.v1.RemoveBorderMessage; import com.lunarclient.apollo.border.v1.ResetBordersMessage; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import lombok.NonNull; @@ -53,7 +53,7 @@ public void displayBorder(@NonNull Recipients recipients, @NonNull Border border .setDurationTicks(checkPositive(border.getDurationTicks(), "Border#durationTicks")) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -62,7 +62,7 @@ public void removeBorder(@NonNull Recipients recipients, @NonNull String borderI .setId(borderId) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -73,7 +73,7 @@ public void removeBorder(@NonNull Recipients recipients, @NonNull Border border) @Override public void resetBorders(@NonNull Recipients recipients) { ResetBordersMessage message = ResetBordersMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/chat/ChatModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/chat/ChatModuleImpl.java index 2ccedc8f..ae4ee548 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/chat/ChatModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/chat/ChatModuleImpl.java @@ -23,10 +23,10 @@ */ package com.lunarclient.apollo.module.chat; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.chat.v1.DisplayLiveChatMessageMessage; import com.lunarclient.apollo.chat.v1.RemoveLiveChatMessageMessage; import com.lunarclient.apollo.common.ApolloComponent; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import lombok.NonNull; import net.kyori.adventure.text.Component; @@ -45,7 +45,7 @@ public void displayLiveChatMessage(@NonNull Recipients recipients, @NonNull Comp .setMessageId(messageId) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -54,7 +54,7 @@ public void removeLiveChatMessage(@NonNull Recipients recipients, int messageId) .setMessageId(messageId) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/coloredfire/ColoredFireModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/coloredfire/ColoredFireModuleImpl.java index d4227e37..297b2983 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/coloredfire/ColoredFireModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/coloredfire/ColoredFireModuleImpl.java @@ -23,11 +23,11 @@ */ package com.lunarclient.apollo.module.coloredfire; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.coloredfire.v1.OverrideColoredFireMessage; import com.lunarclient.apollo.coloredfire.v1.ResetColoredFireMessage; import com.lunarclient.apollo.coloredfire.v1.ResetColoredFiresMessage; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import java.awt.Color; import java.util.UUID; @@ -47,7 +47,7 @@ public void overrideColoredFire(@NonNull Recipients recipients, @NonNull UUID bu .setColor(NetworkTypes.toProtobuf(color)) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -56,13 +56,13 @@ public void resetColoredFire(@NonNull Recipients recipients, @NonNull UUID burni .setPlayerUuid(NetworkTypes.toProtobuf(burningPlayer)) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetColoredFires(@NonNull Recipients recipients) { ResetColoredFiresMessage message = ResetColoredFiresMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/cooldown/CooldownModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/cooldown/CooldownModuleImpl.java index ede71674..7fcf0632 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/cooldown/CooldownModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/cooldown/CooldownModuleImpl.java @@ -23,11 +23,11 @@ */ package com.lunarclient.apollo.module.cooldown; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.cooldown.v1.DisplayCooldownMessage; import com.lunarclient.apollo.cooldown.v1.RemoveCooldownMessage; import com.lunarclient.apollo.cooldown.v1.ResetCooldownsMessage; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import java.awt.Color; import lombok.NonNull; @@ -52,7 +52,7 @@ public void displayCooldown(@NonNull Recipients recipients, @NonNull Cooldown co } DisplayCooldownMessage message = builder.build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -61,7 +61,7 @@ public void removeCooldown(@NonNull Recipients recipients, @NonNull String coold .setName(cooldownName) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -72,7 +72,7 @@ public void removeCooldown(@NonNull Recipients recipients, @NonNull Cooldown coo @Override public void resetCooldowns(@NonNull Recipients recipients) { ResetCooldownsMessage message = ResetCooldownsMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } private com.lunarclient.apollo.cooldown.v1.CooldownStyle toProtobuf(CooldownStyle style) { diff --git a/common/src/main/java/com/lunarclient/apollo/module/cosmetic/CosmeticModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/cosmetic/CosmeticModuleImpl.java index 23af53d3..e9874170 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/cosmetic/CosmeticModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/cosmetic/CosmeticModuleImpl.java @@ -23,6 +23,7 @@ */ package com.lunarclient.apollo.module.cosmetic; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.common.location.ApolloBlockLocation; import com.lunarclient.apollo.cosmetic.v1.DisplaySprayMessage; import com.lunarclient.apollo.cosmetic.v1.EquipNpcCosmeticsMessage; @@ -39,7 +40,6 @@ import com.lunarclient.apollo.module.cosmetic.options.HatOptions; import com.lunarclient.apollo.module.cosmetic.options.PetOptions; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import java.util.List; import java.util.UUID; @@ -73,7 +73,7 @@ public void equipNpcCosmetics(@NonNull Recipients recipients, @NonNull UUID npcU .setCopyLocalCosmetics(copyLocalCosmetics) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -87,7 +87,7 @@ public void unequipNpcCosmetics(@NonNull Recipients recipients, @NonNull UUID np .addAllCosmeticIds(validatedIds) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -96,7 +96,7 @@ public void resetNpcCosmetics(@NonNull Recipients recipients, @NonNull UUID npcU .setNpcUuid(NetworkTypes.toProtobuf(npcUuid)) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -109,7 +109,7 @@ public void startNpcEmote(@NonNull Recipients recipients, @NonNull UUID npcUuid, .build()) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -118,13 +118,13 @@ public void stopNpcEmote(@NonNull Recipients recipients, @NonNull UUID npcUuid) .setNpcUuid(NetworkTypes.toProtobuf(npcUuid)) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetNpcEmotes(@NonNull Recipients recipients) { ResetNpcEmotesMessage message = ResetNpcEmotesMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -137,7 +137,7 @@ public void displaySpray(@NonNull Recipients recipients, @NonNull Spray spray) { .setDuration(NetworkTypes.toProtobuf(spray.getDuration())) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -146,7 +146,7 @@ public void removeSpray(@NonNull Recipients recipients, int sprayId) { .setSprayId(checkStrictlyPositive(sprayId, "Spray#sprayId")) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -159,13 +159,13 @@ public void removeSpray(@NonNull Recipients recipients, int sprayId, @Nullable A } RemoveSprayMessage message = builder.build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetSprays(@NonNull Recipients recipients) { ResetSpraysMessage message = ResetSpraysMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } private com.lunarclient.apollo.cosmetic.v1.Cosmetic toProtobuf(Cosmetic cosmetic) { diff --git a/common/src/main/java/com/lunarclient/apollo/module/entity/EntityModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/entity/EntityModuleImpl.java index e2f6c3b4..e1f06eb5 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/entity/EntityModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/entity/EntityModuleImpl.java @@ -23,6 +23,7 @@ */ package com.lunarclient.apollo.module.entity; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.common.ApolloEntity; import com.lunarclient.apollo.common.v1.EntityId; import com.lunarclient.apollo.entity.v1.FlipEntityMessage; @@ -30,7 +31,6 @@ import com.lunarclient.apollo.entity.v1.ResetFlipedEntityMessage; import com.lunarclient.apollo.entity.v1.ResetRainbowSheepMessage; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import java.util.List; import java.util.Set; @@ -54,7 +54,7 @@ public void overrideRainbowSheep(@NonNull Recipients recipients, @NonNull List ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -67,7 +67,7 @@ public void resetRainbowSheep(@NonNull Recipients recipients, @NonNull List ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -80,7 +80,7 @@ public void flipEntity(@NonNull Recipients recipients, @NonNull List ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -93,7 +93,7 @@ public void resetFlippedEntity(@NonNull Recipients recipients, @NonNull List ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/glow/GlowModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/glow/GlowModuleImpl.java index 59ccdae0..acbcbe60 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/glow/GlowModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/glow/GlowModuleImpl.java @@ -23,11 +23,11 @@ */ package com.lunarclient.apollo.module.glow; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.glow.v1.OverrideGlowEffectMessage; import com.lunarclient.apollo.glow.v1.ResetGlowEffectMessage; import com.lunarclient.apollo.glow.v1.ResetGlowEffectsMessage; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import java.awt.Color; import java.util.UUID; @@ -56,7 +56,7 @@ public void overrideGlow(@NonNull Recipients recipients, @NonNull UUID glowingPl } OverrideGlowEffectMessage message = builder.build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -65,13 +65,13 @@ public void resetGlow(@NonNull Recipients recipients, @NonNull UUID glowingPlaye .setPlayerUuid(NetworkTypes.toProtobuf(glowingPlayer)) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetGlow(@NonNull Recipients recipients) { ResetGlowEffectsMessage message = ResetGlowEffectsMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/hologram/HologramModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/hologram/HologramModuleImpl.java index 03518c0b..16f40520 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/hologram/HologramModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/hologram/HologramModuleImpl.java @@ -23,12 +23,12 @@ */ package com.lunarclient.apollo.module.hologram; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.common.ApolloComponent; import com.lunarclient.apollo.hologram.v1.DisplayHologramMessage; import com.lunarclient.apollo.hologram.v1.RemoveHologramMessage; import com.lunarclient.apollo.hologram.v1.ResetHologramsMessage; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import java.util.stream.Collectors; import lombok.NonNull; @@ -54,7 +54,7 @@ public void displayHologram(@NonNull Recipients recipients, @NonNull Hologram ho .setShowBackground(hologram.isShowBackground()) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -63,7 +63,7 @@ public void removeHologram(@NonNull Recipients recipients, @NonNull String holog .setId(hologramId) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -74,7 +74,7 @@ public void removeHologram(@NonNull Recipients recipients, @NonNull Hologram hol @Override public void resetHolograms(@NonNull Recipients recipients) { ResetHologramsMessage message = ResetHologramsMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/limb/LimbModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/limb/LimbModuleImpl.java index 6a7e24d7..4e0f364c 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/limb/LimbModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/limb/LimbModuleImpl.java @@ -23,12 +23,12 @@ */ package com.lunarclient.apollo.module.limb; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.limb.v1.HideArmorPiecesMessage; import com.lunarclient.apollo.limb.v1.HideBodyPartMessage; import com.lunarclient.apollo.limb.v1.ResetArmorPiecesMessage; import com.lunarclient.apollo.limb.v1.ResetBodyPartMessage; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import java.util.Collection; import java.util.Set; @@ -54,7 +54,7 @@ public void hideArmorPieces(@NonNull Recipients recipients, @NonNull UUID player .addAllArmorPieces(pieces) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -68,7 +68,7 @@ public void resetArmorPieces(@NonNull Recipients recipients, @NonNull UUID playe .addAllArmorPieces(pieces) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -82,7 +82,7 @@ public void hideBodyParts(@NonNull Recipients recipients, @NonNull UUID playerUu .addAllBodyParts(parts) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -96,7 +96,7 @@ public void resetBodyParts(@NonNull Recipients recipients, @NonNull UUID playerU .addAllBodyParts(parts) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } private com.lunarclient.apollo.limb.v1.ArmorPiece toProtobuf(ArmorPiece armorPiece) { diff --git a/common/src/main/java/com/lunarclient/apollo/module/marker/MarkerModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/marker/MarkerModuleImpl.java new file mode 100644 index 00000000..ccd37cec --- /dev/null +++ b/common/src/main/java/com/lunarclient/apollo/module/marker/MarkerModuleImpl.java @@ -0,0 +1,219 @@ +/* + * 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.marker; + +import com.lunarclient.apollo.ApolloManager; +import com.lunarclient.apollo.marker.v1.BlockTarget; +import com.lunarclient.apollo.marker.v1.DangerMarker; +import com.lunarclient.apollo.marker.v1.DisplayMarkerMessage; +import com.lunarclient.apollo.marker.v1.EntityTarget; +import com.lunarclient.apollo.marker.v1.InfoMarker; +import com.lunarclient.apollo.marker.v1.InterestMarker; +import com.lunarclient.apollo.marker.v1.ItemTarget; +import com.lunarclient.apollo.marker.v1.NormalMarker; +import com.lunarclient.apollo.marker.v1.PlayerTarget; +import com.lunarclient.apollo.marker.v1.RemoveMarkerMessage; +import com.lunarclient.apollo.marker.v1.ResetMarkersMessage; +import com.lunarclient.apollo.module.marker.display.MarkerDescriptionDisplay; +import com.lunarclient.apollo.module.marker.display.MarkerDisplayCondition; +import com.lunarclient.apollo.module.marker.display.MarkerFlag; +import com.lunarclient.apollo.module.marker.display.MarkerOwnerDisplay; +import com.lunarclient.apollo.module.marker.target.BlockMarkerTarget; +import com.lunarclient.apollo.module.marker.target.EntityMarkerTarget; +import com.lunarclient.apollo.module.marker.target.ItemMarkerTarget; +import com.lunarclient.apollo.module.marker.target.MarkerTarget; +import com.lunarclient.apollo.module.marker.target.PlayerMarkerTarget; +import com.lunarclient.apollo.network.NetworkTypes; +import com.lunarclient.apollo.recipients.Recipients; +import java.awt.Color; +import java.time.Duration; +import lombok.NonNull; + +import static com.lunarclient.apollo.util.Ranges.checkRange; + +/** + * Provides the marker module. + * + * @since 1.2.8 + */ +public final class MarkerModuleImpl extends MarkerModule { + + @Override + public void displayMarker(@NonNull Recipients recipients, @NonNull Marker marker) { + DisplayMarkerMessage message = this.toProtobuf(marker); + ApolloManager.getNetworkManager().sendPacket(recipients, message); + } + + @Override + public void removeMarker(@NonNull Recipients recipients, @NonNull String markerId) { + RemoveMarkerMessage message = RemoveMarkerMessage.newBuilder() + .setId(markerId) + .build(); + + ApolloManager.getNetworkManager().sendPacket(recipients, message); + } + + @Override + public void removeMarker(@NonNull Recipients recipients, @NonNull Marker marker) { + this.removeMarker(recipients, marker.getId()); + } + + @Override + public void resetMarkers(@NonNull Recipients recipients) { + ResetMarkersMessage message = ResetMarkersMessage.getDefaultInstance(); + ApolloManager.getNetworkManager().sendPacket(recipients, message); + } + + private DisplayMarkerMessage toProtobuf(Marker marker) { + DisplayMarkerMessage.Builder builder = DisplayMarkerMessage.newBuilder() + .setId(marker.getId()) + .setLocation(NetworkTypes.toProtobuf(marker.getLocation())) + .setOwnerId(NetworkTypes.toProtobuf(marker.getOwnerId())) + .setOwnerName(marker.getOwnerName()) + .setInGameNotification(marker.isInGameNotification()) + .setChatNotify(marker.isChatNotify()) + .setMiddleClickRemove(marker.isMiddleClickRemove()); + + this.applyFlag(builder, marker.getFlag(), marker.getColor()); + builder.setTarget(this.toProtobuf(marker.getTarget())); + + Duration duration = marker.getDuration(); + if (duration != null) { + builder.setDuration(NetworkTypes.toProtobuf(duration)); + } + + MarkerStyle style = marker.getStyle(); + if (style != null) { + builder.setStyle(this.toProtobuf(style)); + } + + return builder.build(); + } + + private void applyFlag(DisplayMarkerMessage.Builder builder, MarkerFlag flag, Color color) { + com.lunarclient.apollo.common.v1.Color protoColor = color == null ? null : NetworkTypes.toProtobuf(color); + com.lunarclient.apollo.marker.v1.MarkerFlag.Builder flagBuilder = com.lunarclient.apollo.marker.v1.MarkerFlag.newBuilder(); + + switch (flag) { + case NORMAL: { + NormalMarker.Builder normal = NormalMarker.newBuilder(); + if (protoColor != null) { + normal.setColor(protoColor); + } + flagBuilder.setNormal(normal.build()); + break; + } + + case DANGER: { + DangerMarker.Builder danger = DangerMarker.newBuilder(); + if (protoColor != null) { + danger.setColor(protoColor); + } + flagBuilder.setDanger(danger.build()); + break; + } + + case INFO: { + InfoMarker.Builder info = InfoMarker.newBuilder(); + if (protoColor != null) { + info.setColor(protoColor); + } + flagBuilder.setInfo(info.build()); + break; + } + + case INTEREST: { + InterestMarker.Builder interest = InterestMarker.newBuilder(); + if (protoColor != null) { + interest.setColor(protoColor); + } + flagBuilder.setInterest(interest.build()); + break; + } + + default: { + throw new IllegalArgumentException("Unknown marker flag: " + flag); + } + } + + builder.setFlag(flagBuilder.build()); + } + + private com.lunarclient.apollo.marker.v1.MarkerTarget toProtobuf(MarkerTarget target) { + com.lunarclient.apollo.marker.v1.MarkerTarget.Builder builder = com.lunarclient.apollo.marker.v1.MarkerTarget.newBuilder(); + + if (target instanceof ItemMarkerTarget) { + builder.setItem(ItemTarget.newBuilder() + .setItemStack(NetworkTypes.toProtobuf(((ItemMarkerTarget) target).getItemStack())) + .build()); + } else if (target instanceof BlockMarkerTarget) { + builder.setBlock(BlockTarget.newBuilder() + .setItemStack(NetworkTypes.toProtobuf(((BlockMarkerTarget) target).getItemStack())) + .build()); + } else if (target instanceof EntityMarkerTarget) { + builder.setEntity(EntityTarget.newBuilder() + .setEntityType(((EntityMarkerTarget) target).getEntityType()) + .build()); + } else if (target instanceof PlayerMarkerTarget) { + PlayerMarkerTarget player = (PlayerMarkerTarget) target; + builder.setPlayer(PlayerTarget.newBuilder() + .setUuid(NetworkTypes.toProtobuf(player.getPlayerId())) + .setName(player.getPlayerName()) + .build()); + } else { + throw new IllegalArgumentException("Unknown marker target type: " + target.getClass().getName()); + } + + return builder.build(); + } + + private com.lunarclient.apollo.marker.v1.MarkerStyle toProtobuf(MarkerStyle style) { + return com.lunarclient.apollo.marker.v1.MarkerStyle.newBuilder() + .setScale(checkRange(style.getScale(), 0.5F, 2.0F, "MarkerStyle#scale")) + .setAnimateMarkerOnHover(style.isAnimateMarkerOnHover()) + .setCompactMode(style.isCompactMode()) + .setTextShadow(style.isTextShadow()) + .setOwnerSuffix(style.getOwnerSuffix()) + .setOwnerDisplay(this.toProtobuf(style.getOwnerDisplay())) + .setShowOwner(this.toProtobuf(style.getShowOwner())) + .setShowCoordinates(this.toProtobuf(style.getShowCoordinates())) + .setShowDistance(this.toProtobuf(style.getShowDistance())) + .setShowDescription(this.toProtobuf(style.getShowDescription())) + .setDescriptionDisplay(this.toProtobuf(style.getDescriptionDisplay())) + .build(); + } + + private com.lunarclient.apollo.marker.v1.MarkerDisplayCondition toProtobuf(MarkerDisplayCondition condition) { + return com.lunarclient.apollo.marker.v1.MarkerDisplayCondition.forNumber(condition.ordinal() + 1); + } + + private com.lunarclient.apollo.marker.v1.MarkerOwnerDisplay toProtobuf(MarkerOwnerDisplay display) { + return com.lunarclient.apollo.marker.v1.MarkerOwnerDisplay.forNumber(display.ordinal() + 1); + } + + private com.lunarclient.apollo.marker.v1.MarkerDescriptionDisplay toProtobuf(MarkerDescriptionDisplay display) { + return com.lunarclient.apollo.marker.v1.MarkerDescriptionDisplay.forNumber(display.ordinal() + 1); + } + +} diff --git a/common/src/main/java/com/lunarclient/apollo/module/nametag/NametagModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/nametag/NametagModuleImpl.java index 9164a402..5254595d 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/nametag/NametagModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/nametag/NametagModuleImpl.java @@ -23,17 +23,16 @@ */ package com.lunarclient.apollo.module.nametag; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.common.ApolloComponent; import com.lunarclient.apollo.nametag.v1.OverrideNametagMessage; import com.lunarclient.apollo.nametag.v1.ResetNametagMessage; import com.lunarclient.apollo.nametag.v1.ResetNametagsMessage; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; -import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; import lombok.NonNull; +import net.kyori.adventure.text.Component; /** * Provides the nametag module. @@ -44,16 +43,14 @@ public final class NametagModuleImpl extends NametagModule { @Override public void overrideNametag(@NonNull Recipients recipients, @NonNull UUID playerUuid, @NonNull Nametag nametag) { - List lines = nametag.getLines().stream() - .map(ApolloComponent::toJson) - .collect(Collectors.toList()); + OverrideNametagMessage.Builder builder = OverrideNametagMessage.newBuilder() + .setPlayerUuid(NetworkTypes.toProtobuf(playerUuid)); - OverrideNametagMessage message = OverrideNametagMessage.newBuilder() - .setPlayerUuid(NetworkTypes.toProtobuf(playerUuid)) - .addAllAdventureJsonLines(lines) - .build(); + for (Component line : nametag.getLines()) { + builder.addAdventureJsonLines(ApolloComponent.toJson(line)); + } - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, builder.build()); } @Override @@ -62,13 +59,13 @@ public void resetNametag(@NonNull Recipients recipients, @NonNull UUID playerUui .setPlayerUuid(NetworkTypes.toProtobuf(playerUuid)) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetNametags(@NonNull Recipients recipients) { ResetNametagsMessage message = ResetNametagsMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/nickhider/NickHiderModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/nickhider/NickHiderModuleImpl.java index 11a2faaa..cab61bd0 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/nickhider/NickHiderModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/nickhider/NickHiderModuleImpl.java @@ -23,9 +23,9 @@ */ package com.lunarclient.apollo.module.nickhider; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.nickhider.v1.OverrideNickHiderMessage; import com.lunarclient.apollo.nickhider.v1.ResetNickHiderMessage; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import lombok.NonNull; @@ -42,13 +42,13 @@ public void overrideNick(@NonNull Recipients recipients, @NonNull String nick) { .setNick(nick) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetNick(@NonNull Recipients recipients) { ResetNickHiderMessage message = ResetNickHiderMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/notification/NotificationModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/notification/NotificationModuleImpl.java index 897b65e0..78688bd7 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/notification/NotificationModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/notification/NotificationModuleImpl.java @@ -23,11 +23,11 @@ */ package com.lunarclient.apollo.module.notification; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.common.ApolloComponent; import com.lunarclient.apollo.network.NetworkTypes; import com.lunarclient.apollo.notification.v1.DisplayNotificationMessage; import com.lunarclient.apollo.notification.v1.ResetNotificationsMessage; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import lombok.NonNull; import net.kyori.adventure.text.Component; @@ -70,13 +70,13 @@ public void displayNotification(@NonNull Recipients recipients, @NonNull Notific } DisplayNotificationMessage message = builder.build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetNotifications(@NonNull Recipients recipients) { ResetNotificationsMessage message = ResetNotificationsMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/paynow/PayNowModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/paynow/PayNowModuleImpl.java index 068c3c72..ae549895 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/paynow/PayNowModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/paynow/PayNowModuleImpl.java @@ -23,8 +23,8 @@ */ package com.lunarclient.apollo.module.paynow; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.paynow.v1.OpenPayNowEmbeddedCheckoutMessage; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import lombok.NonNull; @@ -41,7 +41,7 @@ public void displayPayNowEmbeddedCheckout(@NonNull Recipients recipients, @NonNu .setCheckoutToken(checkoutToken) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/richpresence/RichPresenceModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/richpresence/RichPresenceModuleImpl.java index afb22482..6acd584d 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/richpresence/RichPresenceModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/richpresence/RichPresenceModuleImpl.java @@ -23,7 +23,7 @@ */ package com.lunarclient.apollo.module.richpresence; -import com.lunarclient.apollo.player.AbstractApolloPlayer; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.richpresence.v1.OverrideServerRichPresenceMessage; import com.lunarclient.apollo.richpresence.v1.ResetServerRichPresenceMessage; @@ -73,13 +73,13 @@ public void overrideServerRichPresence(@NonNull Recipients recipients, @NonNull } OverrideServerRichPresenceMessage message = builder.build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetServerRichPresence(@NonNull Recipients recipients) { ResetServerRichPresenceMessage message = ResetServerRichPresenceMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/serverlink/ServerLinkModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/serverlink/ServerLinkModuleImpl.java index 4427a971..ef2b05a4 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/serverlink/ServerLinkModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/serverlink/ServerLinkModuleImpl.java @@ -23,10 +23,10 @@ */ package com.lunarclient.apollo.module.serverlink; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.common.ApolloComponent; import com.lunarclient.apollo.common.icon.ResourceLocationIcon; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.serverlink.v1.AddServerLinkMessage; import com.lunarclient.apollo.serverlink.v1.OverrideServerLinkResourceMessage; @@ -51,13 +51,13 @@ public void overrideServerLinkResource(@NonNull Recipients recipients, @NonNull .setIcon(NetworkTypes.toProtobuf(icon)) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetServerLinkResource(@NonNull Recipients recipients) { ResetServerLinkResourceMessage message = ResetServerLinkResourceMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -75,7 +75,7 @@ public void addServerLink(@NonNull Recipients recipients, @NonNull List ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -94,13 +94,13 @@ public void removeServerLink(@NonNull Recipients recipients, @NonNull List ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetServerLinks(@NonNull Recipients recipients) { ResetServerLinksMessage message = ResetServerLinksMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } private com.lunarclient.apollo.serverlink.v1.ServerLink toProtobuf(ServerLink serverLink) { diff --git a/common/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModuleImpl.java index c9a83db4..6b316755 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModuleImpl.java @@ -23,7 +23,7 @@ */ package com.lunarclient.apollo.module.staffmod; -import com.lunarclient.apollo.player.AbstractApolloPlayer; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.staffmod.v1.DisableStaffModsMessage; import com.lunarclient.apollo.staffmod.v1.EnableStaffModsMessage; @@ -54,15 +54,21 @@ public final class StaffModModuleImpl extends StaffModModule { @Override public void enableStaffMods(@NonNull Recipients recipients, @NonNull List mods) { + this.enableStaffMods(recipients, mods, false); + } + + @Override + public void enableStaffMods(@NonNull Recipients recipients, @NonNull List mods, boolean enabledByDefault) { Set staffModsProto = mods.stream() .map(this::toProtobuf) .collect(Collectors.toSet()); EnableStaffModsMessage message = EnableStaffModsMessage.newBuilder() .addAllStaffMods(staffModsProto) + .setEnabledByDefault(enabledByDefault) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -75,17 +81,27 @@ public void disableStaffMods(@NonNull Recipients recipients, @NonNull List ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void enableAllStaffMods(@NonNull Recipients recipients) { - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(this.enableAllStaffModsMessage)); + ApolloManager.getNetworkManager().sendPacket(recipients, this.enableAllStaffModsMessage); + } + + @Override + public void enableAllStaffMods(@NonNull Recipients recipients, boolean enabledByDefault) { + EnableStaffModsMessage message = EnableStaffModsMessage.newBuilder() + .addAllStaffMods(this.staffMods) + .setEnabledByDefault(enabledByDefault) + .build(); + + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void disableAllStaffMods(@NonNull Recipients recipients) { - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(this.disableAllStaffModsMessage)); + ApolloManager.getNetworkManager().sendPacket(recipients, this.disableAllStaffModsMessage); } private com.lunarclient.apollo.staffmod.v1.StaffMod toProtobuf(StaffMod staffMod) { diff --git a/common/src/main/java/com/lunarclient/apollo/module/stopwatch/StopwatchModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/stopwatch/StopwatchModuleImpl.java index ded30e4b..a57741bf 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/stopwatch/StopwatchModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/stopwatch/StopwatchModuleImpl.java @@ -23,10 +23,10 @@ */ package com.lunarclient.apollo.module.stopwatch; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.common.ApolloComponent; import com.lunarclient.apollo.common.location.HudPosition; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.stopwatch.v1.AddStopwatchMessage; import com.lunarclient.apollo.stopwatch.v1.AddTimerMessage; @@ -54,19 +54,19 @@ public final class StopwatchModuleImpl extends StopwatchModule { @Override public void startStopwatch(@NonNull Recipients recipients) { StartStopwatchMessage message = StartStopwatchMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void stopStopwatch(@NonNull Recipients recipients) { StopStopwatchMessage message = StopStopwatchMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetStopwatch(@NonNull Recipients recipients) { ResetStopwatchMessage message = ResetStopwatchMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -94,7 +94,7 @@ public void addStopwatch(@NonNull Recipients recipients, @NonNull Stopwatch stop } AddStopwatchMessage message = builder.build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -103,7 +103,7 @@ public void removeStopwatch(@NonNull Recipients recipients, @NonNull String id) .setId(id) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -112,7 +112,7 @@ public void startStopwatch(@NonNull Recipients recipients, @NonNull String id) { .setId(id) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -121,7 +121,7 @@ public void stopStopwatch(@NonNull Recipients recipients, @NonNull String id) { .setId(id) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -130,13 +130,13 @@ public void resetStopwatch(@NonNull Recipients recipients, @NonNull String id) { .setId(id) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetStopwatches(@NonNull Recipients recipients) { ResetStopwatchesMessage message = ResetStopwatchesMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -171,7 +171,7 @@ public void addTimer(@NonNull Recipients recipients, @NonNull Timer timer) { } AddTimerMessage message = builder.build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -180,7 +180,7 @@ public void removeTimer(@NonNull Recipients recipients, @NonNull String id) { .setId(id) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -189,7 +189,7 @@ public void startTimer(@NonNull Recipients recipients, @NonNull String id) { .setId(id) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -198,7 +198,7 @@ public void stopTimer(@NonNull Recipients recipients, @NonNull String id) { .setId(id) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -207,13 +207,13 @@ public void resetTimer(@NonNull Recipients recipients, @NonNull String id) { .setId(id) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetTimers(@NonNull Recipients recipients) { ResetTimersMessage message = ResetTimersMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/team/TeamModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/team/TeamModuleImpl.java index 89005d29..bb3ffe50 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/team/TeamModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/team/TeamModuleImpl.java @@ -23,16 +23,15 @@ */ package com.lunarclient.apollo.module.team; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.common.ApolloComponent; import com.lunarclient.apollo.common.location.ApolloLocation; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.team.v1.ResetTeamMembersMessage; import com.lunarclient.apollo.team.v1.UpdateTeamMembersMessage; import java.awt.Color; import java.util.List; -import java.util.stream.Collectors; import lombok.NonNull; import net.kyori.adventure.text.Component; @@ -45,21 +44,19 @@ public final class TeamModuleImpl extends TeamModule { @Override public void updateTeamMembers(@NonNull Recipients recipients, @NonNull List teamMembers) { - List teamMembersProto = teamMembers.stream() - .map(this::toProtobuf) - .collect(Collectors.toList()); + UpdateTeamMembersMessage.Builder builder = UpdateTeamMembersMessage.newBuilder(); - UpdateTeamMembersMessage message = UpdateTeamMembersMessage.newBuilder() - .addAllMembers(teamMembersProto) - .build(); + for (TeamMember teamMember : teamMembers) { + builder.addMembers(this.toProtobuf(teamMember)); + } - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, builder.build()); } @Override public void resetTeamMembers(@NonNull Recipients recipients) { ResetTeamMembersMessage message = ResetTeamMembersMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } private com.lunarclient.apollo.team.v1.TeamMember toProtobuf(TeamMember member) { diff --git a/common/src/main/java/com/lunarclient/apollo/module/tebex/TebexModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/tebex/TebexModuleImpl.java index 2b15fbd5..d4ed6fd7 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/tebex/TebexModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/tebex/TebexModuleImpl.java @@ -23,7 +23,7 @@ */ package com.lunarclient.apollo.module.tebex; -import com.lunarclient.apollo.player.AbstractApolloPlayer; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.tebex.v1.OpenTebexEmbeddedCheckoutMessage; import lombok.NonNull; @@ -50,7 +50,7 @@ public void displayTebexEmbeddedCheckout(@NonNull Recipients recipients, @NonNul } OpenTebexEmbeddedCheckoutMessage message = builder.build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/title/TitleModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/title/TitleModuleImpl.java index 250a99c5..e2be6a7d 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/title/TitleModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/title/TitleModuleImpl.java @@ -23,9 +23,9 @@ */ package com.lunarclient.apollo.module.title; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.common.ApolloComponent; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.title.v1.DisplayTitleMessage; import com.lunarclient.apollo.title.v1.ResetTitlesMessage; @@ -54,13 +54,13 @@ public void displayTitle(@NonNull Recipients recipients, @NonNull Title title) { .setInterpolationRate(checkPositive(title.getInterpolationRate(), "Title#interpolationRate")) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetTitles(@NonNull Recipients recipients) { ResetTitlesMessage message = ResetTitlesMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModuleImpl.java index 2697a60f..40b05231 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModuleImpl.java @@ -23,9 +23,9 @@ */ package com.lunarclient.apollo.module.tntcountdown; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.common.ApolloEntity; import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.tntcountdown.v1.SetTntCountdownMessage; import lombok.NonNull; @@ -51,7 +51,7 @@ public void setTntCountdown(@NonNull Recipients recipients, @NonNull ApolloEntit .setDurationTicks(checkPositive(ticks, "TntCountdown#ticks")) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } diff --git a/common/src/main/java/com/lunarclient/apollo/module/vignette/VignetteModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/vignette/VignetteModuleImpl.java index 71e609a9..c461f322 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/vignette/VignetteModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/vignette/VignetteModuleImpl.java @@ -23,7 +23,7 @@ */ package com.lunarclient.apollo.module.vignette; -import com.lunarclient.apollo.player.AbstractApolloPlayer; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.vignette.v1.DisplayVignetteMessage; import com.lunarclient.apollo.vignette.v1.ResetVignetteMessage; @@ -45,13 +45,13 @@ public void displayVignette(@NonNull Recipients recipients, @NonNull Vignette vi .setOpacity(checkRange(vignette.getOpacity(), 0, 1, "Vignette#opacity")) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override public void resetVignette(@NonNull Recipients recipients) { ResetVignetteMessage message = ResetVignetteMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } } 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 03844a1f..b9ed8e3b 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 @@ -23,11 +23,11 @@ */ package com.lunarclient.apollo.module.waypoint; +import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.common.location.ApolloBlockLocation; import com.lunarclient.apollo.event.player.ApolloRegisterPlayerEvent; import com.lunarclient.apollo.network.NetworkTypes; import com.lunarclient.apollo.option.config.Serializer; -import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.player.ApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.waypoint.v1.DisplayWaypointMessage; @@ -68,7 +68,7 @@ public WaypointModuleImpl() { @Override public void displayWaypoint(@NonNull Recipients recipients, @NonNull Waypoint waypoint) { DisplayWaypointMessage message = this.toProtobuf(waypoint); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -77,7 +77,7 @@ public void removeWaypoint(@NonNull Recipients recipients, @NonNull String waypo .setName(waypointName) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -88,7 +88,7 @@ public void removeWaypoint(@NonNull Recipients recipients, @NonNull Waypoint way @Override public void resetWaypoints(@NonNull Recipients recipients) { ResetWaypointsMessage message = ResetWaypointsMessage.getDefaultInstance(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -97,7 +97,7 @@ public void showWaypoint(@NonNull Recipients recipients, @NonNull String waypoin .setName(waypointName) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } @Override @@ -106,7 +106,7 @@ public void hideWaypoint(@NonNull Recipients recipients, @NonNull String waypoin .setName(waypointName) .build(); - recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + ApolloManager.getNetworkManager().sendPacket(recipients, message); } private void onPlayerRegister(ApolloRegisterPlayerEvent event) { @@ -115,7 +115,7 @@ private void onPlayerRegister(ApolloRegisterPlayerEvent event) { if (waypoints != null) { for (Waypoint waypoint : waypoints) { - ((AbstractApolloPlayer) player).sendPacket(this.toProtobuf(waypoint)); + ApolloManager.getNetworkManager().sendPacket(player, this.toProtobuf(waypoint)); } } } diff --git a/common/src/main/java/com/lunarclient/apollo/network/ApolloNetworkManager.java b/common/src/main/java/com/lunarclient/apollo/network/ApolloNetworkManager.java index ee43fb74..7685665b 100644 --- a/common/src/main/java/com/lunarclient/apollo/network/ApolloNetworkManager.java +++ b/common/src/main/java/com/lunarclient/apollo/network/ApolloNetworkManager.java @@ -24,6 +24,7 @@ package com.lunarclient.apollo.network; import com.google.protobuf.Any; +import com.google.protobuf.Message; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.event.ApolloReceivePacketEvent; @@ -31,6 +32,7 @@ import com.lunarclient.apollo.event.EventBus; import com.lunarclient.apollo.player.AbstractApolloPlayer; import com.lunarclient.apollo.player.ApolloPlayer; +import com.lunarclient.apollo.recipients.Recipients; import java.util.UUID; import lombok.NoArgsConstructor; @@ -62,6 +64,31 @@ public void sendPacket(ApolloPlayer player, Any message) { } } + /** + * Sends the provided message packet to the provided {@link Recipients}. + * + * @param recipients the recipients to send the packet to + * @param message the message to send + * @since 1.2.8 + */ + public void sendPacket(Recipients recipients, Message message) { + Any packet = Any.pack(message); + byte[] data = packet.toByteArray(); + + recipients.forEach(recipient -> { + EventBus.EventResult result = EventBus.getBus() + .post(new ApolloSendPacketEvent((ApolloPlayer) recipient, packet)); + + if (!result.getEvent().isCancelled()) { + ((AbstractApolloPlayer) recipient).sendPacket(data); + } + + for (Throwable throwable : result.getThrowing()) { + throwable.printStackTrace(); + } + }); + } + /** * Receives an {@link Any} message packet from the provided player. * diff --git a/common/src/main/java/com/lunarclient/apollo/network/NetworkOptions.java b/common/src/main/java/com/lunarclient/apollo/network/NetworkOptions.java index e62fe44a..a2c38d19 100644 --- a/common/src/main/java/com/lunarclient/apollo/network/NetworkOptions.java +++ b/common/src/main/java/com/lunarclient/apollo/network/NetworkOptions.java @@ -32,8 +32,7 @@ import com.lunarclient.apollo.module.ApolloModule; import com.lunarclient.apollo.option.Option; import com.lunarclient.apollo.option.Options; -import com.lunarclient.apollo.player.AbstractApolloPlayer; -import com.lunarclient.apollo.player.ApolloPlayer; +import com.lunarclient.apollo.recipients.Recipients; import io.leangen.geantyref.GenericTypeReflector; import java.awt.Color; import java.lang.reflect.AnnotatedParameterizedType; @@ -52,18 +51,18 @@ public final class NetworkOptions { /** - * Send a single option to a single player. + * Send a single option to the provided {@link Recipients}. * - * @param module the module the option belongs to - * @param key the option key - * @param value the option value - * @param players the players to send the option to + * @param module the module the option belongs to + * @param key the option key + * @param value the option value + * @param recipients the recipients to send the option to * @since 1.0.0 */ public static void sendOption(@Nullable ApolloModule module, Option key, Value value, - Iterable players) { + Recipients recipients) { if (!key.isNotify()) { return; } @@ -73,35 +72,31 @@ public static void sendOption(@Nullable ApolloModule module, moduleBuilder.putProperties(key.getKey(), value); modulesBuilder.addConfigurableSettings(moduleBuilder.build()); - for (ApolloPlayer player : players) { - ((AbstractApolloPlayer) player).sendPacket(modulesBuilder.build()); - } + ApolloManager.getNetworkManager().sendPacket(recipients, modulesBuilder.build()); } /** * Sends the provided {@link ApolloModule}s options to the provided - * {@link ApolloPlayer}s. + * {@link Recipients}. * * @param modules the modules to send the options of * @param onlyPresent send only the options that have a present value - * @param players the players to send the module options to + * @param recipients the recipients to send the module options to * @since 1.0.0 */ public static void sendOptions(Iterable modules, boolean onlyPresent, - ApolloPlayer... players) { - for (ApolloPlayer player : players) { - OverrideConfigurableSettingsMessage.Builder modulesBuilder = OverrideConfigurableSettingsMessage.newBuilder(); - - for (ApolloModule module : modules) { - modulesBuilder.addConfigurableSettings(NetworkOptions.moduleWithOptions( - module, - onlyPresent - ).build()); - } + Recipients recipients) { + OverrideConfigurableSettingsMessage.Builder modulesBuilder = OverrideConfigurableSettingsMessage.newBuilder(); - ((AbstractApolloPlayer) player).sendPacket(modulesBuilder.build()); + for (ApolloModule module : modules) { + modulesBuilder.addConfigurableSettings(NetworkOptions.moduleWithOptions( + module, + onlyPresent + ).build()); } + + ApolloManager.getNetworkManager().sendPacket(recipients, modulesBuilder.build()); } /** diff --git a/common/src/main/java/com/lunarclient/apollo/option/OptionsImpl.java b/common/src/main/java/com/lunarclient/apollo/option/OptionsImpl.java index bd20e9eb..1cd5b43b 100644 --- a/common/src/main/java/com/lunarclient/apollo/option/OptionsImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/option/OptionsImpl.java @@ -24,12 +24,12 @@ package com.lunarclient.apollo.option; import com.google.protobuf.Value; -import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.event.EventBus; import com.lunarclient.apollo.event.option.ApolloUpdateOptionEvent; import com.lunarclient.apollo.module.ApolloModule; import com.lunarclient.apollo.network.NetworkOptions; import com.lunarclient.apollo.player.ApolloPlayer; +import com.lunarclient.apollo.recipients.Recipients; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -274,11 +274,9 @@ protected void postPacket(Option option, @Nullable ApolloPlayer player, return; } - Collection players = player == null ? Apollo.getPlayerManager() - .getPlayers() : Collections.singleton(player); - + Recipients recipients = player == null ? Recipients.ofEveryone() : player; Value valueWrapper = NetworkOptions.wrapValue(Value.newBuilder(), option.getTypeToken().getType(), value); - NetworkOptions.sendOption(this.module, option, valueWrapper, players); + NetworkOptions.sendOption(this.module, option, valueWrapper, recipients); } } diff --git a/docs/developers/lightweight/json/packet-util.mdx b/docs/developers/lightweight/json/packet-util.mdx index 0dd5b73e..ee5ec7d0 100644 --- a/docs/developers/lightweight/json/packet-util.mdx +++ b/docs/developers/lightweight/json/packet-util.mdx @@ -15,7 +15,7 @@ To utilize Apollo Modules, first define a list of the modules you want to use: ```java private static final List APOLLO_MODULES = Arrays.asList("auto_text_hotkey", "beam", "border", "chat", "colored_fire", "combat", "cooldown", "entity", "glint", "glow", "hologram", "inventory", "limb", "mod_setting", "nametag", "nick_hider", "notification", "pay_now", "packet_enrichment", - "rich_presence", "saturation", "server_rule", "staff_mod", "stopwatch", "team", "tebex", "title", "tnt_countdown", "transfer", "vignette", "waypoint" + "rich_presence", "saturation", "server_link", "server_rule", "staff_mod", "stopwatch", "team", "tebex", "title", "tnt_countdown", "transfer", "vignette", "waypoint" ); ``` @@ -35,11 +35,15 @@ static { // While using the Apollo plugin this would be equivalent to modifying the config.yml CONFIG_MODULE_PROPERTIES.put("colored_fire", "persist-colors-on-unload", false); CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", false); + CONFIG_MODULE_PROPERTIES.put("combat", "disable-block-miss-penalty", false); + CONFIG_MODULE_PROPERTIES.put("combat", "allow-dig-and-use", false); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-attack.send-packet", false); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-open.send-packet", false); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-close.send-packet", false); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-use-item.send-packet", false); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-use-item-bucket.send-packet", false); + CONFIG_MODULE_PROPERTIES.put("server_link", "legacy-button-placement", "NEW_ROW"); + CONFIG_MODULE_PROPERTIES.put("server_link", "modern-button-placement", "REPLACE_REPORT_BUGS"); CONFIG_MODULE_PROPERTIES.put("server_rule", "competitive-game", false); CONFIG_MODULE_PROPERTIES.put("server_rule", "competitive-commands", Arrays.asList("/server", "/servers", "/hub")); CONFIG_MODULE_PROPERTIES.put("server_rule", "disable-shaders", false); diff --git a/docs/developers/lightweight/protobuf.mdx b/docs/developers/lightweight/protobuf.mdx index d18643bf..f39b9e45 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.8 + 0.2.0 ``` @@ -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.8' + api 'com.lunarclient:apollo-protos:0.2.0' } ``` @@ -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.8") + api("com.lunarclient:apollo-protos:0.2.0") } ``` diff --git a/docs/developers/lightweight/protobuf/packet-util.mdx b/docs/developers/lightweight/protobuf/packet-util.mdx index 7290d308..67e7b9d5 100644 --- a/docs/developers/lightweight/protobuf/packet-util.mdx +++ b/docs/developers/lightweight/protobuf/packet-util.mdx @@ -15,7 +15,7 @@ To utilize Apollo Modules, first define a list of the modules you want to use: ```java private static final List APOLLO_MODULES = Arrays.asList("auto_text_hotkey", "beam", "border", "chat", "colored_fire", "combat", "cooldown", "entity", "glint", "glow", "hologram", "inventory", "limb", "mod_setting", "nametag", "nick_hider", "notification", "pay_now", "packet_enrichment", - "rich_presence", "saturation", "server_rule", "staff_mod", "stopwatch", "team", "tebex", "title", "tnt_countdown", "transfer", "vignette", "waypoint" + "rich_presence", "saturation", "server_link", "server_rule", "staff_mod", "stopwatch", "team", "tebex", "title", "tnt_countdown", "transfer", "vignette", "waypoint" ); ``` @@ -35,11 +35,15 @@ static { // While using the Apollo plugin this would be equivalent to modifying the config.yml CONFIG_MODULE_PROPERTIES.put("colored_fire", "persist-colors-on-unload", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("combat", "disable-block-miss-penalty", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("combat", "allow-dig-and-use", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-attack.send-packet", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-open.send-packet", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-close.send-packet", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-use-item.send-packet", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-use-item-bucket.send-packet", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_link", "legacy-button-placement", Value.newBuilder().setStringValue("NEW_ROW").build()); + CONFIG_MODULE_PROPERTIES.put("server_link", "modern-button-placement", Value.newBuilder().setStringValue("REPLACE_REPORT_BUGS").build()); CONFIG_MODULE_PROPERTIES.put("server_rule", "competitive-game", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("server_rule", "competitive-commands", Value.newBuilder().setListValue( ListValue.newBuilder().addAllValues(Arrays.asList( diff --git a/docs/developers/minestom.mdx b/docs/developers/minestom.mdx index 5b4fd5a0..0cd257ac 100644 --- a/docs/developers/minestom.mdx +++ b/docs/developers/minestom.mdx @@ -52,14 +52,14 @@ Next, add the `apollo-minestom` dependency to your project. ```kotlin filename="build.gradle.kts" dependencies { - implementation("com.lunarclient:apollo-minestom:1.2.7") + implementation("com.lunarclient:apollo-minestom:1.2.8") } ``` ```groovy filename="build.gradle" dependencies { - implementation 'com.lunarclient:apollo-minestom:1.2.7' + implementation 'com.lunarclient:apollo-minestom:1.2.8' } ``` @@ -69,7 +69,7 @@ Next, add the `apollo-minestom` dependency to your project. com.lunarclient apollo-minestom - 1.2.7 + 1.2.8 compile diff --git a/docs/developers/mods/_meta.json b/docs/developers/mods/_meta.json index 6dbb83a5..5729f816 100644 --- a/docs/developers/mods/_meta.json +++ b/docs/developers/mods/_meta.json @@ -2,6 +2,7 @@ "2ditems": "2dItems", "3dskins": "3dSkins", "armorstatus": "Armorstatus", + "attackindicator": "AttackIndicator", "audiosubtitles": "AudioSubtitles", "autotextactions": "AutoTextActions", "autotexthotkey": "AutoTextHotkey", @@ -25,6 +26,7 @@ "fps": "Fps", "freelook": "Freelook", "glintcolorizer": "GlintColorizer", + "guiscale": "GuiScale", "hitbox": "Hitbox", "hitcolor": "HitColor", "horsestats": "HorseStats", diff --git a/docs/developers/mods/armorstatus.mdx b/docs/developers/mods/armorstatus.mdx index 8f186505..d7b8e96f 100644 --- a/docs/developers/mods/armorstatus.mdx +++ b/docs/developers/mods/armorstatus.mdx @@ -66,6 +66,26 @@ public void toggleArmorStatusExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BACKGROUND`__ + - Config Key: `background` + - Values + - Type: `Boolean` + - Default: `false` + +- __`BORDER`__ + - Config Key: `border` + - Values + - Type: `Boolean` + - Default: `false` + +- __`BORDER_THICKNESS`__ + - Config Key: `border-thickness` + - Values + - Type: `Float` + - Default: `0.5F` + - Minimum: `0.5F` + - Maximum: `3.0F` + - __`DAMAGE_OVERLAY`__ - Config Key: `damage-overlay` - Values @@ -90,6 +110,18 @@ public void toggleArmorStatusExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `false` +- __`BACKGROUND_COLOR`__ + - Config Key: `background-color` + - Values + - Type: `String` + - Default: `#6F000000` + +- __`BORDER_COLOR`__ + - Config Key: `border-color` + - Values + - Type: `String` + - Default: `#9F000000` + - __`STATIC_DAMAGE_COLORS`__ - Config Key: `static-damage-colors` - Values diff --git a/docs/developers/mods/attackindicator.mdx b/docs/developers/mods/attackindicator.mdx new file mode 100644 index 00000000..dc4b55af --- /dev/null +++ b/docs/developers/mods/attackindicator.mdx @@ -0,0 +1,212 @@ +# Attack Indicator + +Allows you to customize the crosshair attack indicator + +## Integration + +### How to toggle the mod + +```java +public void toggleAttackIndicatorExample(Player viewer, boolean value) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.modSettingModule.getOptions().set(apolloPlayer, ModAttackIndicator.ENABLED, value)); +} +``` + +## Available options + +- __`ENABLED`__ + - Config Key: `enabled` + - Values + - Type: `Boolean` + - Default: `false` + +- __`HORIZONTAL`__ + - Config Key: `horizontal` + - Values + - Type: `Boolean` + - Default: `true` + +- __`SCALE`__ + - Config Key: `scale` + - Values + - Type: `Float` + - Default: `1.0F` + - Minimum: `0.25F` + - Maximum: `5.0F` + +- __`SHOW_IN_HUD_EDITOR`__ + - Config Key: `show-in-hud-editor` + - Values + - Type: `Boolean` + - Default: `true` + +- __`ALWAYS_SHOW`__ + - Config Key: `always-show` + - Values + - Type: `Boolean` + - Default: `true` + +- __`RENDER_ICON`__ + - Config Key: `render-icon` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BACKGROUND`__ + - Config Key: `background` + - Values + - Type: `Boolean` + - Default: `false` + +- __`BACKGROUND_COLOR`__ + - Config Key: `background-color` + - Values + - Type: `String` + - Default: `#6F000000` + +- __`BORDER`__ + - Config Key: `border` + - Values + - Type: `Boolean` + - Default: `false` + +- __`BORDER_THICKNESS`__ + - Config Key: `border-thickness` + - Values + - Type: `Float` + - Default: `0.5F` + - Minimum: `0.5F` + - Maximum: `3.0F` + +- __`BORDER_COLOR`__ + - Config Key: `border-color` + - Values + - Type: `String` + - Default: `#9F000000` + +- __`VANILLA_BLENDING`__ + - Config Key: `vanilla-blending` + - Values + - Type: `Boolean` + - Default: `false` + +- __`DYNAMIC_COLOR`__ + - Config Key: `dynamic-color` + - Values + - Type: `Boolean` + - Default: `false` + +- __`COLOR_LOW`__ + - Config Key: `color-low` + - Values + - Type: `String` + - Default: `#FFFF0000` + +- __`COLOR_HIGH`__ + - Config Key: `color-high` + - Values + - Type: `String` + - Default: `#FF00FF00` + +- __`COLOR`__ + - Config Key: `color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + +- __`SWORDS`__ + - Config Key: `swords` + - Values + - Type: `Boolean` + - Default: `true` + +- __`AXES`__ + - Config Key: `axes` + - Values + - Type: `Boolean` + - Default: `true` + +- __`PICKAXES`__ + - Config Key: `pickaxes` + - Values + - Type: `Boolean` + - Default: `true` + +- __`SHOVEL`__ + - Config Key: `shovel` + - Values + - Type: `Boolean` + - Default: `true` + +- __`NON_WEAPONS`__ + - Show the generic attack swing cooldown when switching items (includes hand) + - Config Key: `non-weapons` + - Values + - Type: `Boolean` + - Default: `false` + +- __`ATTACK_INDICATOR_PLAY_SOUND_VANILLA`__ + - Play a ding when the weapon cooldowns are done + - Config Key: `attack-indicator-play-sound-vanilla` + - Values + - Type: `Boolean` + - Default: `false` + +- __`SLEEP`__ + - Config Key: `sleep` + - Values + - Type: `Boolean` + - Default: `false` + +- __`BLOCK_BREAKING`__ + - Config Key: `block-breaking` + - Values + - Type: `Boolean` + - Default: `false` + +- __`ENDER_PEARL`__ + - Config Key: `ender-pearl` + - Values + - Type: `Boolean` + - Default: `false` + +- __`CHORUS_FRUIT`__ + - Config Key: `chorus-fruit` + - Values + - Type: `Boolean` + - Default: `false` + +- __`BOWS`__ + - Config Key: `bows` + - Values + - Type: `Boolean` + - Default: `false` + +- __`SHIELDS`__ + - Config Key: `shields` + - Values + - Type: `Boolean` + - Default: `false` + +- __`CONSUMABLES`__ + - Foods & Potions + - Config Key: `consumables` + - Values + - Type: `Boolean` + - Default: `false` + +- __`STORAGE`__ + - Show capacity of storage items (bundles, shulker boxes) + - Config Key: `storage` + - Values + - Type: `Boolean` + - Default: `false` + +- __`ATTACK_INDICATOR_PLAY_SOUND_CUSTOM`__ + - Play a ding when the cooldowns/indicators are done (excluding Sleep Progress, Block Breaking, Consumables and Storage Items) + - Config Key: `attack-indicator-play-sound-custom` + - Values + - Type: `Boolean` + - Default: `false` + diff --git a/docs/developers/mods/crosshair.mdx b/docs/developers/mods/crosshair.mdx index 4f70b5a2..0dd2a9ae 100644 --- a/docs/developers/mods/crosshair.mdx +++ b/docs/developers/mods/crosshair.mdx @@ -21,3 +21,9 @@ public void toggleCrosshairExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `false` +- __`SHOW_IN_F5`__ + - Config Key: `show-in-f5` + - Values + - Type: `Boolean` + - Default: `true` + diff --git a/docs/developers/mods/guiscale.mdx b/docs/developers/mods/guiscale.mdx new file mode 100644 index 00000000..44c7964c --- /dev/null +++ b/docs/developers/mods/guiscale.mdx @@ -0,0 +1,39 @@ +# GUI Scale + +Allows you to set a custom GUI scale different from the Minecraft settings. + +## Integration + +### How to toggle the mod + +```java +public void toggleGUIScaleExample(Player viewer, boolean value) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.modSettingModule.getOptions().set(apolloPlayer, ModGuiScale.ENABLED, value)); +} +``` + +## Available options + +- __`ENABLED`__ + - Config Key: `enabled` + - Values + - Type: `Boolean` + - Default: `false` + +- __`HOTBAR_SCALE`__ + - Config Key: `hotbar-scale` + - Values + - Type: `Float` + - Default: `1.0F` + - Minimum: `0.25F` + - Maximum: `2.0F` + +- __`INVENTORY_SCALE`__ + - Config Key: `inventory-scale` + - Values + - Type: `Integer` + - Default: `2` + - Minimum: `1` + - Maximum: `5` + diff --git a/docs/developers/modules/_meta.json b/docs/developers/modules/_meta.json index 1f3fba9c..182a8a35 100644 --- a/docs/developers/modules/_meta.json +++ b/docs/developers/modules/_meta.json @@ -12,6 +12,7 @@ "hologram": "Hologram", "inventory": "Inventory", "limb": "Limb", + "marker": "Marker", "modsetting": "Mod Setting", "nametag": "Nametag", "nickhider": "Nick Hider", diff --git a/docs/developers/modules/combat.mdx b/docs/developers/modules/combat.mdx index 22803ec5..ea1258ee 100644 --- a/docs/developers/modules/combat.mdx +++ b/docs/developers/modules/combat.mdx @@ -7,6 +7,8 @@ import { Callout, Tab, Tabs } from 'nextra-theme-docs' The combat module allows you to modify certain aspects of combat that are usually handled client-sided. - Adds the ability to disable the miss penalty, on all versions 1.8 and above. +- Adds the ability to disable the miss penalty when targeting a block, on all versions 1.8 and above. +- Adds the ability to dig and use an item at the same time, like in 1.7, on all versions 1.8 and above. ### Sample Code Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. @@ -27,6 +29,22 @@ public void setDisableMissPenalty(boolean value) { } ``` +### Toggle Block Miss Penalty + +```java +public void setDisableBlockMissPenalty(boolean value) { + this.combatModule.getOptions().set(CombatModule.DISABLE_BLOCK_MISS_PENALTY, value); +} +``` + +### Toggle Dig and Use + +```java +public void setAllowDigAndUse(boolean value) { + this.combatModule.getOptions().set(CombatModule.ALLOW_DIG_AND_USE, value); +} +``` + @@ -35,7 +53,7 @@ public void setDisableMissPenalty(boolean value) { **Lightweight Protobuf examples.** See [Lightweight Protobuf](/apollo/developers/lightweight/protobuf) for setup. -### Toggle Miss Penalty +**Toggle Miss Penalty** ```java public void setDisableMissPenalty(boolean value) { @@ -47,6 +65,30 @@ public void setDisableMissPenalty(boolean value) { } ``` +**Toggle Block Miss Penalty** + +```java +public void setDisableBlockMissPenalty(boolean value) { + Map properties = new HashMap<>(); + properties.put("disable-block-miss-penalty", Value.newBuilder().setBoolValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("combat", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + +**Toggle Dig and Use** + +```java +public void setAllowDigAndUse(boolean value) { + Map properties = new HashMap<>(); + properties.put("allow-dig-and-use", Value.newBuilder().setBoolValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("combat", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + @@ -55,7 +97,7 @@ public void setDisableMissPenalty(boolean value) { **Lightweight JSON examples.** See [Lightweight JSON](/apollo/developers/lightweight/json) for setup. -### Toggle Miss Penalty +**Toggle Miss Penalty** ```java public void setDisableMissPenalty(boolean value) { @@ -67,6 +109,30 @@ public void setDisableMissPenalty(boolean value) { } ``` +**Toggle Block Miss Penalty** + +```java +public void setDisableBlockMissPenalty(boolean value) { + Map properties = new HashMap<>(); + properties.put("disable-block-miss-penalty", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("combat", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + +**Toggle Dig and Use** + +```java +public void setAllowDigAndUse(boolean value) { + Map properties = new HashMap<>(); + properties.put("allow-dig-and-use", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("combat", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + @@ -74,7 +140,17 @@ public void setDisableMissPenalty(boolean value) { ## Available options - __`DISABLE_MISS_PENALTY`__ - - Whether the player gets a hit delay for a missed hit. + - Whether the player gets a hit delay for a missed hit. Enabling this option may cause compatibility issues with anti-cheats. + - Values + - Type: `Boolean` + - Default: `false` +- __`DISABLE_BLOCK_MISS_PENALTY`__ + - Whether the player gets a hit delay for a missed hit while targeting a block. Applies to all versions 1.8 and above. Enabling this option may cause compatibility issues with anti-cheats. + - Values + - Type: `Boolean` + - Default: `false` +- __`ALLOW_DIG_AND_USE`__ + - Whether the player can dig and use an item at the same time, like in 1.7. Applies to all versions 1.8 and above. Enabling this option may cause compatibility issues with anti-cheats. - Values - Type: `Boolean` - Default: `false` diff --git a/docs/developers/modules/marker.mdx b/docs/developers/modules/marker.mdx new file mode 100644 index 00000000..de64861a --- /dev/null +++ b/docs/developers/modules/marker.mdx @@ -0,0 +1,688 @@ +import { Callout, Tab, Tabs } from 'nextra-theme-docs' + +# Marker Module + +## Overview + +The marker module allows you to place in-world markers from Lunar Client's Markers mod. + +- Place a marker at any exact location, attributed to any owner. +- Pick the marker flag (Normal, Danger, Info, Interest) and optionally override its color. +- Describe what is marked (an item, block, entity or player) to drive the marker's description icon and text. +- Override the appearance per marker + +![Marker Module Example](/modules/marker/overview.gif#center) + +
+ Create your own custom indicators using the Lunar Client Markers mod. +
+ +## Integration + +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + +### Sample Code + + + + + + +**Apollo API examples.** See [General](/apollo/developers/general) for common patterns and helpers. + + +### Marking a block + +```java +public void displayBlockMarkerExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + Location location = viewer.getLocation(); + + this.markerModule.displayMarker(apolloPlayer, Marker.builder() + .id("loot-chest") + .location(ApolloLocation.builder() + .world(location.getWorld().getName()) + .x(location.getX()) + .y(location.getY()) + .z(location.getZ()) + .build()) + .ownerId(viewer.getUniqueId()) + .ownerName("") + .flag(MarkerFlag.INTEREST) + .target(BlockMarkerTarget.builder() + .itemStack(ItemStackIcon.builder().itemName("minecraft:chest").build()) + .build()) + .duration(Duration.ofSeconds(60)) + .style(MarkerStyle.builder() + .showOwner(MarkerDisplayCondition.NEVER) + .showDescription(MarkerDisplayCondition.ALWAYS) + .build()) + .build() + ); + }); +} +``` + +### Marking a player + +```java +public void displayPlayerMarkerExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + Location location = viewer.getLocation(); + + this.markerModule.displayMarker(apolloPlayer, Marker.builder() + .id("bounty") + .location(ApolloLocation.builder() + .world(location.getWorld().getName()) + .x(location.getX()) + .y(location.getY()) + .z(location.getZ()) + .build()) + .ownerId(viewer.getUniqueId()) + .ownerName(viewer.getName()) + .flag(MarkerFlag.DANGER) + .color(Color.RED) + .target(PlayerMarkerTarget.builder() + .playerId(UUID.fromString("f17627d8-1a97-487b-92ea-c04f413394bd")) + .playerName("ItsNature") + .build()) + .inGameNotification(true) + .style(MarkerStyle.builder() + .showOwner(MarkerDisplayCondition.NEVER) + .showDescription(MarkerDisplayCondition.ALWAYS) + .build()) + .build() + ); + }); +} +``` + +### Marking an item + +```java +public void displayItemMarkerExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + Location location = viewer.getLocation(); + + this.markerModule.displayMarker(apolloPlayer, Marker.builder() + .id("wither-loot") + .location(ApolloLocation.builder() + .world(location.getWorld().getName()) + .x(location.getX()) + .y(location.getY()) + .z(location.getZ()) + .build()) + .ownerId(viewer.getUniqueId()) + .ownerName(viewer.getName()) + .flag(MarkerFlag.INFO) + .target(ItemMarkerTarget.builder() + .itemStack(ItemStackIcon.builder().itemName("minecraft:nether_star").build()) + .build()) + .chatNotify(true) + .style(MarkerStyle.builder() + .showOwner(MarkerDisplayCondition.NEVER) + .showDescription(MarkerDisplayCondition.ALWAYS) + .build()) + .build() + ); + }); +} +``` + +### Marking an entity + +```java +public void displayEntityMarkerExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + Location location = viewer.getLocation(); + + this.markerModule.displayMarker(apolloPlayer, Marker.builder() + .id("tutorial-npc") + .location(ApolloLocation.builder() + .world(location.getWorld().getName()) + .x(location.getX()) + .y(location.getY()) + .z(location.getZ()) + .build()) + .ownerId(UUID.randomUUID()) + .ownerName("Tutorial NPC") + .flag(MarkerFlag.INTEREST) + .target(EntityMarkerTarget.builder() + .entityType("minecraft:villager") + .build()) + .style(MarkerStyle.builder() + .scale(1.3F) + .ownerSuffix("") + .ownerDisplay(MarkerOwnerDisplay.NAME) + .showOwner(MarkerDisplayCondition.HOVER) + .showDistance(MarkerDisplayCondition.NEVER) + .build()) + .build() + ); + }); +} +``` + +### Removing markers + +```java +public void removeMarkersExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + this.markerModule.removeMarker(apolloPlayer, "loot-chest"); + this.markerModule.removeMarker(apolloPlayer, "bounty"); + this.markerModule.removeMarker(apolloPlayer, "wither-loot"); + this.markerModule.removeMarker(apolloPlayer, "tutorial-npc"); + }); +} +``` + +### Resetting all markers + +```java +public void resetMarkersExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.markerModule::resetMarkers); +} +``` + +### `Marker` Options + +`.id(String)` should include a unique identifier for the marker. Re-sending a marker with an existing id updates it in place. + +```java +.id("loot-chest") +``` + +`.location(ApolloLocation)` is the exact location the marker is shown at. See the [locations utilities page](/apollo/developers/utilities/locations) for more. + +```java +.location(ApolloLocation.builder() + .world("world") + .x(0.5D) + .y(64.0D) + .z(0.5D) + .build() +) +``` + +`.ownerId(UUID)` and `.ownerName(String)` set the marker's owner. The owner's head is pulled from the player's tab list; if the owner is the viewing player they are shown as themselves. + +```java +.ownerId(viewer.getUniqueId()) +.ownerName(viewer.getName()) +``` + +`.flag(MarkerFlag)` is required and is the marker's flag, which sets its icon shape and base color. One of `NORMAL`, `DANGER`, `INFO`, `INTEREST`. + +```java +.flag(MarkerFlag.DANGER) +``` + +`.color(java.awt.Color)` overrides the color for the chosen flag. Supports alpha. Leave unset to use the player's own configured color for that flag. See the [colors page](/apollo/developers/utilities/colors) for more. + +```java +.color(Color.RED) +``` + +`.target(MarkerTarget)` is required and describes what is marked, which drives the description icon and text. Use an `ItemMarkerTarget` or `BlockMarkerTarget` (each wrapping an `ItemStackIcon` a block uses its item form), an `EntityMarkerTarget` (entity registry name) or a `PlayerMarkerTarget` (a player UUID + name). + +```java +.target(BlockMarkerTarget.builder() + .itemStack(ItemStackIcon.builder().itemName("minecraft:chest").build()) + .build()) +``` + +`.duration(java.time.Duration)` is how long the marker stays visible. Leave unset to defer to the player's configured marker visible-duration. + +```java +.duration(Duration.ofSeconds(60)) +``` + +`.inGameNotification(boolean)` shows a Lunar pop-up when the marker first appears. Defaults to `false`. + +```java +.inGameNotification(false) +``` + +`.chatNotify(boolean)` posts a chat message when the marker first appears. Defaults to `false`. + +```java +.chatNotify(false) +``` + +`.middleClickRemove(boolean)` lets the player middle-click the marker to remove it. Defaults to `true`. + +```java +.middleClickRemove(true) +``` + +`.style(MarkerStyle)` overrides the marker's appearance and text. Leave unset (or `null`) to defer entirely to the player's own Markers mod settings. + + +When `compactMode` is enabled the marker uses a compact single-row layout, and +`ownerDisplay`, `descriptionDisplay` and `ownerSuffix` are ignored. + + +```java +.style(MarkerStyle.builder() + .scale(1.0F) // 0.5F to 2.0F + .animateMarkerOnHover(true) + .compactMode(false) + .textShadow(true) + .ownerSuffix("'s Marker") // "" hides the suffix + .ownerDisplay(MarkerOwnerDisplay.HEAD) + .showOwner(MarkerDisplayCondition.ALWAYS) + .showCoordinates(MarkerDisplayCondition.NEVER) + .showDistance(MarkerDisplayCondition.HOVER) + .showDescription(MarkerDisplayCondition.HOVER) + .descriptionDisplay(MarkerDescriptionDisplay.ICON) + .build() +) +``` + + + + + + +**Lightweight Protobuf examples.** See [Lightweight Protobuf](/apollo/developers/lightweight/protobuf) for setup. + + + + Make sure the server is sending the world name to the client as shown in the [Player Detection](/apollo/developers/lightweight/protobuf/player-detection) example. + + +**Marking a block** + +```java +public void displayBlockMarkerExample(Player viewer) { + DisplayMarkerMessage message = DisplayMarkerMessage.newBuilder() + .setId("loot-chest") + .setLocation(ProtobufUtil.createLocationProto(viewer.getLocation())) + .setOwnerId(ProtobufUtil.createUuidProto(viewer.getUniqueId())) + .setOwnerName("") + .setFlag(MarkerFlag.newBuilder() + .setInterest(InterestMarker.getDefaultInstance()) + .build()) + .setTarget(MarkerTarget.newBuilder() + .setBlock(BlockTarget.newBuilder() + .setItemStack(ProtobufUtil.createItemStackIconProto("minecraft:chest", 0)) + .build()) + .build()) + .setDuration(ProtobufUtil.createDurationProto(Duration.ofSeconds(60))) + .setStyle(MarkerStyle.newBuilder() + .setScale(1.0F) + .setAnimateMarkerOnHover(true) + .setCompactMode(false) + .setTextShadow(true) + .setOwnerSuffix("'s Marker") + .setOwnerDisplay(MarkerOwnerDisplay.MARKER_OWNER_DISPLAY_HEAD) + .setShowOwner(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowCoordinates(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowDistance(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_HOVER) + .setShowDescription(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_ALWAYS) + .setDescriptionDisplay(MarkerDescriptionDisplay.MARKER_DESCRIPTION_DISPLAY_ICON) + .build()) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +**Marking a player** + +```java +public void displayPlayerMarkerExample(Player viewer) { + DisplayMarkerMessage message = DisplayMarkerMessage.newBuilder() + .setId("bounty") + .setLocation(ProtobufUtil.createLocationProto(viewer.getLocation())) + .setOwnerId(ProtobufUtil.createUuidProto(viewer.getUniqueId())) + .setOwnerName(viewer.getName()) + .setFlag(MarkerFlag.newBuilder() + .setDanger(DangerMarker.newBuilder() + .setColor(ProtobufUtil.createColorProto(Color.RED)) + .build()) + .build()) + .setTarget(MarkerTarget.newBuilder() + .setPlayer(PlayerTarget.newBuilder() + .setUuid(ProtobufUtil.createUuidProto(UUID.fromString("f17627d8-1a97-487b-92ea-c04f413394bd"))) + .setName("ItsNature") + .build()) + .build()) + .setInGameNotification(true) + .setStyle(MarkerStyle.newBuilder() + .setScale(1.0F) + .setAnimateMarkerOnHover(true) + .setCompactMode(false) + .setTextShadow(true) + .setOwnerSuffix("'s Marker") + .setOwnerDisplay(MarkerOwnerDisplay.MARKER_OWNER_DISPLAY_HEAD) + .setShowOwner(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowCoordinates(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowDistance(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_HOVER) + .setShowDescription(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_ALWAYS) + .setDescriptionDisplay(MarkerDescriptionDisplay.MARKER_DESCRIPTION_DISPLAY_ICON) + .build()) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +**Marking an item** + +```java +public void displayItemMarkerExample(Player viewer) { + DisplayMarkerMessage message = DisplayMarkerMessage.newBuilder() + .setId("wither-loot") + .setLocation(ProtobufUtil.createLocationProto(viewer.getLocation())) + .setOwnerId(ProtobufUtil.createUuidProto(viewer.getUniqueId())) + .setOwnerName(viewer.getName()) + .setFlag(MarkerFlag.newBuilder() + .setInfo(InfoMarker.getDefaultInstance()) + .build()) + .setTarget(MarkerTarget.newBuilder() + .setItem(ItemTarget.newBuilder() + .setItemStack(ProtobufUtil.createItemStackIconProto("minecraft:nether_star", 0)) + .build()) + .build()) + .setChatNotify(true) + .setStyle(MarkerStyle.newBuilder() + .setScale(1.0F) + .setAnimateMarkerOnHover(true) + .setCompactMode(false) + .setTextShadow(true) + .setOwnerSuffix("'s Marker") + .setOwnerDisplay(MarkerOwnerDisplay.MARKER_OWNER_DISPLAY_HEAD) + .setShowOwner(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowCoordinates(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowDistance(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_HOVER) + .setShowDescription(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_ALWAYS) + .setDescriptionDisplay(MarkerDescriptionDisplay.MARKER_DESCRIPTION_DISPLAY_ICON) + .build()) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +**Marking an entity** + +```java +public void displayEntityMarkerExample(Player viewer) { + DisplayMarkerMessage message = DisplayMarkerMessage.newBuilder() + .setId("tutorial-npc") + .setLocation(ProtobufUtil.createLocationProto(viewer.getLocation())) + .setOwnerId(ProtobufUtil.createUuidProto(UUID.randomUUID())) + .setOwnerName("Tutorial NPC") + .setFlag(MarkerFlag.newBuilder() + .setInterest(InterestMarker.getDefaultInstance()) + .build()) + .setTarget(MarkerTarget.newBuilder() + .setEntity(EntityTarget.newBuilder() + .setEntityType("minecraft:villager") + .build()) + .build()) + .setStyle(MarkerStyle.newBuilder() + .setScale(1.3F) + .setAnimateMarkerOnHover(true) + .setCompactMode(false) + .setTextShadow(true) + .setOwnerSuffix("") + .setOwnerDisplay(MarkerOwnerDisplay.MARKER_OWNER_DISPLAY_NAME) + .setShowOwner(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_HOVER) + .setShowCoordinates(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowDistance(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowDescription(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_HOVER) + .setDescriptionDisplay(MarkerDescriptionDisplay.MARKER_DESCRIPTION_DISPLAY_ICON) + .build()) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +**Removing markers** + +```java +public void removeMarkersExample(Player viewer) { + List markerIds = Arrays.asList("loot-chest", "bounty", "wither-loot", "tutorial-npc"); + for (String id : markerIds) { + RemoveMarkerMessage message = RemoveMarkerMessage.newBuilder() + .setId(id) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } +} +``` + +**Resetting all markers** + +```java +public void resetMarkersExample(Player viewer) { + ResetMarkersMessage message = ResetMarkersMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + + +**Lightweight JSON examples.** See [Lightweight JSON](/apollo/developers/lightweight/json) for setup. + + + + Make sure the server is sending the world name to the client as shown in the [Player Detection](/apollo/developers/lightweight/json/player-detection) example. + + +**Marking a block** + +```java +public void displayBlockMarkerExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.marker.v1.DisplayMarkerMessage"); + message.addProperty("id", "loot-chest"); + message.add("location", JsonUtil.createLocationObject(viewer.getLocation())); + message.add("owner_id", JsonUtil.createUuidObject(viewer.getUniqueId())); + message.addProperty("owner_name", ""); + + JsonObject flag = new JsonObject(); + flag.add("interest", new JsonObject()); + message.add("flag", flag); + + JsonObject itemStack = new JsonObject(); + itemStack.addProperty("item_name", "minecraft:chest"); + JsonObject block = new JsonObject(); + block.add("item_stack", itemStack); + JsonObject target = new JsonObject(); + target.add("block", block); + message.add("target", target); + + message.addProperty("duration", JsonUtil.createDurationObject(Duration.ofSeconds(60))); + + JsonObject style = new JsonObject(); + style.addProperty("scale", 1.0F); + style.addProperty("animate_marker_on_hover", true); + style.addProperty("compact_mode", false); + style.addProperty("text_shadow", true); + style.addProperty("owner_suffix", "'s Marker"); + style.addProperty("owner_display", "MARKER_OWNER_DISPLAY_HEAD"); + style.addProperty("show_owner", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_coordinates", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_distance", "MARKER_DISPLAY_CONDITION_HOVER"); + style.addProperty("show_description", "MARKER_DISPLAY_CONDITION_ALWAYS"); + style.addProperty("description_display", "MARKER_DESCRIPTION_DISPLAY_ICON"); + message.add("style", style); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +**Marking a player** + +```java +public void displayPlayerMarkerExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.marker.v1.DisplayMarkerMessage"); + message.addProperty("id", "bounty"); + message.add("location", JsonUtil.createLocationObject(viewer.getLocation())); + message.add("owner_id", JsonUtil.createUuidObject(viewer.getUniqueId())); + message.addProperty("owner_name", viewer.getName()); + + JsonObject danger = new JsonObject(); + danger.add("color", JsonUtil.createColorObject(Color.RED)); + JsonObject flag = new JsonObject(); + flag.add("danger", danger); + message.add("flag", flag); + + JsonObject player = new JsonObject(); + player.add("uuid", JsonUtil.createUuidObject(UUID.fromString("f17627d8-1a97-487b-92ea-c04f413394bd"))); + player.addProperty("name", "ItsNature"); + JsonObject target = new JsonObject(); + target.add("player", player); + message.add("target", target); + + message.addProperty("in_game_notification", true); + + JsonObject style = new JsonObject(); + style.addProperty("scale", 1.0F); + style.addProperty("animate_marker_on_hover", true); + style.addProperty("compact_mode", false); + style.addProperty("text_shadow", true); + style.addProperty("owner_suffix", "'s Marker"); + style.addProperty("owner_display", "MARKER_OWNER_DISPLAY_HEAD"); + style.addProperty("show_owner", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_coordinates", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_distance", "MARKER_DISPLAY_CONDITION_HOVER"); + style.addProperty("show_description", "MARKER_DISPLAY_CONDITION_ALWAYS"); + style.addProperty("description_display", "MARKER_DESCRIPTION_DISPLAY_ICON"); + message.add("style", style); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +**Marking an item** + +```java +public void displayItemMarkerExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.marker.v1.DisplayMarkerMessage"); + message.addProperty("id", "wither-loot"); + message.add("location", JsonUtil.createLocationObject(viewer.getLocation())); + message.add("owner_id", JsonUtil.createUuidObject(viewer.getUniqueId())); + message.addProperty("owner_name", viewer.getName()); + + JsonObject flag = new JsonObject(); + flag.add("info", new JsonObject()); + message.add("flag", flag); + + JsonObject itemStack = new JsonObject(); + itemStack.addProperty("item_name", "minecraft:nether_star"); + JsonObject item = new JsonObject(); + item.add("item_stack", itemStack); + JsonObject target = new JsonObject(); + target.add("item", item); + message.add("target", target); + + message.addProperty("chat_notify", true); + + JsonObject style = new JsonObject(); + style.addProperty("scale", 1.0F); + style.addProperty("animate_marker_on_hover", true); + style.addProperty("compact_mode", false); + style.addProperty("text_shadow", true); + style.addProperty("owner_suffix", "'s Marker"); + style.addProperty("owner_display", "MARKER_OWNER_DISPLAY_HEAD"); + style.addProperty("show_owner", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_coordinates", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_distance", "MARKER_DISPLAY_CONDITION_HOVER"); + style.addProperty("show_description", "MARKER_DISPLAY_CONDITION_ALWAYS"); + style.addProperty("description_display", "MARKER_DESCRIPTION_DISPLAY_ICON"); + message.add("style", style); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +**Marking an entity** + +```java +public void displayEntityMarkerExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.marker.v1.DisplayMarkerMessage"); + message.addProperty("id", "tutorial-npc"); + message.add("location", JsonUtil.createLocationObject(viewer.getLocation())); + message.add("owner_id", JsonUtil.createUuidObject(UUID.randomUUID())); + message.addProperty("owner_name", "Tutorial NPC"); + + JsonObject flag = new JsonObject(); + flag.add("interest", new JsonObject()); + message.add("flag", flag); + + JsonObject entity = new JsonObject(); + entity.addProperty("entity_type", "minecraft:villager"); + JsonObject target = new JsonObject(); + target.add("entity", entity); + message.add("target", target); + + JsonObject style = new JsonObject(); + style.addProperty("scale", 1.3F); + style.addProperty("animate_marker_on_hover", true); + style.addProperty("compact_mode", false); + style.addProperty("text_shadow", true); + style.addProperty("owner_suffix", ""); + style.addProperty("owner_display", "MARKER_OWNER_DISPLAY_NAME"); + style.addProperty("show_owner", "MARKER_DISPLAY_CONDITION_HOVER"); + style.addProperty("show_coordinates", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_distance", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_description", "MARKER_DISPLAY_CONDITION_HOVER"); + style.addProperty("description_display", "MARKER_DESCRIPTION_DISPLAY_ICON"); + message.add("style", style); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +**Removing markers** + +```java +public void removeMarkersExample(Player viewer) { + List markerIds = Arrays.asList("loot-chest", "bounty", "wither-loot", "tutorial-npc"); + for (String id : markerIds) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.marker.v1.RemoveMarkerMessage"); + message.addProperty("id", id); + + JsonPacketUtil.sendPacket(viewer, message); + } +} +``` + +**Resetting all markers** + +```java +public void resetMarkersExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.marker.v1.ResetMarkersMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + diff --git a/docs/developers/modules/serverlink.mdx b/docs/developers/modules/serverlink.mdx index 9b6ff87f..766cf034 100644 --- a/docs/developers/modules/serverlink.mdx +++ b/docs/developers/modules/serverlink.mdx @@ -100,6 +100,24 @@ public void resetServerLinksExample(Player viewer) { } ``` +### Set Legacy Button Placement + +```java +public void setLegacyButtonPlacementExample(String placement) { + LegacyServerLinkPlacement legacyPlacement = LegacyServerLinkPlacement.valueOf(placement); + this.serverLinkModule.getOptions().set(ServerLinkModule.LEGACY_BUTTON_PLACEMENT, legacyPlacement); +} +``` + +### Set Modern Button Placement + +```java +public void setModernButtonPlacementExample(String placement) { + ModernServerLinkPlacement modernPlacement = ModernServerLinkPlacement.valueOf(placement); + this.serverLinkModule.getOptions().set(ServerLinkModule.MODERN_BUTTON_PLACEMENT, modernPlacement); +} +``` + ### `ServerLink` Options `.id(String)` sets a unique identifier for the server link. @@ -205,6 +223,30 @@ public void resetServerLinksExample(Player viewer) { } ``` +**Set Legacy Button Placement** + +```java +public void setLegacyButtonPlacementExample(String placement) { + Map properties = new HashMap<>(); + properties.put("legacy-button-placement", Value.newBuilder().setStringValue(placement).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_link", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + +**Set Modern Button Placement** + +```java +public void setModernButtonPlacementExample(String placement) { + Map properties = new HashMap<>(); + properties.put("modern-button-placement", Value.newBuilder().setStringValue(placement).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_link", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + @@ -288,6 +330,44 @@ public void resetServerLinksExample(Player viewer) { } ``` +**Set Legacy Button Placement** + +```java +public void setLegacyButtonPlacementExample(String placement) { + Map properties = new HashMap<>(); + properties.put("legacy-button-placement", placement); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_link", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + +**Set Modern Button Placement** + +```java +public void setModernButtonPlacementExample(String placement) { + Map properties = new HashMap<>(); + properties.put("modern-button-placement", placement); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_link", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + + +## Available options + +- __`LEGACY_BUTTON_PLACEMENT`__ + - Where the server links button appears in the pause menu (1.7-1.12), where it is added on a new line by default. + - Values + - Type: `LegacyServerLinkPlacement` (`NEW_ROW`, `REPLACE_ACHIEVEMENTS`, `REPLACE_STATISTICS`) + - Default: `NEW_ROW` + +- __`MODERN_BUTTON_PLACEMENT`__ + - Where the server links button appears in the pause menu (1.16.1+), where it replaces the existing report bugs button by default. Has no effect on 1.21+ (handled natively). + - Values + - Type: `ModernServerLinkPlacement` (`REPLACE_REPORT_BUGS`, `REPLACE_ACHIEVEMENTS`, `REPLACE_STATISTICS`) + - Default: `REPLACE_REPORT_BUGS` diff --git a/docs/developers/modules/staffmod.mdx b/docs/developers/modules/staffmod.mdx index 92f02101..8c547999 100644 --- a/docs/developers/modules/staffmod.mdx +++ b/docs/developers/modules/staffmod.mdx @@ -37,7 +37,7 @@ public void enableStaffModsExample(Player viewer) { } Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(apolloPlayer -> this.staffModModule.enableStaffMods(apolloPlayer, Collections.singletonList(StaffMod.XRAY))); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.staffModModule.enableStaffMods(apolloPlayer, Collections.singletonList(StaffMod.XRAY), true)); } ``` @@ -56,6 +56,8 @@ public void disableStaffModsExample(Player viewer) { - A list of all the player(s) you want to enable or disable the staff mod. 2. `StaffMod.TYPE` - The type of staff mod(s) you want to enable for the `Recipients` player. See the [staff mod types](#staffmod-types) section for more. +3. `boolean enabledByDefault` + - Only available on `enableStaffMods`. When `true`, the staff mod is automatically enabled on the player's client; when `false`, it is unlocked but left disabled for the player to toggle on themselves. ## `StaffMod` Types @@ -79,6 +81,7 @@ public void enableStaffModsExample(Player viewer) { EnableStaffModsMessage message = EnableStaffModsMessage.newBuilder() .addAllStaffMods(Collections.singletonList(StaffMod.STAFF_MOD_XRAY)) + .setEnabledByDefault(true) .build(); ProtobufPacketUtil.sendPacket(viewer, message); @@ -121,6 +124,7 @@ public void enableStaffModsExample(Player viewer) { JsonObject message = new JsonObject(); message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.staffmod.v1.EnableStaffModsMessage"); message.add("staff_mods", staffMods); + message.addProperty("enabled_by_default", true); JsonPacketUtil.sendPacket(viewer, message); } diff --git a/docs/public/modules/marker/overview.gif b/docs/public/modules/marker/overview.gif new file mode 100644 index 00000000..a84d934e Binary files /dev/null and b/docs/public/modules/marker/overview.gif differ diff --git a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java index 5b26d6f8..2ae26a66 100644 --- a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java +++ b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java @@ -42,6 +42,7 @@ import com.lunarclient.apollo.example.api.module.GlowApiExample; import com.lunarclient.apollo.example.api.module.HologramApiExample; import com.lunarclient.apollo.example.api.module.LimbApiExample; +import com.lunarclient.apollo.example.api.module.MarkerApiExample; import com.lunarclient.apollo.example.api.module.ModSettingsApiExample; import com.lunarclient.apollo.example.api.module.NametagApiExample; import com.lunarclient.apollo.example.api.module.NickHiderApiExample; @@ -94,6 +95,7 @@ public void registerModuleExamples() { this.setGlowExample(new GlowApiExample()); this.setHologramExample(new HologramApiExample()); this.setLimbExample(new LimbApiExample()); + this.setMarkerExample(new MarkerApiExample()); this.setModSettingsExample(new ModSettingsApiExample()); this.setNametagExample(new NametagApiExample()); this.setNickHiderExample(new NickHiderApiExample()); diff --git a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/MarkerApiExample.java b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/MarkerApiExample.java new file mode 100644 index 00000000..ce51ea85 --- /dev/null +++ b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/MarkerApiExample.java @@ -0,0 +1,203 @@ +/* + * 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.example.api.module; + +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.common.icon.ItemStackIcon; +import com.lunarclient.apollo.common.location.ApolloLocation; +import com.lunarclient.apollo.example.module.impl.MarkerExample; +import com.lunarclient.apollo.module.marker.Marker; +import com.lunarclient.apollo.module.marker.MarkerModule; +import com.lunarclient.apollo.module.marker.MarkerStyle; +import com.lunarclient.apollo.module.marker.display.MarkerDisplayCondition; +import com.lunarclient.apollo.module.marker.display.MarkerFlag; +import com.lunarclient.apollo.module.marker.display.MarkerOwnerDisplay; +import com.lunarclient.apollo.module.marker.target.BlockMarkerTarget; +import com.lunarclient.apollo.module.marker.target.EntityMarkerTarget; +import com.lunarclient.apollo.module.marker.target.ItemMarkerTarget; +import com.lunarclient.apollo.module.marker.target.PlayerMarkerTarget; +import com.lunarclient.apollo.player.ApolloPlayer; +import java.awt.Color; +import java.time.Duration; +import java.util.Optional; +import java.util.UUID; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class MarkerApiExample extends MarkerExample { + + private final MarkerModule markerModule = Apollo.getModuleManager().getModule(MarkerModule.class); + + @Override + public void displayBlockMarkerExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + Location location = viewer.getLocation(); + + this.markerModule.displayMarker(apolloPlayer, Marker.builder() + .id("loot-chest") + .location(ApolloLocation.builder() + .world(location.getWorld().getName()) + .x(location.getX()) + .y(location.getY()) + .z(location.getZ()) + .build()) + .ownerId(viewer.getUniqueId()) + .ownerName("") + .flag(MarkerFlag.INTEREST) + .target(BlockMarkerTarget.builder() + .itemStack(ItemStackIcon + .builder() + .itemName("minecraft:chest") + .build()) + .build()) + .duration(Duration.ofSeconds(60)) + .style(MarkerStyle.builder() + .showOwner(MarkerDisplayCondition.NEVER) + .showDescription(MarkerDisplayCondition.ALWAYS) + .build()) + .build() + ); + }); + } + + @Override + public void displayPlayerMarkerExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + Location location = viewer.getLocation(); + + this.markerModule.displayMarker(apolloPlayer, Marker.builder() + .id("bounty") + .location(ApolloLocation.builder() + .world(location.getWorld().getName()) + .x(location.getX()) + .y(location.getY()) + .z(location.getZ()) + .build()) + .ownerId(viewer.getUniqueId()) + .ownerName(viewer.getName()) + .flag(MarkerFlag.DANGER) + .color(Color.RED) + .target(PlayerMarkerTarget.builder() + .playerId(UUID.fromString("f17627d8-1a97-487b-92ea-c04f413394bd")) + .playerName("ItsNature") + .build()) + .inGameNotification(true) + .style(MarkerStyle.builder() + .showOwner(MarkerDisplayCondition.NEVER) + .showDescription(MarkerDisplayCondition.ALWAYS) + .build()) + .build() + ); + }); + } + + @Override + public void displayItemMarkerExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + Location location = viewer.getLocation(); + + this.markerModule.displayMarker(apolloPlayer, Marker.builder() + .id("wither-loot") + .location(ApolloLocation.builder() + .world(location.getWorld().getName()) + .x(location.getX()) + .y(location.getY()) + .z(location.getZ()) + .build()) + .ownerId(viewer.getUniqueId()) + .ownerName(viewer.getName()) + .flag(MarkerFlag.INFO) + .target(ItemMarkerTarget.builder() + .itemStack(ItemStackIcon + .builder() + .itemName("minecraft:nether_star") + .build()) + .build()) + .style(MarkerStyle.builder() + .showOwner(MarkerDisplayCondition.NEVER) + .showDescription(MarkerDisplayCondition.ALWAYS) + .build()) + .build() + ); + }); + } + + @Override + public void displayEntityMarkerExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + Location location = viewer.getLocation(); + + this.markerModule.displayMarker(apolloPlayer, Marker.builder() + .id("tutorial-npc") + .location(ApolloLocation.builder() + .world(location.getWorld().getName()) + .x(location.getX()) + .y(location.getY()) + .z(location.getZ()) + .build()) + .ownerId(UUID.randomUUID()) + .ownerName("Tutorial NPC") + .flag(MarkerFlag.INTEREST) + .target(EntityMarkerTarget.builder() + .entityType("minecraft:villager") + .build()) + .style(MarkerStyle.builder() + .scale(1.3F) + .ownerSuffix("") + .ownerDisplay(MarkerOwnerDisplay.NAME) + .showOwner(MarkerDisplayCondition.HOVER) + .showDistance(MarkerDisplayCondition.NEVER) + .build()) + .build() + ); + }); + } + + @Override + public void removeMarkersExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + this.markerModule.removeMarker(apolloPlayer, "loot-chest"); + this.markerModule.removeMarker(apolloPlayer, "bounty"); + this.markerModule.removeMarker(apolloPlayer, "wither-loot"); + this.markerModule.removeMarker(apolloPlayer, "tutorial-npc"); + }); + } + + @Override + public void resetMarkersExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.markerModule::resetMarkers); + } + +} diff --git a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/ServerLinkApiExample.java b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/ServerLinkApiExample.java index 8c8f9e44..77e1026f 100644 --- a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/ServerLinkApiExample.java +++ b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/ServerLinkApiExample.java @@ -29,6 +29,8 @@ import com.lunarclient.apollo.example.module.impl.ServerLinkExample; import com.lunarclient.apollo.module.serverlink.ServerLink; import com.lunarclient.apollo.module.serverlink.ServerLinkModule; +import com.lunarclient.apollo.module.serverlink.pausemenu.LegacyServerLinkPlacement; +import com.lunarclient.apollo.module.serverlink.pausemenu.ModernServerLinkPlacement; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.Optional; import net.kyori.adventure.text.Component; @@ -98,4 +100,16 @@ public void resetServerLinksExample(Player viewer) { apolloPlayerOpt.ifPresent(this.serverLinkModule::resetServerLinks); } + @Override + public void setLegacyButtonPlacementExample(String placement) { + LegacyServerLinkPlacement legacyPlacement = LegacyServerLinkPlacement.valueOf(placement); + this.serverLinkModule.getOptions().set(ServerLinkModule.LEGACY_BUTTON_PLACEMENT, legacyPlacement); + } + + @Override + public void setModernButtonPlacementExample(String placement) { + ModernServerLinkPlacement modernPlacement = ModernServerLinkPlacement.valueOf(placement); + this.serverLinkModule.getOptions().set(ServerLinkModule.MODERN_BUTTON_PLACEMENT, modernPlacement); + } + } diff --git a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/StaffModApiExample.java b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/StaffModApiExample.java index 6deaa3dd..d38ae3da 100644 --- a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/StaffModApiExample.java +++ b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/StaffModApiExample.java @@ -43,7 +43,7 @@ public void enableStaffModsExample(Player viewer) { } Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(apolloPlayer -> this.staffModModule.enableStaffMods(apolloPlayer, Collections.singletonList(StaffMod.XRAY))); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.staffModModule.enableStaffMods(apolloPlayer, Collections.singletonList(StaffMod.XRAY), true)); } @Override diff --git a/example/bukkit/api/src/main/resources/plugin.yml b/example/bukkit/api/src/main/resources/plugin.yml index 9bc92e8b..9ba142c0 100644 --- a/example/bukkit/api/src/main/resources/plugin.yml +++ b/example/bukkit/api/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: Apollo-API-Example main: com.lunarclient.apollo.example.api.ApolloApiExamplePlatform -version: 1.2.7 +version: 1.2.8 author: Moonsworth softdepend: [ Apollo-Bukkit, Apollo-Folia ] api-version: 1.13 @@ -42,6 +42,8 @@ commands: description: "Inventory!" limb: description: "Limb!" + marker: + description: "Markers!" modsettings: description: "ModSettings!" nametag: diff --git a/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java index 9d29803e..c39d80f2 100644 --- a/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java +++ b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java @@ -37,6 +37,7 @@ import com.lunarclient.apollo.example.command.HologramCommand; import com.lunarclient.apollo.example.command.InventoryCommand; import com.lunarclient.apollo.example.command.LimbCommand; +import com.lunarclient.apollo.example.command.MarkerCommand; import com.lunarclient.apollo.example.command.ModSettingsCommand; import com.lunarclient.apollo.example.command.NametagCommand; import com.lunarclient.apollo.example.command.NickHiderCommand; @@ -70,6 +71,7 @@ import com.lunarclient.apollo.example.module.impl.HologramExample; import com.lunarclient.apollo.example.module.impl.InventoryExample; import com.lunarclient.apollo.example.module.impl.LimbExample; +import com.lunarclient.apollo.example.module.impl.MarkerExample; import com.lunarclient.apollo.example.module.impl.ModSettingsExample; import com.lunarclient.apollo.example.module.impl.NametagExample; import com.lunarclient.apollo.example.module.impl.NickHiderExample; @@ -115,6 +117,7 @@ public abstract class ApolloExamplePlugin extends JavaPlugin { private HologramExample hologramExample; private InventoryExample inventoryExample; private LimbExample limbExample; + private MarkerExample markerExample; private ModSettingsExample modSettingsExample; private NametagExample nametagExample; private NickHiderExample nickHiderExample; @@ -173,6 +176,7 @@ private void registerCommonCommands() { this.getCommand("hologram").setExecutor(new HologramCommand()); this.getCommand("inventory").setExecutor(new InventoryCommand()); this.getCommand("limb").setExecutor(new LimbCommand()); + this.getCommand("marker").setExecutor(new MarkerCommand()); this.getCommand("modsettings").setExecutor(new ModSettingsCommand()); this.getCommand("nametag").setExecutor(new NametagCommand()); this.getCommand("nickhider").setExecutor(new NickHiderCommand()); diff --git a/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/command/MarkerCommand.java b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/command/MarkerCommand.java new file mode 100644 index 00000000..c62b6a1f --- /dev/null +++ b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/command/MarkerCommand.java @@ -0,0 +1,97 @@ +/* + * 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.example.command; + +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.module.impl.MarkerExample; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class MarkerCommand implements CommandExecutor { + + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { + if (!(sender instanceof Player)) { + sender.sendMessage("Player only!"); + return true; + } + + Player player = (Player) sender; + + if (args.length != 1) { + player.sendMessage("Usage: /marker "); + return true; + } + + MarkerExample markerExample = ApolloExamplePlugin.getInstance().getMarkerExample(); + + switch (args[0].toLowerCase()) { + case "chest": { + markerExample.displayBlockMarkerExample(player); + player.sendMessage("Marking a block...."); + break; + } + + case "player": { + markerExample.displayPlayerMarkerExample(player); + player.sendMessage("Marking a player...."); + break; + } + + case "item": { + markerExample.displayItemMarkerExample(player); + player.sendMessage("Marking an item...."); + break; + } + + case "entity": { + markerExample.displayEntityMarkerExample(player); + player.sendMessage("Marking an entity...."); + break; + } + + case "remove": { + markerExample.removeMarkersExample(player); + player.sendMessage("Removing markers...."); + break; + } + + case "reset": { + markerExample.resetMarkersExample(player); + player.sendMessage("Resetting markers..."); + break; + } + + default: { + player.sendMessage("Usage: /marker "); + break; + } + } + + return true; + } +} diff --git a/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/command/ServerLinkCommand.java b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/command/ServerLinkCommand.java index d5280228..5d8e22ca 100644 --- a/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/command/ServerLinkCommand.java +++ b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/command/ServerLinkCommand.java @@ -25,6 +25,8 @@ import com.lunarclient.apollo.example.ApolloExamplePlugin; import com.lunarclient.apollo.example.module.impl.ServerLinkExample; +import java.util.Arrays; +import java.util.List; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,6 +35,9 @@ public class ServerLinkCommand implements CommandExecutor { + private static final List LEGACY_PLACEMENTS = Arrays.asList("NEW_ROW", "REPLACE_ACHIEVEMENTS", "REPLACE_STATISTICS"); + private static final List MODERN_PLACEMENTS = Arrays.asList("REPLACE_REPORT_BUGS", "REPLACE_ACHIEVEMENTS", "REPLACE_STATISTICS"); + @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -42,8 +47,8 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command Player player = (Player) sender; - if (args.length != 1) { - player.sendMessage("Usage: /serverlink "); + if (args.length < 1) { + this.sendUsage(player); return true; } @@ -80,12 +85,55 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command break; } + case "legacyplacement": { + if (args.length != 2) { + player.sendMessage("Usage: /serverlink legacyPlacement <" + String.join("|", LEGACY_PLACEMENTS) + ">"); + return true; + } + + String placement = args[1].toUpperCase(); + + if (!LEGACY_PLACEMENTS.contains(placement)) { + player.sendMessage("Invalid placement, must be one of: " + String.join("|", LEGACY_PLACEMENTS)); + return true; + } + + serverLinkExample.setLegacyButtonPlacementExample(placement); + player.sendMessage("Legacy server link button placement has been set to " + placement); + break; + } + + case "modernplacement": { + if (args.length != 2) { + player.sendMessage("Usage: /serverlink modernPlacement <" + String.join("|", MODERN_PLACEMENTS) + ">"); + return true; + } + + String placement = args[1].toUpperCase(); + + if (!MODERN_PLACEMENTS.contains(placement)) { + player.sendMessage("Invalid placement, must be one of: " + String.join("|", MODERN_PLACEMENTS)); + return true; + } + + serverLinkExample.setModernButtonPlacementExample(placement); + player.sendMessage("Modern server link button placement has been set to " + placement); + break; + } + default: { - player.sendMessage("Usage: /serverlink "); + this.sendUsage(player); break; } } return true; } + + private void sendUsage(Player player) { + player.sendMessage("Usage:"); + player.sendMessage("/serverlink "); + player.sendMessage("/serverlink legacyPlacement <" + String.join("|", LEGACY_PLACEMENTS) + ">"); + player.sendMessage("/serverlink modernPlacement <" + String.join("|", MODERN_PLACEMENTS) + ">"); + } } diff --git a/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/module/impl/MarkerExample.java b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/module/impl/MarkerExample.java new file mode 100644 index 00000000..14b91cf0 --- /dev/null +++ b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/module/impl/MarkerExample.java @@ -0,0 +1,43 @@ +/* + * 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.example.module.impl; + +import com.lunarclient.apollo.example.module.ApolloModuleExample; +import org.bukkit.entity.Player; + +public abstract class MarkerExample extends ApolloModuleExample { + + public abstract void displayBlockMarkerExample(Player viewer); + + public abstract void displayPlayerMarkerExample(Player viewer); + + public abstract void displayItemMarkerExample(Player viewer); + + public abstract void displayEntityMarkerExample(Player viewer); + + public abstract void removeMarkersExample(Player viewer); + + public abstract void resetMarkersExample(Player viewer); + +} diff --git a/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/module/impl/ServerLinkExample.java b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/module/impl/ServerLinkExample.java index 26ad56fb..b3f529ba 100644 --- a/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/module/impl/ServerLinkExample.java +++ b/example/bukkit/common/src/main/java/com/lunarclient/apollo/example/module/impl/ServerLinkExample.java @@ -38,4 +38,8 @@ public abstract class ServerLinkExample extends ApolloModuleExample { public abstract void resetServerLinksExample(Player viewer); + public abstract void setLegacyButtonPlacementExample(String placement); + + public abstract void setModernButtonPlacementExample(String placement); + } diff --git a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java index 7240c067..391c46d7 100644 --- a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java +++ b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java @@ -38,6 +38,7 @@ import com.lunarclient.apollo.example.json.module.GlowJsonExample; import com.lunarclient.apollo.example.json.module.HologramJsonExample; import com.lunarclient.apollo.example.json.module.LimbJsonExample; +import com.lunarclient.apollo.example.json.module.MarkerJsonExample; import com.lunarclient.apollo.example.json.module.ModSettingsJsonExample; import com.lunarclient.apollo.example.json.module.NametagJsonExample; import com.lunarclient.apollo.example.json.module.NickHiderJsonExample; @@ -82,6 +83,7 @@ public void registerModuleExamples() { this.setGlowExample(new GlowJsonExample()); this.setHologramExample(new HologramJsonExample()); this.setLimbExample(new LimbJsonExample()); + this.setMarkerExample(new MarkerJsonExample()); this.setModSettingsExample(new ModSettingsJsonExample()); this.setNametagExample(new NametagJsonExample()); this.setNickHiderExample(new NickHiderJsonExample()); diff --git a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/MarkerJsonExample.java b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/MarkerJsonExample.java new file mode 100644 index 00000000..80b6f260 --- /dev/null +++ b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/MarkerJsonExample.java @@ -0,0 +1,216 @@ +/* + * 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.example.json.module; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.MarkerExample; +import java.awt.Color; +import java.time.Duration; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; +import org.bukkit.entity.Player; + +public class MarkerJsonExample extends MarkerExample { + + @Override + public void displayBlockMarkerExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.marker.v1.DisplayMarkerMessage"); + message.addProperty("id", "loot-chest"); + message.add("location", JsonUtil.createLocationObject(viewer.getLocation())); + message.add("owner_id", JsonUtil.createUuidObject(viewer.getUniqueId())); + message.addProperty("owner_name", ""); + + JsonObject flag = new JsonObject(); + flag.add("interest", new JsonObject()); + message.add("flag", flag); + + JsonObject itemStack = new JsonObject(); + itemStack.addProperty("item_name", "minecraft:chest"); + JsonObject block = new JsonObject(); + block.add("item_stack", itemStack); + JsonObject target = new JsonObject(); + target.add("block", block); + message.add("target", target); + + message.addProperty("duration", JsonUtil.createDurationObject(Duration.ofSeconds(60))); + + JsonObject style = new JsonObject(); + style.addProperty("scale", 1.0F); + style.addProperty("animate_marker_on_hover", true); + style.addProperty("compact_mode", false); + style.addProperty("text_shadow", true); + style.addProperty("owner_suffix", "'s Marker"); + style.addProperty("owner_display", "MARKER_OWNER_DISPLAY_HEAD"); + style.addProperty("show_owner", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_coordinates", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_distance", "MARKER_DISPLAY_CONDITION_HOVER"); + style.addProperty("show_description", "MARKER_DISPLAY_CONDITION_ALWAYS"); + style.addProperty("description_display", "MARKER_DESCRIPTION_DISPLAY_ICON"); + message.add("style", style); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void displayPlayerMarkerExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.marker.v1.DisplayMarkerMessage"); + message.addProperty("id", "bounty"); + message.add("location", JsonUtil.createLocationObject(viewer.getLocation())); + message.add("owner_id", JsonUtil.createUuidObject(viewer.getUniqueId())); + message.addProperty("owner_name", viewer.getName()); + + JsonObject danger = new JsonObject(); + danger.add("color", JsonUtil.createColorObject(Color.RED)); + JsonObject flag = new JsonObject(); + flag.add("danger", danger); + message.add("flag", flag); + + JsonObject player = new JsonObject(); + player.add("uuid", JsonUtil.createUuidObject(UUID.fromString("f17627d8-1a97-487b-92ea-c04f413394bd"))); + player.addProperty("name", "ItsNature"); + JsonObject target = new JsonObject(); + target.add("player", player); + message.add("target", target); + + message.addProperty("in_game_notification", true); + + JsonObject style = new JsonObject(); + style.addProperty("scale", 1.0F); + style.addProperty("animate_marker_on_hover", true); + style.addProperty("compact_mode", false); + style.addProperty("text_shadow", true); + style.addProperty("owner_suffix", "'s Marker"); + style.addProperty("owner_display", "MARKER_OWNER_DISPLAY_HEAD"); + style.addProperty("show_owner", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_coordinates", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_distance", "MARKER_DISPLAY_CONDITION_HOVER"); + style.addProperty("show_description", "MARKER_DISPLAY_CONDITION_ALWAYS"); + style.addProperty("description_display", "MARKER_DESCRIPTION_DISPLAY_ICON"); + message.add("style", style); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void displayItemMarkerExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.marker.v1.DisplayMarkerMessage"); + message.addProperty("id", "wither-loot"); + message.add("location", JsonUtil.createLocationObject(viewer.getLocation())); + message.add("owner_id", JsonUtil.createUuidObject(viewer.getUniqueId())); + message.addProperty("owner_name", viewer.getName()); + + JsonObject flag = new JsonObject(); + flag.add("info", new JsonObject()); + message.add("flag", flag); + + JsonObject itemStack = new JsonObject(); + itemStack.addProperty("item_name", "minecraft:nether_star"); + JsonObject item = new JsonObject(); + item.add("item_stack", itemStack); + JsonObject target = new JsonObject(); + target.add("item", item); + message.add("target", target); + + message.addProperty("chat_notify", true); + + JsonObject style = new JsonObject(); + style.addProperty("scale", 1.0F); + style.addProperty("animate_marker_on_hover", true); + style.addProperty("compact_mode", false); + style.addProperty("text_shadow", true); + style.addProperty("owner_suffix", "'s Marker"); + style.addProperty("owner_display", "MARKER_OWNER_DISPLAY_HEAD"); + style.addProperty("show_owner", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_coordinates", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_distance", "MARKER_DISPLAY_CONDITION_HOVER"); + style.addProperty("show_description", "MARKER_DISPLAY_CONDITION_ALWAYS"); + style.addProperty("description_display", "MARKER_DESCRIPTION_DISPLAY_ICON"); + message.add("style", style); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void displayEntityMarkerExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.marker.v1.DisplayMarkerMessage"); + message.addProperty("id", "tutorial-npc"); + message.add("location", JsonUtil.createLocationObject(viewer.getLocation())); + message.add("owner_id", JsonUtil.createUuidObject(UUID.randomUUID())); + message.addProperty("owner_name", "Tutorial NPC"); + + JsonObject flag = new JsonObject(); + flag.add("interest", new JsonObject()); + message.add("flag", flag); + + JsonObject entity = new JsonObject(); + entity.addProperty("entity_type", "minecraft:villager"); + JsonObject target = new JsonObject(); + target.add("entity", entity); + message.add("target", target); + + JsonObject style = new JsonObject(); + style.addProperty("scale", 1.3F); + style.addProperty("animate_marker_on_hover", true); + style.addProperty("compact_mode", false); + style.addProperty("text_shadow", true); + style.addProperty("owner_suffix", ""); + style.addProperty("owner_display", "MARKER_OWNER_DISPLAY_NAME"); + style.addProperty("show_owner", "MARKER_DISPLAY_CONDITION_HOVER"); + style.addProperty("show_coordinates", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_distance", "MARKER_DISPLAY_CONDITION_NEVER"); + style.addProperty("show_description", "MARKER_DISPLAY_CONDITION_HOVER"); + style.addProperty("description_display", "MARKER_DESCRIPTION_DISPLAY_ICON"); + message.add("style", style); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void removeMarkersExample(Player viewer) { + List markerIds = Arrays.asList("loot-chest", "bounty", "wither-loot", "tutorial-npc"); + for (String id : markerIds) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.marker.v1.RemoveMarkerMessage"); + message.addProperty("id", id); + + JsonPacketUtil.sendPacket(viewer, message); + } + } + + @Override + public void resetMarkersExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.marker.v1.ResetMarkersMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/ServerLinkJsonExample.java b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/ServerLinkJsonExample.java index 6cd6f7cd..bbe27452 100644 --- a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/ServerLinkJsonExample.java +++ b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/ServerLinkJsonExample.java @@ -30,6 +30,8 @@ import com.lunarclient.apollo.example.json.util.JsonPacketUtil; import com.lunarclient.apollo.example.json.util.JsonUtil; import com.lunarclient.apollo.example.module.impl.ServerLinkExample; +import java.util.HashMap; +import java.util.Map; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.entity.Player; @@ -96,4 +98,22 @@ public void resetServerLinksExample(Player viewer) { JsonPacketUtil.sendPacket(viewer, message); } + @Override + public void setLegacyButtonPlacementExample(String placement) { + Map properties = new HashMap<>(); + properties.put("legacy-button-placement", placement); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_link", properties); + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void setModernButtonPlacementExample(String placement) { + Map properties = new HashMap<>(); + properties.put("modern-button-placement", placement); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_link", properties); + JsonPacketUtil.broadcastPacket(message); + } + } diff --git a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/StaffModJsonExample.java b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/StaffModJsonExample.java index 9967db00..ee0d0d87 100644 --- a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/StaffModJsonExample.java +++ b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/StaffModJsonExample.java @@ -47,6 +47,7 @@ public void enableStaffModsExample(Player viewer) { JsonObject message = new JsonObject(); message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.staffmod.v1.EnableStaffModsMessage"); message.add("staff_mods", staffMods); + message.addProperty("enabled_by_default", true); JsonPacketUtil.sendPacket(viewer, message); } diff --git a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/util/JsonPacketUtil.java b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/util/JsonPacketUtil.java index c2c03685..31617883 100644 --- a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/util/JsonPacketUtil.java +++ b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/util/JsonPacketUtil.java @@ -41,8 +41,8 @@ public final class JsonPacketUtil { private static final List APOLLO_MODULES = Arrays.asList("auto_text_hotkey", "beam", "border", "chat", "colored_fire", "combat", "cooldown", - "cosmetic", "entity", "glint", "glow", "hologram", "inventory", "limb", "mod_setting", "nametag", "nick_hider", "notification", "pay_now", "packet_enrichment", - "rich_presence", "saturation", "server_rule", "staff_mod", "stopwatch", "team", "tebex", "title", "tnt_countdown", "transfer", "vignette", "waypoint" + "cosmetic", "entity", "glint", "glow", "hologram", "inventory", "limb", "marker", "mod_setting", "nametag", "nick_hider", "notification", "pay_now", "packet_enrichment", + "rich_presence", "saturation", "server_link", "server_rule", "staff_mod", "stopwatch", "team", "tebex", "title", "tnt_countdown", "transfer", "vignette", "waypoint" ); // Module Id -> Option key -> Object @@ -53,11 +53,15 @@ public final class JsonPacketUtil { // While using the Apollo plugin this would be equivalent to modifying the config.yml CONFIG_MODULE_PROPERTIES.put("colored_fire", "persist-colors-on-unload", false); CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", false); + CONFIG_MODULE_PROPERTIES.put("combat", "disable-block-miss-penalty", false); + CONFIG_MODULE_PROPERTIES.put("combat", "allow-dig-and-use", false); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-attack.send-packet", false); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-open.send-packet", false); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-close.send-packet", false); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-use-item.send-packet", false); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-use-item-bucket.send-packet", false); + CONFIG_MODULE_PROPERTIES.put("server_link", "legacy-button-placement", "NEW_ROW"); + CONFIG_MODULE_PROPERTIES.put("server_link", "modern-button-placement", "REPLACE_REPORT_BUGS"); CONFIG_MODULE_PROPERTIES.put("server_rule", "competitive-game", false); CONFIG_MODULE_PROPERTIES.put("server_rule", "competitive-commands", Arrays.asList("/server", "/servers", "/hub")); CONFIG_MODULE_PROPERTIES.put("server_rule", "disable-shaders", false); diff --git a/example/bukkit/json/src/main/resources/plugin.yml b/example/bukkit/json/src/main/resources/plugin.yml index 12672845..334fe2a4 100644 --- a/example/bukkit/json/src/main/resources/plugin.yml +++ b/example/bukkit/json/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: Apollo-Json-Example main: com.lunarclient.apollo.example.json.ApolloJsonExamplePlatform -version: 1.2.7 +version: 1.2.8 author: Moonsworth softdepend: [ Apollo-Bukkit ] api-version: 1.13 @@ -38,6 +38,8 @@ commands: description: "Inventory!" limb: description: "Limb!" + marker: + description: "Markers!" modsettings: description: "ModSettings!" nametag: diff --git a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java index 9112f059..94578ad4 100644 --- a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java +++ b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java @@ -38,6 +38,7 @@ import com.lunarclient.apollo.example.proto.module.GlowProtoExample; import com.lunarclient.apollo.example.proto.module.HologramProtoExample; import com.lunarclient.apollo.example.proto.module.LimbProtoExample; +import com.lunarclient.apollo.example.proto.module.MarkerProtoExample; import com.lunarclient.apollo.example.proto.module.ModSettingsProtoExample; import com.lunarclient.apollo.example.proto.module.NametagProtoExample; import com.lunarclient.apollo.example.proto.module.NickHiderProtoExample; @@ -82,6 +83,7 @@ public void registerModuleExamples() { this.setGlowExample(new GlowProtoExample()); this.setHologramExample(new HologramProtoExample()); this.setLimbExample(new LimbProtoExample()); + this.setMarkerExample(new MarkerProtoExample()); this.setModSettingsExample(new ModSettingsProtoExample()); this.setNametagExample(new NametagProtoExample()); this.setNickHiderExample(new NickHiderProtoExample()); diff --git a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/MarkerProtoExample.java b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/MarkerProtoExample.java new file mode 100644 index 00000000..998a1d73 --- /dev/null +++ b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/MarkerProtoExample.java @@ -0,0 +1,210 @@ +/* + * 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.example.proto.module; + +import com.lunarclient.apollo.example.module.impl.MarkerExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; +import com.lunarclient.apollo.marker.v1.BlockTarget; +import com.lunarclient.apollo.marker.v1.DangerMarker; +import com.lunarclient.apollo.marker.v1.DisplayMarkerMessage; +import com.lunarclient.apollo.marker.v1.EntityTarget; +import com.lunarclient.apollo.marker.v1.InfoMarker; +import com.lunarclient.apollo.marker.v1.InterestMarker; +import com.lunarclient.apollo.marker.v1.ItemTarget; +import com.lunarclient.apollo.marker.v1.MarkerDescriptionDisplay; +import com.lunarclient.apollo.marker.v1.MarkerDisplayCondition; +import com.lunarclient.apollo.marker.v1.MarkerFlag; +import com.lunarclient.apollo.marker.v1.MarkerOwnerDisplay; +import com.lunarclient.apollo.marker.v1.MarkerStyle; +import com.lunarclient.apollo.marker.v1.MarkerTarget; +import com.lunarclient.apollo.marker.v1.PlayerTarget; +import com.lunarclient.apollo.marker.v1.RemoveMarkerMessage; +import com.lunarclient.apollo.marker.v1.ResetMarkersMessage; +import java.awt.Color; +import java.time.Duration; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; +import org.bukkit.entity.Player; + +public class MarkerProtoExample extends MarkerExample { + + @Override + public void displayBlockMarkerExample(Player viewer) { + DisplayMarkerMessage message = DisplayMarkerMessage.newBuilder() + .setId("loot-chest") + .setLocation(ProtobufUtil.createLocationProto(viewer.getLocation())) + .setOwnerId(ProtobufUtil.createUuidProto(viewer.getUniqueId())) + .setOwnerName("") + .setFlag(MarkerFlag.newBuilder() + .setInterest(InterestMarker.getDefaultInstance()) + .build()) + .setTarget(MarkerTarget.newBuilder() + .setBlock(BlockTarget.newBuilder() + .setItemStack(ProtobufUtil.createItemStackIconProto("minecraft:chest", 0)) + .build()) + .build()) + .setDuration(ProtobufUtil.createDurationProto(Duration.ofSeconds(60))) + .setStyle(MarkerStyle.newBuilder() + .setScale(1.0F) + .setAnimateMarkerOnHover(true) + .setCompactMode(false) + .setTextShadow(true) + .setOwnerSuffix("'s Marker") + .setOwnerDisplay(MarkerOwnerDisplay.MARKER_OWNER_DISPLAY_HEAD) + .setShowOwner(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowCoordinates(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowDistance(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_HOVER) + .setShowDescription(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_ALWAYS) + .setDescriptionDisplay(MarkerDescriptionDisplay.MARKER_DESCRIPTION_DISPLAY_ICON) + .build()) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void displayPlayerMarkerExample(Player viewer) { + DisplayMarkerMessage message = DisplayMarkerMessage.newBuilder() + .setId("bounty") + .setLocation(ProtobufUtil.createLocationProto(viewer.getLocation())) + .setOwnerId(ProtobufUtil.createUuidProto(viewer.getUniqueId())) + .setOwnerName(viewer.getName()) + .setFlag(MarkerFlag.newBuilder() + .setDanger(DangerMarker.newBuilder() + .setColor(ProtobufUtil.createColorProto(Color.RED)) + .build()) + .build()) + .setTarget(MarkerTarget.newBuilder() + .setPlayer(PlayerTarget.newBuilder() + .setUuid(ProtobufUtil.createUuidProto(UUID.fromString("f17627d8-1a97-487b-92ea-c04f413394bd"))) + .setName("ItsNature") + .build()) + .build()) + .setInGameNotification(true) + .setStyle(MarkerStyle.newBuilder() + .setScale(1.0F) + .setAnimateMarkerOnHover(true) + .setCompactMode(false) + .setTextShadow(true) + .setOwnerSuffix("'s Marker") + .setOwnerDisplay(MarkerOwnerDisplay.MARKER_OWNER_DISPLAY_HEAD) + .setShowOwner(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowCoordinates(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowDistance(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_HOVER) + .setShowDescription(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_ALWAYS) + .setDescriptionDisplay(MarkerDescriptionDisplay.MARKER_DESCRIPTION_DISPLAY_ICON) + .build()) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void displayItemMarkerExample(Player viewer) { + DisplayMarkerMessage message = DisplayMarkerMessage.newBuilder() + .setId("wither-loot") + .setLocation(ProtobufUtil.createLocationProto(viewer.getLocation())) + .setOwnerId(ProtobufUtil.createUuidProto(viewer.getUniqueId())) + .setOwnerName(viewer.getName()) + .setFlag(MarkerFlag.newBuilder() + .setInfo(InfoMarker.getDefaultInstance()) + .build()) + .setTarget(MarkerTarget.newBuilder() + .setItem(ItemTarget.newBuilder() + .setItemStack(ProtobufUtil.createItemStackIconProto("minecraft:nether_star", 0)) + .build()) + .build()) + .setChatNotify(true) + .setStyle(MarkerStyle.newBuilder() + .setScale(1.0F) + .setAnimateMarkerOnHover(true) + .setCompactMode(false) + .setTextShadow(true) + .setOwnerSuffix("'s Marker") + .setOwnerDisplay(MarkerOwnerDisplay.MARKER_OWNER_DISPLAY_HEAD) + .setShowOwner(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowCoordinates(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowDistance(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_HOVER) + .setShowDescription(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_ALWAYS) + .setDescriptionDisplay(MarkerDescriptionDisplay.MARKER_DESCRIPTION_DISPLAY_ICON) + .build()) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void displayEntityMarkerExample(Player viewer) { + DisplayMarkerMessage message = DisplayMarkerMessage.newBuilder() + .setId("tutorial-npc") + .setLocation(ProtobufUtil.createLocationProto(viewer.getLocation())) + .setOwnerId(ProtobufUtil.createUuidProto(UUID.randomUUID())) + .setOwnerName("Tutorial NPC") + .setFlag(MarkerFlag.newBuilder() + .setInterest(InterestMarker.getDefaultInstance()) + .build()) + .setTarget(MarkerTarget.newBuilder() + .setEntity(EntityTarget.newBuilder() + .setEntityType("minecraft:villager") + .build()) + .build()) + .setStyle(MarkerStyle.newBuilder() + .setScale(1.3F) + .setAnimateMarkerOnHover(true) + .setCompactMode(false) + .setTextShadow(true) + .setOwnerSuffix("") + .setOwnerDisplay(MarkerOwnerDisplay.MARKER_OWNER_DISPLAY_NAME) + .setShowOwner(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_HOVER) + .setShowCoordinates(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowDistance(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_NEVER) + .setShowDescription(MarkerDisplayCondition.MARKER_DISPLAY_CONDITION_HOVER) + .setDescriptionDisplay(MarkerDescriptionDisplay.MARKER_DESCRIPTION_DISPLAY_ICON) + .build()) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void removeMarkersExample(Player viewer) { + List markerIds = Arrays.asList("loot-chest", "bounty", "wither-loot", "tutorial-npc"); + for (String id : markerIds) { + RemoveMarkerMessage message = RemoveMarkerMessage.newBuilder() + .setId(id) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + } + + @Override + public void resetMarkersExample(Player viewer) { + ResetMarkersMessage message = ResetMarkersMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/ServerLinkProtoExample.java b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/ServerLinkProtoExample.java index c39e53cc..ec4bbd02 100644 --- a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/ServerLinkProtoExample.java +++ b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/ServerLinkProtoExample.java @@ -24,6 +24,8 @@ package com.lunarclient.apollo.example.proto.module; import com.google.common.collect.Lists; +import com.google.protobuf.Value; +import com.lunarclient.apollo.configurable.v1.ConfigurableSettings; import com.lunarclient.apollo.example.module.impl.ServerLinkExample; import com.lunarclient.apollo.example.proto.util.AdventureUtil; import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; @@ -34,7 +36,9 @@ import com.lunarclient.apollo.serverlink.v1.ResetServerLinkResourceMessage; import com.lunarclient.apollo.serverlink.v1.ResetServerLinksMessage; import com.lunarclient.apollo.serverlink.v1.ServerLink; +import java.util.HashMap; import java.util.List; +import java.util.Map; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.entity.Player; @@ -103,4 +107,22 @@ public void resetServerLinksExample(Player viewer) { ProtobufPacketUtil.sendPacket(viewer, message); } + @Override + public void setLegacyButtonPlacementExample(String placement) { + Map properties = new HashMap<>(); + properties.put("legacy-button-placement", Value.newBuilder().setStringValue(placement).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_link", properties); + ProtobufPacketUtil.broadcastPacket(settings); + } + + @Override + public void setModernButtonPlacementExample(String placement) { + Map properties = new HashMap<>(); + properties.put("modern-button-placement", Value.newBuilder().setStringValue(placement).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_link", properties); + ProtobufPacketUtil.broadcastPacket(settings); + } + } diff --git a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/StaffModProtoExample.java b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/StaffModProtoExample.java index baabe174..9af09b1a 100644 --- a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/StaffModProtoExample.java +++ b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/StaffModProtoExample.java @@ -41,6 +41,7 @@ public void enableStaffModsExample(Player viewer) { EnableStaffModsMessage message = EnableStaffModsMessage.newBuilder() .addAllStaffMods(Collections.singletonList(StaffMod.STAFF_MOD_XRAY)) + .setEnabledByDefault(true) .build(); ProtobufPacketUtil.sendPacket(viewer, message); diff --git a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufPacketUtil.java b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufPacketUtil.java index 97bea1c8..f8a0e17c 100644 --- a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufPacketUtil.java +++ b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufPacketUtil.java @@ -42,8 +42,8 @@ public final class ProtobufPacketUtil { private static final List APOLLO_MODULES = Arrays.asList("auto_text_hotkey", "beam", "border", "chat", "colored_fire", "combat", "cooldown", - "cosmetic", "entity", "glint", "glow", "hologram", "inventory", "limb", "mod_setting", "nametag", "nick_hider", "notification", "pay_now", "packet_enrichment", - "rich_presence", "saturation", "server_rule", "staff_mod", "stopwatch", "team", "tebex", "title", "tnt_countdown", "transfer", "vignette", "waypoint" + "cosmetic", "entity", "glint", "glow", "hologram", "inventory", "limb", "marker", "mod_setting", "nametag", "nick_hider", "notification", "pay_now", "packet_enrichment", + "rich_presence", "saturation", "server_link", "server_rule", "staff_mod", "stopwatch", "team", "tebex", "title", "tnt_countdown", "transfer", "vignette", "waypoint" ); // Module Id -> Option key -> Value @@ -54,11 +54,15 @@ public final class ProtobufPacketUtil { // While using the Apollo plugin this would be equivalent to modifying the config.yml CONFIG_MODULE_PROPERTIES.put("colored_fire", "persist-colors-on-unload", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("combat", "disable-block-miss-penalty", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("combat", "allow-dig-and-use", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-attack.send-packet", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-open.send-packet", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-close.send-packet", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-use-item.send-packet", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-use-item-bucket.send-packet", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_link", "legacy-button-placement", Value.newBuilder().setStringValue("NEW_ROW").build()); + CONFIG_MODULE_PROPERTIES.put("server_link", "modern-button-placement", Value.newBuilder().setStringValue("REPLACE_REPORT_BUGS").build()); CONFIG_MODULE_PROPERTIES.put("server_rule", "competitive-game", Value.newBuilder().setBoolValue(false).build()); CONFIG_MODULE_PROPERTIES.put("server_rule", "competitive-commands", Value.newBuilder().setListValue( ListValue.newBuilder().addAllValues(Arrays.asList( diff --git a/example/bukkit/proto/src/main/resources/plugin.yml b/example/bukkit/proto/src/main/resources/plugin.yml index ef931e21..f74f917e 100644 --- a/example/bukkit/proto/src/main/resources/plugin.yml +++ b/example/bukkit/proto/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: Apollo-Proto-Example main: com.lunarclient.apollo.example.proto.ApolloProtoExamplePlatform -version: 1.2.7 +version: 1.2.8 author: Moonsworth softdepend: [ Apollo-Bukkit ] api-version: 1.13 @@ -38,6 +38,8 @@ commands: description: "Inventory!" limb: description: "Limb!" + marker: + description: "Markers!" modsettings: description: "ModSettings!" nametag: diff --git a/gradle.properties b/gradle.properties index 8fa85dcb..1cecc874 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=com.lunarclient -version=1.2.7 +version=1.2.8 description=The API for interacting with Lunar Client players. org.gradle.parallel=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9389be29..d83b4d64 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.8" +protobuf = "0.2.0" gson = "2.10.1" shadow = "9.4.1" spotless = "8.4.0" diff --git a/platform/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java b/platform/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java index 220be9b1..6de2e988 100644 --- a/platform/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java +++ b/platform/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java @@ -55,6 +55,8 @@ import com.lunarclient.apollo.module.inventory.InventoryModule; import com.lunarclient.apollo.module.limb.LimbModule; import com.lunarclient.apollo.module.limb.LimbModuleImpl; +import com.lunarclient.apollo.module.marker.MarkerModule; +import com.lunarclient.apollo.module.marker.MarkerModuleImpl; import com.lunarclient.apollo.module.modsetting.ModSettingModule; import com.lunarclient.apollo.module.modsettings.ModSettingModuleImpl; import com.lunarclient.apollo.module.nametag.NametagModule; @@ -150,6 +152,7 @@ public void onEnable() { .addModule(HologramModule.class, new HologramModuleImpl()) .addModule(InventoryModule.class) .addModule(LimbModule.class, new LimbModuleImpl()) + .addModule(MarkerModule.class, new MarkerModuleImpl()) .addModule(ModSettingModule.class, new ModSettingModuleImpl()) .addModule(NametagModule.class, new NametagModuleImpl()) .addModule(NickHiderModule.class, new NickHiderModuleImpl()) diff --git a/platform/bukkit/src/main/java/com/lunarclient/apollo/wrapper/BukkitApolloWorld.java b/platform/bukkit/src/main/java/com/lunarclient/apollo/wrapper/BukkitApolloWorld.java index 48c8dc01..ee4a8849 100644 --- a/platform/bukkit/src/main/java/com/lunarclient/apollo/wrapper/BukkitApolloWorld.java +++ b/platform/bukkit/src/main/java/com/lunarclient/apollo/wrapper/BukkitApolloWorld.java @@ -25,14 +25,16 @@ import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.player.ApolloPlayer; +import com.lunarclient.apollo.player.ApolloPlayerManager; import com.lunarclient.apollo.recipients.ForwardingRecipients; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.world.ApolloWorld; +import java.util.ArrayList; import java.util.Collection; -import java.util.Optional; -import java.util.stream.Collectors; +import java.util.List; import lombok.AllArgsConstructor; import org.bukkit.World; +import org.bukkit.entity.Player; /** * The Bukkit implementation of {@link ApolloWorld}. @@ -51,11 +53,16 @@ public String getName() { @Override public Collection getPlayers() { - return this.world.getPlayers().stream() - .map(player -> Apollo.getPlayerManager().getPlayer(player.getUniqueId())) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); + ApolloPlayerManager playerManager = Apollo.getPlayerManager(); + List players = this.world.getPlayers(); + List apolloPlayers = new ArrayList<>(players.size()); + + for (Player player : players) { + playerManager.getPlayer(player.getUniqueId()) + .ifPresent(apolloPlayers::add); + } + + return apolloPlayers; } @Override diff --git a/platform/bukkit/src/platform-loader/resources/plugin.yml b/platform/bukkit/src/platform-loader/resources/plugin.yml index 2910c1d9..6be0fb25 100644 --- a/platform/bukkit/src/platform-loader/resources/plugin.yml +++ b/platform/bukkit/src/platform-loader/resources/plugin.yml @@ -1,6 +1,6 @@ name: Apollo-Bukkit main: com.lunarclient.apollo.loader.BukkitPlatformLoader -version: 1.2.7 +version: 1.2.8 author: Moonsworth api-version: 1.13 soft-depend: [LunarClient-API] diff --git a/platform/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java b/platform/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java index 76cad083..a5f50d27 100644 --- a/platform/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java +++ b/platform/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java @@ -50,6 +50,8 @@ import com.lunarclient.apollo.module.hologram.HologramModuleImpl; import com.lunarclient.apollo.module.limb.LimbModule; import com.lunarclient.apollo.module.limb.LimbModuleImpl; +import com.lunarclient.apollo.module.marker.MarkerModule; +import com.lunarclient.apollo.module.marker.MarkerModuleImpl; import com.lunarclient.apollo.module.modsetting.ModSettingModule; import com.lunarclient.apollo.module.modsettings.ModSettingModuleImpl; import com.lunarclient.apollo.module.nametag.NametagModule; @@ -131,6 +133,7 @@ public void onEnable() { .addModule(EntityModule.class, new EntityModuleImpl()) .addModule(HologramModule.class, new HologramModuleImpl()) .addModule(LimbModule.class, new LimbModuleImpl()) + .addModule(MarkerModule.class, new MarkerModuleImpl()) .addModule(ModSettingModule.class, new ModSettingModuleImpl()) .addModule(NametagModule.class, new NametagModuleImpl()) .addModule(NotificationModule.class, new NotificationModuleImpl()) diff --git a/platform/bungee/src/platform-loader/resources/plugin.yml b/platform/bungee/src/platform-loader/resources/plugin.yml index 61f37adf..2baf5bca 100644 --- a/platform/bungee/src/platform-loader/resources/plugin.yml +++ b/platform/bungee/src/platform-loader/resources/plugin.yml @@ -1,4 +1,4 @@ name: Apollo-Bungee main: com.lunarclient.apollo.loader.BungeePlatformLoader -version: 1.2.7 +version: 1.2.8 author: Moonsworth diff --git a/platform/folia/src/main/java/com/lunarclient/apollo/ApolloFoliaPlatform.java b/platform/folia/src/main/java/com/lunarclient/apollo/ApolloFoliaPlatform.java index ecf29b87..19a4878b 100644 --- a/platform/folia/src/main/java/com/lunarclient/apollo/ApolloFoliaPlatform.java +++ b/platform/folia/src/main/java/com/lunarclient/apollo/ApolloFoliaPlatform.java @@ -52,6 +52,8 @@ import com.lunarclient.apollo.module.hologram.HologramModuleImpl; import com.lunarclient.apollo.module.limb.LimbModule; import com.lunarclient.apollo.module.limb.LimbModuleImpl; +import com.lunarclient.apollo.module.marker.MarkerModule; +import com.lunarclient.apollo.module.marker.MarkerModuleImpl; import com.lunarclient.apollo.module.modsetting.ModSettingModule; import com.lunarclient.apollo.module.modsettings.ModSettingModuleImpl; import com.lunarclient.apollo.module.nametag.NametagModule; @@ -138,6 +140,7 @@ public void onEnable() { .addModule(GlowModule.class, new GlowModuleImpl()) .addModule(HologramModule.class, new HologramModuleImpl()) .addModule(LimbModule.class, new LimbModuleImpl()) + .addModule(MarkerModule.class, new MarkerModuleImpl()) .addModule(ModSettingModule.class, new ModSettingModuleImpl()) .addModule(NametagModule.class, new NametagModuleImpl()) .addModule(NickHiderModule.class, new NickHiderModuleImpl()) diff --git a/platform/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloWorld.java b/platform/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloWorld.java index 7d07d92a..510749b7 100644 --- a/platform/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloWorld.java +++ b/platform/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloWorld.java @@ -25,14 +25,16 @@ import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.player.ApolloPlayer; +import com.lunarclient.apollo.player.ApolloPlayerManager; import com.lunarclient.apollo.recipients.ForwardingRecipients; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.world.ApolloWorld; +import java.util.ArrayList; import java.util.Collection; -import java.util.Optional; -import java.util.stream.Collectors; +import java.util.List; import lombok.AllArgsConstructor; import org.bukkit.World; +import org.bukkit.entity.Player; /** * The Folia implementation of {@link ApolloWorld}. @@ -51,11 +53,16 @@ public String getName() { @Override public Collection getPlayers() { - return this.world.getPlayers().stream() - .map(player -> Apollo.getPlayerManager().getPlayer(player.getUniqueId())) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); + ApolloPlayerManager playerManager = Apollo.getPlayerManager(); + List players = this.world.getPlayers(); + List apolloPlayers = new ArrayList<>(players.size()); + + for (Player player : players) { + playerManager.getPlayer(player.getUniqueId()) + .ifPresent(apolloPlayers::add); + } + + return apolloPlayers; } @Override diff --git a/platform/folia/src/main/resources/plugin.yml b/platform/folia/src/main/resources/plugin.yml index 5e40d187..25c7425f 100644 --- a/platform/folia/src/main/resources/plugin.yml +++ b/platform/folia/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: Apollo-Folia main: com.lunarclient.apollo.ApolloFoliaPlatform -version: 1.2.7 +version: 1.2.8 author: Moonsworth api-version: 1.13 folia-supported: true diff --git a/platform/minestom/src/main/java/com/lunarclient/apollo/ApolloMinestomPlatform.java b/platform/minestom/src/main/java/com/lunarclient/apollo/ApolloMinestomPlatform.java index ceb47d1e..8c2e26ab 100644 --- a/platform/minestom/src/main/java/com/lunarclient/apollo/ApolloMinestomPlatform.java +++ b/platform/minestom/src/main/java/com/lunarclient/apollo/ApolloMinestomPlatform.java @@ -54,6 +54,8 @@ import com.lunarclient.apollo.module.inventory.InventoryModule; import com.lunarclient.apollo.module.limb.LimbModule; import com.lunarclient.apollo.module.limb.LimbModuleImpl; +import com.lunarclient.apollo.module.marker.MarkerModule; +import com.lunarclient.apollo.module.marker.MarkerModuleImpl; import com.lunarclient.apollo.module.modsetting.ModSettingModule; import com.lunarclient.apollo.module.modsettings.ModSettingModuleImpl; import com.lunarclient.apollo.module.nametag.NametagModule; @@ -172,6 +174,7 @@ public static void init(ApolloMinestomProperties properties) { .addModule(HologramModule.class, new HologramModuleImpl()) .addModule(InventoryModule.class) .addModule(LimbModule.class, new LimbModuleImpl()) + .addModule(MarkerModule.class, new MarkerModuleImpl()) .addModule(ModSettingModule.class, new ModSettingModuleImpl()) .addModule(NametagModule.class, new NametagModuleImpl()) .addModule(NickHiderModule.class, new NickHiderModuleImpl()) @@ -243,7 +246,7 @@ public Options getOptions() { @Override public String getApolloVersion() { - return "1.2.7"; + return "1.2.8"; } @Override diff --git a/platform/minestom/src/main/java/com/lunarclient/apollo/wrapper/MinestomApolloWorld.java b/platform/minestom/src/main/java/com/lunarclient/apollo/wrapper/MinestomApolloWorld.java index a4c30f4c..57be618e 100644 --- a/platform/minestom/src/main/java/com/lunarclient/apollo/wrapper/MinestomApolloWorld.java +++ b/platform/minestom/src/main/java/com/lunarclient/apollo/wrapper/MinestomApolloWorld.java @@ -25,13 +25,16 @@ import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.player.ApolloPlayer; +import com.lunarclient.apollo.player.ApolloPlayerManager; import com.lunarclient.apollo.recipients.ForwardingRecipients; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.world.ApolloWorld; +import java.util.ArrayList; import java.util.Collection; -import java.util.Optional; -import java.util.stream.Collectors; +import java.util.List; +import java.util.Set; import lombok.AllArgsConstructor; +import net.minestom.server.entity.Player; import net.minestom.server.instance.Instance; /** @@ -51,11 +54,16 @@ public String getName() { @Override public Collection getPlayers() { - return this.instance.getPlayers().stream() - .map(player -> Apollo.getPlayerManager().getPlayer(player.getUuid())) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); + ApolloPlayerManager playerManager = Apollo.getPlayerManager(); + Set players = this.instance.getPlayers(); + List apolloPlayers = new ArrayList<>(players.size()); + + for (Player player : players) { + playerManager.getPlayer(player.getUuid()) + .ifPresent(apolloPlayers::add); + } + + return apolloPlayers; } @Override diff --git a/platform/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java b/platform/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java index e9b04e67..8d3ed35f 100644 --- a/platform/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java +++ b/platform/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java @@ -50,6 +50,8 @@ import com.lunarclient.apollo.module.hologram.HologramModuleImpl; import com.lunarclient.apollo.module.limb.LimbModule; import com.lunarclient.apollo.module.limb.LimbModuleImpl; +import com.lunarclient.apollo.module.marker.MarkerModule; +import com.lunarclient.apollo.module.marker.MarkerModuleImpl; import com.lunarclient.apollo.module.modsetting.ModSettingModule; import com.lunarclient.apollo.module.modsettings.ModSettingModuleImpl; import com.lunarclient.apollo.module.nametag.NametagModule; @@ -110,7 +112,7 @@ @Plugin( id = "apollo", name = "Apollo-Velocity", - version = "1.2.7", + version = "1.2.8", url = "https://moonsworth.com", description = "Implementation of Apollo for Velocity", authors = {"Moonsworth"} @@ -198,6 +200,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) { .addModule(EntityModule.class, new EntityModuleImpl()) .addModule(HologramModule.class, new HologramModuleImpl()) .addModule(LimbModule.class, new LimbModuleImpl()) + .addModule(MarkerModule.class, new MarkerModuleImpl()) .addModule(ModSettingModule.class, new ModSettingModuleImpl()) .addModule(NametagModule.class, new NametagModuleImpl()) .addModule(NotificationModule.class, new NotificationModuleImpl()) diff --git a/settings.gradle.kts b/settings.gradle.kts index ff9bce4d..94c4f945 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,14 +1,6 @@ pluginManagement { includeBuild("build-logic") repositories { - maven(url = "https://repo.stellardrift.ca/repository/internal/") { - name = "stellardriftReleases" - mavenContent { releasesOnly() } - } - maven(url = "https://repo.stellardrift.ca/repository/snapshots/") { - name = "stellardriftSnapshots" - mavenContent { snapshotsOnly() } - } gradlePluginPortal() maven("https://repo.jpenilla.xyz/snapshots") }