diff --git a/README.md b/README.md index 1d533c25..6d554e82 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # Apollo -![Build Status](https://img.shields.io/github/actions/workflow/status/LunarClient/Apollo/.github/workflows/deploy.yml) [![Discord](https://img.shields.io/discord/1080556677004271666?logo=discord&label=discord)](https://discord.gg/3T9Atyb6pf) Apollo is a powerful tool that allows developers to create custom integrations with Lunar Client. diff --git a/api/src/main/java/com/lunarclient/apollo/event/player/ApolloPlayerHandshakeEvent.java b/api/src/main/java/com/lunarclient/apollo/event/player/ApolloPlayerHandshakeEvent.java index 0691150c..43061554 100644 --- a/api/src/main/java/com/lunarclient/apollo/event/player/ApolloPlayerHandshakeEvent.java +++ b/api/src/main/java/com/lunarclient/apollo/event/player/ApolloPlayerHandshakeEvent.java @@ -27,6 +27,7 @@ import com.lunarclient.apollo.client.version.LunarClientVersion; import com.lunarclient.apollo.client.version.MinecraftVersion; import com.lunarclient.apollo.event.Event; +import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.List; import lombok.Value; @@ -71,4 +72,12 @@ public class ApolloPlayerHandshakeEvent implements Event { */ List installedMods; + /** + * The {@link TebexEmbeddedCheckoutSupport} type. + * + * @return the Tebex checkout support type + * @since 1.1.6 + */ + TebexEmbeddedCheckoutSupport tebexEmbeddedCheckoutSupport; + } diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModChat.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModChat.java index 0c464e31..a72f2526 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModChat.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModChat.java @@ -118,6 +118,17 @@ public final class ModChat { .notifyClient() .build(); + /** + * Requires the ping message to exactly contain your name.For example, if your name is Notch, this will ping on Notch but not Notch123. + * + * @since 1.1.6 + */ + public static final SimpleOption CHAT_PING_EXACT_MATCH = SimpleOption.builder() + .comment("Requires the ping message to exactly contain your name.For example, if your name is Notch, this will ping on Notch but not Notch123.") + .node("chat", "chat-ping-exact-match").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + /** * Copies the hovered chat message when holding the keybind and clicking. * diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModClock.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModClock.java index 57630c76..1e9d2c0c 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModClock.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModClock.java @@ -66,6 +66,26 @@ public final class ModClock { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption BRACKETS = SimpleOption.builder() + .node("clock", "brackets").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption BRACKET_COLOR = SimpleOption.builder() + .node("clock", "bracket-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * No documentation available. * @@ -88,13 +108,13 @@ public final class ModClock { .build(); /** - * No documentation available. + * If this is disabled the background will change size with the text. * - * @since 1.0.0 + * @since 1.1.6 */ - public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() - .node("clock", "background-width").type(TypeToken.get(Integer.class)) - .min(46).max(62) + public static final SimpleOption STATIC_BACKGROUND_HEIGHT = SimpleOption.builder() + .comment("If this is disabled the background will change size with the text.") + .node("clock", "static-background-height").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -103,9 +123,9 @@ public final class ModClock { * * @since 1.0.0 */ - public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() - .node("clock", "background-height").type(TypeToken.get(Integer.class)) - .min(10).max(22) + public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() + .node("clock", "background-width").type(TypeToken.get(Integer.class)) + .min(46).max(62) .notifyClient() .build(); @@ -114,8 +134,9 @@ public final class ModClock { * * @since 1.0.0 */ - public static final SimpleOption BRACKETS = SimpleOption.builder() - .node("clock", "brackets").type(TypeToken.get(Boolean.class)) + public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() + .node("clock", "background-height").type(TypeToken.get(Integer.class)) + .min(10).max(22) .notifyClient() .build(); @@ -145,8 +166,8 @@ public final class ModClock { * * @since 1.0.0 */ - public static final SimpleOption TEXT_COLOR = SimpleOption.builder() - .node("clock", "text-color").type(TypeToken.get(Color.class)) + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("clock", "border-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -165,8 +186,8 @@ public final class ModClock { * * @since 1.0.0 */ - public static final SimpleOption BORDER_COLOR = SimpleOption.builder() - .node("clock", "border-color").type(TypeToken.get(Color.class)) + public static final SimpleOption TEXT_COLOR = SimpleOption.builder() + .node("clock", "text-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModCombo.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModCombo.java index fec59804..db3d956f 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModCombo.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModCombo.java @@ -66,6 +66,26 @@ public final class ModCombo { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption BRACKETS = SimpleOption.builder() + .node("combo", "brackets").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption BRACKET_COLOR = SimpleOption.builder() + .node("combo", "bracket-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * No documentation available. * @@ -88,13 +108,13 @@ public final class ModCombo { .build(); /** - * No documentation available. + * If this is disabled the background will change size with the text. * - * @since 1.0.0 + * @since 1.1.6 */ - public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() - .node("combo", "background-width").type(TypeToken.get(Integer.class)) - .min(46).max(62) + public static final SimpleOption STATIC_BACKGROUND_HEIGHT = SimpleOption.builder() + .comment("If this is disabled the background will change size with the text.") + .node("combo", "static-background-height").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -103,9 +123,9 @@ public final class ModCombo { * * @since 1.0.0 */ - public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() - .node("combo", "background-height").type(TypeToken.get(Integer.class)) - .min(10).max(22) + public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() + .node("combo", "background-width").type(TypeToken.get(Integer.class)) + .min(46).max(62) .notifyClient() .build(); @@ -114,8 +134,9 @@ public final class ModCombo { * * @since 1.0.0 */ - public static final SimpleOption BRACKETS = SimpleOption.builder() - .node("combo", "brackets").type(TypeToken.get(Boolean.class)) + public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() + .node("combo", "background-height").type(TypeToken.get(Integer.class)) + .min(10).max(22) .notifyClient() .build(); @@ -145,8 +166,8 @@ public final class ModCombo { * * @since 1.0.0 */ - public static final SimpleOption TEXT_COLOR = SimpleOption.builder() - .node("combo", "text-color").type(TypeToken.get(Color.class)) + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("combo", "border-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -165,8 +186,8 @@ public final class ModCombo { * * @since 1.0.0 */ - public static final SimpleOption BORDER_COLOR = SimpleOption.builder() - .node("combo", "border-color").type(TypeToken.get(Color.class)) + public static final SimpleOption TEXT_COLOR = SimpleOption.builder() + .node("combo", "text-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModCps.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModCps.java index 25ac423d..83b71afa 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModCps.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModCps.java @@ -66,6 +66,26 @@ public final class ModCps { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption BRACKETS = SimpleOption.builder() + .node("cps", "brackets").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption BRACKET_COLOR = SimpleOption.builder() + .node("cps", "bracket-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * No documentation available. * @@ -88,13 +108,13 @@ public final class ModCps { .build(); /** - * No documentation available. + * If this is disabled the background will change size with the text. * - * @since 1.0.0 + * @since 1.1.6 */ - public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() - .node("cps", "background-width").type(TypeToken.get(Integer.class)) - .min(40).max(62) + public static final SimpleOption STATIC_BACKGROUND_HEIGHT = SimpleOption.builder() + .comment("If this is disabled the background will change size with the text.") + .node("cps", "static-background-height").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -103,9 +123,9 @@ public final class ModCps { * * @since 1.0.0 */ - public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() - .node("cps", "background-height").type(TypeToken.get(Integer.class)) - .min(10).max(22) + public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() + .node("cps", "background-width").type(TypeToken.get(Integer.class)) + .min(40).max(62) .notifyClient() .build(); @@ -114,8 +134,9 @@ public final class ModCps { * * @since 1.0.0 */ - public static final SimpleOption BRACKETS = SimpleOption.builder() - .node("cps", "brackets").type(TypeToken.get(Boolean.class)) + public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() + .node("cps", "background-height").type(TypeToken.get(Integer.class)) + .min(10).max(22) .notifyClient() .build(); @@ -145,8 +166,8 @@ public final class ModCps { * * @since 1.0.0 */ - public static final SimpleOption TEXT_COLOR = SimpleOption.builder() - .node("cps", "text-color").type(TypeToken.get(Color.class)) + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("cps", "border-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -165,8 +186,8 @@ public final class ModCps { * * @since 1.0.0 */ - public static final SimpleOption BORDER_COLOR = SimpleOption.builder() - .node("cps", "border-color").type(TypeToken.get(Color.class)) + public static final SimpleOption TEXT_COLOR = SimpleOption.builder() + .node("cps", "text-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -185,8 +206,8 @@ public final class ModCps { * * @since 1.0.0 */ - public static final SimpleOption SHOW_CPSTEXT = SimpleOption.builder() - .node("cps", "show-c-p-s-text").type(TypeToken.get(Boolean.class)) + public static final SimpleOption LINE_COLOR = SimpleOption.builder() + .node("cps", "line-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -195,8 +216,8 @@ public final class ModCps { * * @since 1.0.0 */ - public static final SimpleOption LINE_COLOR = SimpleOption.builder() - .node("cps", "line-color").type(TypeToken.get(Color.class)) + public static final SimpleOption SHOW_CPSTEXT = SimpleOption.builder() + .node("cps", "show-c-p-s-text").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModDayCounter.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModDayCounter.java index 2103bffa..790a17da 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModDayCounter.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModDayCounter.java @@ -66,6 +66,26 @@ public final class ModDayCounter { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption BRACKETS = SimpleOption.builder() + .node("day-counter", "brackets").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption BRACKET_COLOR = SimpleOption.builder() + .node("day-counter", "bracket-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * No documentation available. * @@ -88,13 +108,13 @@ public final class ModDayCounter { .build(); /** - * No documentation available. + * If this is disabled the background will change size with the text. * - * @since 1.0.0 + * @since 1.1.6 */ - public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() - .node("day-counter", "background-width").type(TypeToken.get(Integer.class)) - .min(46).max(62) + public static final SimpleOption STATIC_BACKGROUND_HEIGHT = SimpleOption.builder() + .comment("If this is disabled the background will change size with the text.") + .node("day-counter", "static-background-height").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -103,9 +123,9 @@ public final class ModDayCounter { * * @since 1.0.0 */ - public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() - .node("day-counter", "background-height").type(TypeToken.get(Integer.class)) - .min(10).max(22) + public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() + .node("day-counter", "background-width").type(TypeToken.get(Integer.class)) + .min(46).max(62) .notifyClient() .build(); @@ -114,8 +134,9 @@ public final class ModDayCounter { * * @since 1.0.0 */ - public static final SimpleOption BRACKETS = SimpleOption.builder() - .node("day-counter", "brackets").type(TypeToken.get(Boolean.class)) + public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() + .node("day-counter", "background-height").type(TypeToken.get(Integer.class)) + .min(10).max(22) .notifyClient() .build(); @@ -145,8 +166,8 @@ public final class ModDayCounter { * * @since 1.0.0 */ - public static final SimpleOption TEXT_COLOR = SimpleOption.builder() - .node("day-counter", "text-color").type(TypeToken.get(Color.class)) + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("day-counter", "border-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -165,8 +186,8 @@ public final class ModDayCounter { * * @since 1.0.0 */ - public static final SimpleOption BORDER_COLOR = SimpleOption.builder() - .node("day-counter", "border-color").type(TypeToken.get(Color.class)) + public static final SimpleOption TEXT_COLOR = SimpleOption.builder() + .node("day-counter", "text-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModFps.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModFps.java index c220e0a8..767cfe95 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModFps.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModFps.java @@ -66,6 +66,26 @@ public final class ModFps { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption BRACKETS = SimpleOption.builder() + .node("fps", "brackets").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption BRACKET_COLOR = SimpleOption.builder() + .node("fps", "bracket-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * No documentation available. * @@ -88,13 +108,13 @@ public final class ModFps { .build(); /** - * No documentation available. + * If this is disabled the background will change size with the text. * - * @since 1.0.0 + * @since 1.1.6 */ - public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() - .node("fps", "background-width").type(TypeToken.get(Integer.class)) - .min(50).max(62) + public static final SimpleOption STATIC_BACKGROUND_HEIGHT = SimpleOption.builder() + .comment("If this is disabled the background will change size with the text.") + .node("fps", "static-background-height").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -103,9 +123,9 @@ public final class ModFps { * * @since 1.0.0 */ - public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() - .node("fps", "background-height").type(TypeToken.get(Integer.class)) - .min(10).max(22) + public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() + .node("fps", "background-width").type(TypeToken.get(Integer.class)) + .min(50).max(62) .notifyClient() .build(); @@ -114,8 +134,9 @@ public final class ModFps { * * @since 1.0.0 */ - public static final SimpleOption BRACKETS = SimpleOption.builder() - .node("fps", "brackets").type(TypeToken.get(Boolean.class)) + public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() + .node("fps", "background-height").type(TypeToken.get(Integer.class)) + .min(10).max(22) .notifyClient() .build(); @@ -145,8 +166,8 @@ public final class ModFps { * * @since 1.0.0 */ - public static final SimpleOption TEXT_COLOR = SimpleOption.builder() - .node("fps", "text-color").type(TypeToken.get(Color.class)) + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("fps", "border-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -165,8 +186,8 @@ public final class ModFps { * * @since 1.0.0 */ - public static final SimpleOption BORDER_COLOR = SimpleOption.builder() - .node("fps", "border-color").type(TypeToken.get(Color.class)) + public static final SimpleOption TEXT_COLOR = SimpleOption.builder() + .node("fps", "text-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModMemory.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModMemory.java index 8d8cfedf..2feb08fb 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModMemory.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModMemory.java @@ -66,6 +66,26 @@ public final class ModMemory { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption BRACKETS = SimpleOption.builder() + .node("memory", "brackets").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption BRACKET_COLOR = SimpleOption.builder() + .node("memory", "bracket-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * No documentation available. * @@ -88,13 +108,13 @@ public final class ModMemory { .build(); /** - * No documentation available. + * If this is disabled the background will change size with the text. * - * @since 1.0.0 + * @since 1.1.6 */ - public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() - .node("memory", "background-width").type(TypeToken.get(Integer.class)) - .min(46).max(62) + public static final SimpleOption STATIC_BACKGROUND_HEIGHT = SimpleOption.builder() + .comment("If this is disabled the background will change size with the text.") + .node("memory", "static-background-height").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -103,9 +123,9 @@ public final class ModMemory { * * @since 1.0.0 */ - public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() - .node("memory", "background-height").type(TypeToken.get(Integer.class)) - .min(10).max(22) + public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() + .node("memory", "background-width").type(TypeToken.get(Integer.class)) + .min(46).max(62) .notifyClient() .build(); @@ -114,8 +134,9 @@ public final class ModMemory { * * @since 1.0.0 */ - public static final SimpleOption BRACKETS = SimpleOption.builder() - .node("memory", "brackets").type(TypeToken.get(Boolean.class)) + public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() + .node("memory", "background-height").type(TypeToken.get(Integer.class)) + .min(10).max(22) .notifyClient() .build(); @@ -145,8 +166,8 @@ public final class ModMemory { * * @since 1.0.0 */ - public static final SimpleOption TEXT_COLOR = SimpleOption.builder() - .node("memory", "text-color").type(TypeToken.get(Color.class)) + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("memory", "border-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -165,8 +186,8 @@ public final class ModMemory { * * @since 1.0.0 */ - public static final SimpleOption BORDER_COLOR = SimpleOption.builder() - .node("memory", "border-color").type(TypeToken.get(Color.class)) + public static final SimpleOption TEXT_COLOR = SimpleOption.builder() + .node("memory", "text-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModMomentum.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModMomentum.java index 7bb08a9c..bc5e5a40 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModMomentum.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModMomentum.java @@ -66,6 +66,26 @@ public final class ModMomentum { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption BRACKETS = SimpleOption.builder() + .node("momentum", "brackets").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption BRACKET_COLOR = SimpleOption.builder() + .node("momentum", "bracket-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * No documentation available. * @@ -88,13 +108,13 @@ public final class ModMomentum { .build(); /** - * No documentation available. + * If this is disabled the background will change size with the text. * - * @since 1.0.0 + * @since 1.1.6 */ - public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() - .node("momentum", "background-width").type(TypeToken.get(Integer.class)) - .min(50).max(62) + public static final SimpleOption STATIC_BACKGROUND_HEIGHT = SimpleOption.builder() + .comment("If this is disabled the background will change size with the text.") + .node("momentum", "static-background-height").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -103,9 +123,9 @@ public final class ModMomentum { * * @since 1.0.0 */ - public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() - .node("momentum", "background-height").type(TypeToken.get(Integer.class)) - .min(10).max(22) + public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() + .node("momentum", "background-width").type(TypeToken.get(Integer.class)) + .min(50).max(62) .notifyClient() .build(); @@ -114,8 +134,9 @@ public final class ModMomentum { * * @since 1.0.0 */ - public static final SimpleOption BRACKETS = SimpleOption.builder() - .node("momentum", "brackets").type(TypeToken.get(Boolean.class)) + public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() + .node("momentum", "background-height").type(TypeToken.get(Integer.class)) + .min(10).max(22) .notifyClient() .build(); @@ -145,8 +166,8 @@ public final class ModMomentum { * * @since 1.0.0 */ - public static final SimpleOption TEXT_COLOR = SimpleOption.builder() - .node("momentum", "text-color").type(TypeToken.get(Color.class)) + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("momentum", "border-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -165,8 +186,8 @@ public final class ModMomentum { * * @since 1.0.0 */ - public static final SimpleOption BORDER_COLOR = SimpleOption.builder() - .node("momentum", "border-color").type(TypeToken.get(Color.class)) + public static final SimpleOption TEXT_COLOR = SimpleOption.builder() + .node("momentum", "text-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModPackDisplay.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModPackDisplay.java index a968bc7f..883d4931 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModPackDisplay.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModPackDisplay.java @@ -66,6 +66,26 @@ public final class ModPackDisplay { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption BRACKETS = SimpleOption.builder() + .node("pack-display", "brackets").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption BRACKET_COLOR = SimpleOption.builder() + .node("pack-display", "bracket-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * No documentation available. * @@ -88,13 +108,13 @@ public final class ModPackDisplay { .build(); /** - * No documentation available. + * If this is disabled the background will change size with the text. * - * @since 1.0.0 + * @since 1.1.6 */ - public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() - .node("pack-display", "background-width").type(TypeToken.get(Integer.class)) - .min(60).max(300) + public static final SimpleOption STATIC_BACKGROUND_HEIGHT = SimpleOption.builder() + .comment("If this is disabled the background will change size with the text.") + .node("pack-display", "static-background-height").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -103,9 +123,9 @@ public final class ModPackDisplay { * * @since 1.0.0 */ - public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() - .node("pack-display", "background-height").type(TypeToken.get(Integer.class)) - .min(12).max(64) + public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() + .node("pack-display", "background-width").type(TypeToken.get(Integer.class)) + .min(60).max(300) .notifyClient() .build(); @@ -114,8 +134,9 @@ public final class ModPackDisplay { * * @since 1.0.0 */ - public static final SimpleOption BRACKETS = SimpleOption.builder() - .node("pack-display", "brackets").type(TypeToken.get(Boolean.class)) + public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() + .node("pack-display", "background-height").type(TypeToken.get(Integer.class)) + .min(12).max(64) .notifyClient() .build(); @@ -145,8 +166,8 @@ public final class ModPackDisplay { * * @since 1.0.0 */ - public static final SimpleOption TEXT_COLOR = SimpleOption.builder() - .node("pack-display", "text-color").type(TypeToken.get(Color.class)) + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("pack-display", "border-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -165,8 +186,8 @@ public final class ModPackDisplay { * * @since 1.0.0 */ - public static final SimpleOption BORDER_COLOR = SimpleOption.builder() - .node("pack-display", "border-color").type(TypeToken.get(Color.class)) + public static final SimpleOption TEXT_COLOR = SimpleOption.builder() + .node("pack-display", "text-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModPlaytime.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModPlaytime.java index ca587b75..57a67f40 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModPlaytime.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModPlaytime.java @@ -66,6 +66,26 @@ public final class ModPlaytime { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption BRACKETS = SimpleOption.builder() + .node("playtime", "brackets").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption BRACKET_COLOR = SimpleOption.builder() + .node("playtime", "bracket-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * No documentation available. * @@ -88,13 +108,13 @@ public final class ModPlaytime { .build(); /** - * No documentation available. + * If this is disabled the background will change size with the text. * - * @since 1.0.0 + * @since 1.1.6 */ - public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() - .node("playtime", "background-width").type(TypeToken.get(Integer.class)) - .min(60).max(120) + public static final SimpleOption STATIC_BACKGROUND_HEIGHT = SimpleOption.builder() + .comment("If this is disabled the background will change size with the text.") + .node("playtime", "static-background-height").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -103,9 +123,9 @@ public final class ModPlaytime { * * @since 1.0.0 */ - public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() - .node("playtime", "background-height").type(TypeToken.get(Integer.class)) - .min(10).max(22) + public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() + .node("playtime", "background-width").type(TypeToken.get(Integer.class)) + .min(60).max(120) .notifyClient() .build(); @@ -114,8 +134,9 @@ public final class ModPlaytime { * * @since 1.0.0 */ - public static final SimpleOption BRACKETS = SimpleOption.builder() - .node("playtime", "brackets").type(TypeToken.get(Boolean.class)) + public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() + .node("playtime", "background-height").type(TypeToken.get(Integer.class)) + .min(10).max(22) .notifyClient() .build(); @@ -145,8 +166,8 @@ public final class ModPlaytime { * * @since 1.0.0 */ - public static final SimpleOption TEXT_COLOR = SimpleOption.builder() - .node("playtime", "text-color").type(TypeToken.get(Color.class)) + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("playtime", "border-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -165,8 +186,8 @@ public final class ModPlaytime { * * @since 1.0.0 */ - public static final SimpleOption BORDER_COLOR = SimpleOption.builder() - .node("playtime", "border-color").type(TypeToken.get(Color.class)) + public static final SimpleOption TEXT_COLOR = SimpleOption.builder() + .node("playtime", "text-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModReachDisplay.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModReachDisplay.java index 8b97982b..63f6a9b0 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModReachDisplay.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModReachDisplay.java @@ -66,6 +66,26 @@ public final class ModReachDisplay { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption BRACKETS = SimpleOption.builder() + .node("reach-display", "brackets").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption BRACKET_COLOR = SimpleOption.builder() + .node("reach-display", "bracket-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * No documentation available. * @@ -88,13 +108,13 @@ public final class ModReachDisplay { .build(); /** - * No documentation available. + * If this is disabled the background will change size with the text. * - * @since 1.0.0 + * @since 1.1.6 */ - public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() - .node("reach-display", "background-width").type(TypeToken.get(Integer.class)) - .min(40).max(72) + public static final SimpleOption STATIC_BACKGROUND_HEIGHT = SimpleOption.builder() + .comment("If this is disabled the background will change size with the text.") + .node("reach-display", "static-background-height").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -103,9 +123,9 @@ public final class ModReachDisplay { * * @since 1.0.0 */ - public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() - .node("reach-display", "background-height").type(TypeToken.get(Integer.class)) - .min(10).max(22) + public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() + .node("reach-display", "background-width").type(TypeToken.get(Integer.class)) + .min(40).max(72) .notifyClient() .build(); @@ -114,8 +134,9 @@ public final class ModReachDisplay { * * @since 1.0.0 */ - public static final SimpleOption BRACKETS = SimpleOption.builder() - .node("reach-display", "brackets").type(TypeToken.get(Boolean.class)) + public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() + .node("reach-display", "background-height").type(TypeToken.get(Integer.class)) + .min(10).max(22) .notifyClient() .build(); @@ -145,8 +166,8 @@ public final class ModReachDisplay { * * @since 1.0.0 */ - public static final SimpleOption TEXT_COLOR = SimpleOption.builder() - .node("reach-display", "text-color").type(TypeToken.get(Color.class)) + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("reach-display", "border-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -165,8 +186,8 @@ public final class ModReachDisplay { * * @since 1.0.0 */ - public static final SimpleOption BORDER_COLOR = SimpleOption.builder() - .node("reach-display", "border-color").type(TypeToken.get(Color.class)) + public static final SimpleOption TEXT_COLOR = SimpleOption.builder() + .node("reach-display", "text-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModServerAddress.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModServerAddress.java index 0bb3ce97..90835cc4 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModServerAddress.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModServerAddress.java @@ -66,6 +66,26 @@ public final class ModServerAddress { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption BRACKETS = SimpleOption.builder() + .node("server-address", "brackets").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption BRACKET_COLOR = SimpleOption.builder() + .node("server-address", "bracket-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * No documentation available. * @@ -88,13 +108,13 @@ public final class ModServerAddress { .build(); /** - * No documentation available. + * If this is disabled the background will change size with the text. * - * @since 1.0.0 + * @since 1.1.6 */ - public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() - .node("server-address", "background-width").type(TypeToken.get(Integer.class)) - .min(40).max(62) + public static final SimpleOption STATIC_BACKGROUND_HEIGHT = SimpleOption.builder() + .comment("If this is disabled the background will change size with the text.") + .node("server-address", "static-background-height").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -103,9 +123,9 @@ public final class ModServerAddress { * * @since 1.0.0 */ - public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() - .node("server-address", "background-height").type(TypeToken.get(Integer.class)) - .min(10).max(22) + public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() + .node("server-address", "background-width").type(TypeToken.get(Integer.class)) + .min(40).max(62) .notifyClient() .build(); @@ -114,8 +134,9 @@ public final class ModServerAddress { * * @since 1.0.0 */ - public static final SimpleOption BRACKETS = SimpleOption.builder() - .node("server-address", "brackets").type(TypeToken.get(Boolean.class)) + public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() + .node("server-address", "background-height").type(TypeToken.get(Integer.class)) + .min(10).max(22) .notifyClient() .build(); @@ -145,8 +166,8 @@ public final class ModServerAddress { * * @since 1.0.0 */ - public static final SimpleOption TEXT_COLOR = SimpleOption.builder() - .node("server-address", "text-color").type(TypeToken.get(Color.class)) + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("server-address", "border-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -165,8 +186,8 @@ public final class ModServerAddress { * * @since 1.0.0 */ - public static final SimpleOption BORDER_COLOR = SimpleOption.builder() - .node("server-address", "border-color").type(TypeToken.get(Color.class)) + public static final SimpleOption TEXT_COLOR = SimpleOption.builder() + .node("server-address", "text-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModSkyblock.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModSkyblock.java index 05497b5d..f151b8ad 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModSkyblock.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModSkyblock.java @@ -170,6 +170,36 @@ public final class ModSkyblock { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption SKY_BLOCK_WISHING_COMPASS = SimpleOption.builder() + .node("skyblock", "sky-block-wishing-compass").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption SKY_BLOCK_METAL_DETECTOR = SimpleOption.builder() + .node("skyblock", "sky-block-metal-detector").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption SKY_BLOCK_FINISHED_COMMISSIONS = SimpleOption.builder() + .node("skyblock", "sky-block-finished-commissions").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + /** * Fixes your fishing bobber sinking in lava. * diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModStopwatch.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModStopwatch.java index 08bda120..4eeca98e 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModStopwatch.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModStopwatch.java @@ -66,6 +66,26 @@ public final class ModStopwatch { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption BRACKETS = SimpleOption.builder() + .node("stopwatch", "brackets").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption BRACKET_COLOR = SimpleOption.builder() + .node("stopwatch", "bracket-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * No documentation available. * @@ -88,13 +108,13 @@ public final class ModStopwatch { .build(); /** - * No documentation available. + * If this is disabled the background will change size with the text. * - * @since 1.0.0 + * @since 1.1.6 */ - public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() - .node("stopwatch", "background-width").type(TypeToken.get(Integer.class)) - .min(44).max(120) + public static final SimpleOption STATIC_BACKGROUND_HEIGHT = SimpleOption.builder() + .comment("If this is disabled the background will change size with the text.") + .node("stopwatch", "static-background-height").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -103,9 +123,9 @@ public final class ModStopwatch { * * @since 1.0.0 */ - public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() - .node("stopwatch", "background-height").type(TypeToken.get(Integer.class)) - .min(10).max(22) + public static final NumberOption BACKGROUND_WIDTH = NumberOption.number() + .node("stopwatch", "background-width").type(TypeToken.get(Integer.class)) + .min(44).max(120) .notifyClient() .build(); @@ -114,8 +134,9 @@ public final class ModStopwatch { * * @since 1.0.0 */ - public static final SimpleOption BRACKETS = SimpleOption.builder() - .node("stopwatch", "brackets").type(TypeToken.get(Boolean.class)) + public static final NumberOption BACKGROUND_HEIGHT = NumberOption.number() + .node("stopwatch", "background-height").type(TypeToken.get(Integer.class)) + .min(10).max(22) .notifyClient() .build(); @@ -145,8 +166,8 @@ public final class ModStopwatch { * * @since 1.0.0 */ - public static final SimpleOption TEXT_COLOR = SimpleOption.builder() - .node("stopwatch", "text-color").type(TypeToken.get(Color.class)) + public static final SimpleOption BORDER_COLOR = SimpleOption.builder() + .node("stopwatch", "border-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); @@ -165,8 +186,8 @@ public final class ModStopwatch { * * @since 1.0.0 */ - public static final SimpleOption BORDER_COLOR = SimpleOption.builder() - .node("stopwatch", "border-color").type(TypeToken.get(Color.class)) + public static final SimpleOption TEXT_COLOR = SimpleOption.builder() + .node("stopwatch", "text-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModTab.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModTab.java index 7a0a62b4..4caa91ef 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModTab.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModTab.java @@ -216,16 +216,6 @@ public final class ModTab { .notifyClient() .build(); - /** - * No documentation available. - * - * @since 1.0.0 - */ - public static final SimpleOption DYNAMIC_PING_COLOR = SimpleOption.builder() - .node("tab", "dynamic-ping-color").type(TypeToken.get(Boolean.class)) - .notifyClient() - .build(); - /** * No documentation available. * @@ -241,8 +231,8 @@ public final class ModTab { * * @since 1.0.0 */ - public static final SimpleOption PING_NUMBER_COLOR = SimpleOption.builder() - .node("tab", "ping-number-color").type(TypeToken.get(Color.class)) + public static final SimpleOption DYNAMIC_PING_COLOR = SimpleOption.builder() + .node("tab", "dynamic-ping-color").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -286,6 +276,16 @@ public final class ModTab { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.0.0 + */ + public static final SimpleOption PING_NUMBER_COLOR = SimpleOption.builder() + .node("tab", "ping-number-color").type(TypeToken.get(Color.class)) + .notifyClient() + .build(); + /** * An option to toggle LC logos in player list tab overlay. * diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModTitles.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModTitles.java index 0ce8b09a..93e99f52 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModTitles.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModTitles.java @@ -67,64 +67,64 @@ public final class ModTitles { .build(); /** - * Keep the title centered around the center of the mod on-screen. + * No documentation available. * - * @since 1.1.2 + * @since 1.0.0 */ - public static final SimpleOption KEEP_TITLE_CENTERED = SimpleOption.builder() - .comment("Keep the title centered around the center of the mod on-screen") - .node("titles", "keep-title-centered").type(TypeToken.get(Boolean.class)) + public static final SimpleOption TITLE_COLOR = SimpleOption.builder() + .node("titles", "title-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); /** - * Show title of height limit display. + * No documentation available. * - * @since 1.1.5 + * @since 1.0.0 */ - public static final SimpleOption SHOW_TITLE = SimpleOption.builder() - .comment("Show title of height limit display") - .node("titles", "show-title").type(TypeToken.get(Boolean.class)) + public static final SimpleOption SUBTITLE_COLOR = SimpleOption.builder() + .node("titles", "subtitle-color").type(TypeToken.get(Color.class)) .notifyClient() .build(); /** * No documentation available. * - * @since 1.1.5 + * @since 1.1.3 */ - public static final SimpleOption SHOW_SUBTITLE = SimpleOption.builder() - .node("titles", "show-subtitle").type(TypeToken.get(Boolean.class)) + public static final SimpleOption USE_MINECRAFT_GUISCALE = SimpleOption.builder() + .node("titles", "use-minecraft-g-u-i-scale").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); /** - * No documentation available. + * Keep the title centered around the center of the mod on-screen. * - * @since 1.0.0 + * @since 1.1.2 */ - public static final SimpleOption TITLE_COLOR = SimpleOption.builder() - .node("titles", "title-color").type(TypeToken.get(Color.class)) + public static final SimpleOption KEEP_TITLE_CENTERED = SimpleOption.builder() + .comment("Keep the title centered around the center of the mod on-screen") + .node("titles", "keep-title-centered").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); /** - * No documentation available. + * Show title of height limit display. * - * @since 1.0.0 + * @since 1.1.5 */ - public static final SimpleOption SUBTITLE_COLOR = SimpleOption.builder() - .node("titles", "subtitle-color").type(TypeToken.get(Color.class)) + public static final SimpleOption SHOW_TITLE = SimpleOption.builder() + .comment("Show title of height limit display") + .node("titles", "show-title").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); /** * No documentation available. * - * @since 1.1.3 + * @since 1.1.5 */ - public static final SimpleOption USE_MINECRAFT_GUISCALE = SimpleOption.builder() - .node("titles", "use-minecraft-g-u-i-scale").type(TypeToken.get(Boolean.class)) + public static final SimpleOption SHOW_SUBTITLE = SimpleOption.builder() + .node("titles", "show-subtitle").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModToggleSneak.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModToggleSneak.java index bede3eb1..d1394391 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModToggleSneak.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModToggleSneak.java @@ -69,8 +69,8 @@ public final class ModToggleSneak { * * @since 1.0.0 */ - public static final SimpleOption DOUBLE_TAP = SimpleOption.builder() - .node("toggle-sneak", "double-tap").type(TypeToken.get(Boolean.class)) + public static final SimpleOption TOGGLE_SNEAK_CONTAINER = SimpleOption.builder() + .node("toggle-sneak", "toggle-sneak-container").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); @@ -79,8 +79,8 @@ public final class ModToggleSneak { * * @since 1.0.0 */ - public static final SimpleOption TOGGLE_SNEAK_CONTAINER = SimpleOption.builder() - .node("toggle-sneak", "toggle-sneak-container").type(TypeToken.get(Boolean.class)) + public static final SimpleOption DOUBLE_TAP = SimpleOption.builder() + .node("toggle-sneak", "double-tap").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModWaypoints.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModWaypoints.java index 4f9dcfbb..c5284a60 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModWaypoints.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModWaypoints.java @@ -139,6 +139,16 @@ public final class ModWaypoints { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.1.6 + */ + public static final SimpleOption ADD_WAYPOINTS_FROM_CHAT = SimpleOption.builder() + .node("waypoints", "add-waypoints-from-chat").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + /** * Adds a waypoint if coordinates are clicked in chat. * diff --git a/api/src/main/java/com/lunarclient/apollo/module/tebex/TebexEmbeddedCheckoutSupport.java b/api/src/main/java/com/lunarclient/apollo/module/tebex/TebexEmbeddedCheckoutSupport.java new file mode 100644 index 00000000..7b8ab72e --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/tebex/TebexEmbeddedCheckoutSupport.java @@ -0,0 +1,54 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.tebex; + +/** + * Represents an embedded checkout support type. + * + * @since 1.1.6 + */ +public enum TebexEmbeddedCheckoutSupport { + + /** + * External checkout is supported as a game overlay. + * + * @since 1.1.6 + */ + OVERLAY, + + /** + * Embedded checkout is supported in an external window. + * + * @since 1.1.6 + */ + WINDOW, + + /** + * The checkout is not supported. + * + * @since 1.1.6 + */ + UNSUPPORTED + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/tebex/TebexModule.java b/api/src/main/java/com/lunarclient/apollo/module/tebex/TebexModule.java new file mode 100644 index 00000000..48b90d36 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/tebex/TebexModule.java @@ -0,0 +1,60 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.tebex; + +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 tebex module. + * + * @since 1.1.6 + */ +@ApiStatus.NonExtendable +@ModuleDefinition(id = "tebex", name = "Tebex") +public abstract class TebexModule extends ApolloModule { + + /** + * Displays the checkout with the provided {@link String} basked ident to the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param basketIdent the tebex basket ident + * @since 1.1.6 + */ + public abstract void displayTebexEmbeddedCheckout(Recipients recipients, String basketIdent); + + /** + * Displays the checkout with the provided {@link String} basked ident + * with optional {@link String} locale to the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param basketIdent the tebex basket ident + * @param locale the locale + * @since 1.1.6 + */ + public abstract void displayTebexEmbeddedCheckout(Recipients recipients, String basketIdent, String locale); + +} diff --git a/api/src/main/java/com/lunarclient/apollo/player/ApolloPlayer.java b/api/src/main/java/com/lunarclient/apollo/player/ApolloPlayer.java index 45fcb5d1..3ed20bd5 100644 --- a/api/src/main/java/com/lunarclient/apollo/player/ApolloPlayer.java +++ b/api/src/main/java/com/lunarclient/apollo/player/ApolloPlayer.java @@ -23,15 +23,21 @@ */ package com.lunarclient.apollo.player; +import com.lunarclient.apollo.client.mod.LunarClientMod; +import com.lunarclient.apollo.client.version.LunarClientVersion; +import com.lunarclient.apollo.client.version.MinecraftVersion; import com.lunarclient.apollo.common.location.ApolloLocation; +import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport; import com.lunarclient.apollo.option.Option; import com.lunarclient.apollo.option.Options; import com.lunarclient.apollo.recipients.Recipients; import com.lunarclient.apollo.world.ApolloWorld; +import java.util.List; import java.util.Optional; import java.util.UUID; import net.kyori.adventure.audience.ForwardingAudience; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; /** * Represents a player on Apollo. @@ -106,4 +112,36 @@ default boolean hasPermission(Options options, Option option) { */ Object getPlayer(); + /** + * Returns the {@link MinecraftVersion} the player is running. + * + * @return the minecraft version + * @since 1.1.6 + */ + @Nullable MinecraftVersion getMinecraftVersion(); + + /** + * Returns the {@link LunarClientVersion} the player is running. + * + * @return the lunar client version + * @since 1.1.6 + */ + @Nullable LunarClientVersion getLunarClientVersion(); + + /** + * Returns a {@link List} of {@link LunarClientMod} the player has installed. + * + * @return the installed mods + * @since 1.1.6 + */ + @Nullable List getInstalledMods(); + + /** + * Returns the {@link TebexEmbeddedCheckoutSupport} type. + * + * @return the Tebex checkout support type + * @since 1.1.6 + */ + @Nullable TebexEmbeddedCheckoutSupport getTebexEmbeddedCheckoutSupport(); + } diff --git a/bukkit-example/build.gradle.kts b/bukkit-example/build.gradle.kts index c2e4d456..3f9240e3 100644 --- a/bukkit-example/build.gradle.kts +++ b/bukkit-example/build.gradle.kts @@ -1,10 +1,23 @@ plugins { id("apollo.base-conventions") + id("apollo.shadow-conventions") } dependencies { compileOnly(libs.bukkit.api) + // Used for Proto Implementation + api(libs.protobuf) + + // Used for Proto & Json Implementation + api(libs.bundles.adventure) { + exclude("org.checkerframework") + exclude("net.kyori", "adventure-api") + exclude("net.kyori", "adventure-bom") + } + + // Used for API Implementation compileOnly(project(":extra:apollo-extra-adventure4")) compileOnly(project(path = ":apollo-api", configuration = "bukkit")) + compileOnly(project(path = ":apollo-common", configuration = "shadow")) } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java index 5088e289..4526747e 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java @@ -23,56 +23,138 @@ */ package com.lunarclient.apollo.example; -import com.lunarclient.apollo.event.EventBus; -import com.lunarclient.apollo.example.commands.BeamCommand; -import com.lunarclient.apollo.example.commands.BorderCommand; -import com.lunarclient.apollo.example.commands.ChatCommand; -import com.lunarclient.apollo.example.commands.ColoredFireCommand; -import com.lunarclient.apollo.example.commands.CombatCommand; -import com.lunarclient.apollo.example.commands.CooldownCommand; -import com.lunarclient.apollo.example.commands.EntityCommand; -import com.lunarclient.apollo.example.commands.GlowCommand; -import com.lunarclient.apollo.example.commands.HologramCommand; -import com.lunarclient.apollo.example.commands.LimbCommand; -import com.lunarclient.apollo.example.commands.ModSettingsCommand; -import com.lunarclient.apollo.example.commands.NametagCommand; -import com.lunarclient.apollo.example.commands.NickHiderCommand; -import com.lunarclient.apollo.example.commands.NotificationCommand; -import com.lunarclient.apollo.example.commands.RichPresenceCommand; -import com.lunarclient.apollo.example.commands.ServerRuleCommand; -import com.lunarclient.apollo.example.commands.StaffModCommand; -import com.lunarclient.apollo.example.commands.StopwatchCommand; -import com.lunarclient.apollo.example.commands.TeamCommand; -import com.lunarclient.apollo.example.commands.TitleCommand; -import com.lunarclient.apollo.example.commands.TntCountdownCommand; -import com.lunarclient.apollo.example.commands.TransferCommand; -import com.lunarclient.apollo.example.commands.VignetteCommand; -import com.lunarclient.apollo.example.commands.WaypointCommand; -import com.lunarclient.apollo.example.listeners.PlayerListener; -import com.lunarclient.apollo.example.modules.BeamExample; -import com.lunarclient.apollo.example.modules.BorderExample; -import com.lunarclient.apollo.example.modules.ChatExample; -import com.lunarclient.apollo.example.modules.ColoredFireExample; -import com.lunarclient.apollo.example.modules.CombatExample; -import com.lunarclient.apollo.example.modules.CooldownExample; -import com.lunarclient.apollo.example.modules.EntityExample; -import com.lunarclient.apollo.example.modules.GlowExample; -import com.lunarclient.apollo.example.modules.HologramExample; -import com.lunarclient.apollo.example.modules.LimbExample; -import com.lunarclient.apollo.example.modules.ModSettingsExample; -import com.lunarclient.apollo.example.modules.NametagExample; -import com.lunarclient.apollo.example.modules.NickHiderExample; -import com.lunarclient.apollo.example.modules.NotificationExample; -import com.lunarclient.apollo.example.modules.RichPresenceExample; -import com.lunarclient.apollo.example.modules.ServerRuleExample; -import com.lunarclient.apollo.example.modules.StaffModExample; -import com.lunarclient.apollo.example.modules.StopwatchExample; -import com.lunarclient.apollo.example.modules.TeamExample; -import com.lunarclient.apollo.example.modules.TitleExample; -import com.lunarclient.apollo.example.modules.TntCountdownExample; -import com.lunarclient.apollo.example.modules.TransferExample; -import com.lunarclient.apollo.example.modules.VignetteExample; -import com.lunarclient.apollo.example.modules.WaypointExample; +import com.lunarclient.apollo.example.api.examples.BeamApiExample; +import com.lunarclient.apollo.example.api.examples.BorderApiExample; +import com.lunarclient.apollo.example.api.examples.ChatApiExample; +import com.lunarclient.apollo.example.api.examples.ColoredFireApiExample; +import com.lunarclient.apollo.example.api.examples.CombatApiExample; +import com.lunarclient.apollo.example.api.examples.CooldownApiExample; +import com.lunarclient.apollo.example.api.examples.EntityApiExample; +import com.lunarclient.apollo.example.api.examples.GlowApiExample; +import com.lunarclient.apollo.example.api.examples.HologramApiExample; +import com.lunarclient.apollo.example.api.examples.LimbApiExample; +import com.lunarclient.apollo.example.api.examples.ModSettingsApiExample; +import com.lunarclient.apollo.example.api.examples.NametagApiExample; +import com.lunarclient.apollo.example.api.examples.NickHiderApiExample; +import com.lunarclient.apollo.example.api.examples.NotificationApiExample; +import com.lunarclient.apollo.example.api.examples.RichPresenceApiExample; +import com.lunarclient.apollo.example.api.examples.ServerRuleApiExample; +import com.lunarclient.apollo.example.api.examples.StaffModApiExample; +import com.lunarclient.apollo.example.api.examples.StopwatchApiExample; +import com.lunarclient.apollo.example.api.examples.TeamApiExample; +import com.lunarclient.apollo.example.api.examples.TebexApiExample; +import com.lunarclient.apollo.example.api.examples.TitleApiExample; +import com.lunarclient.apollo.example.api.examples.TntCountdownApiExample; +import com.lunarclient.apollo.example.api.examples.TransferApiExample; +import com.lunarclient.apollo.example.api.examples.VignetteApiExample; +import com.lunarclient.apollo.example.api.examples.WaypointApiExample; +import com.lunarclient.apollo.example.api.listeners.ApolloPlayerApiListener; +import com.lunarclient.apollo.example.common.commands.SwitchCommand; +import com.lunarclient.apollo.example.common.commands.debug.ApolloDebugCommand; +import com.lunarclient.apollo.example.common.commands.module.BeamCommand; +import com.lunarclient.apollo.example.common.commands.module.BorderCommand; +import com.lunarclient.apollo.example.common.commands.module.ChatCommand; +import com.lunarclient.apollo.example.common.commands.module.ColoredFireCommand; +import com.lunarclient.apollo.example.common.commands.module.CombatCommand; +import com.lunarclient.apollo.example.common.commands.module.CooldownCommand; +import com.lunarclient.apollo.example.common.commands.module.EntityCommand; +import com.lunarclient.apollo.example.common.commands.module.GlowCommand; +import com.lunarclient.apollo.example.common.commands.module.HologramCommand; +import com.lunarclient.apollo.example.common.commands.module.LimbCommand; +import com.lunarclient.apollo.example.common.commands.module.ModSettingsCommand; +import com.lunarclient.apollo.example.common.commands.module.NametagCommand; +import com.lunarclient.apollo.example.common.commands.module.NickHiderCommand; +import com.lunarclient.apollo.example.common.commands.module.NotificationCommand; +import com.lunarclient.apollo.example.common.commands.module.RichPresenceCommand; +import com.lunarclient.apollo.example.common.commands.module.ServerRuleCommand; +import com.lunarclient.apollo.example.common.commands.module.StaffModCommand; +import com.lunarclient.apollo.example.common.commands.module.StopwatchCommand; +import com.lunarclient.apollo.example.common.commands.module.TeamCommand; +import com.lunarclient.apollo.example.common.commands.module.TebexCommand; +import com.lunarclient.apollo.example.common.commands.module.TitleCommand; +import com.lunarclient.apollo.example.common.commands.module.TntCountdownCommand; +import com.lunarclient.apollo.example.common.commands.module.TransferCommand; +import com.lunarclient.apollo.example.common.commands.module.VignetteCommand; +import com.lunarclient.apollo.example.common.commands.module.WaypointCommand; +import com.lunarclient.apollo.example.common.modules.ApolloExampleType; +import com.lunarclient.apollo.example.common.modules.impl.BeamExample; +import com.lunarclient.apollo.example.common.modules.impl.BorderExample; +import com.lunarclient.apollo.example.common.modules.impl.ChatExample; +import com.lunarclient.apollo.example.common.modules.impl.ColoredFireExample; +import com.lunarclient.apollo.example.common.modules.impl.CombatExample; +import com.lunarclient.apollo.example.common.modules.impl.CooldownExample; +import com.lunarclient.apollo.example.common.modules.impl.EntityExample; +import com.lunarclient.apollo.example.common.modules.impl.GlowExample; +import com.lunarclient.apollo.example.common.modules.impl.HologramExample; +import com.lunarclient.apollo.example.common.modules.impl.LimbExample; +import com.lunarclient.apollo.example.common.modules.impl.ModSettingsExample; +import com.lunarclient.apollo.example.common.modules.impl.NametagExample; +import com.lunarclient.apollo.example.common.modules.impl.NickHiderExample; +import com.lunarclient.apollo.example.common.modules.impl.NotificationExample; +import com.lunarclient.apollo.example.common.modules.impl.RichPresenceExample; +import com.lunarclient.apollo.example.common.modules.impl.ServerRuleExample; +import com.lunarclient.apollo.example.common.modules.impl.StaffModExample; +import com.lunarclient.apollo.example.common.modules.impl.StopwatchExample; +import com.lunarclient.apollo.example.common.modules.impl.TeamExample; +import com.lunarclient.apollo.example.common.modules.impl.TebexExample; +import com.lunarclient.apollo.example.common.modules.impl.TitleExample; +import com.lunarclient.apollo.example.common.modules.impl.TntCountdownExample; +import com.lunarclient.apollo.example.common.modules.impl.TransferExample; +import com.lunarclient.apollo.example.common.modules.impl.VignetteExample; +import com.lunarclient.apollo.example.common.modules.impl.WaypointExample; +import com.lunarclient.apollo.example.debug.SpamPacketDebug; +import com.lunarclient.apollo.example.json.examples.BeamJsonExample; +import com.lunarclient.apollo.example.json.examples.BorderJsonExample; +import com.lunarclient.apollo.example.json.examples.ChatJsonExample; +import com.lunarclient.apollo.example.json.examples.ColoredFireJsonExample; +import com.lunarclient.apollo.example.json.examples.CombatJsonExample; +import com.lunarclient.apollo.example.json.examples.CooldownJsonExample; +import com.lunarclient.apollo.example.json.examples.EntityJsonExample; +import com.lunarclient.apollo.example.json.examples.GlowJsonExample; +import com.lunarclient.apollo.example.json.examples.HologramJsonExample; +import com.lunarclient.apollo.example.json.examples.LimbJsonExample; +import com.lunarclient.apollo.example.json.examples.ModSettingsJsonExample; +import com.lunarclient.apollo.example.json.examples.NametagJsonExample; +import com.lunarclient.apollo.example.json.examples.NickHiderJsonExample; +import com.lunarclient.apollo.example.json.examples.NotificationJsonExample; +import com.lunarclient.apollo.example.json.examples.RichPresenceJsonExample; +import com.lunarclient.apollo.example.json.examples.ServerRuleJsonExample; +import com.lunarclient.apollo.example.json.examples.StaffModJsonExample; +import com.lunarclient.apollo.example.json.examples.StopwatchJsonExample; +import com.lunarclient.apollo.example.json.examples.TeamJsonExample; +import com.lunarclient.apollo.example.json.examples.TebexJsonExample; +import com.lunarclient.apollo.example.json.examples.TitleJsonExample; +import com.lunarclient.apollo.example.json.examples.TntCountdownJsonExample; +import com.lunarclient.apollo.example.json.examples.TransferJsonExample; +import com.lunarclient.apollo.example.json.examples.VignetteJsonExample; +import com.lunarclient.apollo.example.json.examples.WaypointJsonExample; +import com.lunarclient.apollo.example.json.listeners.ApolloPlayerJsonListener; +import com.lunarclient.apollo.example.proto.examples.BeamProtoExample; +import com.lunarclient.apollo.example.proto.examples.BorderProtoExample; +import com.lunarclient.apollo.example.proto.examples.ChatProtoExample; +import com.lunarclient.apollo.example.proto.examples.ColoredFireProtoExample; +import com.lunarclient.apollo.example.proto.examples.CombatProtoExample; +import com.lunarclient.apollo.example.proto.examples.CooldownProtoExample; +import com.lunarclient.apollo.example.proto.examples.EntityProtoExample; +import com.lunarclient.apollo.example.proto.examples.GlowProtoExample; +import com.lunarclient.apollo.example.proto.examples.HologramProtoExample; +import com.lunarclient.apollo.example.proto.examples.LimbProtoExample; +import com.lunarclient.apollo.example.proto.examples.ModSettingsProtoExample; +import com.lunarclient.apollo.example.proto.examples.NametagProtoExample; +import com.lunarclient.apollo.example.proto.examples.NickHiderProtoExample; +import com.lunarclient.apollo.example.proto.examples.NotificationProtoExample; +import com.lunarclient.apollo.example.proto.examples.RichPresenceProtoExample; +import com.lunarclient.apollo.example.proto.examples.ServerRuleProtoExample; +import com.lunarclient.apollo.example.proto.examples.StaffModProtoExample; +import com.lunarclient.apollo.example.proto.examples.StopwatchProtoExample; +import com.lunarclient.apollo.example.proto.examples.TeamProtoExample; +import com.lunarclient.apollo.example.proto.examples.TebexProtoExample; +import com.lunarclient.apollo.example.proto.examples.TitleProtoExample; +import com.lunarclient.apollo.example.proto.examples.TntCountdownProtoExample; +import com.lunarclient.apollo.example.proto.examples.TransferProtoExample; +import com.lunarclient.apollo.example.proto.examples.VignetteProtoExample; +import com.lunarclient.apollo.example.proto.examples.WaypointProtoExample; +import com.lunarclient.apollo.example.proto.listeners.ApolloPlayerProtoListener; import lombok.Getter; import org.bukkit.plugin.java.JavaPlugin; @@ -82,6 +164,12 @@ public class ApolloExamplePlugin extends JavaPlugin { @Getter private static ApolloExamplePlugin plugin; + public static ApolloExampleType TYPE; + + private ApolloPlayerApiListener playerApiListener; + private ApolloPlayerProtoListener playerProtoListener; + private ApolloPlayerJsonListener playerJsonListener; + private BeamExample beamExample; private BorderExample borderExample; private ChatExample chatExample; @@ -101,19 +189,21 @@ public class ApolloExamplePlugin extends JavaPlugin { private StaffModExample staffModExample; private StopwatchExample stopwatchExample; private TeamExample teamExample; + private TebexExample tebexExample; private TitleExample titleExample; private TntCountdownExample tntCountdownExample; private TransferExample transferExample; private VignetteExample vignetteExample; private WaypointExample waypointExample; + private SpamPacketDebug spamPacketDebug; + @Override public void onEnable() { plugin = this; - this.registerModuleExamples(); + this.changeImplementationType(ApolloExampleType.API); this.registerCommands(); - this.registerListeners(); } @Override @@ -121,34 +211,10 @@ public void onDisable() { } - private void registerModuleExamples() { - this.beamExample = new BeamExample(); - this.borderExample = new BorderExample(); - this.chatExample = new ChatExample(); - this.coloredFireExample = new ColoredFireExample(); - this.combatExample = new CombatExample(); - this.cooldownExample = new CooldownExample(); - this.entityExample = new EntityExample(); - this.glowExample = new GlowExample(); - this.hologramExample = new HologramExample(); - this.limbExample = new LimbExample(); - this.modSettingsExample = new ModSettingsExample(); - this.nametagExample = new NametagExample(); - this.nickHiderExample = new NickHiderExample(); - this.notificationExample = new NotificationExample(); - this.richPresenceExample = new RichPresenceExample(); - this.serverRuleExample = new ServerRuleExample(); - this.staffModExample = new StaffModExample(); - this.stopwatchExample = new StopwatchExample(); - this.teamExample = new TeamExample(); - this.titleExample = new TitleExample(); - this.tntCountdownExample = new TntCountdownExample(); - this.transferExample = new TransferExample(); - this.vignetteExample = new VignetteExample(); - this.waypointExample = new WaypointExample(); - } - private void registerCommands() { + this.getCommand("apollodebug").setExecutor(new ApolloDebugCommand()); + this.getCommand("switch").setExecutor(new SwitchCommand()); + this.getCommand("beam").setExecutor(new BeamCommand()); this.getCommand("border").setExecutor(new BorderCommand()); this.getCommand("chat").setExecutor(new ChatCommand()); @@ -168,6 +234,7 @@ private void registerCommands() { this.getCommand("staffmod").setExecutor(new StaffModCommand()); this.getCommand("stopwatch").setExecutor(new StopwatchCommand()); this.getCommand("team").setExecutor(new TeamCommand()); + this.getCommand("tebex").setExecutor(new TebexCommand()); this.getCommand("title").setExecutor(new TitleCommand()); this.getCommand("tntcountdown").setExecutor(new TntCountdownCommand()); this.getCommand("transfer").setExecutor(new TransferCommand()); @@ -175,8 +242,138 @@ private void registerCommands() { this.getCommand("waypoint").setExecutor(new WaypointCommand()); } + public void changeImplementationType(ApolloExampleType type) { + TYPE = type; + + if (this.playerApiListener != null) { + this.playerApiListener.disable(); + this.playerApiListener = null; + } + + if (this.playerProtoListener != null) { + this.playerProtoListener.disable(); + this.playerProtoListener = null; + } + + if (this.playerJsonListener != null) { + this.playerJsonListener.disable(); + this.playerJsonListener = null; + } + + this.registerModuleExamples(); + this.registerListeners(); + } + + private void registerModuleExamples() { + this.spamPacketDebug = new SpamPacketDebug(); + + switch (TYPE) { + case API: { + this.beamExample = new BeamApiExample(); + this.borderExample = new BorderApiExample(); + this.chatExample = new ChatApiExample(); + this.coloredFireExample = new ColoredFireApiExample(); + this.combatExample = new CombatApiExample(); + this.cooldownExample = new CooldownApiExample(); + this.entityExample = new EntityApiExample(); + this.glowExample = new GlowApiExample(); + this.hologramExample = new HologramApiExample(); + this.limbExample = new LimbApiExample(); + this.modSettingsExample = new ModSettingsApiExample(); + this.nametagExample = new NametagApiExample(); + this.nickHiderExample = new NickHiderApiExample(); + this.notificationExample = new NotificationApiExample(); + this.richPresenceExample = new RichPresenceApiExample(); + this.serverRuleExample = new ServerRuleApiExample(); + this.staffModExample = new StaffModApiExample(); + this.stopwatchExample = new StopwatchApiExample(); + this.teamExample = new TeamApiExample(); + this.tebexExample = new TebexApiExample(); + this.titleExample = new TitleApiExample(); + this.tntCountdownExample = new TntCountdownApiExample(); + this.transferExample = new TransferApiExample(); + this.vignetteExample = new VignetteApiExample(); + this.waypointExample = new WaypointApiExample(); + break; + } + + case JSON: { + this.beamExample = new BeamJsonExample(); + this.borderExample = new BorderJsonExample(); + this.chatExample = new ChatJsonExample(); + this.coloredFireExample = new ColoredFireJsonExample(); + this.combatExample = new CombatJsonExample(); + this.cooldownExample = new CooldownJsonExample(); + this.entityExample = new EntityJsonExample(); + this.glowExample = new GlowJsonExample(); + this.hologramExample = new HologramJsonExample(); + this.limbExample = new LimbJsonExample(); + this.modSettingsExample = new ModSettingsJsonExample(); + this.nametagExample = new NametagJsonExample(); + this.nickHiderExample = new NickHiderJsonExample(); + this.notificationExample = new NotificationJsonExample(); + this.richPresenceExample = new RichPresenceJsonExample(); + this.serverRuleExample = new ServerRuleJsonExample(); + this.staffModExample = new StaffModJsonExample(); + this.stopwatchExample = new StopwatchJsonExample(); + this.teamExample = new TeamJsonExample(); + this.tebexExample = new TebexJsonExample(); + this.titleExample = new TitleJsonExample(); + this.tntCountdownExample = new TntCountdownJsonExample(); + this.transferExample = new TransferJsonExample(); + this.vignetteExample = new VignetteJsonExample(); + this.waypointExample = new WaypointJsonExample(); + break; + } + + case PROTO: { + this.beamExample = new BeamProtoExample(); + this.borderExample = new BorderProtoExample(); + this.chatExample = new ChatProtoExample(); + this.coloredFireExample = new ColoredFireProtoExample(); + this.combatExample = new CombatProtoExample(); + this.cooldownExample = new CooldownProtoExample(); + this.entityExample = new EntityProtoExample(); + this.glowExample = new GlowProtoExample(); + this.hologramExample = new HologramProtoExample(); + this.limbExample = new LimbProtoExample(); + this.modSettingsExample = new ModSettingsProtoExample(); + this.nametagExample = new NametagProtoExample(); + this.nickHiderExample = new NickHiderProtoExample(); + this.notificationExample = new NotificationProtoExample(); + this.richPresenceExample = new RichPresenceProtoExample(); + this.serverRuleExample = new ServerRuleProtoExample(); + this.staffModExample = new StaffModProtoExample(); + this.stopwatchExample = new StopwatchProtoExample(); + this.teamExample = new TeamProtoExample(); + this.tebexExample = new TebexProtoExample(); + this.titleExample = new TitleProtoExample(); + this.tntCountdownExample = new TntCountdownProtoExample(); + this.transferExample = new TransferProtoExample(); + this.vignetteExample = new VignetteProtoExample(); + this.waypointExample = new WaypointProtoExample(); + break; + } + } + } + private void registerListeners() { - EventBus.getBus().register(new PlayerListener()); + switch (TYPE) { + case API: { + this.playerApiListener = new ApolloPlayerApiListener(this); + break; + } + + case JSON: { + this.playerJsonListener = new ApolloPlayerJsonListener(this); + break; + } + + case PROTO: { + this.playerProtoListener = new ApolloPlayerProtoListener(this); + break; + } + } } } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/ApolloGeneralExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/ApolloGeneralExample.java similarity index 98% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/ApolloGeneralExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/ApolloGeneralExample.java index ec1fa966..1be6f101 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/ApolloGeneralExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/ApolloGeneralExample.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example; +package com.lunarclient.apollo.example.api; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.module.border.BorderModule; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/BeamExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/BeamApiExample.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/BeamExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/BeamApiExample.java index 0fb01c07..c0abd96a 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/BeamExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/BeamApiExample.java @@ -21,10 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.common.location.ApolloBlockLocation; +import com.lunarclient.apollo.example.common.modules.impl.BeamExample; import com.lunarclient.apollo.module.beam.Beam; import com.lunarclient.apollo.module.beam.BeamModule; import com.lunarclient.apollo.player.ApolloPlayer; @@ -32,10 +33,11 @@ import java.util.Optional; import org.bukkit.entity.Player; -public class BeamExample { +public class BeamApiExample extends BeamExample { private final BeamModule beamModule = Apollo.getModuleManager().getModule(BeamModule.class); + @Override public void displayBeamExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -55,11 +57,13 @@ public void displayBeamExample(Player viewer) { }); } + @Override public void removeBeamExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(apolloPlayer -> this.beamModule.removeBeam(apolloPlayer, "spawn-beacon")); } + @Override public void resetBeamsExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.beamModule::resetBeams); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/BorderExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/BorderApiExample.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/BorderExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/BorderApiExample.java index 6ecf854e..1df60349 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/BorderExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/BorderApiExample.java @@ -21,10 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.common.cuboid.Cuboid2D; +import com.lunarclient.apollo.example.common.modules.impl.BorderExample; import com.lunarclient.apollo.module.border.Border; import com.lunarclient.apollo.module.border.BorderModule; import com.lunarclient.apollo.player.ApolloPlayer; @@ -32,10 +33,11 @@ import java.util.Optional; import org.bukkit.entity.Player; -public class BorderExample { +public class BorderApiExample extends BorderExample { private final BorderModule borderModule = Apollo.getModuleManager().getModule(BorderModule.class); + @Override public void displayBorderExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -60,11 +62,13 @@ public void displayBorderExample(Player viewer) { }); } + @Override public void removeBorderExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(apolloPlayer -> this.borderModule.removeBorder(apolloPlayer, "pvp-tagged-spawn")); } + @Override public void resetBordersExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.borderModule::resetBorders); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/ChatExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ChatApiExample.java similarity index 89% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/ChatExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ChatApiExample.java index 29c71854..25e4a776 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/ChatExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ChatApiExample.java @@ -21,27 +21,27 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.ChatExample; import com.lunarclient.apollo.module.chat.ChatModule; import com.lunarclient.apollo.recipients.Recipients; -import java.util.concurrent.ThreadLocalRandom; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; -public class ChatExample { +public class ChatApiExample extends ChatExample { private final ChatModule chatModule = Apollo.getModuleManager().getModule(ChatModule.class); - private final int messageId = ThreadLocalRandom.current().nextInt(100); private int countdown = 5; + @Override public void displayLiveChatMessageExample() { this.chatModule.displayLiveChatMessage(Recipients.ofEveryone(), Component.text("Game starting in ", NamedTextColor.GREEN) .append(Component.text(this.countdown, NamedTextColor.BLUE)), - this.messageId + 13 ); if (--this.countdown == 0) { @@ -49,8 +49,9 @@ public void displayLiveChatMessageExample() { } } + @Override public void removeLiveChatMessageExample() { - this.chatModule.removeLiveChatMessage(Recipients.ofEveryone(), this.messageId); + this.chatModule.removeLiveChatMessage(Recipients.ofEveryone(), 13); } } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/ColoredFireExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ColoredFireApiExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/ColoredFireExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ColoredFireApiExample.java index 8fe7918c..bfc16dde 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/ColoredFireExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ColoredFireApiExample.java @@ -21,9 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.ColoredFireExample; import com.lunarclient.apollo.module.coloredfire.ColoredFireModule; import com.lunarclient.apollo.player.ApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; @@ -32,10 +33,11 @@ import java.util.UUID; import org.bukkit.entity.Player; -public class ColoredFireExample { +public class ColoredFireApiExample extends ColoredFireExample { private final ColoredFireModule coloredFireModule = Apollo.getModuleManager().getModule(ColoredFireModule.class); + @Override public void overrideColoredFireExample(UUID burningPlayer) { this.coloredFireModule.overrideColoredFire(Recipients.ofEveryone(), burningPlayer, @@ -43,10 +45,12 @@ public void overrideColoredFireExample(UUID burningPlayer) { ); } + @Override public void resetColoredFireExample(UUID burningPlayer) { this.coloredFireModule.resetColoredFire(Recipients.ofEveryone(), burningPlayer); } + @Override public void resetColoredFiresExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.coloredFireModule::resetColoredFires); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/CombatExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/CombatApiExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/CombatExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/CombatApiExample.java index 5f811a3a..7d48b4ca 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/CombatExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/CombatApiExample.java @@ -21,15 +21,17 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.CombatExample; import com.lunarclient.apollo.module.combat.CombatModule; -public class CombatExample { +public class CombatApiExample extends CombatExample { private final CombatModule combatModule = Apollo.getModuleManager().getModule(CombatModule.class); + @Override public void setDisableMissPenalty(boolean value) { this.combatModule.getOptions().set(CombatModule.DISABLE_MISS_PENALTY, value); } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/CooldownExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/CooldownApiExample.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/CooldownExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/CooldownApiExample.java index e01072a3..9c44d982 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/CooldownExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/CooldownApiExample.java @@ -21,11 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.common.icon.ItemStackIcon; import com.lunarclient.apollo.common.icon.SimpleResourceLocationIcon; +import com.lunarclient.apollo.example.common.modules.impl.CooldownExample; import com.lunarclient.apollo.module.cooldown.Cooldown; import com.lunarclient.apollo.module.cooldown.CooldownModule; import com.lunarclient.apollo.player.ApolloPlayer; @@ -33,10 +34,11 @@ import java.util.Optional; import org.bukkit.entity.Player; -public class CooldownExample { +public class CooldownApiExample extends CooldownExample { private final CooldownModule cooldownModule = Apollo.getModuleManager().getModule(CooldownModule.class); + @Override public void displayCooldownItemExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -53,6 +55,7 @@ public void displayCooldownItemExample(Player viewer) { }); } + @Override public void displayCooldownResourceExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -70,6 +73,7 @@ public void displayCooldownResourceExample(Player viewer) { }); } + @Override public void removeCooldownExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -79,6 +83,7 @@ public void removeCooldownExample(Player viewer) { }); } + @Override public void resetCooldownsExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.cooldownModule::resetCooldowns); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/EntityExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/EntityApiExample.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/EntityExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/EntityApiExample.java index 3d0cece2..4b69d44b 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/EntityExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/EntityApiExample.java @@ -21,10 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.common.ApolloEntity; +import com.lunarclient.apollo.example.common.modules.impl.EntityExample; import com.lunarclient.apollo.module.entity.EntityModule; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.List; @@ -34,10 +35,11 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Sheep; -public class EntityExample { +public class EntityApiExample extends EntityExample { private final EntityModule entityModule = Apollo.getModuleManager().getModule(EntityModule.class); + @Override public void overrideRainbowSheepExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -51,6 +53,7 @@ public void overrideRainbowSheepExample(Player viewer) { }); } + @Override public void resetRainbowSheepExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -64,6 +67,7 @@ public void resetRainbowSheepExample(Player viewer) { }); } + @Override public void flipEntityExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -79,6 +83,7 @@ public void flipEntityExample(Player viewer) { }); } + @Override public void resetFlippedEntityExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/GlowExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/GlowApiExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/GlowExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/GlowApiExample.java index a3ff090e..a42af2c3 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/GlowExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/GlowApiExample.java @@ -21,9 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.GlowExample; import com.lunarclient.apollo.module.glow.GlowModule; import com.lunarclient.apollo.player.ApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; @@ -32,10 +33,11 @@ import java.util.UUID; import org.bukkit.entity.Player; -public class GlowExample { +public class GlowApiExample extends GlowExample { private final GlowModule glowModule = Apollo.getModuleManager().getModule(GlowModule.class); + @Override public void overrideGlowEffectExample(UUID glowingPlayer) { this.glowModule.overrideGlow(Recipients.ofEveryone(), glowingPlayer, @@ -43,10 +45,12 @@ public void overrideGlowEffectExample(UUID glowingPlayer) { ); } + @Override public void resetGlowEffectExample(UUID glowingPlayer) { this.glowModule.resetGlow(Recipients.ofEveryone(), glowingPlayer); } + @Override public void resetGlowEffectsExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.glowModule::resetGlow); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/HologramExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/HologramApiExample.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/HologramExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/HologramApiExample.java index e58a15da..fd71257f 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/HologramExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/HologramApiExample.java @@ -21,11 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.google.common.collect.Lists; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.common.location.ApolloLocation; +import com.lunarclient.apollo.example.common.modules.impl.HologramExample; import com.lunarclient.apollo.module.hologram.Hologram; import com.lunarclient.apollo.module.hologram.HologramModule; import com.lunarclient.apollo.player.ApolloPlayer; @@ -36,10 +37,11 @@ import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.entity.Player; -public class HologramExample { +public class HologramApiExample extends HologramExample { private final HologramModule hologramModule = Apollo.getModuleManager().getModule(HologramModule.class); + @Override public void displayHologramExample() { this.hologramModule.displayHologram(Recipients.ofEveryone(), Hologram.builder() .id("welcome-hologram") @@ -66,10 +68,12 @@ public void displayHologramExample() { ); } + @Override public void removeHologramExample() { this.hologramModule.removeHologram(Recipients.ofEveryone(), "welcome-hologram"); } + @Override public void resetHologramsExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.hologramModule::resetHolograms); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/LimbExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/LimbApiExample.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/LimbExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/LimbApiExample.java index 7f67ba80..a4704fda 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/LimbExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/LimbApiExample.java @@ -21,9 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.LimbExample; import com.lunarclient.apollo.module.limb.ArmorPiece; import com.lunarclient.apollo.module.limb.BodyPart; import com.lunarclient.apollo.module.limb.LimbModule; @@ -32,10 +33,11 @@ import java.util.Optional; import org.bukkit.entity.Player; -public class LimbExample { +public class LimbApiExample extends LimbExample { private final LimbModule limbModule = Apollo.getModuleManager().getModule(LimbModule.class); + @Override public void hideArmorExample(Player viewer, Player target) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -47,6 +49,7 @@ public void hideArmorExample(Player viewer, Player target) { }); } + @Override public void resetArmorExample(Player viewer, Player target) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -58,6 +61,7 @@ public void resetArmorExample(Player viewer, Player target) { }); } + @Override public void hideBodyExample(Player viewer, Player target) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -69,6 +73,7 @@ public void hideBodyExample(Player viewer, Player target) { }); } + @Override public void resetBodyExample(Player viewer, Player target) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/ModSettingsExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ModSettingsApiExample.java similarity index 84% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/ModSettingsExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ModSettingsApiExample.java index 74af2611..9d4fbbdc 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/ModSettingsExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ModSettingsApiExample.java @@ -21,31 +21,35 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.ModSettingsExample; import com.lunarclient.apollo.mods.impl.ModLighting; import com.lunarclient.apollo.module.modsetting.ModSettingModule; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.Optional; import org.bukkit.entity.Player; -public class ModSettingsExample { +public class ModSettingsApiExample extends ModSettingsExample { private final ModSettingModule modSettingModule = Apollo.getModuleManager().getModule(ModSettingModule.class); - public void disableLightningModExample(Player viewer) { + @Override + public void disableLightingModExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(apolloPlayer -> this.modSettingModule.getOptions().set(apolloPlayer, ModLighting.ENABLED, false)); } - public void rollbackLightningModEnabledState(Player viewer) { + @Override + public void rollbackLightingModEnabledState(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); // To rollback the server override value of the setting, simply set the value to "null" apolloPlayerOpt.ifPresent(apolloPlayer -> this.modSettingModule.getOptions().set(apolloPlayer, ModLighting.ENABLED, null)); } - public void broadcastDisableLightningModExample() { + @Override + public void broadcastDisableLightingModExample() { this.modSettingModule.getOptions().set(ModLighting.ENABLED, false); } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/NametagExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NametagApiExample.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/NametagExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NametagApiExample.java index d58940c2..b6bcd544 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/NametagExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NametagApiExample.java @@ -21,10 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.google.common.collect.Lists; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.NametagExample; import com.lunarclient.apollo.module.nametag.Nametag; import com.lunarclient.apollo.module.nametag.NametagModule; import com.lunarclient.apollo.player.ApolloPlayer; @@ -35,10 +36,11 @@ import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.entity.Player; -public class NametagExample { +public class NametagApiExample extends NametagExample { private final NametagModule nametagModule = Apollo.getModuleManager().getModule(NametagModule.class); + @Override public void overrideNametagExample(Player target) { this.nametagModule.overrideNametag(Recipients.ofEveryone(), target.getUniqueId(), Nametag.builder() .lines(Lists.newArrayList( @@ -56,10 +58,12 @@ public void overrideNametagExample(Player target) { ); } + @Override public void resetNametagExample(Player target) { this.nametagModule.resetNametag(Recipients.ofEveryone(), target.getUniqueId()); } + @Override public void resetNametagsExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.nametagModule::resetNametags); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/NickHiderExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NickHiderApiExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/NickHiderExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NickHiderApiExample.java index 76d854fe..30341d00 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/NickHiderExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NickHiderApiExample.java @@ -21,23 +21,26 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.NickHiderExample; import com.lunarclient.apollo.module.nickhider.NickHiderModule; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.Optional; import org.bukkit.entity.Player; -public class NickHiderExample { +public class NickHiderApiExample extends NickHiderExample { private final NickHiderModule nickHiderModule = Apollo.getModuleManager().getModule(NickHiderModule.class); + @Override public void overrideNickExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(apolloPlayer -> this.nickHiderModule.overrideNick(apolloPlayer, "Notch")); } + @Override public void resetNickExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.nickHiderModule::resetNick); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/NotificationExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NotificationApiExample.java similarity index 67% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/NotificationExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NotificationApiExample.java index 56d0f7f8..54ede6f2 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/NotificationExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NotificationApiExample.java @@ -21,9 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.NotificationExample; import com.lunarclient.apollo.module.notification.Notification; import com.lunarclient.apollo.module.notification.NotificationModule; import com.lunarclient.apollo.player.ApolloPlayer; @@ -33,27 +34,30 @@ import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.entity.Player; -public class NotificationExample { +public class NotificationApiExample extends NotificationExample { private final NotificationModule notificationModule = Apollo.getModuleManager().getModule(NotificationModule.class); - private final Notification uhcAnnouncement = Notification.builder() - .titleComponent(Component.text("UHC Announcement", NamedTextColor.GREEN)) - .descriptionComponent(Component.text("UHC starts in 5 minutes...", NamedTextColor.RED) - .appendNewline() - .append(Component.text("Get ready!", NamedTextColor.WHITE)) - .appendNewline() - .append(Component.text("Good luck!", NamedTextColor.GOLD)) - ) - .resourceLocation("icons/golden_apple.png") // This field is optional - .displayTime(Duration.ofSeconds(5)) - .build(); - + @Override public void displayNotificationExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(apolloPlayer -> this.notificationModule.displayNotification(apolloPlayer, this.uhcAnnouncement)); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + this.notificationModule.displayNotification(apolloPlayer, Notification.builder() + .titleComponent(Component.text("UHC Announcement", NamedTextColor.GREEN)) + .descriptionComponent(Component.text("UHC starts in 5 minutes...", NamedTextColor.RED) + .append(Component.newline()) + .append(Component.text("Get ready!", NamedTextColor.WHITE)) + .append(Component.newline()) + .append(Component.text("Good luck!", NamedTextColor.GOLD)) + ) + .resourceLocation("icons/golden_apple.png") // This field is optional + .displayTime(Duration.ofSeconds(5)) + .build()); + }); } + @Override public void resetNotificationsExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.notificationModule::resetNotifications); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/RichPresenceExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/RichPresenceApiExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/RichPresenceExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/RichPresenceApiExample.java index a4716836..53673969 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/RichPresenceExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/RichPresenceApiExample.java @@ -21,19 +21,21 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.RichPresenceExample; import com.lunarclient.apollo.module.richpresence.RichPresenceModule; import com.lunarclient.apollo.module.richpresence.ServerRichPresence; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.Optional; import org.bukkit.entity.Player; -public class RichPresenceExample { +public class RichPresenceApiExample extends RichPresenceExample { private final RichPresenceModule richPresenceModule = Apollo.getModuleManager().getModule(RichPresenceModule.class); + @Override public void overrideServerRichPresenceExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -52,6 +54,7 @@ public void overrideServerRichPresenceExample(Player viewer) { }); } + @Override public void resetServerRichPresenceExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.richPresenceModule::resetServerRichPresence); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/ServerRuleExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ServerRuleApiExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/ServerRuleExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ServerRuleApiExample.java index c6ed1b66..7f1e7a87 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/ServerRuleExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ServerRuleApiExample.java @@ -21,22 +21,25 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.ServerRuleExample; import com.lunarclient.apollo.module.serverrule.ServerRuleModule; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.Optional; import org.bukkit.entity.Player; -public class ServerRuleExample { +public class ServerRuleApiExample extends ServerRuleExample { private final ServerRuleModule serverRuleModule = Apollo.getModuleManager().getModule(ServerRuleModule.class); + @Override public void setAntiPortalTraps(boolean value) { this.serverRuleModule.getOptions().set(ServerRuleModule.ANTI_PORTAL_TRAPS, value); } + @Override public void setOverrideNametagRenderDistance(Player viewer, boolean value) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -46,6 +49,7 @@ public void setOverrideNametagRenderDistance(Player viewer, boolean value) { }); } + @Override public void setNametagRenderDistanceExample(int value) { this.serverRuleModule.getOptions().set(ServerRuleModule.NAMETAG_RENDER_DISTANCE, value); } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/StaffModExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/StaffModApiExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/StaffModExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/StaffModApiExample.java index 448084f3..67db3782 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/StaffModExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/StaffModApiExample.java @@ -21,9 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.StaffModExample; import com.lunarclient.apollo.module.staffmod.StaffMod; import com.lunarclient.apollo.module.staffmod.StaffModModule; import com.lunarclient.apollo.player.ApolloPlayer; @@ -31,10 +32,11 @@ import java.util.Optional; import org.bukkit.entity.Player; -public class StaffModExample { +public class StaffModApiExample extends StaffModExample { private final StaffModModule staffModModule = Apollo.getModuleManager().getModule(StaffModModule.class); + @Override public void enableStaffModsExample(Player viewer) { if (!viewer.hasPermission("apollo.staff")) { return; @@ -44,6 +46,7 @@ public void enableStaffModsExample(Player viewer) { apolloPlayerOpt.ifPresent(apolloPlayer -> this.staffModModule.enableStaffMods(apolloPlayer, Collections.singletonList(StaffMod.XRAY))); } + @Override public void disableStaffModsExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(apolloPlayer -> this.staffModModule.disableStaffMods(apolloPlayer, Collections.singletonList(StaffMod.XRAY))); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/StopwatchExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/StopwatchApiExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/StopwatchExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/StopwatchApiExample.java index 2668ce1c..1a5bd858 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/StopwatchExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/StopwatchApiExample.java @@ -21,28 +21,32 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.StopwatchExample; import com.lunarclient.apollo.module.stopwatch.StopwatchModule; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.Optional; import org.bukkit.entity.Player; -public class StopwatchExample { +public class StopwatchApiExample extends StopwatchExample { private final StopwatchModule stopwatchModule = Apollo.getModuleManager().getModule(StopwatchModule.class); + @Override public void startStopwatchExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.stopwatchModule::startStopwatch); } + @Override public void stopStopwatchExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.stopwatchModule::stopStopwatch); } + @Override public void resetStopwatchExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.stopwatchModule::resetStopwatch); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/TeamExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TeamApiExample.java similarity index 68% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/TeamExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TeamApiExample.java index 0d3b41c3..943099be 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/TeamExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TeamApiExample.java @@ -21,13 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.common.location.ApolloLocation; import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.common.modules.impl.TeamExample; import com.lunarclient.apollo.module.team.TeamMember; import com.lunarclient.apollo.module.team.TeamModule; import java.awt.Color; @@ -47,14 +48,14 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.scheduler.BukkitRunnable; -public class TeamExample implements Listener { +public class TeamApiExample extends TeamExample implements Listener { private final TeamModule teamModule = Apollo.getModuleManager().getModule(TeamModule.class); private final Map teamsByTeamId = Maps.newHashMap(); private final Map teamsByPlayerUuid = Maps.newHashMap(); - public TeamExample() { + public TeamApiExample() { new TeamUpdateTask(); Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); @@ -106,15 +107,15 @@ public Team() { public void addMember(Player player) { this.members.add(player); - TeamExample.this.teamsByPlayerUuid.put(player.getUniqueId(), this); + TeamApiExample.this.teamsByPlayerUuid.put(player.getUniqueId(), this); } public void removeMember(Player player) { this.members.remove(player); - TeamExample.this.teamsByPlayerUuid.remove(player.getUniqueId()); + TeamApiExample.this.teamsByPlayerUuid.remove(player.getUniqueId()); Apollo.getPlayerManager().getPlayer(player.getUniqueId()) - .ifPresent(TeamExample.this.teamModule::resetTeamMembers); + .ifPresent(TeamApiExample.this.teamModule::resetTeamMembers); } private TeamMember createTeamMember(Player member) { @@ -143,7 +144,7 @@ public void refresh() { .collect(Collectors.toList()); this.members.forEach(member -> Apollo.getPlayerManager().getPlayer(member.getUniqueId()) - .ifPresent(apolloPlayer -> TeamExample.this.teamModule.updateTeamMembers(apolloPlayer, teammates))); + .ifPresent(apolloPlayer -> TeamApiExample.this.teamModule.updateTeamMembers(apolloPlayer, teammates))); } public UUID getTeamId() { @@ -183,7 +184,74 @@ public TeamUpdateTask() { @Override public void run() { - TeamExample.this.teamsByTeamId.values().forEach(Team::refresh); + TeamApiExample.this.teamsByTeamId.values().forEach(Team::refresh); } } + + @Override + public void createTeam(Player player) { + Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); + + if (teamOpt.isPresent()) { + player.sendMessage("You already have a team..."); + return; + } + + Team team = this.createTeam(); + team.addMember(player); + + player.sendMessage("Creating team..."); + } + + @Override + public void deleteTeam(Player player) { + Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); + + if (teamOpt.isPresent()) { + this.deleteTeam(teamOpt.get().getTeamId()); + player.sendMessage("Deleting team..."); + return; + } + + player.sendMessage("No team found..."); + } + + @Override + public void addMember(Player player, Player target) { + Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); + Optional targetTeamOpt = this.getByPlayerUuid(target.getUniqueId()); + + if (targetTeamOpt.isPresent()) { + player.sendMessage("Player " + target.getName() + " already has a team..."); + return; + } + + if (teamOpt.isPresent()) { + teamOpt.get().addMember(target); + player.sendMessage("Added " + target.getName() + " to your team..."); + return; + } + + player.sendMessage("No team found..."); + } + + @Override + public void removeMember(Player player, Player target) { + Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); + Optional targetTeamOpt = this.getByPlayerUuid(target.getUniqueId()); + + if (!targetTeamOpt.isPresent()) { + player.sendMessage("Player " + target.getName() + " doesn't have a team..."); + return; + } + + if (teamOpt.isPresent()) { + teamOpt.get().removeMember(target); + player.sendMessage("Removed " + target.getName() + " from your team..."); + return; + } + + player.sendMessage("No team found..."); + } + } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TebexApiExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TebexApiExample.java new file mode 100644 index 00000000..36829578 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TebexApiExample.java @@ -0,0 +1,50 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.TebexExample; +import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport; +import com.lunarclient.apollo.module.tebex.TebexModule; +import com.lunarclient.apollo.player.ApolloPlayer; +import java.util.Optional; +import org.bukkit.entity.Player; + +public class TebexApiExample extends TebexExample { + + private final TebexModule tebexModule = Apollo.getModuleManager().getModule(TebexModule.class); + + @Override + public void displayTebexEmbeddedCheckoutExample(Player viewer, String basketIdent, String locale) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(apolloPlayer -> { + if (apolloPlayer.getTebexEmbeddedCheckoutSupport() == TebexEmbeddedCheckoutSupport.UNSUPPORTED) { + return; + } + + this.tebexModule.displayTebexEmbeddedCheckout(apolloPlayer, basketIdent, locale); + }); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/TitleExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TitleApiExample.java similarity index 60% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/TitleExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TitleApiExample.java index cc933988..e57bcff7 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/TitleExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TitleApiExample.java @@ -21,9 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.TitleExample; import com.lunarclient.apollo.module.title.Title; import com.lunarclient.apollo.module.title.TitleModule; import com.lunarclient.apollo.module.title.TitleType; @@ -35,43 +36,47 @@ import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.entity.Player; -public class TitleExample { +public class TitleApiExample extends TitleExample { private final TitleModule titleModule = Apollo.getModuleManager().getModule(TitleModule.class); - private final Title helloTitle = Title.builder() - .type(TitleType.TITLE) - .message(Component.text() - .content("Hello, player!") - .color(NamedTextColor.GREEN) - .decorate(TextDecoration.BOLD) - .build()) - .scale(1.0f) - .displayTime(Duration.ofMillis(1500L)) - .fadeInTime(Duration.ofMillis(250)) - .fadeOutTime(Duration.ofMillis(300)) - .build(); - - private final Title interpolatedTitle = Title.builder() - .type(TitleType.TITLE) - .message(Component.text() - .content("This title expands!") - .color(NamedTextColor.GREEN) - .decorate(TextDecoration.BOLD) - .build()) - .scale(0.1f) - .interpolationScale(1.0f) - .interpolationRate(0.01f) - .displayTime(Duration.ofMillis(5000L)) - .fadeInTime(Duration.ofMillis(250)) - .fadeOutTime(Duration.ofMillis(300)) - .build(); - + @Override public void displayTitleExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(apolloPlayer -> this.titleModule.displayTitle(apolloPlayer, this.helloTitle)); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.titleModule.displayTitle(apolloPlayer, Title.builder() + .type(TitleType.TITLE) + .message(Component.text() + .content("Hello, player!") + .color(NamedTextColor.GREEN) + .decorate(TextDecoration.BOLD) + .build()) + .scale(1.0f) + .displayTime(Duration.ofMillis(1500L)) + .fadeInTime(Duration.ofMillis(250)) + .fadeOutTime(Duration.ofMillis(300)) + .build())); + } + + @Override + public void displayTitleInterpolatedExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.titleModule.displayTitle(apolloPlayer, Title.builder() + .type(TitleType.TITLE) + .message(Component.text() + .content("This title expands!") + .color(NamedTextColor.GREEN) + .decorate(TextDecoration.BOLD) + .build()) + .scale(0.1f) + .interpolationScale(1.0f) + .interpolationRate(0.01f) + .displayTime(Duration.ofMillis(5000L)) + .fadeInTime(Duration.ofMillis(250)) + .fadeOutTime(Duration.ofMillis(300)) + .build())); } + @Override public void resetTitlesExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.titleModule::resetTitles); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/TntCountdownExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TntCountdownApiExample.java similarity index 89% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/TntCountdownExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TntCountdownApiExample.java index 3fab40c2..d2f8a609 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/TntCountdownExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TntCountdownApiExample.java @@ -21,10 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.common.ApolloEntity; +import com.lunarclient.apollo.example.common.modules.impl.TntCountdownExample; import com.lunarclient.apollo.module.tntcountdown.TntCountdownModule; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.Optional; @@ -34,14 +35,16 @@ import org.bukkit.entity.TNTPrimed; import org.bukkit.event.Listener; -public class TntCountdownExample implements Listener { +public class TntCountdownApiExample extends TntCountdownExample implements Listener { private final TntCountdownModule tntCountdownModule = Apollo.getModuleManager().getModule(TntCountdownModule.class); + @Override public void setTntCountdownExample() { this.tntCountdownModule.getOptions().set(TntCountdownModule.TNT_TICKS, 160); } + @Override public void overrideTntCountdownExample(Player viewer) { Location location = viewer.getLocation(); World world = viewer.getWorld(); @@ -55,8 +58,9 @@ public void overrideTntCountdownExample(Player viewer) { }); } + @Override public void clearTntCountdownOptionExample() { - this.tntCountdownModule.getOptions().remove(TntCountdownModule.TNT_TICKS, 160); + this.tntCountdownModule.getOptions().remove(TntCountdownModule.TNT_TICKS, 80); } } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/TransferExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TransferApiExample.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/TransferExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TransferApiExample.java index 111fd5fa..252dc74d 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/TransferExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TransferApiExample.java @@ -21,20 +21,22 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.google.common.collect.Lists; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.TransferExample; import com.lunarclient.apollo.module.transfer.PingResponse; import com.lunarclient.apollo.module.transfer.TransferModule; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.Optional; import org.bukkit.entity.Player; -public class TransferExample { +public class TransferApiExample extends TransferExample { private final TransferModule transferModule = Apollo.getModuleManager().getModule(TransferModule.class); + @Override public void transferExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -68,6 +70,7 @@ public void transferExample(Player viewer) { }); } + @Override public void pingExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/VignetteExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/VignetteApiExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/VignetteExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/VignetteApiExample.java index 13c929bf..36c1edef 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/VignetteExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/VignetteApiExample.java @@ -21,19 +21,21 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.common.modules.impl.VignetteExample; import com.lunarclient.apollo.module.vignette.Vignette; import com.lunarclient.apollo.module.vignette.VignetteModule; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.Optional; import org.bukkit.entity.Player; -public class VignetteExample { +public class VignetteApiExample extends VignetteExample { private final VignetteModule vignetteModule = Apollo.getModuleManager().getModule(VignetteModule.class); + @Override public void displayVignetteExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -46,6 +48,7 @@ public void displayVignetteExample(Player viewer) { }); } + @Override public void resetVignetteExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.vignetteModule::resetVignette); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/WaypointExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/WaypointApiExample.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/WaypointExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/WaypointApiExample.java index 03b37424..eb5b8e6a 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/modules/WaypointExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/WaypointApiExample.java @@ -21,10 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.modules; +package com.lunarclient.apollo.example.api.examples; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.common.location.ApolloBlockLocation; +import com.lunarclient.apollo.example.common.modules.impl.WaypointExample; import com.lunarclient.apollo.module.waypoint.Waypoint; import com.lunarclient.apollo.module.waypoint.WaypointModule; import com.lunarclient.apollo.player.ApolloPlayer; @@ -32,10 +33,11 @@ import java.util.Optional; import org.bukkit.entity.Player; -public class WaypointExample { +public class WaypointApiExample extends WaypointExample { private final WaypointModule waypointModule = Apollo.getModuleManager().getModule(WaypointModule.class); + @Override public void displayWaypointExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -57,11 +59,13 @@ public void displayWaypointExample(Player viewer) { }); } + @Override public void removeWaypointExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(apolloPlayer -> this.waypointModule.removeWaypoint(apolloPlayer, "KoTH")); } + @Override public void resetWaypointsExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.waypointModule::resetWaypoints); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/listeners/GeneralListenerExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/listeners/ApolloGeneralApiListener.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/listeners/GeneralListenerExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/listeners/ApolloGeneralApiListener.java index 4b129839..afe1c0c1 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/listeners/GeneralListenerExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/listeners/ApolloGeneralApiListener.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.listeners; +package com.lunarclient.apollo.example.api.listeners; import com.lunarclient.apollo.event.ApolloListener; import com.lunarclient.apollo.event.Event; @@ -32,7 +32,7 @@ import com.lunarclient.apollo.player.ApolloPlayer; import org.bukkit.entity.Player; -public class GeneralListenerExample { +public class ApolloGeneralApiListener { // Method 1 public class GeneralExample1 implements ApolloListener { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/listeners/PlayerListener.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/listeners/ApolloPlayerApiListener.java similarity index 76% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/listeners/PlayerListener.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/listeners/ApolloPlayerApiListener.java index 4ab8e097..47e7bf04 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/listeners/PlayerListener.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/listeners/ApolloPlayerApiListener.java @@ -21,20 +21,32 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.listeners; +package com.lunarclient.apollo.example.api.listeners; import com.lunarclient.apollo.event.ApolloListener; +import com.lunarclient.apollo.event.EventBus; import com.lunarclient.apollo.event.Listen; import com.lunarclient.apollo.event.player.ApolloRegisterPlayerEvent; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.TeamExample; +import com.lunarclient.apollo.example.api.examples.TeamApiExample; import com.lunarclient.apollo.player.ApolloPlayer; import org.bukkit.entity.Player; -public class PlayerListener implements ApolloListener { +public class ApolloPlayerApiListener implements ApolloListener { - private final ApolloExamplePlugin plugin = ApolloExamplePlugin.getPlugin(); - private final TeamExample.Team defaultTeam = this.plugin.getTeamExample().createTeam(); + private final ApolloExamplePlugin plugin; + private final TeamApiExample.Team defaultTeam; + + public ApolloPlayerApiListener(ApolloExamplePlugin plugin) { + this.plugin = plugin; + this.defaultTeam = ((TeamApiExample) this.plugin.getTeamExample()).createTeam(); + + EventBus.getBus().register(this); + } + + public void disable() { + EventBus.getBus().unregister(this); + } @Listen private void onApolloRegister(ApolloRegisterPlayerEvent event) { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/BukkitApolloExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/BukkitApolloExample.java similarity index 98% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/BukkitApolloExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/BukkitApolloExample.java index 64024fc3..12abb7b4 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/BukkitApolloExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/BukkitApolloExample.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.utilities; +package com.lunarclient.apollo.example.api.utilities; import com.google.common.collect.Lists; import com.lunarclient.apollo.Apollo; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/ComponentExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/ComponentExample.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/ComponentExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/ComponentExample.java index 3e3b7f95..f9bfc005 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/ComponentExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/ComponentExample.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.utilities; +package com.lunarclient.apollo.example.api.utilities; import com.google.common.collect.Lists; import net.kyori.adventure.text.Component; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/CuboidExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/CuboidExample.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/CuboidExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/CuboidExample.java index 1af50583..241a27e6 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/CuboidExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/CuboidExample.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.utilities; +package com.lunarclient.apollo.example.api.utilities; import com.lunarclient.apollo.common.cuboid.Cuboid2D; import com.lunarclient.apollo.common.cuboid.Cuboid3D; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/IconExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/IconExample.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/IconExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/IconExample.java index 23d90eb8..f7bfe085 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/IconExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/IconExample.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.utilities; +package com.lunarclient.apollo.example.api.utilities; import com.lunarclient.apollo.common.icon.AdvancedResourceLocationIcon; import com.lunarclient.apollo.common.icon.ItemStackIcon; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/LocationExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/LocationExample.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/LocationExample.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/LocationExample.java index 015f2545..f8d3486d 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/utilities/LocationExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/LocationExample.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.utilities; +package com.lunarclient.apollo.example.api.utilities; import com.lunarclient.apollo.common.location.ApolloBlockLocation; import com.lunarclient.apollo.common.location.ApolloLocation; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/SwitchCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/SwitchCommand.java new file mode 100644 index 00000000..2a960e15 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/SwitchCommand.java @@ -0,0 +1,76 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.commands; + +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.common.modules.ApolloExampleType; +import java.util.NoSuchElementException; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; + +public class SwitchCommand implements CommandExecutor { + + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { + if (args.length != 1) { + sender.sendMessage("Usage: /switch "); + sender.sendMessage("Current implementation: " + ApolloExamplePlugin.TYPE.name()); + return true; + } + + ApolloExampleType type; + try { + type = ApolloExampleType.valueOf(args[0].toUpperCase()); + } catch (NoSuchElementException e) { + sender.sendMessage("No implementation '" + args[0] + "' found!"); + return false; + } + + if (type == ApolloExamplePlugin.TYPE) { + sender.sendMessage("The implementation type is already set to " + ApolloExamplePlugin.TYPE.name()); + return true; + } + + Plugin plugin = Bukkit.getPluginManager().getPlugin("Apollo-Bukkit"); + if (type == ApolloExampleType.API && plugin == null) { + sender.sendMessage("Can't switch implementation to API, the Apollo-Bukkit plugin must be running."); + return true; + } + + if (type != ApolloExampleType.API && plugin != null) { + sender.sendMessage("Can't switch implementation to " + ApolloExamplePlugin.TYPE.name() + ", the Apollo-Bukkit must be deleted."); + return true; + } + + ApolloExamplePlugin.getPlugin().changeImplementationType(type); + sender.sendMessage("Successfully switched example implementation to " + type.name() + "!"); + sender.sendMessage("Re-join the server to apply the changes!"); + return true; + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/debug/ApolloDebugCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/debug/ApolloDebugCommand.java new file mode 100644 index 00000000..77373e72 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/debug/ApolloDebugCommand.java @@ -0,0 +1,63 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.commands.debug; + +import com.lunarclient.apollo.common.ApolloComponent; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; +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 ApolloDebugCommand 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(ApolloComponent.toLegacy(Component.text() + .append(Component.text("-------------------------------------", NamedTextColor.GRAY, TextDecoration.STRIKETHROUGH)) + .appendNewline() + .append(Component.text("/apollodebug spampackets [start|stop|stopall] ", NamedTextColor.WHITE)) + .append(Component.text("# Spam modsetting update packets to the client.", NamedTextColor.GREEN)) + .appendNewline() + .append(Component.text("-------------------------------------", NamedTextColor.GRAY, TextDecoration.STRIKETHROUGH)) + .build() + )); + } else if(args[0].equalsIgnoreCase("spampackets")) { + return new SpamPacketsCommand().onCommand(sender, command, label, args); + } + + return true; + } +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/debug/SpamPacketsCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/debug/SpamPacketsCommand.java new file mode 100644 index 00000000..8c2379f9 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/debug/SpamPacketsCommand.java @@ -0,0 +1,104 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.commands.debug; + +import com.lunarclient.apollo.common.ApolloComponent; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.debug.SpamPacketDebug; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; +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 SpamPacketsCommand implements CommandExecutor { + + private final SpamPacketDebug spamPacketDebug = ApolloExamplePlugin.getPlugin().getSpamPacketDebug(); + + @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 < 2) { + this.sendUsage(player); + } else { + switch (args[1].toLowerCase()) { + case "start": { + int amount = args.length > 2 ? Integer.parseInt(args[2]) : Integer.MAX_VALUE; + int delay = args.length > 3 ? Integer.parseInt(args[3]) : 50; + + this.spamPacketDebug.start(player, amount, delay, () -> player.sendMessage("Debug completed!")); + + player.sendMessage("Debug started. (Amount: " + amount + ", Delay: " + delay + "ms)"); + break; + } + + case "stop": { + this.spamPacketDebug.stop(player); + player.sendMessage("Debug stopped."); + break; + } + + case "stopall": { + this.spamPacketDebug.stopAll(); + player.sendMessage("Debug stopped for all debuggers."); + break; + } + + default: { + this.sendUsage(player); + break; + } + } + } + + return true; + } + + private void sendUsage(Player player) { + player.sendMessage(ApolloComponent.toLegacy(Component.text() + .append(Component.text("-------------------------------------", NamedTextColor.GRAY, TextDecoration.STRIKETHROUGH)) + .appendNewline() + .append(Component.text("/apollodebug spampackets start ", NamedTextColor.WHITE)) + .append(Component.text("# Starts spamming modsetting update packets to the client, delay is in milliseconds.", NamedTextColor.GREEN)) + .appendNewline() + .append(Component.text("/apollodebug spampackets stop ", NamedTextColor.WHITE)) + .append(Component.text("# Stop spamming modsetting update packets to the client.", NamedTextColor.GREEN)) + .appendNewline() + .append(Component.text("/apollodebug spampackets stopall ", NamedTextColor.WHITE)) + .append(Component.text("# Stops spamming modsetting update packets to the client, for all debuggers.", NamedTextColor.GREEN)) + .appendNewline() + .append(Component.text("-------------------------------------", NamedTextColor.GRAY, TextDecoration.STRIKETHROUGH)) + .build() + )); + } +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/BeamCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/BeamCommand.java similarity index 86% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/BeamCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/BeamCommand.java index 3611c337..d070d7e2 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/BeamCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/BeamCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.BeamExample; +import com.lunarclient.apollo.example.common.modules.impl.BeamExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class BeamCommand implements CommandExecutor { - private final BeamExample beamExample = ApolloExamplePlugin.getPlugin().getBeamExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,21 +47,23 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + BeamExample beamExample = ApolloExamplePlugin.getPlugin().getBeamExample(); + switch (args[0].toLowerCase()) { case "display": { - this.beamExample.displayBeamExample(player); + beamExample.displayBeamExample(player); player.sendMessage("Displaying beam...."); break; } case "remove": { - this.beamExample.removeBeamExample(player); + beamExample.removeBeamExample(player); player.sendMessage("Removing beam...."); break; } case "reset": { - this.beamExample.resetBeamsExample(player); + beamExample.resetBeamsExample(player); player.sendMessage("Resetting beams..."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/BorderCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/BorderCommand.java similarity index 86% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/BorderCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/BorderCommand.java index 56b2b43b..da532482 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/BorderCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/BorderCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.BorderExample; +import com.lunarclient.apollo.example.common.modules.impl.BorderExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class BorderCommand implements CommandExecutor { - private final BorderExample borderExample = ApolloExamplePlugin.getPlugin().getBorderExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,21 +47,23 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + BorderExample borderExample = ApolloExamplePlugin.getPlugin().getBorderExample(); + switch (args[0].toLowerCase()) { case "display": { - this.borderExample.displayBorderExample(player); + borderExample.displayBorderExample(player); player.sendMessage("Displaying border...."); break; } case "remove": { - this.borderExample.removeBorderExample(player); + borderExample.removeBorderExample(player); player.sendMessage("Removing border...."); break; } case "reset": { - this.borderExample.resetBordersExample(player); + borderExample.resetBordersExample(player); player.sendMessage("Resetting borders..."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/ChatCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ChatCommand.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/ChatCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ChatCommand.java index b502375f..6c0dff5d 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/ChatCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ChatCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.ChatExample; +import com.lunarclient.apollo.example.common.modules.impl.ChatExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class ChatCommand implements CommandExecutor { - private final ChatExample chatExample = ApolloExamplePlugin.getPlugin().getChatExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,15 +47,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + ChatExample chatExample = ApolloExamplePlugin.getPlugin().getChatExample(); + switch (args[0].toLowerCase()) { case "display": { - this.chatExample.displayLiveChatMessageExample(); + chatExample.displayLiveChatMessageExample(); player.sendMessage("Displaying live message...."); break; } case "remove": { - this.chatExample.removeLiveChatMessageExample(); + chatExample.removeLiveChatMessageExample(); player.sendMessage("Removing live message...."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/ColoredFireCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ColoredFireCommand.java similarity index 85% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/ColoredFireCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ColoredFireCommand.java index ce0aa8ed..cd61c305 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/ColoredFireCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ColoredFireCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.ColoredFireExample; +import com.lunarclient.apollo.example.common.modules.impl.ColoredFireExample; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -34,8 +34,6 @@ public class ColoredFireCommand implements CommandExecutor { - private final ColoredFireExample coloredFireExample = ApolloExamplePlugin.getPlugin().getColoredFireExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -44,9 +42,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } Player player = (Player) sender; + ColoredFireExample coloredFireExample = ApolloExamplePlugin.getPlugin().getColoredFireExample(); if (args.length == 1 && args[0].equalsIgnoreCase("clear")) { - this.coloredFireExample.resetColoredFiresExample(player); + coloredFireExample.resetColoredFiresExample(player); player.sendMessage("Resetting colored fires..."); return true; } @@ -65,13 +64,13 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command switch (args[0].toLowerCase()) { case "override": { - this.coloredFireExample.overrideColoredFireExample(target.getUniqueId()); + coloredFireExample.overrideColoredFireExample(target.getUniqueId()); player.sendMessage("Displaying colored fire...."); break; } case "reset": { - this.coloredFireExample.resetColoredFireExample(target.getUniqueId()); + coloredFireExample.resetColoredFireExample(target.getUniqueId()); player.sendMessage("Resetting colored fire...."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/CombatCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/CombatCommand.java similarity index 89% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/CombatCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/CombatCommand.java index a06198f2..b6f9e839 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/CombatCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/CombatCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.CombatExample; +import com.lunarclient.apollo.example.common.modules.impl.CombatExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class CombatCommand implements CommandExecutor { - private final CombatExample combatExample = ApolloExamplePlugin.getPlugin().getCombatExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,9 +47,11 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + CombatExample combatExample = ApolloExamplePlugin.getPlugin().getCombatExample(); + if (args[0].equalsIgnoreCase("disablemisspenalty")) { boolean value = Boolean.parseBoolean(args[1]); - this.combatExample.setDisableMissPenalty(value); + combatExample.setDisableMissPenalty(value); player.sendMessage("Disable miss penalty rule has been set to " + value); } else { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/CooldownCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/CooldownCommand.java similarity index 84% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/CooldownCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/CooldownCommand.java index 003ce99b..36535ee0 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/CooldownCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/CooldownCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.CooldownExample; +import com.lunarclient.apollo.example.common.modules.impl.CooldownExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class CooldownCommand implements CommandExecutor { - private final CooldownExample cooldownExample = ApolloExamplePlugin.getPlugin().getCooldownExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,27 +47,29 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + CooldownExample cooldownExample = ApolloExamplePlugin.getPlugin().getCooldownExample(); + switch (args[0].toLowerCase()) { case "displayitem": { - this.cooldownExample.displayCooldownItemExample(player); + cooldownExample.displayCooldownItemExample(player); player.sendMessage("Displaying cooldown item...."); break; } case "displayresource": { - this.cooldownExample.displayCooldownResourceExample(player); + cooldownExample.displayCooldownResourceExample(player); player.sendMessage("Displaying cooldown resource...."); break; } case "remove": { - this.cooldownExample.removeCooldownExample(player); + cooldownExample.removeCooldownExample(player); player.sendMessage("Removing cooldown...."); break; } case "reset": { - this.cooldownExample.resetCooldownsExample(player); + cooldownExample.resetCooldownsExample(player); player.sendMessage("Resetting cooldowns..."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/EntityCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/EntityCommand.java similarity index 85% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/EntityCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/EntityCommand.java index f8492bed..64c0db1a 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/EntityCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/EntityCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.EntityExample; +import com.lunarclient.apollo.example.common.modules.impl.EntityExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class EntityCommand implements CommandExecutor { - private final EntityExample entityExample = ApolloExamplePlugin.getPlugin().getEntityExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,27 +47,29 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + EntityExample entityExample = ApolloExamplePlugin.getPlugin().getEntityExample(); + switch (args[0].toLowerCase()) { case "overridesheep": { - this.entityExample.overrideRainbowSheepExample(player); + entityExample.overrideRainbowSheepExample(player); player.sendMessage("Overriding rainbow sheep...."); break; } case "resetsheep": { - this.entityExample.resetRainbowSheepExample(player); + entityExample.resetRainbowSheepExample(player); player.sendMessage("Resetting rainbow sheep...."); break; } case "flipentities": { - this.entityExample.flipEntityExample(player); + entityExample.flipEntityExample(player); player.sendMessage("Flipping entities...."); break; } case "resetflippedentities": { - this.entityExample.resetFlippedEntityExample(player); + entityExample.resetFlippedEntityExample(player); player.sendMessage("Resetting flipped entities...."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/GlowCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/GlowCommand.java similarity index 86% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/GlowCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/GlowCommand.java index c5eb2d79..abff7295 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/GlowCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/GlowCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.GlowExample; +import com.lunarclient.apollo.example.common.modules.impl.GlowExample; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -34,8 +34,6 @@ public class GlowCommand implements CommandExecutor { - private final GlowExample glowExample = ApolloExamplePlugin.getPlugin().getGlowExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -44,9 +42,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } Player player = (Player) sender; + GlowExample glowExample = ApolloExamplePlugin.getPlugin().getGlowExample(); if (args.length == 1 && args[0].equalsIgnoreCase("clear")) { - this.glowExample.resetGlowEffectsExample(player); + glowExample.resetGlowEffectsExample(player); player.sendMessage("Resetting glow effects..."); return true; } @@ -65,13 +64,13 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command switch (args[0].toLowerCase()) { case "override": { - this.glowExample.overrideGlowEffectExample(target.getUniqueId()); + glowExample.overrideGlowEffectExample(target.getUniqueId()); player.sendMessage("Displaying glow effect...."); break; } case "reset": { - this.glowExample.resetGlowEffectExample(target.getUniqueId()); + glowExample.resetGlowEffectExample(target.getUniqueId()); player.sendMessage("Resetting glow effect...."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/HologramCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/HologramCommand.java similarity index 86% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/HologramCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/HologramCommand.java index 86967315..62c9dea6 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/HologramCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/HologramCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.HologramExample; +import com.lunarclient.apollo.example.common.modules.impl.HologramExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class HologramCommand implements CommandExecutor { - private final HologramExample hologramExample = ApolloExamplePlugin.getPlugin().getHologramExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,21 +47,23 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + HologramExample hologramExample = ApolloExamplePlugin.getPlugin().getHologramExample(); + switch (args[0].toLowerCase()) { case "display": { - this.hologramExample.displayHologramExample(); + hologramExample.displayHologramExample(); player.sendMessage("Displaying hologram...."); break; } case "remove": { - this.hologramExample.removeHologramExample(); + hologramExample.removeHologramExample(); player.sendMessage("Removing hologram...."); break; } case "reset": { - this.hologramExample.resetHologramsExample(player); + hologramExample.resetHologramsExample(player); player.sendMessage("Resetting holograms..."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/LimbCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/LimbCommand.java similarity index 86% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/LimbCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/LimbCommand.java index 5e90b52f..19df9cd8 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/LimbCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/LimbCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.LimbExample; +import com.lunarclient.apollo.example.common.modules.impl.LimbExample; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -34,8 +34,6 @@ public class LimbCommand implements CommandExecutor { - private final LimbExample limbExample = ApolloExamplePlugin.getPlugin().getLimbExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -57,27 +55,29 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + LimbExample limbExample = ApolloExamplePlugin.getPlugin().getLimbExample(); + switch (args[0].toLowerCase()) { case "hidearmor": { - this.limbExample.hideArmorExample(player, target); + limbExample.hideArmorExample(player, target); player.sendMessage("Hiding armor...."); break; } case "resetarmor": { - this.limbExample.resetArmorExample(player, target); + limbExample.resetArmorExample(player, target); player.sendMessage("Resetting armor...."); break; } case "hidebody": { - this.limbExample.hideBodyExample(player, target); + limbExample.hideBodyExample(player, target); player.sendMessage("Hiding body...."); break; } case "resetbody": { - this.limbExample.resetBodyExample(player, target); + limbExample.resetBodyExample(player, target); player.sendMessage("Resetting body...."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/ModSettingsCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ModSettingsCommand.java similarity index 77% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/ModSettingsCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ModSettingsCommand.java index f8d44fe2..1346054d 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/ModSettingsCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ModSettingsCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.ModSettingsExample; +import com.lunarclient.apollo.example.common.modules.impl.ModSettingsExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class ModSettingsCommand implements CommandExecutor { - private final ModSettingsExample modSettingsExample = ApolloExamplePlugin.getPlugin().getModSettingsExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,22 +47,24 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + ModSettingsExample modSettingsExample = ApolloExamplePlugin.getPlugin().getModSettingsExample(); + switch (args[0].toLowerCase()) { case "disable": { - this.modSettingsExample.disableLightningModExample(player); - player.sendMessage("Disabling lightning mod...."); + modSettingsExample.disableLightingModExample(player); + player.sendMessage("Disabling lighting mod...."); break; } case "reset": { - this.modSettingsExample.rollbackLightningModEnabledState(player); - player.sendMessage("Rollbacking lightning mod enabled state...."); + modSettingsExample.rollbackLightingModEnabledState(player); + player.sendMessage("Rollbacking lighting mod enabled state...."); break; } case "broadcast": { - this.modSettingsExample.broadcastDisableLightningModExample(); - player.sendMessage("Broadcasting disable lightning mod...."); + modSettingsExample.broadcastDisableLightingModExample(); + player.sendMessage("Broadcasting disable lighting mod...."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/NametagCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NametagCommand.java similarity index 86% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/NametagCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NametagCommand.java index d346a36f..a1443cd2 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/NametagCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NametagCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.NametagExample; +import com.lunarclient.apollo.example.common.modules.impl.NametagExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class NametagCommand implements CommandExecutor { - private final NametagExample nametagExample = ApolloExamplePlugin.getPlugin().getNametagExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,21 +47,23 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + NametagExample nametagExample = ApolloExamplePlugin.getPlugin().getNametagExample(); + switch (args[0].toLowerCase()) { case "override": { - this.nametagExample.overrideNametagExample(player); + nametagExample.overrideNametagExample(player); player.sendMessage("Overriding nametag...."); break; } case "reset": { - this.nametagExample.resetNametagExample(player); + nametagExample.resetNametagExample(player); player.sendMessage("Resetting nametag...."); break; } case "clear": { - this.nametagExample.resetNametagsExample(player); + nametagExample.resetNametagsExample(player); player.sendMessage("Clearing nametags..."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/NickHiderCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NickHiderCommand.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/NickHiderCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NickHiderCommand.java index 368e8e8d..5e42f6a8 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/NickHiderCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NickHiderCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.NickHiderExample; +import com.lunarclient.apollo.example.common.modules.impl.NickHiderExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class NickHiderCommand implements CommandExecutor { - private final NickHiderExample nickHiderExample = ApolloExamplePlugin.getPlugin().getNickHiderExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,15 +47,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + NickHiderExample nickHiderExample = ApolloExamplePlugin.getPlugin().getNickHiderExample(); + switch (args[0].toLowerCase()) { case "override": { - this.nickHiderExample.overrideNickExample(player); + nickHiderExample.overrideNickExample(player); player.sendMessage("Overriding nick...."); break; } case "reset": { - this.nickHiderExample.resetNickExample(player); + nickHiderExample.resetNickExample(player); player.sendMessage("Resetting nick..."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/NotificationCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NotificationCommand.java similarity index 86% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/NotificationCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NotificationCommand.java index 289307bd..bb4eb8f4 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/NotificationCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NotificationCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.NotificationExample; +import com.lunarclient.apollo.example.common.modules.impl.NotificationExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class NotificationCommand implements CommandExecutor { - private final NotificationExample notificationExample = ApolloExamplePlugin.getPlugin().getNotificationExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,15 +47,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + NotificationExample notificationExample = ApolloExamplePlugin.getPlugin().getNotificationExample(); + switch (args[0].toLowerCase()) { case "display": { - this.notificationExample.displayNotificationExample(player); + notificationExample.displayNotificationExample(player); player.sendMessage("Displaying notification...."); break; } case "reset": { - this.notificationExample.resetNotificationsExample(player); + notificationExample.resetNotificationsExample(player); player.sendMessage("Resetting notifications..."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/RichPresenceCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/RichPresenceCommand.java similarity index 85% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/RichPresenceCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/RichPresenceCommand.java index 9f6e49c6..30b547e2 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/RichPresenceCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/RichPresenceCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.RichPresenceExample; +import com.lunarclient.apollo.example.common.modules.impl.RichPresenceExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class RichPresenceCommand implements CommandExecutor { - private final RichPresenceExample richPresenceExample = ApolloExamplePlugin.getPlugin().getRichPresenceExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,15 +47,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + RichPresenceExample richPresenceExample = ApolloExamplePlugin.getPlugin().getRichPresenceExample(); + switch (args[0].toLowerCase()) { case "override": { - this.richPresenceExample.overrideServerRichPresenceExample(player); + richPresenceExample.overrideServerRichPresenceExample(player); player.sendMessage("Overriding rich presence...."); break; } case "reset": { - this.richPresenceExample.resetServerRichPresenceExample(player); + richPresenceExample.resetServerRichPresenceExample(player); player.sendMessage("Resetting rich presence..."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/ServerRuleCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ServerRuleCommand.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/ServerRuleCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ServerRuleCommand.java index a5b67af2..beac095e 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/ServerRuleCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ServerRuleCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.ServerRuleExample; +import com.lunarclient.apollo.example.common.modules.impl.ServerRuleExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class ServerRuleCommand implements CommandExecutor { - private final ServerRuleExample serverRuleExample = ApolloExamplePlugin.getPlugin().getServerRuleExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,10 +47,12 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + ServerRuleExample serverRuleExample = ApolloExamplePlugin.getPlugin().getServerRuleExample(); + switch (args[0].toLowerCase()) { case "antiportaltraps": { boolean value = Boolean.parseBoolean(args[1]); - this.serverRuleExample.setAntiPortalTraps(value); + serverRuleExample.setAntiPortalTraps(value); player.sendMessage("Anti portal traps rule has been set to " + value); break; @@ -60,7 +60,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command case "overridenametagrenderdistance": { boolean value = Boolean.parseBoolean(args[1]); - this.serverRuleExample.setOverrideNametagRenderDistance(player, value); + serverRuleExample.setOverrideNametagRenderDistance(player, value); player.sendMessage("Override nametag render distance rule has been set to " + value); break; @@ -76,7 +76,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - this.serverRuleExample.setNametagRenderDistanceExample(value); + serverRuleExample.setNametagRenderDistanceExample(value); player.sendMessage("Nametag render distance has been set to " + value); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/StaffModCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/StaffModCommand.java similarity index 86% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/StaffModCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/StaffModCommand.java index 54b07b46..2ffaf2bc 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/StaffModCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/StaffModCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.StaffModExample; +import com.lunarclient.apollo.example.common.modules.impl.StaffModExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class StaffModCommand implements CommandExecutor { - private final StaffModExample staffModExample = ApolloExamplePlugin.getPlugin().getStaffModExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,15 +47,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + StaffModExample staffModExample = ApolloExamplePlugin.getPlugin().getStaffModExample(); + switch (args[0].toLowerCase()) { case "enable": { - this.staffModExample.enableStaffModsExample(player); + staffModExample.enableStaffModsExample(player); player.sendMessage("Enabling staff mods...."); break; } case "disable": { - this.staffModExample.disableStaffModsExample(player); + staffModExample.disableStaffModsExample(player); player.sendMessage("Disabling staff mods...."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/StopwatchCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/StopwatchCommand.java similarity index 85% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/StopwatchCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/StopwatchCommand.java index 17dd34d7..86cb2c50 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/StopwatchCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/StopwatchCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.StopwatchExample; +import com.lunarclient.apollo.example.common.modules.impl.StopwatchExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class StopwatchCommand implements CommandExecutor { - private final StopwatchExample stopwatchExample = ApolloExamplePlugin.getPlugin().getStopwatchExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,21 +47,23 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + StopwatchExample stopwatchExample = ApolloExamplePlugin.getPlugin().getStopwatchExample(); + switch (args[0].toLowerCase()) { case "start": { - this.stopwatchExample.startStopwatchExample(player); + stopwatchExample.startStopwatchExample(player); player.sendMessage("Starting stopwatch...."); break; } case "stop": { - this.stopwatchExample.stopStopwatchExample(player); + stopwatchExample.stopStopwatchExample(player); player.sendMessage("Stopping stopwatch...."); break; } case "reset": { - this.stopwatchExample.resetStopwatchExample(player); + stopwatchExample.resetStopwatchExample(player); player.sendMessage("Resetting stopwatch...."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/TeamCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TeamCommand.java similarity index 57% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/TeamCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TeamCommand.java index cd1eb101..d62ad942 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/TeamCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TeamCommand.java @@ -21,11 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.TeamExample; -import java.util.Optional; +import com.lunarclient.apollo.example.common.modules.impl.TeamExample; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -35,8 +34,6 @@ public class TeamCommand implements CommandExecutor { - private final TeamExample teamExample = ApolloExamplePlugin.getPlugin().getTeamExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -45,34 +42,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } Player player = (Player) sender; + TeamExample teamExample = ApolloExamplePlugin.getPlugin().getTeamExample(); if (args.length == 1) { switch (args[0].toLowerCase()) { case "create": { - Optional teamOpt = this.teamExample.getByPlayerUuid(player.getUniqueId()); - - if (teamOpt.isPresent()) { - player.sendMessage("You already have a team..."); - break; - } - - TeamExample.Team team = this.teamExample.createTeam(); - team.addMember(player); - - player.sendMessage("Creating team..."); + teamExample.createTeam(player); break; } case "delete": { - Optional teamOpt = this.teamExample.getByPlayerUuid(player.getUniqueId()); - - if (teamOpt.isPresent()) { - this.teamExample.deleteTeam(teamOpt.get().getTeamId()); - player.sendMessage("Deleting team..."); - break; - } - - player.sendMessage("No team found..."); + teamExample.deleteTeam(player); break; } @@ -94,39 +74,14 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - Optional teamOpt = this.teamExample.getByPlayerUuid(player.getUniqueId()); - Optional targetTeamOpt = this.teamExample.getByPlayerUuid(target.getUniqueId()); - switch (args[0].toLowerCase()) { case "addmember": { - if (targetTeamOpt.isPresent()) { - player.sendMessage("Player " + target.getName() + " already has a team..."); - break; - } - - if (teamOpt.isPresent()) { - teamOpt.get().addMember(target); - player.sendMessage("Added " + target.getName() + " to your team..."); - break; - } - - player.sendMessage("No team found..."); + teamExample.addMember(player, target); break; } case "removemember": { - if (!targetTeamOpt.isPresent()) { - player.sendMessage("Player " + target.getName() + " doesn't have a team..."); - break; - } - - if (teamOpt.isPresent()) { - teamOpt.get().removeMember(target); - player.sendMessage("Removed " + target.getName() + " from your team..."); - break; - } - - player.sendMessage("No team found..."); + teamExample.removeMember(player, target); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TebexCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TebexCommand.java new file mode 100644 index 00000000..c26d2d34 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TebexCommand.java @@ -0,0 +1,69 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.commands.module; + +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.common.modules.impl.TebexExample; +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 TebexCommand 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 < 2) { + player.sendMessage("Usage: /tebex [locale]"); + return true; + } + + TebexExample tebexExample = ApolloExamplePlugin.getPlugin().getTebexExample(); + String locale = args.length == 3 ? args[2] : null; + + switch (args[0].toLowerCase()) { + case "display": { + tebexExample.displayTebexEmbeddedCheckoutExample(player, args[1], locale); + player.sendMessage("Displaying checkout...."); + break; + } + + default: { + player.sendMessage("Usage: /tebex [locale]"); + break; + } + } + + return true; + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/TitleCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TitleCommand.java similarity index 75% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/TitleCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TitleCommand.java index 338bc5b4..f8f191df 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/TitleCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TitleCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.TitleExample; +import com.lunarclient.apollo.example.common.modules.impl.TitleExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class TitleCommand implements CommandExecutor { - private final TitleExample titleExample = ApolloExamplePlugin.getPlugin().getTitleExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -45,25 +43,33 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command Player player = (Player) sender; if (args.length != 1) { - player.sendMessage("Usage: /title "); + player.sendMessage("Usage: /title "); return true; } + TitleExample titleExample = ApolloExamplePlugin.getPlugin().getTitleExample(); + switch (args[0].toLowerCase()) { case "display": { - this.titleExample.displayTitleExample(player); + titleExample.displayTitleExample(player); player.sendMessage("Displaying title...."); break; } + case "displayinterpolated": { + titleExample.displayTitleInterpolatedExample(player); + player.sendMessage("Displaying interpolated title..."); + break; + } + case "reset": { - this.titleExample.resetTitlesExample(player); + titleExample.resetTitlesExample(player); player.sendMessage("Resetting titles...."); break; } default: { - player.sendMessage("Usage: /title "); + player.sendMessage("Usage: /title "); break; } } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/TntCountdownCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TntCountdownCommand.java similarity index 85% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/TntCountdownCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TntCountdownCommand.java index 78f64908..67871040 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/TntCountdownCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TntCountdownCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.TntCountdownExample; +import com.lunarclient.apollo.example.common.modules.impl.TntCountdownExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class TntCountdownCommand implements CommandExecutor { - private final TntCountdownExample tntCountdownExample = ApolloExamplePlugin.getPlugin().getTntCountdownExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,21 +47,23 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + TntCountdownExample tntCountdownExample = ApolloExamplePlugin.getPlugin().getTntCountdownExample(); + switch (args[0].toLowerCase()) { case "override": { - this.tntCountdownExample.overrideTntCountdownExample(player); + tntCountdownExample.overrideTntCountdownExample(player); player.sendMessage("Overriding custom tnt countdown option..."); break; } case "set": { - this.tntCountdownExample.setTntCountdownExample(); + tntCountdownExample.setTntCountdownExample(); player.sendMessage("Setting custom tnt countdown option...."); break; } case "clear": { - this.tntCountdownExample.clearTntCountdownOptionExample(); + tntCountdownExample.clearTntCountdownOptionExample(); player.sendMessage("Removing custom tnt countdown option...."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/TransferCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TransferCommand.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/TransferCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TransferCommand.java index d5c08aec..1e316472 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/TransferCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TransferCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.TransferExample; +import com.lunarclient.apollo.example.common.modules.impl.TransferExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class TransferCommand implements CommandExecutor { - private final TransferExample transferExample = ApolloExamplePlugin.getPlugin().getTransferExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,15 +47,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + TransferExample transferExample = ApolloExamplePlugin.getPlugin().getTransferExample(); + switch (args[0].toLowerCase()) { case "transfer": { - this.transferExample.transferExample(player); + transferExample.transferExample(player); player.sendMessage("Transferring player..."); break; } case "ping": { - this.transferExample.pingExample(player); + transferExample.pingExample(player); player.sendMessage("Pinging...."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/VignetteCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/VignetteCommand.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/VignetteCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/VignetteCommand.java index 61e133f4..b25fe357 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/VignetteCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/VignetteCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.VignetteExample; +import com.lunarclient.apollo.example.common.modules.impl.VignetteExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class VignetteCommand implements CommandExecutor { - private final VignetteExample vignetteExample = ApolloExamplePlugin.getPlugin().getVignetteExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,15 +47,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + VignetteExample vignetteExample = ApolloExamplePlugin.getPlugin().getVignetteExample(); + switch (args[0].toLowerCase()) { case "display": { - this.vignetteExample.displayVignetteExample(player); + vignetteExample.displayVignetteExample(player); player.sendMessage("Displaying vignette...."); break; } case "reset": { - this.vignetteExample.resetVignetteExample(player); + vignetteExample.resetVignetteExample(player); player.sendMessage("Resetting vignette...."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/WaypointCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/WaypointCommand.java similarity index 85% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/WaypointCommand.java rename to bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/WaypointCommand.java index 28bd0b4e..af4942d6 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/commands/WaypointCommand.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/WaypointCommand.java @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.commands; +package com.lunarclient.apollo.example.common.commands.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.modules.WaypointExample; +import com.lunarclient.apollo.example.common.modules.impl.WaypointExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -33,8 +33,6 @@ public class WaypointCommand implements CommandExecutor { - private final WaypointExample waypointExample = ApolloExamplePlugin.getPlugin().getWaypointExample(); - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { @@ -49,20 +47,22 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } + WaypointExample waypointExample = ApolloExamplePlugin.getPlugin().getWaypointExample(); + switch (args[0].toLowerCase()) { case "display": { - this.waypointExample.displayWaypointExample(player); + waypointExample.displayWaypointExample(player); player.sendMessage("Displaying waypoint...."); break; } case "remove": { - this.waypointExample.removeWaypointExample(player); + waypointExample.removeWaypointExample(player); player.sendMessage("Removing waypoint...."); break; } case "reset": { - this.waypointExample.resetWaypointsExample(player); + waypointExample.resetWaypointsExample(player); player.sendMessage("Resetting waypoints..."); break; } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/ApolloExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/ApolloExample.java new file mode 100644 index 00000000..f69f6a5a --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/ApolloExample.java @@ -0,0 +1,37 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules; + +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +public abstract class ApolloExample { + + protected void sendNotImplemented(Player player) { + player.sendMessage(ChatColor.RED + "This command is not available with the " + + ApolloExamplePlugin.TYPE.name().toLowerCase() + " implementation!"); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/ApolloExampleType.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/ApolloExampleType.java new file mode 100644 index 00000000..9eedd2e3 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/ApolloExampleType.java @@ -0,0 +1,30 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules; + +public enum ApolloExampleType { + + API, PROTO, JSON + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/BeamExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/BeamExample.java new file mode 100644 index 00000000..7dd40427 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/BeamExample.java @@ -0,0 +1,37 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class BeamExample extends ApolloExample { + + public abstract void displayBeamExample(Player viewer); + + public abstract void removeBeamExample(Player viewer); + + public abstract void resetBeamsExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/BorderExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/BorderExample.java new file mode 100644 index 00000000..d24c606c --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/BorderExample.java @@ -0,0 +1,37 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class BorderExample extends ApolloExample { + + public abstract void displayBorderExample(Player viewer); + + public abstract void removeBorderExample(Player viewer); + + public abstract void resetBordersExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ChatExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ChatExample.java new file mode 100644 index 00000000..9108a1d5 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ChatExample.java @@ -0,0 +1,34 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; + +public abstract class ChatExample extends ApolloExample { + + public abstract void displayLiveChatMessageExample(); + + public abstract void removeLiveChatMessageExample(); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ColoredFireExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ColoredFireExample.java new file mode 100644 index 00000000..88d2a92b --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ColoredFireExample.java @@ -0,0 +1,38 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import java.util.UUID; +import org.bukkit.entity.Player; + +public abstract class ColoredFireExample extends ApolloExample { + + public abstract void overrideColoredFireExample(UUID burningPlayer); + + public abstract void resetColoredFireExample(UUID burningPlayer); + + public abstract void resetColoredFiresExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/CombatExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/CombatExample.java new file mode 100644 index 00000000..4d3bfc50 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/CombatExample.java @@ -0,0 +1,32 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; + +public abstract class CombatExample extends ApolloExample { + + public abstract void setDisableMissPenalty(boolean value); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/CooldownExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/CooldownExample.java new file mode 100644 index 00000000..b68190ef --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/CooldownExample.java @@ -0,0 +1,39 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class CooldownExample extends ApolloExample { + + public abstract void displayCooldownItemExample(Player viewer); + + public abstract void displayCooldownResourceExample(Player viewer); + + public abstract void removeCooldownExample(Player viewer); + + public abstract void resetCooldownsExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/EntityExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/EntityExample.java new file mode 100644 index 00000000..bfd12ce1 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/EntityExample.java @@ -0,0 +1,39 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class EntityExample extends ApolloExample { + + public abstract void overrideRainbowSheepExample(Player viewer); + + public abstract void resetRainbowSheepExample(Player viewer); + + public abstract void flipEntityExample(Player viewer); + + public abstract void resetFlippedEntityExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/GlowExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/GlowExample.java new file mode 100644 index 00000000..d94bf83e --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/GlowExample.java @@ -0,0 +1,38 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import java.util.UUID; +import org.bukkit.entity.Player; + +public abstract class GlowExample extends ApolloExample { + + public abstract void overrideGlowEffectExample(UUID glowingPlayer); + + public abstract void resetGlowEffectExample(UUID glowingPlayer); + + public abstract void resetGlowEffectsExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/HologramExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/HologramExample.java new file mode 100644 index 00000000..47514208 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/HologramExample.java @@ -0,0 +1,37 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class HologramExample extends ApolloExample { + + public abstract void displayHologramExample(); + + public abstract void removeHologramExample(); + + public abstract void resetHologramsExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/LimbExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/LimbExample.java new file mode 100644 index 00000000..a7b1af2c --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/LimbExample.java @@ -0,0 +1,39 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class LimbExample extends ApolloExample { + + public abstract void hideArmorExample(Player viewer, Player target); + + public abstract void resetArmorExample(Player viewer, Player target); + + public abstract void hideBodyExample(Player viewer, Player target); + + public abstract void resetBodyExample(Player viewer, Player target); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ModSettingsExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ModSettingsExample.java new file mode 100644 index 00000000..e5f39512 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ModSettingsExample.java @@ -0,0 +1,37 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class ModSettingsExample extends ApolloExample { + + public abstract void disableLightingModExample(Player viewer); + + public abstract void rollbackLightingModEnabledState(Player viewer); + + public abstract void broadcastDisableLightingModExample(); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NametagExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NametagExample.java new file mode 100644 index 00000000..a1887109 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NametagExample.java @@ -0,0 +1,37 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class NametagExample extends ApolloExample { + + public abstract void overrideNametagExample(Player target); + + public abstract void resetNametagExample(Player target); + + public abstract void resetNametagsExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NickHiderExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NickHiderExample.java new file mode 100644 index 00000000..1a5dbdb5 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NickHiderExample.java @@ -0,0 +1,35 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class NickHiderExample extends ApolloExample { + + public abstract void overrideNickExample(Player viewer); + + public abstract void resetNickExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NotificationExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NotificationExample.java new file mode 100644 index 00000000..3cdb8937 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NotificationExample.java @@ -0,0 +1,35 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class NotificationExample extends ApolloExample { + + public abstract void displayNotificationExample(Player viewer); + + public abstract void resetNotificationsExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/RichPresenceExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/RichPresenceExample.java new file mode 100644 index 00000000..221b2a58 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/RichPresenceExample.java @@ -0,0 +1,35 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class RichPresenceExample extends ApolloExample { + + public abstract void overrideServerRichPresenceExample(Player viewer); + + public abstract void resetServerRichPresenceExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ServerRuleExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ServerRuleExample.java new file mode 100644 index 00000000..a7ea8776 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ServerRuleExample.java @@ -0,0 +1,37 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class ServerRuleExample extends ApolloExample { + + public abstract void setAntiPortalTraps(boolean value); + + public abstract void setOverrideNametagRenderDistance(Player viewer, boolean value); + + public abstract void setNametagRenderDistanceExample(int value); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/StaffModExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/StaffModExample.java new file mode 100644 index 00000000..05c20f55 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/StaffModExample.java @@ -0,0 +1,35 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class StaffModExample extends ApolloExample { + + public abstract void enableStaffModsExample(Player viewer); + + public abstract void disableStaffModsExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/StopwatchExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/StopwatchExample.java new file mode 100644 index 00000000..92417caa --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/StopwatchExample.java @@ -0,0 +1,37 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class StopwatchExample extends ApolloExample { + + public abstract void startStopwatchExample(Player viewer); + + public abstract void stopStopwatchExample(Player viewer); + + public abstract void resetStopwatchExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TeamExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TeamExample.java new file mode 100644 index 00000000..3da27f9e --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TeamExample.java @@ -0,0 +1,39 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class TeamExample extends ApolloExample { + + public abstract void createTeam(Player player); + + public abstract void deleteTeam(Player player); + + public abstract void addMember(Player player, Player target); + + public abstract void removeMember(Player player, Player target); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TebexExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TebexExample.java new file mode 100644 index 00000000..ba23761e --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TebexExample.java @@ -0,0 +1,33 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class TebexExample extends ApolloExample { + + public abstract void displayTebexEmbeddedCheckoutExample(Player viewer, String basketIdent, String locale); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TitleExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TitleExample.java new file mode 100644 index 00000000..063afd4b --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TitleExample.java @@ -0,0 +1,37 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class TitleExample extends ApolloExample { + + public abstract void displayTitleExample(Player viewer); + + public abstract void displayTitleInterpolatedExample(Player viewer); + + public abstract void resetTitlesExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TntCountdownExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TntCountdownExample.java new file mode 100644 index 00000000..46796516 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TntCountdownExample.java @@ -0,0 +1,37 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class TntCountdownExample extends ApolloExample { + + public abstract void setTntCountdownExample(); + + public abstract void overrideTntCountdownExample(Player viewer); + + public abstract void clearTntCountdownOptionExample(); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TransferExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TransferExample.java new file mode 100644 index 00000000..5bdf38d1 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TransferExample.java @@ -0,0 +1,35 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class TransferExample extends ApolloExample { + + public abstract void transferExample(Player player); + + public abstract void pingExample(Player player); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/VignetteExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/VignetteExample.java new file mode 100644 index 00000000..fc6b8520 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/VignetteExample.java @@ -0,0 +1,35 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class VignetteExample extends ApolloExample { + + public abstract void displayVignetteExample(Player viewer); + + public abstract void resetVignetteExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/WaypointExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/WaypointExample.java new file mode 100644 index 00000000..9859b498 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/WaypointExample.java @@ -0,0 +1,37 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.common.modules.impl; + +import com.lunarclient.apollo.example.common.modules.ApolloExample; +import org.bukkit.entity.Player; + +public abstract class WaypointExample extends ApolloExample { + + public abstract void displayWaypointExample(Player viewer); + + public abstract void removeWaypointExample(Player viewer); + + public abstract void resetWaypointsExample(Player viewer); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/debug/SpamPacketDebug.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/debug/SpamPacketDebug.java new file mode 100644 index 00000000..5d9de7e2 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/debug/SpamPacketDebug.java @@ -0,0 +1,125 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.debug; + +import com.google.common.collect.Maps; +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.network.NetworkOptions; +import java.util.Map; +import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; + +public class SpamPacketDebug implements Listener { + + private final Map players = Maps.newConcurrentMap(); + + public SpamPacketDebug() { + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); + } + + @EventHandler + private void onPlayerQuit(PlayerQuitEvent event) { + this.stop(event.getPlayer()); + } + + public void start(Player player, int amount, long delay, Runnable callback) { + UUID playerIdentifier = player.getUniqueId(); + SpamPacketTask task = new SpamPacketTask(playerIdentifier, amount, delay, callback); + this.players.put(playerIdentifier, task); + task.start(); + } + + public void stop(Player player) { + UUID playerIdentifier = player.getUniqueId(); + SpamPacketTask task = this.players.remove(playerIdentifier); + if (task != null) { + task.stop(); + } + } + + public void stopAll() { + for (SpamPacketTask task : this.players.values()) { + task.stop(); + } + + this.players.clear(); + } + + public static class SpamPacketTask implements Runnable { + private final UUID player; + private final int amount; + private final long delay; + private final Runnable onComplete; + + private volatile boolean running; + private int sent; + + public SpamPacketTask(UUID player, int amount, long delay, Runnable onComplete) { + this.player = player; + this.amount = amount; + this.delay = delay; + this.onComplete = onComplete; + } + + public void start() { + this.running = true; + + Thread debugThread = new Thread(this); + debugThread.setDaemon(true); + debugThread.start(); + } + + public void stop() { + this.running = false; + } + + @Override + public void run() { + while (this.running) { + if (this.sent > this.amount) { + this.onComplete.run(); + this.running = false; + break; + } + + Apollo.getPlayerManager().getPlayer(this.player) + .ifPresent(apolloPlayer -> NetworkOptions.sendOptions(Apollo.getModuleManager().getModules(), true, apolloPlayer)); + + this.sent++; + + try { + Thread.sleep(this.delay); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + break; + } + } + } + } +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/AdventureUtil.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/AdventureUtil.java new file mode 100644 index 00000000..91e172d2 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/AdventureUtil.java @@ -0,0 +1,39 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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; + +import lombok.NonNull; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; + +public final class AdventureUtil { + + public static String toJson(@NonNull Component component) { + return GsonComponentSerializer.gson().serialize(component); + } + + private AdventureUtil() { + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/JsonPacketUtil.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/JsonPacketUtil.java new file mode 100644 index 00000000..585cf7d8 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/JsonPacketUtil.java @@ -0,0 +1,134 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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; + +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Table; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public final class JsonPacketUtil { + + private static final List APOLLO_MODULES = Arrays.asList("limb", "beam", "border", "chat", "colored_fire", "combat", "cooldown", + "entity", "glow", "hologram", "mod_setting", "nametag", "nick_hider", "notification", "packet_enrichment", "rich_presence", + "server_rule", "staff_mod", "stopwatch", "team", "title", "tnt_countdown", "transfer", "vignette", "waypoint" + ); + + // Module Id -> Option key -> Object + private static final Table CONFIG_MODULE_PROPERTIES = HashBasedTable.create(); + + static { + // Module Options that the client needs to notified about, these properties are sent with the enable module packet + // While using the Apollo plugin this would be equivalent to modifying the config.yml + CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", false); + 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); + CONFIG_MODULE_PROPERTIES.put("server_rule", "disable-chunk-reloading", false); + CONFIG_MODULE_PROPERTIES.put("server_rule", "disable-broadcasting", false); + CONFIG_MODULE_PROPERTIES.put("server_rule", "anti-portal-traps", true); + CONFIG_MODULE_PROPERTIES.put("server_rule", "override-brightness", false); + CONFIG_MODULE_PROPERTIES.put("server_rule", "brightness", 50); + CONFIG_MODULE_PROPERTIES.put("server_rule", "override-nametag-render-distance", false); + CONFIG_MODULE_PROPERTIES.put("server_rule", "nametag-render-distance", 64); + CONFIG_MODULE_PROPERTIES.put("server_rule", "override-max-chat-length", false); + CONFIG_MODULE_PROPERTIES.put("server_rule", "max-chat-length", 256); + CONFIG_MODULE_PROPERTIES.put("tnt_countdown", "tnt-ticks", 80); + CONFIG_MODULE_PROPERTIES.put("waypoint", "server-handles-waypoints", false); + } + + public static void sendPacket(Player player, JsonObject message) { + player.sendPluginMessage(ApolloExamplePlugin.getPlugin(), "apollo:json", message.toString().getBytes()); + } + + public static void broadcastPacket(JsonObject message) { + byte[] data = message.toString().getBytes(); + + Bukkit.getOnlinePlayers().forEach(player -> + player.sendPluginMessage(ApolloExamplePlugin.getPlugin(), "apollo:json", data)); + } + + public static JsonObject createEnableModuleObject(@NotNull String module, Map properties) { + JsonObject enableModuleObject = new JsonObject(); + enableModuleObject.addProperty("apollo_module", module); + enableModuleObject.addProperty("enable", true); + + if (properties != null) { + JsonObject propertiesObject = new JsonObject(); + for (Map.Entry entry : properties.entrySet()) { + propertiesObject.add(entry.getKey(), JsonPacketUtil.convertToJsonElement(entry.getValue())); + } + + enableModuleObject.add("properties", propertiesObject); + } + + return enableModuleObject; + } + + private static JsonElement convertToJsonElement(Object value) { + if (value == null) { + return JsonNull.INSTANCE; + } else if (value instanceof String) { + return new JsonPrimitive((String) value); + } else if (value instanceof Number) { + return new JsonPrimitive((Number) value); + } else if (value instanceof Boolean) { + return new JsonPrimitive((Boolean) value); + } else if (value instanceof List) { + JsonArray jsonArray = new JsonArray(); + for (Object item : (List) value) { + jsonArray.add(JsonPacketUtil.convertToJsonElement(item)); + } + return jsonArray; + } + + throw new RuntimeException("Unable to wrap value of type '" + value.getClass().getSimpleName() + "'!"); + } + + public static void enableModules(Player player) { + JsonArray settings = APOLLO_MODULES.stream() + .map(module -> JsonPacketUtil.createEnableModuleObject(module, CONFIG_MODULE_PROPERTIES.row(module))) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.OverrideConfigurableSettingsMessage"); + message.add("configurable_settings", settings); + + JsonPacketUtil.sendPacket(player, message); + } + + private JsonPacketUtil() { + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/JsonUtil.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/JsonUtil.java new file mode 100644 index 00000000..bc494929 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/JsonUtil.java @@ -0,0 +1,154 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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; + +import com.google.gson.JsonObject; +import java.awt.Color; +import java.time.Duration; +import java.util.Map; +import java.util.UUID; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public final class JsonUtil { + + public static JsonObject createEnableModuleObjectWithType(@NotNull String module, Map properties) { + JsonObject enableModuleObject = JsonPacketUtil.createEnableModuleObject(module, properties); + enableModuleObject.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.ConfigurableSettings"); + return enableModuleObject; + } + + public static JsonObject createUuidObject(@NotNull UUID uuid) { + JsonObject uuidObject = new JsonObject(); + uuidObject.addProperty("high64", Long.toUnsignedString(uuid.getMostSignificantBits())); + uuidObject.addProperty("low64", Long.toUnsignedString(uuid.getLeastSignificantBits())); + return uuidObject; + } + + public static JsonObject createColorObject(@NotNull Color color) { + JsonObject colorObject = new JsonObject(); + colorObject.addProperty("color", color.getRGB()); + return colorObject; + } + + public static String createDurationObject(@NotNull Duration duration) { + long seconds = duration.getSeconds(); + int nanos = duration.getNano(); + + // Is there a better way to do this? + String durationString; + if (nanos == 0) { + durationString = seconds + "s"; + } else { + durationString = String.format("%d.%09ds", seconds, nanos) + .replaceAll("0+$", "") + .replaceAll("\\.$", ""); + } + + return durationString; + } + + public static JsonObject createCuboid2DObject(double minX, double minZ, double maxX, double maxZ) { + JsonObject cuboid2DObject = new JsonObject(); + cuboid2DObject.addProperty("min_x", minX); + cuboid2DObject.addProperty("min_z", minZ); + cuboid2DObject.addProperty("max_x", maxX); + cuboid2DObject.addProperty("max_z", maxZ); + return cuboid2DObject; + } + + public static JsonObject createEntityIdObject(@NotNull Entity entity) { + JsonObject entityIdObject = new JsonObject(); + entityIdObject.addProperty("entity_id", entity.getEntityId()); + entityIdObject.add("entity_uuid", JsonUtil.createUuidObject(entity.getUniqueId())); + return entityIdObject; + } + + public static JsonObject createLocationObject(@NotNull Location location) { + JsonObject locationObject = new JsonObject(); + locationObject.addProperty("world", location.getWorld().getName()); + locationObject.addProperty("x", location.getX()); + locationObject.addProperty("y", location.getY()); + locationObject.addProperty("z", location.getZ()); + return locationObject; + } + + public static JsonObject createBlockLocationObject(@NotNull Location location) { + JsonObject locationObject = new JsonObject(); + locationObject.addProperty("world", location.getWorld().getName()); + locationObject.addProperty("x", location.getBlockX()); + locationObject.addProperty("y", location.getBlockY()); + locationObject.addProperty("z", location.getBlockZ()); + return locationObject; + } + + public static JsonObject createItemStackIconObject(@Nullable String itemName, int itemId, int customModelData) { + JsonObject itemIconObject = new JsonObject(); + if (itemName != null) { + itemIconObject.addProperty("item_name", itemName); + } else { + itemIconObject.addProperty("item_id", itemId); + } + + itemIconObject.addProperty("custom_model_data", customModelData); + + JsonObject iconObject = new JsonObject(); + iconObject.add("item_stack", itemIconObject); + return iconObject; + } + + public static JsonObject createSimpleResourceLocationIconObject(@NotNull String resourceLocation, int size) { + JsonObject simpleIconObject = new JsonObject(); + simpleIconObject.addProperty("resource_location", resourceLocation); + simpleIconObject.addProperty("size", size); + + JsonObject iconObject = new JsonObject(); + iconObject.add("simple_resource_location", simpleIconObject); + + return iconObject; + } + + public static JsonObject createAdvancedResourceLocationIconObject(@NotNull String resourceLocation, float width, float height, + float minU, float maxU, float minV, float maxV) { + JsonObject advancedIcon = new JsonObject(); + advancedIcon.addProperty("resource_location", resourceLocation); + advancedIcon.addProperty("width", width); + advancedIcon.addProperty("height", height); + advancedIcon.addProperty("min_u", minU); + advancedIcon.addProperty("max_u", maxU); + advancedIcon.addProperty("min_v", minV); + advancedIcon.addProperty("max_v", maxV); + + JsonObject iconObject = new JsonObject(); + iconObject.add("advanced_resource_location", advancedIcon); + + return iconObject; + } + + private JsonUtil() { + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/BeamJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/BeamJsonExample.java new file mode 100644 index 00000000..2446e73c --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/BeamJsonExample.java @@ -0,0 +1,67 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.BeamExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.awt.Color; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class BeamJsonExample extends BeamExample { + + @Override + public void displayBeamExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.beam.v1.DisplayBeaconBeamMessage"); + message.addProperty("id", "spawn-beacon"); + message.add("location", JsonUtil.createBlockLocationObject( + new Location(Bukkit.getWorld("world"), 0, 60, 0) + )); + message.add("color", JsonUtil.createColorObject(Color.CYAN)); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void removeBeamExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.beam.v1.RemoveBeaconBeamMessage"); + message.addProperty("id", "spawn-beacon"); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetBeamsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.beam.v1.ResetBeaconBeamsMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/BorderJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/BorderJsonExample.java new file mode 100644 index 00000000..317f2856 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/BorderJsonExample.java @@ -0,0 +1,68 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.BorderExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.awt.Color; +import org.bukkit.entity.Player; + +public class BorderJsonExample extends BorderExample { + + @Override + public void displayBorderExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.border.v1.DisplayBorderMessage"); + message.addProperty("id", "pvp-tagged-spawn"); + message.addProperty("world", "world"); + message.addProperty("cancel_entry", true); + message.addProperty("cancel_exit", true); + message.addProperty("can_shrink_or_expand", false); + message.add("color", JsonUtil.createColorObject(Color.RED)); + message.add("bounds", JsonUtil.createCuboid2DObject(-50, -50, 50, 50)); + message.addProperty("duration_ticks", 1000); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void removeBorderExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.border.v1.RemoveBorderMessage"); + message.addProperty("id", "pvp-tagged-spawn"); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetBordersExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.border.v1.ResetBordersMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ChatJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ChatJsonExample.java new file mode 100644 index 00000000..092285e6 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ChatJsonExample.java @@ -0,0 +1,63 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.ChatExample; +import com.lunarclient.apollo.example.json.AdventureUtil; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; + +public class ChatJsonExample extends ChatExample { + + private int countdown = 5; + + @Override + public void displayLiveChatMessageExample() { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.chat.v1.DisplayLiveChatMessageMessage"); + message.addProperty("message_id", 13); + message.addProperty("adventure_json_lines", AdventureUtil.toJson( + Component.text("Game starting in ", NamedTextColor.GREEN) + .append(Component.text(this.countdown, NamedTextColor.BLUE)) + )); + + if (--this.countdown == 0) { + this.countdown = 5; + } + + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void removeLiveChatMessageExample() { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.chat.v1.RemoveLiveChatMessageMessage"); + message.addProperty("message_id", 13); + + JsonPacketUtil.broadcastPacket(message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ColoredFireJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ColoredFireJsonExample.java new file mode 100644 index 00000000..662335b0 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ColoredFireJsonExample.java @@ -0,0 +1,63 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.ColoredFireExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.awt.Color; +import java.util.UUID; +import org.bukkit.entity.Player; + +public class ColoredFireJsonExample extends ColoredFireExample { + + @Override + public void overrideColoredFireExample(UUID burningPlayer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.coloredfire.v1.OverrideColoredFireMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(burningPlayer)); + message.add("color", JsonUtil.createColorObject(Color.BLUE)); + + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void resetColoredFireExample(UUID burningPlayer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.coloredfire.v1.ResetColoredFireMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(burningPlayer)); + + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void resetColoredFiresExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.coloredfire.v1.ResetColoredFiresMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/CombatJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/CombatJsonExample.java new file mode 100644 index 00000000..94e32230 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/CombatJsonExample.java @@ -0,0 +1,44 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.CombatExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.util.HashMap; +import java.util.Map; + +public class CombatJsonExample extends CombatExample { + + @Override + public void setDisableMissPenalty(boolean value) { + Map properties = new HashMap<>(); + properties.put("disable-miss-penalty", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("combat", properties); + JsonPacketUtil.broadcastPacket(message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/CooldownJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/CooldownJsonExample.java new file mode 100644 index 00000000..2bf52d19 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/CooldownJsonExample.java @@ -0,0 +1,74 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.CooldownExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.time.Duration; +import org.bukkit.entity.Player; + +public class CooldownJsonExample extends CooldownExample { + + @Override + public void displayCooldownItemExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cooldown.v1.DisplayCooldownMessage"); + message.addProperty("name", "enderpearl-cooldown"); + message.addProperty("duration", JsonUtil.createDurationObject(Duration.ofSeconds(15))); + message.add("icon", JsonUtil.createItemStackIconObject("ENDER_PEARL", 0, 0)); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void displayCooldownResourceExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cooldown.v1.DisplayCooldownMessage"); + message.addProperty("name", "lunar-cooldown"); + message.addProperty("duration", JsonUtil.createDurationObject(Duration.ofSeconds(15))); + message.add("icon", JsonUtil.createSimpleResourceLocationIconObject("lunar:logo/logo-200x182.svg", 12)); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void removeCooldownExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cooldown.v1.RemoveCooldownMessage"); + message.addProperty("name", "enderpearl-cooldown"); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetCooldownsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cooldown.v1.ResetCooldownsMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/EntityJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/EntityJsonExample.java new file mode 100644 index 00000000..9094fc3b --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/EntityJsonExample.java @@ -0,0 +1,93 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.EntityExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import org.bukkit.entity.Cow; +import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; + +public class EntityJsonExample extends EntityExample { + + @Override + public void overrideRainbowSheepExample(Player viewer) { + JsonArray entityIds = viewer.getWorld().getEntitiesByClass(Sheep.class).stream() + .map(JsonUtil::createEntityIdObject) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.entity.v1.OverrideRainbowSheepMessage"); + message.add("entity_ids", entityIds); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetRainbowSheepExample(Player viewer) { + JsonArray entityIds = viewer.getWorld().getEntitiesByClass(Sheep.class).stream() + .map(JsonUtil::createEntityIdObject) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.entity.v1.ResetRainbowSheepMessage"); + message.add("entity_ids", entityIds); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void flipEntityExample(Player viewer) { + JsonArray entityIds = viewer.getWorld() + .getNearbyEntities(viewer.getLocation(), 10, 10, 10) + .stream().filter(entity -> entity instanceof Cow) + .map(JsonUtil::createEntityIdObject) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.entity.v1.FlipEntityMessage"); + message.add("entity_ids", entityIds); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetFlippedEntityExample(Player viewer) { + JsonArray entityIds = viewer.getWorld() + .getNearbyEntities(viewer.getLocation(), 10, 10, 10) + .stream().filter(entity -> entity instanceof Cow) + .map(JsonUtil::createEntityIdObject) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.entity.v1.ResetFlipedEntityMessage"); + message.add("entity_ids", entityIds); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/GlowJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/GlowJsonExample.java new file mode 100644 index 00000000..fef33533 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/GlowJsonExample.java @@ -0,0 +1,63 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.GlowExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.awt.Color; +import java.util.UUID; +import org.bukkit.entity.Player; + +public class GlowJsonExample extends GlowExample { + + @Override + public void overrideGlowEffectExample(UUID glowingPlayer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.glow.v1.OverrideGlowEffectMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(glowingPlayer)); + message.add("color", JsonUtil.createColorObject(Color.RED)); + + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void resetGlowEffectExample(UUID glowingPlayer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.glow.v1.ResetGlowEffectMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(glowingPlayer)); + + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void resetGlowEffectsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.glow.v1.ResetGlowEffectsMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/HologramJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/HologramJsonExample.java new file mode 100644 index 00000000..101e498b --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/HologramJsonExample.java @@ -0,0 +1,88 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.common.collect.Lists; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import com.lunarclient.apollo.example.common.modules.impl.HologramExample; +import com.lunarclient.apollo.example.json.AdventureUtil; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class HologramJsonExample extends HologramExample { + + @Override + public void displayHologramExample() { + JsonArray lines = Lists.newArrayList( + Component.text() + .content("Welcome to my server!") + .color(NamedTextColor.RED) + .decorate(TextDecoration.BOLD, TextDecoration.UNDERLINED) + .build(), + Component.text() + .content("Type /help to get started!") + .build() + ).stream().map(AdventureUtil::toJson).map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.hologram.v1.DisplayHologramMessage"); + message.addProperty("id", "welcome-hologram"); + message.add("location", JsonUtil.createLocationObject( + new Location(Bukkit.getWorld("world"), 5, 105, 0) + )); + message.add("adventure_json_lines", lines); + message.addProperty("show_through_walls", true); + message.addProperty("show_shadow", false); + message.addProperty("show_background", true); + + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void removeHologramExample() { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.hologram.v1.RemoveHologramMessage"); + message.addProperty("id", "welcome-hologram"); + + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void resetHologramsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.hologram.v1.ResetHologramsMessage"); + + JsonPacketUtil.broadcastPacket(message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/LimbJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/LimbJsonExample.java new file mode 100644 index 00000000..9790e81e --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/LimbJsonExample.java @@ -0,0 +1,97 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.common.collect.Lists; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import com.lunarclient.apollo.example.common.modules.impl.LimbExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import org.bukkit.entity.Player; + +public class LimbJsonExample extends LimbExample { + + @Override + public void hideArmorExample(Player viewer, Player target) { + // 1 = helmet, 2 = chestplate, 3 = leggings, 4 = boots + JsonArray armorPieces = Lists.newArrayList(1, 3) + .stream().map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.limb.v1.HideArmorPiecesMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(target.getUniqueId())); + message.add("armor_pieces", armorPieces); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetArmorExample(Player viewer, Player target) { + // 1 = helmet, 2 = chestplate, 3 = leggings, 4 = boots + JsonArray armorPieces = Lists.newArrayList(1, 3) + .stream().map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.limb.v1.ResetArmorPiecesMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(target.getUniqueId())); + message.add("armor_pieces", armorPieces); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void hideBodyExample(Player viewer, Player target) { + // 1 = head, 2 = torso, 3 = left arm, 4 = right arm, 5 = left leg, 6 = right leg + JsonArray bodyParts = Lists.newArrayList(1, 4) + .stream().map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.limb.v1.HideBodyPartMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(target.getUniqueId())); + message.add("body_parts", bodyParts); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetBodyExample(Player viewer, Player target) { + // 1 = head, 2 = torso, 3 = left arm, 4 = right arm, 5 = left leg, 6 = right leg + JsonArray bodyParts = Lists.newArrayList(1, 4) + .stream().map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.limb.v1.ResetBodyPartMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(target.getUniqueId())); + message.add("body_parts", bodyParts); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ModSettingsJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ModSettingsJsonExample.java new file mode 100644 index 00000000..6982ad1e --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ModSettingsJsonExample.java @@ -0,0 +1,64 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.ModSettingsExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.util.HashMap; +import java.util.Map; +import org.bukkit.entity.Player; + +public class ModSettingsJsonExample extends ModSettingsExample { + + @Override + public void disableLightingModExample(Player viewer) { + Map properties = new HashMap<>(); + properties.put("lighting.enabled", false); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("mod_setting", properties); + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void rollbackLightingModEnabledState(Player viewer) { + Map properties = new HashMap<>(); + // To rollback the server override value of the setting, simply set the value to "null" + properties.put("lighting.enabled", null); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("mod_setting", properties); + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void broadcastDisableLightingModExample() { + Map properties = new HashMap<>(); + properties.put("lighting.enabled", false); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("mod_setting", properties); + JsonPacketUtil.broadcastPacket(message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NametagJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NametagJsonExample.java new file mode 100644 index 00000000..74283938 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NametagJsonExample.java @@ -0,0 +1,82 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.common.collect.Lists; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import com.lunarclient.apollo.example.common.modules.impl.NametagExample; +import com.lunarclient.apollo.example.json.AdventureUtil; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; +import org.bukkit.entity.Player; + +public class NametagJsonExample extends NametagExample { + + @Override + public void overrideNametagExample(Player target) { + JsonArray lines = Lists.newArrayList( + Component.text() + .content("[StaffMode]") + .decorate(TextDecoration.ITALIC) + .color(NamedTextColor.GRAY) + .build(), + Component.text() + .content(target.getName()) + .color(NamedTextColor.RED) + .build() + ) + .stream().map(AdventureUtil::toJson).map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.nametag.v1.OverrideNametagMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(target.getUniqueId())); + message.add("adventure_json_lines", lines); + + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void resetNametagExample(Player target) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.nametag.v1.ResetNametagMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(target.getUniqueId())); + + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void resetNametagsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.nametag.v1.ResetNametagsMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NickHiderJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NickHiderJsonExample.java new file mode 100644 index 00000000..c93cca16 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NickHiderJsonExample.java @@ -0,0 +1,50 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.NickHiderExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import org.bukkit.entity.Player; + +public class NickHiderJsonExample extends NickHiderExample { + + @Override + public void overrideNickExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.nickhider.v1.OverrideNickHiderMessage"); + message.addProperty("nick", "Notch"); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetNickExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.nickhider.v1.ResetNickHiderMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NotificationJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NotificationJsonExample.java new file mode 100644 index 00000000..13c860ca --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NotificationJsonExample.java @@ -0,0 +1,67 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.NotificationExample; +import com.lunarclient.apollo.example.json.AdventureUtil; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.time.Duration; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.entity.Player; + +public class NotificationJsonExample extends NotificationExample { + + @Override + public void displayNotificationExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.notification.v1.DisplayNotificationMessage"); + message.addProperty("title_adventure_json_lines", AdventureUtil.toJson( + Component.text("UHC Announcement", NamedTextColor.GREEN) + )); + message.addProperty("description_adventure_json_lines", AdventureUtil.toJson( + Component.text("UHC starts in 5 minutes...", NamedTextColor.RED) + .append(Component.newline()) + .append(Component.text("Get ready!", NamedTextColor.WHITE)) + .append(Component.newline()) + .append(Component.text("Good luck!", NamedTextColor.GOLD)) + )); + + message.addProperty("display_time", JsonUtil.createDurationObject(Duration.ofSeconds(5))); + message.addProperty("resource_location", "icons/golden_apple.png"); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetNotificationsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.notification.v1.ResetNotificationsMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/RichPresenceJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/RichPresenceJsonExample.java new file mode 100644 index 00000000..855f6283 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/RichPresenceJsonExample.java @@ -0,0 +1,57 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.RichPresenceExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import org.bukkit.entity.Player; + +public class RichPresenceJsonExample extends RichPresenceExample { + + @Override + public void overrideServerRichPresenceExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.richpresence.v1.OverrideServerRichPresenceMessage"); + message.addProperty("game_name", "BedWars"); + message.addProperty("game_variant_name", "Solo"); + message.addProperty("game_state", "In Game"); + message.addProperty("player_state", "Playing"); + message.addProperty("map_name", "Winter"); + message.addProperty("sub_server", "BW02"); + message.addProperty("team_current_size", 3); + message.addProperty("team_max_size", 4); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetServerRichPresenceExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.richpresence.v1.ResetServerRichPresenceMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ServerRuleJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ServerRuleJsonExample.java new file mode 100644 index 00000000..ea6ab10d --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ServerRuleJsonExample.java @@ -0,0 +1,63 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.ServerRuleExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.util.HashMap; +import java.util.Map; +import org.bukkit.entity.Player; + +public class ServerRuleJsonExample extends ServerRuleExample { + + @Override + public void setAntiPortalTraps(boolean value) { + Map properties = new HashMap<>(); + properties.put("anti-portal-traps", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_rule", properties); + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void setOverrideNametagRenderDistance(Player viewer, boolean value) { + Map properties = new HashMap<>(); + properties.put("override-nametag-render-distance", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_rule", properties); + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void setNametagRenderDistanceExample(int value) { + Map properties = new HashMap<>(); + properties.put("nametag-render-distance", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_rule", properties); + JsonPacketUtil.broadcastPacket(message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/StaffModJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/StaffModJsonExample.java new file mode 100644 index 00000000..88c45481 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/StaffModJsonExample.java @@ -0,0 +1,68 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import com.lunarclient.apollo.example.common.modules.impl.StaffModExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import java.util.stream.Stream; +import org.bukkit.entity.Player; + +public class StaffModJsonExample extends StaffModExample { + + @Override + public void enableStaffModsExample(Player viewer) { + if (!viewer.hasPermission("apollo.staff")) { + return; + } + + // 1 = xray + JsonArray staffMods = Stream.of(1) + .map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.staffmod.v1.EnableStaffModsMessage"); + message.add("staff_mods", staffMods); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void disableStaffModsExample(Player viewer) { + // 1 = xray + JsonArray staffMods = Stream.of(1) + .map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.staffmod.v1.DisableStaffModsMessage"); + message.add("staff_mods", staffMods); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/StopwatchJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/StopwatchJsonExample.java new file mode 100644 index 00000000..3d64539c --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/StopwatchJsonExample.java @@ -0,0 +1,57 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.StopwatchExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import org.bukkit.entity.Player; + +public class StopwatchJsonExample extends StopwatchExample { + + @Override + public void startStopwatchExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.stopwatch.v1.StartStopwatchMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void stopStopwatchExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.stopwatch.v1.StopStopwatchMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetStopwatchExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.stopwatch.v1.ResetStopwatchMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TeamJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TeamJsonExample.java new file mode 100644 index 00000000..61d933e0 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TeamJsonExample.java @@ -0,0 +1,255 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.common.modules.impl.TeamExample; +import com.lunarclient.apollo.example.json.AdventureUtil; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.awt.Color; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.scheduler.BukkitRunnable; + +public class TeamJsonExample extends TeamExample implements Listener { + + private final Map teamsByTeamId = Maps.newHashMap(); + private final Map teamsByPlayerUuid = Maps.newHashMap(); + + public TeamJsonExample() { + new TeamUpdateTask(); + + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); + } + + @EventHandler + private void onPlayerQuit(PlayerQuitEvent event) { + Player player = event.getPlayer(); + + this.getByPlayerUuid(player.getUniqueId()).ifPresent(team -> { + if (team.getMembers().size() == 1) { + this.deleteTeam(team.getTeamId()); + } + }); + } + + public Optional getByPlayerUuid(UUID playerUuid) { + return Optional.ofNullable(this.teamsByPlayerUuid.get(playerUuid)); + } + + public Optional getByTeamId(UUID teamId) { + return Optional.ofNullable(this.teamsByTeamId.get(teamId)); + } + + public Team createTeam() { + Team team = new Team(); + this.teamsByTeamId.put(team.getTeamId(), team); + + return team; + } + + public void deleteTeam(UUID teamId) { + Team team = this.teamsByTeamId.remove(teamId); + + if (team != null) { + team.getMembers().forEach(team::removeMember); + } + } + + public class Team { + + private final UUID teamId; + private final Set members; + + public Team() { + this.teamId = UUID.randomUUID(); + this.members = Sets.newHashSet(); + } + + public void addMember(Player player) { + this.members.add(player); + TeamJsonExample.this.teamsByPlayerUuid.put(player.getUniqueId(), this); + } + + public void removeMember(Player player) { + this.members.remove(player); + TeamJsonExample.this.teamsByPlayerUuid.remove(player.getUniqueId()); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.team.v1.ResetTeamMembersMessage"); + + JsonPacketUtil.sendPacket(player, message); + } + + private JsonObject createTeamMember(Player member) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.team.v1.TeamMember"); + message.add("player_uuid", JsonUtil.createUuidObject(member.getUniqueId())); + message.addProperty("adventure_json_player_name", AdventureUtil.toJson( + Component.text() + .content(member.getName()) + .color(NamedTextColor.WHITE) + .build() + )); + message.add("marker_color", JsonUtil.createColorObject(Color.WHITE)); + message.add("location", JsonUtil.createLocationObject(member.getLocation())); + + return message; + } + + // The refresh method used for updating members locations + public void refresh() { + JsonArray teammates = this.members.stream().filter(Player::isOnline) + .map(this::createTeamMember) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.team.v1.UpdateTeamMembersMessage"); + message.add("members", teammates); + + this.members.forEach(member -> JsonPacketUtil.sendPacket(member, message)); + } + + public UUID getTeamId() { + return this.teamId; + } + + public Set getMembers() { + return this.members; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + + if (other == null || other.getClass() != this.getClass()) { + return false; + } + + Team team = (Team) other; + return this.teamId.equals(team.getTeamId()); + } + + @Override + public int hashCode() { + return this.teamId.hashCode(); + } + } + + // Updates players location every 1 tick (50ms) + public class TeamUpdateTask extends BukkitRunnable { + + public TeamUpdateTask() { + this.runTaskTimerAsynchronously(ApolloExamplePlugin.getPlugin(), 1L, 1L); + } + + @Override + public void run() { + TeamJsonExample.this.teamsByTeamId.values().forEach(Team::refresh); + } + } + + @Override + public void createTeam(Player player) { + Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); + + if (teamOpt.isPresent()) { + player.sendMessage("You already have a team..."); + return; + } + + Team team = this.createTeam(); + team.addMember(player); + + player.sendMessage("Creating team..."); + } + + @Override + public void deleteTeam(Player player) { + Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); + + if (teamOpt.isPresent()) { + this.deleteTeam(teamOpt.get().getTeamId()); + player.sendMessage("Deleting team..."); + return; + } + + player.sendMessage("No team found..."); + } + + @Override + public void addMember(Player player, Player target) { + Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); + Optional targetTeamOpt = this.getByPlayerUuid(target.getUniqueId()); + + if (targetTeamOpt.isPresent()) { + player.sendMessage("Player " + target.getName() + " already has a team..."); + return; + } + + if (teamOpt.isPresent()) { + teamOpt.get().addMember(target); + player.sendMessage("Added " + target.getName() + " to your team..."); + return; + } + + player.sendMessage("No team found..."); + } + + @Override + public void removeMember(Player player, Player target) { + Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); + Optional targetTeamOpt = this.getByPlayerUuid(target.getUniqueId()); + + if (!targetTeamOpt.isPresent()) { + player.sendMessage("Player " + target.getName() + " doesn't have a team..."); + return; + } + + if (teamOpt.isPresent()) { + teamOpt.get().removeMember(target); + player.sendMessage("Removed " + target.getName() + " from your team..."); + return; + } + + player.sendMessage("No team found..."); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TebexJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TebexJsonExample.java new file mode 100644 index 00000000..ff740125 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TebexJsonExample.java @@ -0,0 +1,46 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.TebexExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import org.bukkit.entity.Player; + +public class TebexJsonExample extends TebexExample { + + @Override + public void displayTebexEmbeddedCheckoutExample(Player viewer, String basketIdent, String locale) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.tebex.v1.OpenTebexEmbeddedCheckoutMessage"); + message.addProperty("basket_ident", basketIdent); + + if (locale != null) { + message.addProperty("locale", locale); + } + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TitleJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TitleJsonExample.java new file mode 100644 index 00000000..184a6a89 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TitleJsonExample.java @@ -0,0 +1,89 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.TitleExample; +import com.lunarclient.apollo.example.json.AdventureUtil; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.time.Duration; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; +import org.bukkit.entity.Player; + +public class TitleJsonExample extends TitleExample { + + @Override + public void displayTitleExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.title.v1.DisplayTitleMessage"); + message.addProperty("title_type", 1); // 1 = title, 2 = subtitle + message.addProperty("adventure_json_message", AdventureUtil.toJson( + Component.text() + .content("Hello, player!") + .color(NamedTextColor.GREEN) + .decorate(TextDecoration.BOLD) + .build() + )); + message.addProperty("scale", 1.0f); + message.addProperty("fade_in_time", JsonUtil.createDurationObject(Duration.ofMillis(1500))); + message.addProperty("display_time", JsonUtil.createDurationObject(Duration.ofMillis(250))); + message.addProperty("fade_out_time", JsonUtil.createDurationObject(Duration.ofMillis(300))); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void displayTitleInterpolatedExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.title.v1.DisplayTitleMessage"); + message.addProperty("title_type", 1); // 1 = title, 2 = subtitle + message.addProperty("adventure_json_message", AdventureUtil.toJson( + Component.text() + .content("This title expands!") + .color(NamedTextColor.GREEN) + .decorate(TextDecoration.BOLD) + .build() + )); + message.addProperty("scale", 0.1f); + message.addProperty("interpolation_scale", 1.0f); + message.addProperty("interpolation_rate", 0.01f); + message.addProperty("fade_in_time", JsonUtil.createDurationObject(Duration.ofMillis(5000))); + message.addProperty("display_time", JsonUtil.createDurationObject(Duration.ofMillis(250))); + message.addProperty("fade_out_time", JsonUtil.createDurationObject(Duration.ofMillis(300))); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetTitlesExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.title.v1.ResetTitlesMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TntCountdownJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TntCountdownJsonExample.java new file mode 100644 index 00000000..6abac834 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TntCountdownJsonExample.java @@ -0,0 +1,140 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.common.modules.impl.TntCountdownExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntitySpawnEvent; + +public class TntCountdownJsonExample extends TntCountdownExample implements Listener { + + private static Method entityGetter; + + static { + try { + TntCountdownJsonExample.entityGetter = Bukkit.class.getDeclaredMethod("getEntity", UUID.class); + } catch (Throwable throwable) { + // Ignore for legacy versions. + } + } + + public TntCountdownJsonExample() { + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); + } + + @Override + public void setTntCountdownExample() { + Map properties = new HashMap<>(); + properties.put("tnt-ticks", 160); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("tnt_countdown", properties); + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void overrideTntCountdownExample(Player viewer) { + Location location = viewer.getLocation(); + TNTPrimed entity = viewer.getWorld().spawn(location, TNTPrimed.class); + int customTicks = 200; + + TNTPrimed target = null; + if (TntCountdownJsonExample.entityGetter != null) { + try { + target = (TNTPrimed) TntCountdownJsonExample.entityGetter.invoke(null, entity.getUniqueId()); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + } else { + for (World world : Bukkit.getWorlds()) { + for (TNTPrimed compare : world.getEntitiesByClass(TNTPrimed.class)) { + if (compare.getUniqueId().equals(entity.getUniqueId())) { + target = compare; + break; + } + } + } + } + + if (target != null) { + target.setFuseTicks(customTicks); + } + + JsonPacketUtil.sendPacket(viewer, this.createTNTCountdownMessage(entity, customTicks)); + } + + @Override + public void clearTntCountdownOptionExample() { + Map properties = new HashMap<>(); + properties.put("tnt-ticks", 80); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("tnt_countdown", properties); + JsonPacketUtil.broadcastPacket(message); + } + + private JsonObject createTNTCountdownMessage(Entity entity, int ticks) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.tntcountdown.v1.SetTntCountdownMessage"); + message.add("entity_id", JsonUtil.createEntityIdObject(entity)); + message.addProperty("duration_ticks", ticks); + return message; + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + private void onTntSpawn(EntitySpawnEvent event) { + String entityName = event.getEntityType().name(); + if (!entityName.equals("PRIMED_TNT") && !entityName.equals("TNT")) { + return; + } + + TNTPrimed primed = (TNTPrimed) event.getEntity(); + int customTicks = 200; + int defaultTicks = 80; + int currentTicks = primed.getFuseTicks(); + + if (currentTicks != defaultTicks) { + customTicks = currentTicks; + + JsonPacketUtil.broadcastPacket(this.createTNTCountdownMessage(primed, customTicks)); + } + + primed.setFuseTicks(customTicks); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TransferJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TransferJsonExample.java new file mode 100644 index 00000000..8fdc2719 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TransferJsonExample.java @@ -0,0 +1,41 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.example.common.modules.impl.TransferExample; +import org.bukkit.entity.Player; + +public class TransferJsonExample extends TransferExample { + + @Override + public void transferExample(Player player) { + this.sendNotImplemented(player); + } + + @Override + public void pingExample(Player player) { + this.sendNotImplemented(player); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/VignetteJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/VignetteJsonExample.java new file mode 100644 index 00000000..8a227562 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/VignetteJsonExample.java @@ -0,0 +1,51 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.VignetteExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import org.bukkit.entity.Player; + +public class VignetteJsonExample extends VignetteExample { + + @Override + public void displayVignetteExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.vignette.v1.DisplayVignetteMessage"); + message.addProperty("resource_location", "textures/misc/pumpkinblur.png"); + message.addProperty("opacity", 0.75f); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetVignetteExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.vignette.v1.ResetVignetteMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/WaypointJsonExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/WaypointJsonExample.java new file mode 100644 index 00000000..1d206699 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/WaypointJsonExample.java @@ -0,0 +1,69 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.common.modules.impl.WaypointExample; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.JsonUtil; +import java.awt.Color; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class WaypointJsonExample extends WaypointExample { + + @Override + public void displayWaypointExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.waypoint.v1.DisplayWaypointMessage"); + message.addProperty("name", "KoTH"); + message.add("location", JsonUtil.createBlockLocationObject( + new Location(Bukkit.getWorld("world"), 500, 100, 500) + )); + message.add("color", JsonUtil.createColorObject(Color.ORANGE)); + message.addProperty("prevent_removal", false); + message.addProperty("hidden", false); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void removeWaypointExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.waypoint.v1.RemoveWaypointMessage"); + message.addProperty("name", "KoTH"); + + JsonPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetWaypointsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.waypoint.v1.ResetWaypointsMessage"); + + JsonPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/listeners/ApolloPlayerJsonListener.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/listeners/ApolloPlayerJsonListener.java new file mode 100644 index 00000000..1df631db --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/listeners/ApolloPlayerJsonListener.java @@ -0,0 +1,107 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.listeners; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.json.JsonPacketUtil; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerRegisterChannelEvent; +import org.bukkit.plugin.messaging.Messenger; + +public class ApolloPlayerJsonListener implements Listener { + + private final ApolloExamplePlugin plugin; + + private final Set playersRunningApollo = new HashSet<>(); + + public ApolloPlayerJsonListener(ApolloExamplePlugin plugin) { + this.plugin = plugin; + + Messenger messenger = Bukkit.getServer().getMessenger(); + messenger.registerIncomingPluginChannel(plugin, "lunar:apollo", (s, player, bytes) -> { }); + messenger.registerIncomingPluginChannel(plugin, "apollo:json", (s, player, bytes) -> { }); + messenger.registerOutgoingPluginChannel(plugin, "apollo:json"); + + Bukkit.getPluginManager().registerEvents(this, plugin); + } + + public void disable() { + this.playersRunningApollo.clear(); + + Messenger messenger = Bukkit.getServer().getMessenger(); + messenger.unregisterIncomingPluginChannel(this.plugin, "lunar:apollo"); + messenger.unregisterIncomingPluginChannel(this.plugin, "apollo:json"); + messenger.unregisterOutgoingPluginChannel(this.plugin, "apollo:json"); + + HandlerList.unregisterAll(this); + } + + @EventHandler + private void onRegisterChannel(PlayerRegisterChannelEvent event) { + if (!event.getChannel().equalsIgnoreCase("lunar:apollo")) { + return; + } + + this.onApolloRegister(event.getPlayer()); + } + + @EventHandler + private void onPlayerChangedWorld(PlayerChangedWorldEvent event) { + Player player = event.getPlayer(); + + // Sending the player's world name to the client is required for some modules + JsonPacketUtil.sendPacket(player, this.createUpdatePlayerWorldMessage(player)); + } + + private JsonObject createUpdatePlayerWorldMessage(Player player) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.player.v1.UpdatePlayerWorldMessage"); + message.addProperty("world", player.getWorld().getName()); + return message; + } + + private boolean isPlayerRunningApollo(Player player) { + return this.playersRunningApollo.contains(player.getUniqueId()); + } + + private void onApolloRegister(Player player) { + JsonPacketUtil.enableModules(player); + + // Sending the player's world name to the client is required for some modules + JsonPacketUtil.sendPacket(player, this.createUpdatePlayerWorldMessage(player)); + + this.playersRunningApollo.add(player.getUniqueId()); + player.sendMessage("You are using LunarClient!"); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/AdventureUtil.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/AdventureUtil.java new file mode 100644 index 00000000..aaab531d --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/AdventureUtil.java @@ -0,0 +1,39 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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; + +import lombok.NonNull; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; + +public final class AdventureUtil { + + public static String toJson(@NonNull Component component) { + return GsonComponentSerializer.gson().serialize(component); + } + + private AdventureUtil() { + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/ProtobufPacketUtil.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/ProtobufPacketUtil.java new file mode 100644 index 00000000..4810dfcb --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/ProtobufPacketUtil.java @@ -0,0 +1,118 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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; + +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Table; +import com.google.protobuf.Any; +import com.google.protobuf.GeneratedMessageV3; +import com.google.protobuf.ListValue; +import com.google.protobuf.Value; +import com.lunarclient.apollo.configurable.v1.ConfigurableSettings; +import com.lunarclient.apollo.configurable.v1.OverrideConfigurableSettingsMessage; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +public final class ProtobufPacketUtil { + + private static final List APOLLO_MODULES = Arrays.asList("limb", "beam", "border", "chat", "colored_fire", "combat", "cooldown", + "entity", "glow", "hologram", "mod_setting", "nametag", "nick_hider", "notification", "packet_enrichment", "rich_presence", + "server_rule", "staff_mod", "stopwatch", "team", "title", "tnt_countdown", "transfer", "vignette", "waypoint" + ); + + // Module Id -> Option key -> Value + private static final Table CONFIG_MODULE_PROPERTIES = HashBasedTable.create(); + + static { + // Module Options that the client needs to notified about, these properties are sent with the enable module packet + // While using the Apollo plugin this would be equivalent to modifying the config.yml + CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", Value.newBuilder().setBoolValue(false).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( + Value.newBuilder().setStringValue("/server").build(), + Value.newBuilder().setStringValue("/servers").build(), + Value.newBuilder().setStringValue("/hub").build())) + .build() + ).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "disable-shaders", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "disable-chunk-reloading", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "disable-broadcasting", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "anti-portal-traps", Value.newBuilder().setBoolValue(true).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "override-brightness", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "brightness", Value.newBuilder().setNumberValue(50).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "override-nametag-render-distance", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "nametag-render-distance", Value.newBuilder().setNumberValue(64).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "override-max-chat-length", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "max-chat-length", Value.newBuilder().setNumberValue(256).build()); + CONFIG_MODULE_PROPERTIES.put("tnt_countdown", "tnt-ticks", Value.newBuilder().setNumberValue(80).build()); + CONFIG_MODULE_PROPERTIES.put("waypoint", "server-handles-waypoints", Value.newBuilder().setBoolValue(false).build()); + } + + public static void enableModules(Player player) { + List settings = APOLLO_MODULES.stream() + .map(module -> createModuleMessage(module, CONFIG_MODULE_PROPERTIES.row(module))) + .collect(Collectors.toList()); + + OverrideConfigurableSettingsMessage message = OverrideConfigurableSettingsMessage + .newBuilder() + .addAllConfigurableSettings(settings) + .build(); + + ProtobufPacketUtil.sendPacket(player, message); + } + + public static ConfigurableSettings createModuleMessage(String module, Map properties) { + ConfigurableSettings.Builder moduleBuilder = ConfigurableSettings.newBuilder() + .setApolloModule(module) + .setEnable(true); + + if (properties != null) { + moduleBuilder.putAllProperties(properties); + } + + return moduleBuilder.build(); + } + + public static void sendPacket(Player player, GeneratedMessageV3 message) { + byte[] bytes = Any.pack(message).toByteArray(); + player.sendPluginMessage(ApolloExamplePlugin.getPlugin(), "lunar:apollo", bytes); + } + + public static void broadcastPacket(GeneratedMessageV3 message) { + byte[] bytes = Any.pack(message).toByteArray(); + + Bukkit.getOnlinePlayers().forEach(player -> + player.sendPluginMessage(ApolloExamplePlugin.getPlugin(), "lunar:apollo", bytes)); + } + + private ProtobufPacketUtil() { + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/ProtobufUtil.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/ProtobufUtil.java new file mode 100644 index 00000000..a8ea6dfe --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/ProtobufUtil.java @@ -0,0 +1,156 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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; + +import com.google.protobuf.Timestamp; +import com.lunarclient.apollo.common.v1.AdvancedResourceLocationIcon; +import com.lunarclient.apollo.common.v1.BlockLocation; +import com.lunarclient.apollo.common.v1.Cuboid2D; +import com.lunarclient.apollo.common.v1.EntityId; +import com.lunarclient.apollo.common.v1.Icon; +import com.lunarclient.apollo.common.v1.ItemStackIcon; +import com.lunarclient.apollo.common.v1.SimpleResourceLocationIcon; +import com.lunarclient.apollo.common.v1.Uuid; +import java.awt.Color; +import java.time.Duration; +import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.jetbrains.annotations.Nullable; + +public final class ProtobufUtil { + + public static UUID toJavaUuid(Uuid message) { + return new UUID(message.getHigh64(), message.getLow64()); + } + + public static long toJavaTimestamp(Timestamp message) { + return message.getSeconds() * 1000 + message.getNanos() / 1000000; + } + + public static Uuid createUuidProto(UUID object) { + return Uuid.newBuilder() + .setHigh64(object.getMostSignificantBits()) + .setLow64(object.getLeastSignificantBits()) + .build(); + } + + public static com.lunarclient.apollo.common.v1.Color createColorProto(Color object) { + return com.lunarclient.apollo.common.v1.Color.newBuilder() + .setColor(object.getRGB()) + .build(); + } + + public static com.google.protobuf.Duration createDurationProto(Duration object) { + return com.google.protobuf.Duration.newBuilder() + .setSeconds(object.getSeconds()) + .setNanos(object.getNano()) + .build(); + } + + public static Cuboid2D createCuboid2DProto(double minX, double minZ, double maxX, double maxZ) { + return Cuboid2D.newBuilder() + .setMinX(minX) + .setMinZ(minZ) + .setMaxX(maxX) + .setMaxZ(maxZ) + .build(); + } + + public static EntityId createEntityIdProto(int id, UUID uuid) { + return EntityId.newBuilder() + .setEntityId(id) + .setEntityUuid(ProtobufUtil.createUuidProto(uuid)) + .build(); + } + + public static com.lunarclient.apollo.common.v1.Location createLocationProto(Location location) { + return com.lunarclient.apollo.common.v1.Location.newBuilder() + .setWorld(location.getWorld().getName()) + .setX(location.getX()) + .setY(location.getY()) + .setZ(location.getZ()) + .build(); + } + + public static BlockLocation createBlockLocationProto(Location location) { + return BlockLocation.newBuilder() + .setWorld(location.getWorld().getName()) + .setX(location.getBlockX()) + .setY(location.getBlockY()) + .setZ(location.getBlockZ()) + .build(); + } + + public static Location toBukkitLocation(com.lunarclient.apollo.common.v1.Location message) { + return new Location(Bukkit.getWorld(message.getWorld()), message.getX(), message.getY(), message.getZ()); + } + + public static Location toBukkitLocation(com.lunarclient.apollo.common.v1.PlayerLocation message) { + Location location = ProtobufUtil.toBukkitLocation(message.getLocation()); + location.setYaw(message.getYaw()); + location.setPitch(message.getPitch()); + return location; + } + + public static Icon createItemStackIconProto(@Nullable String itemName, int itemId, int customModelData) { + ItemStackIcon.Builder iconBuilder = ItemStackIcon.newBuilder() + .setItemId(itemId) + .setCustomModelData(customModelData); + + if (itemName != null) { + iconBuilder.setItemName(itemName); + } + + return Icon.newBuilder().setItemStack(iconBuilder.build()).build(); + } + + public static Icon createSimpleResourceLocationIconProto(String resourceLocation, int size) { + SimpleResourceLocationIcon icon = SimpleResourceLocationIcon.newBuilder() + .setResourceLocation(resourceLocation) + .setSize(size) + .build(); + + return Icon.newBuilder().setSimpleResourceLocation(icon).build(); + } + + public static Icon createAdvancedResourceLocationIconProto(String resourceLocation, float width, float height, + float minU, float maxU, float minV, float maxV) { + AdvancedResourceLocationIcon icon = AdvancedResourceLocationIcon.newBuilder() + .setResourceLocation(resourceLocation) + .setWidth(width) + .setHeight(height) + .setMinU(minU) + .setMaxU(maxU) + .setMinV(minV) + .setMaxV(maxV) + .build(); + + return Icon.newBuilder().setAdvancedResourceLocation(icon).build(); + } + + private ProtobufUtil() { + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/BeamProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/BeamProtoExample.java new file mode 100644 index 00000000..0eba19f7 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/BeamProtoExample.java @@ -0,0 +1,64 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +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.example.common.modules.impl.BeamExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import java.awt.Color; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class BeamProtoExample extends BeamExample { + + @Override + public void displayBeamExample(Player viewer) { + DisplayBeaconBeamMessage message = DisplayBeaconBeamMessage.newBuilder() + .setId("spawn-beacon") + .setColor(ProtobufUtil.createColorProto(Color.CYAN)) + .setLocation(ProtobufUtil.createBlockLocationProto(new Location(viewer.getWorld(), 0, 60, 0))) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void removeBeamExample(Player viewer) { + RemoveBeaconBeamMessage message = RemoveBeaconBeamMessage.newBuilder() + .setId("spawn-beacon") + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetBeamsExample(Player viewer) { + ResetBeaconBeamsMessage message = ResetBeaconBeamsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/BorderProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/BorderProtoExample.java new file mode 100644 index 00000000..03f1d934 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/BorderProtoExample.java @@ -0,0 +1,68 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +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.example.common.modules.impl.BorderExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import java.awt.Color; +import org.bukkit.entity.Player; + +public class BorderProtoExample extends BorderExample { + + @Override + public void displayBorderExample(Player viewer) { + DisplayBorderMessage message = DisplayBorderMessage.newBuilder() + .setId("pvp-tagged-spawn") + .setWorld("world") + .setCancelEntry(true) + .setCancelExit(true) + .setCanShrinkOrExpand(false) + .setColor(ProtobufUtil.createColorProto(Color.RED)) + .setBounds(ProtobufUtil.createCuboid2DProto(-50, -50, 50, 50)) + .setDurationTicks(1000) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void removeBorderExample(Player viewer) { + RemoveBorderMessage message = RemoveBorderMessage.newBuilder() + .setId("pvp-tagged-spawn") + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetBordersExample(Player viewer) { + ResetBordersMessage message = ResetBordersMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ChatProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ChatProtoExample.java new file mode 100644 index 00000000..adda6d26 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ChatProtoExample.java @@ -0,0 +1,64 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.chat.v1.DisplayLiveChatMessageMessage; +import com.lunarclient.apollo.chat.v1.RemoveLiveChatMessageMessage; +import com.lunarclient.apollo.example.common.modules.impl.ChatExample; +import com.lunarclient.apollo.example.proto.AdventureUtil; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; + +public class ChatProtoExample extends ChatExample { + + private int countdown = 5; + + @Override + public void displayLiveChatMessageExample() { + DisplayLiveChatMessageMessage message = DisplayLiveChatMessageMessage.newBuilder() + .setAdventureJsonLines(AdventureUtil.toJson( + Component.text("Game starting in ", NamedTextColor.GREEN) + .append(Component.text(this.countdown, NamedTextColor.BLUE))) + ) + .setMessageId(13) + .build(); + + if (--this.countdown == 0) { + this.countdown = 5; + } + + ProtobufPacketUtil.broadcastPacket(message); + } + + @Override + public void removeLiveChatMessageExample() { + RemoveLiveChatMessageMessage message = RemoveLiveChatMessageMessage.newBuilder() + .setMessageId(13) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ColoredFireProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ColoredFireProtoExample.java new file mode 100644 index 00000000..7c201692 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ColoredFireProtoExample.java @@ -0,0 +1,63 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +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.example.common.modules.impl.ColoredFireExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import java.awt.Color; +import java.util.UUID; +import org.bukkit.entity.Player; + +public class ColoredFireProtoExample extends ColoredFireExample { + + @Override + public void overrideColoredFireExample(UUID burningPlayer) { + OverrideColoredFireMessage message = OverrideColoredFireMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(burningPlayer)) + .setColor(ProtobufUtil.createColorProto(Color.BLUE)) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); + } + + @Override + public void resetColoredFireExample(UUID burningPlayer) { + ResetColoredFireMessage message = ResetColoredFireMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(burningPlayer)) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); + } + + @Override + public void resetColoredFiresExample(Player viewer) { + ResetColoredFiresMessage message = ResetColoredFiresMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/CombatProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/CombatProtoExample.java new file mode 100644 index 00000000..69d5b67f --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/CombatProtoExample.java @@ -0,0 +1,44 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.protobuf.Value; +import com.lunarclient.apollo.configurable.v1.ConfigurableSettings; +import com.lunarclient.apollo.example.common.modules.impl.CombatExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import java.util.HashMap; +import java.util.Map; + +public class CombatProtoExample extends CombatExample { + + @Override + public void setDisableMissPenalty(boolean value) { + Map properties = new HashMap<>(); + properties.put("disable-miss-penalty", Value.newBuilder().setBoolValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("combat", properties); + ProtobufPacketUtil.broadcastPacket(settings); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/CooldownProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/CooldownProtoExample.java new file mode 100644 index 00000000..9746ec35 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/CooldownProtoExample.java @@ -0,0 +1,74 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +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.example.common.modules.impl.CooldownExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import java.time.Duration; +import org.bukkit.entity.Player; + +public class CooldownProtoExample extends CooldownExample { + + @Override + public void displayCooldownItemExample(Player viewer) { + DisplayCooldownMessage message = DisplayCooldownMessage.newBuilder() + .setName("enderpearl-cooldown") + .setDuration(ProtobufUtil.createDurationProto(Duration.ofSeconds(15))) + .setIcon(ProtobufUtil.createItemStackIconProto("ENDER_PEARL", 0, 0)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void displayCooldownResourceExample(Player viewer) { + DisplayCooldownMessage message = DisplayCooldownMessage.newBuilder() + .setName("lunar-cooldown") + .setDuration(ProtobufUtil.createDurationProto(Duration.ofSeconds(15))) + .setIcon(ProtobufUtil.createSimpleResourceLocationIconProto("lunar:logo/logo-200x182.svg", 12)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void removeCooldownExample(Player viewer) { + RemoveCooldownMessage enderpearlMessage = RemoveCooldownMessage.newBuilder() + .setName("enderpearl-cooldown") + .build(); + + ProtobufPacketUtil.sendPacket(viewer, enderpearlMessage); + } + + @Override + public void resetCooldownsExample(Player viewer) { + ResetCooldownsMessage message = ResetCooldownsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/EntityProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/EntityProtoExample.java new file mode 100644 index 00000000..80c450c9 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/EntityProtoExample.java @@ -0,0 +1,98 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.common.v1.EntityId; +import com.lunarclient.apollo.entity.v1.FlipEntityMessage; +import com.lunarclient.apollo.entity.v1.OverrideRainbowSheepMessage; +import com.lunarclient.apollo.entity.v1.ResetFlipedEntityMessage; +import com.lunarclient.apollo.entity.v1.ResetRainbowSheepMessage; +import com.lunarclient.apollo.example.common.modules.impl.EntityExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import java.util.Set; +import java.util.stream.Collectors; +import org.bukkit.entity.Cow; +import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; + +public class EntityProtoExample extends EntityExample { + + @Override + public void overrideRainbowSheepExample(Player viewer) { + Set sheepUuidsProto = viewer.getWorld().getEntitiesByClass(Sheep.class).stream() + .map(sheep -> ProtobufUtil.createEntityIdProto(sheep.getEntityId(), sheep.getUniqueId())) + .collect(Collectors.toSet()); + + OverrideRainbowSheepMessage message = OverrideRainbowSheepMessage.newBuilder() + .addAllEntityIds(sheepUuidsProto) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetRainbowSheepExample(Player viewer) { + Set sheepUuidsProto = viewer.getWorld().getEntitiesByClass(Sheep.class).stream() + .map(sheep -> ProtobufUtil.createEntityIdProto(sheep.getEntityId(), sheep.getUniqueId())) + .collect(Collectors.toSet()); + + ResetRainbowSheepMessage message = ResetRainbowSheepMessage.newBuilder() + .addAllEntityIds(sheepUuidsProto) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void flipEntityExample(Player viewer) { + Set entityUuidsProto = viewer.getWorld() + .getNearbyEntities(viewer.getLocation(), 10, 10, 10) + .stream().filter(entity -> entity instanceof Cow) + .map(sheep -> ProtobufUtil.createEntityIdProto(sheep.getEntityId(), sheep.getUniqueId())) + .collect(Collectors.toSet()); + + FlipEntityMessage message = FlipEntityMessage.newBuilder() + .addAllEntityIds(entityUuidsProto) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetFlippedEntityExample(Player viewer) { + Set entityUuidsProto = viewer.getWorld() + .getNearbyEntities(viewer.getLocation(), 10, 10, 10) + .stream().filter(entity -> entity instanceof Cow) + .map(sheep -> ProtobufUtil.createEntityIdProto(sheep.getEntityId(), sheep.getUniqueId())) + .collect(Collectors.toSet()); + + ResetFlipedEntityMessage message = ResetFlipedEntityMessage.newBuilder() + .addAllEntityIds(entityUuidsProto) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/GlowProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/GlowProtoExample.java new file mode 100644 index 00000000..94546c5a --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/GlowProtoExample.java @@ -0,0 +1,63 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.example.common.modules.impl.GlowExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import com.lunarclient.apollo.glow.v1.OverrideGlowEffectMessage; +import com.lunarclient.apollo.glow.v1.ResetGlowEffectMessage; +import com.lunarclient.apollo.glow.v1.ResetGlowEffectsMessage; +import java.awt.Color; +import java.util.UUID; +import org.bukkit.entity.Player; + +public class GlowProtoExample extends GlowExample { + + @Override + public void overrideGlowEffectExample(UUID glowingPlayer) { + OverrideGlowEffectMessage message = OverrideGlowEffectMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(glowingPlayer)) + .setColor(ProtobufUtil.createColorProto(Color.RED)) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); + } + + @Override + public void resetGlowEffectExample(UUID glowingPlayer) { + ResetGlowEffectMessage message = ResetGlowEffectMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(glowingPlayer)) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); + } + + @Override + public void resetGlowEffectsExample(Player viewer) { + ResetGlowEffectsMessage message = ResetGlowEffectsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/HologramProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/HologramProtoExample.java new file mode 100644 index 00000000..2756b97b --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/HologramProtoExample.java @@ -0,0 +1,89 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.common.collect.Lists; +import com.lunarclient.apollo.example.common.modules.impl.HologramExample; +import com.lunarclient.apollo.example.proto.AdventureUtil; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import com.lunarclient.apollo.hologram.v1.DisplayHologramMessage; +import com.lunarclient.apollo.hologram.v1.RemoveHologramMessage; +import com.lunarclient.apollo.hologram.v1.ResetHologramsMessage; +import java.util.List; +import java.util.stream.Collectors; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class HologramProtoExample extends HologramExample { + + @Override + public void displayHologramExample() { + List lines = Lists.newArrayList( + Component.text() + .content("Welcome to my server!") + .color(NamedTextColor.RED) + .decorate(TextDecoration.BOLD, TextDecoration.UNDERLINED) + .build(), + Component.text() + .content("Type /help to get started!") + .build() + ) + .stream().map(AdventureUtil::toJson) + .collect(Collectors.toList()); + + DisplayHologramMessage message = DisplayHologramMessage.newBuilder() + .setId("welcome-hologram") + .setLocation(ProtobufUtil.createLocationProto( + new Location(Bukkit.getWorld("world"), 5, 105, 0) + )) + .addAllAdventureJsonLines(lines) + .setShowThroughWalls(true) + .setShowShadow(false) + .setShowBackground(true) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); + } + + @Override + public void removeHologramExample() { + RemoveHologramMessage message = RemoveHologramMessage.newBuilder() + .setId("welcome-hologram") + .build(); + + ProtobufPacketUtil.broadcastPacket(message); + } + + @Override + public void resetHologramsExample(Player viewer) { + ResetHologramsMessage message = ResetHologramsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/LimbProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/LimbProtoExample.java new file mode 100644 index 00000000..ee22585d --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/LimbProtoExample.java @@ -0,0 +1,80 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.example.common.modules.impl.LimbExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import com.lunarclient.apollo.limb.v1.ArmorPiece; +import com.lunarclient.apollo.limb.v1.BodyPart; +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 java.util.EnumSet; +import org.bukkit.entity.Player; + +public class LimbProtoExample extends LimbExample { + + @Override + public void hideArmorExample(Player viewer, Player target) { + HideArmorPiecesMessage message = HideArmorPiecesMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(target.getUniqueId())) + .addAllArmorPieces(EnumSet.of(ArmorPiece.ARMOR_PIECE_HELMET, ArmorPiece.ARMOR_PIECE_LEGGINGS)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetArmorExample(Player viewer, Player target) { + ResetArmorPiecesMessage message = ResetArmorPiecesMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(target.getUniqueId())) + .addAllArmorPieces(EnumSet.of(ArmorPiece.ARMOR_PIECE_HELMET, ArmorPiece.ARMOR_PIECE_LEGGINGS)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void hideBodyExample(Player viewer, Player target) { + HideBodyPartMessage message = HideBodyPartMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(target.getUniqueId())) + .addAllBodyParts(EnumSet.of(BodyPart.BODY_PART_HEAD, BodyPart.BODY_PART_RIGHT_ARM)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message);; + } + + @Override + public void resetBodyExample(Player viewer, Player target) { + ResetBodyPartMessage message = ResetBodyPartMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(target.getUniqueId())) + .addAllBodyParts(EnumSet.of(BodyPart.BODY_PART_HEAD, BodyPart.BODY_PART_RIGHT_ARM)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message);; + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ModSettingsProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ModSettingsProtoExample.java new file mode 100644 index 00000000..e9056e7e --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ModSettingsProtoExample.java @@ -0,0 +1,65 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.protobuf.NullValue; +import com.google.protobuf.Value; +import com.lunarclient.apollo.configurable.v1.ConfigurableSettings; +import com.lunarclient.apollo.example.common.modules.impl.ModSettingsExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import java.util.HashMap; +import java.util.Map; +import org.bukkit.entity.Player; + +public class ModSettingsProtoExample extends ModSettingsExample { + + @Override + public void disableLightingModExample(Player viewer) { + Map properties = new HashMap<>(); + properties.put("lighting.enabled", Value.newBuilder().setBoolValue(false).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("mod_setting", properties); + ProtobufPacketUtil.sendPacket(viewer, settings); + } + + @Override + public void rollbackLightingModEnabledState(Player viewer) { + Map properties = new HashMap<>(); + // To rollback the server override value of the setting, simply set the value to "null" + properties.put("lighting.enabled", Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("mod_setting", properties); + ProtobufPacketUtil.sendPacket(viewer, settings); + } + + @Override + public void broadcastDisableLightingModExample() { + Map properties = new HashMap<>(); + properties.put("lighting.enabled", Value.newBuilder().setBoolValue(false).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("mod_setting", properties); + ProtobufPacketUtil.broadcastPacket(settings); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NametagProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NametagProtoExample.java new file mode 100644 index 00000000..8bafd5f8 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NametagProtoExample.java @@ -0,0 +1,82 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.common.collect.Lists; +import com.lunarclient.apollo.example.common.modules.impl.NametagExample; +import com.lunarclient.apollo.example.proto.AdventureUtil; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import com.lunarclient.apollo.nametag.v1.OverrideNametagMessage; +import com.lunarclient.apollo.nametag.v1.ResetNametagMessage; +import com.lunarclient.apollo.nametag.v1.ResetNametagsMessage; +import java.util.List; +import java.util.stream.Collectors; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; +import org.bukkit.entity.Player; + +public class NametagProtoExample extends NametagExample { + + @Override + public void overrideNametagExample(Player target) { + List lines = Lists.newArrayList( + Component.text() + .content("[StaffMode]") + .decorate(TextDecoration.ITALIC) + .color(NamedTextColor.GRAY) + .build(), + Component.text() + .content(target.getName()) + .color(NamedTextColor.RED) + .build() + ) + .stream().map(AdventureUtil::toJson) + .collect(Collectors.toList()); + + OverrideNametagMessage message = OverrideNametagMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(target.getUniqueId())) + .addAllAdventureJsonLines(lines) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); + } + + @Override + public void resetNametagExample(Player target) { + ResetNametagMessage message = ResetNametagMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(target.getUniqueId())) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); + } + + @Override + public void resetNametagsExample(Player viewer) { + ResetNametagsMessage message = ResetNametagsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NickHiderProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NickHiderProtoExample.java new file mode 100644 index 00000000..9fb7dc47 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NickHiderProtoExample.java @@ -0,0 +1,49 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.example.common.modules.impl.NickHiderExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.nickhider.v1.OverrideNickHiderMessage; +import com.lunarclient.apollo.nickhider.v1.ResetNickHiderMessage; +import org.bukkit.entity.Player; + +public class NickHiderProtoExample extends NickHiderExample { + + @Override + public void overrideNickExample(Player viewer) { + OverrideNickHiderMessage message = OverrideNickHiderMessage.newBuilder() + .setNick("Notch") + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetNickExample(Player viewer) { + ResetNickHiderMessage message = ResetNickHiderMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NotificationProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NotificationProtoExample.java new file mode 100644 index 00000000..6ee666da --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NotificationProtoExample.java @@ -0,0 +1,66 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.example.common.modules.impl.NotificationExample; +import com.lunarclient.apollo.example.proto.AdventureUtil; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import com.lunarclient.apollo.notification.v1.DisplayNotificationMessage; +import com.lunarclient.apollo.notification.v1.ResetNotificationsMessage; +import java.time.Duration; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.entity.Player; + +public class NotificationProtoExample extends NotificationExample { + + @Override + public void displayNotificationExample(Player viewer) { + DisplayNotificationMessage message = DisplayNotificationMessage.newBuilder() + .setTitleAdventureJsonLines(AdventureUtil.toJson( + Component.text("UHC Announcement", NamedTextColor.GREEN) + )) + .setDescriptionAdventureJsonLines(AdventureUtil.toJson( + Component.text("UHC starts in 5 minutes...", NamedTextColor.RED) + .append(Component.newline()) + .append(Component.text("Get ready!", NamedTextColor.WHITE)) + .append(Component.newline()) + .append(Component.text("Good luck!", NamedTextColor.GOLD)) + ) + ) + .setResourceLocation("icons/golden_apple.png") // This field is optional + .setDisplayTime(ProtobufUtil.createDurationProto(Duration.ofSeconds(5))) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetNotificationsExample(Player viewer) { + ResetNotificationsMessage message = ResetNotificationsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/RichPresenceProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/RichPresenceProtoExample.java new file mode 100644 index 00000000..d407941a --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/RichPresenceProtoExample.java @@ -0,0 +1,56 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.example.common.modules.impl.RichPresenceExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.richpresence.v1.OverrideServerRichPresenceMessage; +import com.lunarclient.apollo.richpresence.v1.ResetServerRichPresenceMessage; +import org.bukkit.entity.Player; + +public class RichPresenceProtoExample extends RichPresenceExample { + + @Override + public void overrideServerRichPresenceExample(Player viewer) { + OverrideServerRichPresenceMessage message = OverrideServerRichPresenceMessage.newBuilder() + .setGameName("BedWars") + .setGameVariantName("Solo") + .setGameState("In Game") + .setPlayerState("Playing") + .setMapName("Winter") + .setSubServer("BW02") + .setTeamCurrentSize(3) + .setTeamMaxSize(4) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetServerRichPresenceExample(Player viewer) { + ResetServerRichPresenceMessage message = ResetServerRichPresenceMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ServerRuleProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ServerRuleProtoExample.java new file mode 100644 index 00000000..32f8c9a4 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ServerRuleProtoExample.java @@ -0,0 +1,63 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.protobuf.Value; +import com.lunarclient.apollo.configurable.v1.ConfigurableSettings; +import com.lunarclient.apollo.example.common.modules.impl.ServerRuleExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import java.util.HashMap; +import java.util.Map; +import org.bukkit.entity.Player; + +public class ServerRuleProtoExample extends ServerRuleExample { + + @Override + public void setAntiPortalTraps(boolean value) { + Map properties = new HashMap<>(); + properties.put("anti-portal-traps", Value.newBuilder().setBoolValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_rule", properties); + ProtobufPacketUtil.broadcastPacket(settings); + } + + @Override + public void setOverrideNametagRenderDistance(Player viewer, boolean value) { + Map properties = new HashMap<>(); + properties.put("override-nametag-render-distance", Value.newBuilder().setBoolValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_rule", properties); + ProtobufPacketUtil.sendPacket(viewer, settings); + } + + @Override + public void setNametagRenderDistanceExample(int value) { + Map properties = new HashMap<>(); + properties.put("nametag-render-distance", Value.newBuilder().setNumberValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_rule", properties); + ProtobufPacketUtil.broadcastPacket(settings); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/StaffModProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/StaffModProtoExample.java new file mode 100644 index 00000000..9e6a8299 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/StaffModProtoExample.java @@ -0,0 +1,58 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.example.common.modules.impl.StaffModExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.staffmod.v1.DisableStaffModsMessage; +import com.lunarclient.apollo.staffmod.v1.EnableStaffModsMessage; +import com.lunarclient.apollo.staffmod.v1.StaffMod; +import java.util.Collections; +import org.bukkit.entity.Player; + +public class StaffModProtoExample extends StaffModExample { + + @Override + public void enableStaffModsExample(Player viewer) { + if (!viewer.hasPermission("apollo.staff")) { + return; + } + + EnableStaffModsMessage message = EnableStaffModsMessage.newBuilder() + .addAllStaffMods(Collections.singletonList(StaffMod.STAFF_MOD_XRAY)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void disableStaffModsExample(Player viewer) { + DisableStaffModsMessage message = DisableStaffModsMessage.newBuilder() + .addAllStaffMods(Collections.singletonList(StaffMod.STAFF_MOD_XRAY)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/StopwatchProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/StopwatchProtoExample.java new file mode 100644 index 00000000..67ea1840 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/StopwatchProtoExample.java @@ -0,0 +1,53 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.example.common.modules.impl.StopwatchExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.stopwatch.v1.ResetStopwatchMessage; +import com.lunarclient.apollo.stopwatch.v1.StartStopwatchMessage; +import com.lunarclient.apollo.stopwatch.v1.StopStopwatchMessage; +import org.bukkit.entity.Player; + +public class StopwatchProtoExample extends StopwatchExample { + + @Override + public void startStopwatchExample(Player viewer) { + StartStopwatchMessage message = StartStopwatchMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void stopStopwatchExample(Player viewer) { + StopStopwatchMessage message = StopStopwatchMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetStopwatchExample(Player viewer) { + ResetStopwatchMessage message = ResetStopwatchMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TeamProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TeamProtoExample.java new file mode 100644 index 00000000..5837c985 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TeamProtoExample.java @@ -0,0 +1,254 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.common.modules.impl.TeamExample; +import com.lunarclient.apollo.example.proto.AdventureUtil; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import com.lunarclient.apollo.team.v1.ResetTeamMembersMessage; +import com.lunarclient.apollo.team.v1.TeamMember; +import com.lunarclient.apollo.team.v1.UpdateTeamMembersMessage; +import java.awt.Color; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.scheduler.BukkitRunnable; + +public class TeamProtoExample extends TeamExample implements Listener { + + private final Map teamsByTeamId = Maps.newHashMap(); + private final Map teamsByPlayerUuid = Maps.newHashMap(); + + public TeamProtoExample() { + new TeamUpdateTask(); + + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); + } + + @EventHandler + private void onPlayerQuit(PlayerQuitEvent event) { + Player player = event.getPlayer(); + + this.getByPlayerUuid(player.getUniqueId()).ifPresent(team -> { + if (team.getMembers().size() == 1) { + this.deleteTeam(team.getTeamId()); + } + }); + } + + public Optional getByPlayerUuid(UUID playerUuid) { + return Optional.ofNullable(this.teamsByPlayerUuid.get(playerUuid)); + } + + public Optional getByTeamId(UUID teamId) { + return Optional.ofNullable(this.teamsByTeamId.get(teamId)); + } + + public Team createTeam() { + Team team = new Team(); + this.teamsByTeamId.put(team.getTeamId(), team); + + return team; + } + + public void deleteTeam(UUID teamId) { + Team team = this.teamsByTeamId.remove(teamId); + + if (team != null) { + team.getMembers().forEach(team::removeMember); + } + } + + public class Team { + + private final UUID teamId; + private final Set members; + + public Team() { + this.teamId = UUID.randomUUID(); + this.members = Sets.newHashSet(); + } + + public void addMember(Player player) { + this.members.add(player); + TeamProtoExample.this.teamsByPlayerUuid.put(player.getUniqueId(), this); + } + + public void removeMember(Player player) { + this.members.remove(player); + TeamProtoExample.this.teamsByPlayerUuid.remove(player.getUniqueId()); + + ResetTeamMembersMessage message = ResetTeamMembersMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(player, message); + } + + private TeamMember createTeamMember(Player member) { + return TeamMember.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(member.getUniqueId())) + .setAdventureJsonPlayerName(AdventureUtil.toJson( + Component.text() + .content(member.getName()) + .color(NamedTextColor.WHITE) + .build() + )) + .setMarkerColor(ProtobufUtil.createColorProto(Color.WHITE)) + .setLocation(ProtobufUtil.createLocationProto(member.getLocation())) + .build(); + } + + // The refresh method used for updating members locations + public void refresh() { + List teammates = this.members.stream().filter(Player::isOnline) + .map(this::createTeamMember) + .collect(Collectors.toList()); + + UpdateTeamMembersMessage message = UpdateTeamMembersMessage.newBuilder() + .addAllMembers(teammates) + .build(); + + this.members.forEach(member -> ProtobufPacketUtil.sendPacket(member, message)); + } + + public UUID getTeamId() { + return this.teamId; + } + + public Set getMembers() { + return this.members; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + + if (other == null || other.getClass() != this.getClass()) { + return false; + } + + Team team = (Team) other; + return this.teamId.equals(team.getTeamId()); + } + + @Override + public int hashCode() { + return this.teamId.hashCode(); + } + } + + // Updates players location every 1 tick (50ms) + public class TeamUpdateTask extends BukkitRunnable { + + public TeamUpdateTask() { + this.runTaskTimerAsynchronously(ApolloExamplePlugin.getPlugin(), 1L, 1L); + } + + @Override + public void run() { + TeamProtoExample.this.teamsByTeamId.values().forEach(Team::refresh); + } + } + + @Override + public void createTeam(Player player) { + Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); + + if (teamOpt.isPresent()) { + player.sendMessage("You already have a team..."); + return; + } + + Team team = this.createTeam(); + team.addMember(player); + + player.sendMessage("Creating team..."); + } + + @Override + public void deleteTeam(Player player) { + Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); + + if (teamOpt.isPresent()) { + this.deleteTeam(teamOpt.get().getTeamId()); + player.sendMessage("Deleting team..."); + return; + } + + player.sendMessage("No team found..."); + } + + @Override + public void addMember(Player player, Player target) { + Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); + Optional targetTeamOpt = this.getByPlayerUuid(target.getUniqueId()); + + if (targetTeamOpt.isPresent()) { + player.sendMessage("Player " + target.getName() + " already has a team..."); + return; + } + + if (teamOpt.isPresent()) { + teamOpt.get().addMember(target); + player.sendMessage("Added " + target.getName() + " to your team..."); + return; + } + + player.sendMessage("No team found..."); + } + + @Override + public void removeMember(Player player, Player target) { + Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); + Optional targetTeamOpt = this.getByPlayerUuid(target.getUniqueId()); + + if (!targetTeamOpt.isPresent()) { + player.sendMessage("Player " + target.getName() + " doesn't have a team..."); + return; + } + + if (teamOpt.isPresent()) { + teamOpt.get().removeMember(target); + player.sendMessage("Removed " + target.getName() + " from your team..."); + return; + } + + player.sendMessage("No team found..."); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TebexProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TebexProtoExample.java new file mode 100644 index 00000000..d547ead0 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TebexProtoExample.java @@ -0,0 +1,46 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.example.common.modules.impl.TebexExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.tebex.v1.OpenTebexEmbeddedCheckoutMessage; +import org.bukkit.entity.Player; + +public class TebexProtoExample extends TebexExample { + + @Override + public void displayTebexEmbeddedCheckoutExample(Player viewer, String basketIdent, String locale) { + OpenTebexEmbeddedCheckoutMessage.Builder builder = OpenTebexEmbeddedCheckoutMessage.newBuilder() + .setBasketIdent(basketIdent); + + if (locale != null) { + builder.setLocale(locale); + } + + OpenTebexEmbeddedCheckoutMessage message = builder.build(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TitleProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TitleProtoExample.java new file mode 100644 index 00000000..705752a0 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TitleProtoExample.java @@ -0,0 +1,89 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.example.json.examples.TitleJsonExample; +import com.lunarclient.apollo.example.proto.AdventureUtil; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import com.lunarclient.apollo.title.v1.DisplayTitleMessage; +import com.lunarclient.apollo.title.v1.ResetTitlesMessage; +import com.lunarclient.apollo.title.v1.TitleType; +import java.time.Duration; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; +import org.bukkit.entity.Player; + +public class TitleProtoExample extends TitleJsonExample { + + @Override + public void displayTitleExample(Player viewer) { + DisplayTitleMessage message = DisplayTitleMessage.newBuilder() + .setTitleType(TitleType.TITLE_TYPE_TITLE) + .setAdventureJsonMessage(AdventureUtil.toJson( + Component.text() + .content("Hello, player!") + .color(NamedTextColor.GREEN) + .decorate(TextDecoration.BOLD) + .build() + )) + .setScale(1.0f) + .setFadeInTime(ProtobufUtil.createDurationProto(Duration.ofMillis(1500))) + .setDisplayTime(ProtobufUtil.createDurationProto(Duration.ofMillis(250))) + .setFadeOutTime(ProtobufUtil.createDurationProto(Duration.ofMillis(300))) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void displayTitleInterpolatedExample(Player viewer) { + DisplayTitleMessage message = DisplayTitleMessage.newBuilder() + .setTitleType(TitleType.TITLE_TYPE_TITLE) + .setAdventureJsonMessage(AdventureUtil.toJson( + Component.text() + .content("This title expands!") + .color(NamedTextColor.GREEN) + .decorate(TextDecoration.BOLD) + .build() + )) + .setScale(0.1f) + .setInterpolationScale(1.0f) + .setInterpolationRate(0.01f) + .setFadeInTime(ProtobufUtil.createDurationProto(Duration.ofMillis(5000))) + .setDisplayTime(ProtobufUtil.createDurationProto(Duration.ofMillis(250))) + .setFadeOutTime(ProtobufUtil.createDurationProto(Duration.ofMillis(300))) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetTitlesExample(Player viewer) { + ResetTitlesMessage message = ResetTitlesMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TntCountdownProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TntCountdownProtoExample.java new file mode 100644 index 00000000..16ef01c3 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TntCountdownProtoExample.java @@ -0,0 +1,143 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.protobuf.Value; +import com.lunarclient.apollo.configurable.v1.ConfigurableSettings; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.common.modules.impl.TntCountdownExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import com.lunarclient.apollo.tntcountdown.v1.SetTntCountdownMessage; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntitySpawnEvent; + +public class TntCountdownProtoExample extends TntCountdownExample implements Listener { + + private static Method entityGetter; + + static { + try { + TntCountdownProtoExample.entityGetter = Bukkit.class.getDeclaredMethod("getEntity", UUID.class); + } catch (Throwable throwable) { + // Ignore for legacy versions. + } + } + + public TntCountdownProtoExample() { + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); + } + + @Override + public void setTntCountdownExample() { + Map properties = new HashMap<>(); + properties.put("tnt-ticks", Value.newBuilder().setNumberValue(160).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("tnt_countdown", properties); + ProtobufPacketUtil.broadcastPacket(settings); + } + + @Override + public void overrideTntCountdownExample(Player viewer) { + Location location = viewer.getLocation(); + TNTPrimed entity = viewer.getWorld().spawn(location, TNTPrimed.class); + int customTicks = 200; + + TNTPrimed target = null; + if (TntCountdownProtoExample.entityGetter != null) { + try { + target = (TNTPrimed) TntCountdownProtoExample.entityGetter.invoke(null, entity.getUniqueId()); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + } else { + for (World world : Bukkit.getWorlds()) { + for (TNTPrimed compare : world.getEntitiesByClass(TNTPrimed.class)) { + if (compare.getUniqueId().equals(entity.getUniqueId())) { + target = compare; + break; + } + } + } + } + + if (target != null) { + target.setFuseTicks(customTicks); + } + + SetTntCountdownMessage message = SetTntCountdownMessage.newBuilder() + .setEntityId(ProtobufUtil.createEntityIdProto(entity.getEntityId(), entity.getUniqueId())) + .setDurationTicks(customTicks) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void clearTntCountdownOptionExample() { + Map properties = new HashMap<>(); + properties.put("tnt-ticks", Value.newBuilder().setNumberValue(80).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("tnt_countdown", properties); + ProtobufPacketUtil.broadcastPacket(settings); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + private void onTntSpawn(EntitySpawnEvent event) { + String entityName = event.getEntityType().name(); + if (!entityName.equals("PRIMED_TNT") && !entityName.equals("TNT")) { + return; + } + + TNTPrimed primed = (TNTPrimed) event.getEntity(); + int customTicks = 200; + int defaultTicks = 80; + int currentTicks = primed.getFuseTicks(); + + if (currentTicks != defaultTicks) { + customTicks = currentTicks; + + SetTntCountdownMessage message = SetTntCountdownMessage.newBuilder() + .setEntityId(ProtobufUtil.createEntityIdProto(primed.getEntityId(), primed.getUniqueId())) + .setDurationTicks(customTicks) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); + } + + primed.setFuseTicks(customTicks); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TransferProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TransferProtoExample.java new file mode 100644 index 00000000..f674601b --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TransferProtoExample.java @@ -0,0 +1,110 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.google.common.collect.Lists; +import com.google.protobuf.ByteString; +import com.lunarclient.apollo.example.common.modules.impl.TransferExample; +import com.lunarclient.apollo.example.proto.listeners.ApolloRoundtripProtoListener; +import com.lunarclient.apollo.transfer.v1.PingData; +import com.lunarclient.apollo.transfer.v1.PingRequest; +import com.lunarclient.apollo.transfer.v1.PingResponse; +import com.lunarclient.apollo.transfer.v1.TransferRequest; +import com.lunarclient.apollo.transfer.v1.TransferResponse; +import java.util.UUID; +import org.bukkit.entity.Player; + +public class TransferProtoExample extends TransferExample { + + @Override + public void transferExample(Player player) { + UUID requestId = UUID.randomUUID(); + + TransferRequest transferRequestMessage = TransferRequest.newBuilder() + .setRequestId(ByteString.copyFromUtf8(requestId.toString())) + .setServerIp("mc.hypixel.net") + .build(); + + ApolloRoundtripProtoListener.getInstance() + .sendRequest(player, requestId, transferRequestMessage, TransferResponse.class) + .thenAccept(response -> { + String message = ""; + + switch (response.getStatus()) { + case STATUS_ACCEPTED: { + message = "Transfer accepted! Goodbye!"; + break; + } + + case STATUS_REJECTED: { + message = "Transfer rejected by client!"; + break; + } + } + + player.sendMessage(message); + }).exceptionally(throwable -> { + player.sendMessage("Failed to receive a response in time."); + return null; + }); + } + + @Override + public void pingExample(Player player) { + UUID requestId = UUID.randomUUID(); + + PingRequest pingRequestMessage = PingRequest.newBuilder() + .setRequestId(ByteString.copyFromUtf8(requestId.toString())) + .addAllServerIps(Lists.newArrayList("mc.hypixel.net", "minehut.com")) + .build(); + + ApolloRoundtripProtoListener.getInstance() + .sendRequest(player, requestId, pingRequestMessage, PingResponse.class) + .thenAccept(response -> { + for (PingData pingData : response.getPingDataList()) { + String message = ""; + + switch (pingData.getStatus()) { + // Displays successful ping request to display the server IP and the players ping to that server. + case STATUS_SUCCESS: { + message = String.format("Ping to %s is %d ms.", pingData.getServerIp(), pingData.getPing()); + break; + } + + // If the ping request times-out + case STATUS_TIMED_OUT: { + message = String.format("Failed to ping %s", pingData.getServerIp()); + break; + } + } + + player.sendMessage(message); + } + }).exceptionally(throwable -> { + player.sendMessage("Failed to receive a response in time."); + return null; + }); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/VignetteProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/VignetteProtoExample.java new file mode 100644 index 00000000..3cb665c9 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/VignetteProtoExample.java @@ -0,0 +1,50 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.example.common.modules.impl.VignetteExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.vignette.v1.DisplayVignetteMessage; +import com.lunarclient.apollo.vignette.v1.ResetVignetteMessage; +import org.bukkit.entity.Player; + +public class VignetteProtoExample extends VignetteExample { + + @Override + public void displayVignetteExample(Player viewer) { + DisplayVignetteMessage message = DisplayVignetteMessage.newBuilder() + .setResourceLocation("textures/misc/pumpkinblur.png") + .setOpacity(0.75f) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetVignetteExample(Player viewer) { + ResetVignetteMessage message = ResetVignetteMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/WaypointProtoExample.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/WaypointProtoExample.java new file mode 100644 index 00000000..df457fa9 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/WaypointProtoExample.java @@ -0,0 +1,66 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.examples; + +import com.lunarclient.apollo.example.common.modules.impl.WaypointExample; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import com.lunarclient.apollo.waypoint.v1.DisplayWaypointMessage; +import com.lunarclient.apollo.waypoint.v1.RemoveWaypointMessage; +import com.lunarclient.apollo.waypoint.v1.ResetWaypointsMessage; +import java.awt.Color; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class WaypointProtoExample extends WaypointExample { + + @Override + public void displayWaypointExample(Player viewer) { + DisplayWaypointMessage message = DisplayWaypointMessage.newBuilder() + .setName("KoTH") + .setLocation(ProtobufUtil.createBlockLocationProto(new Location(viewer.getWorld(), 500, 100, 500))) + .setColor(ProtobufUtil.createColorProto(Color.ORANGE)) + .setPreventRemoval(false) + .setHidden(false) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void removeWaypointExample(Player viewer) { + RemoveWaypointMessage message = RemoveWaypointMessage.newBuilder() + .setName("KoTH") + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); + } + + @Override + public void resetWaypointsExample(Player viewer) { + ResetWaypointsMessage message = ResetWaypointsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloPacketReceiveProtoListener.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloPacketReceiveProtoListener.java new file mode 100644 index 00000000..37c22bd9 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloPacketReceiveProtoListener.java @@ -0,0 +1,135 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.listeners; + +import com.google.protobuf.Any; +import com.google.protobuf.InvalidProtocolBufferException; +import com.lunarclient.apollo.common.v1.LunarClientVersion; +import com.lunarclient.apollo.common.v1.MinecraftVersion; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.proto.ProtobufUtil; +import com.lunarclient.apollo.packetenrichment.v1.PlayerAttackMessage; +import com.lunarclient.apollo.packetenrichment.v1.PlayerChatCloseMessage; +import com.lunarclient.apollo.packetenrichment.v1.PlayerChatOpenMessage; +import com.lunarclient.apollo.packetenrichment.v1.PlayerInfo; +import com.lunarclient.apollo.packetenrichment.v1.PlayerUseItemMessage; +import com.lunarclient.apollo.player.v1.ModMessage; +import com.lunarclient.apollo.player.v1.PlayerHandshakeMessage; +import java.util.List; +import java.util.UUID; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.plugin.messaging.PluginMessageListener; + +public class ApolloPacketReceiveProtoListener implements PluginMessageListener { + + public ApolloPacketReceiveProtoListener(ApolloExamplePlugin plugin) { + + } + + @Override + public void onPluginMessageReceived(String s, Player player, byte[] bytes) { + try { + Any any = Any.parseFrom(bytes); + + if (any.is(PlayerHandshakeMessage.class)) { + this.onPlayerHandshake(any.unpack(PlayerHandshakeMessage.class)); + } + + // Packet Enrichment Module + if (any.is(PlayerAttackMessage.class)) { + this.onPlayerAttack(any.unpack(PlayerAttackMessage.class)); + } else if (any.is(PlayerChatOpenMessage.class)) { + this.onPlayerChatOpen(any.unpack(PlayerChatOpenMessage.class)); + } else if (any.is(PlayerChatCloseMessage.class)) { + this.onPlayerChatClose(any.unpack(PlayerChatCloseMessage.class)); + } else if (any.is(PlayerUseItemMessage.class)) { + this.onPlayerUseItem(any.unpack(PlayerUseItemMessage.class)); + } + } catch (InvalidProtocolBufferException e) { + throw new RuntimeException(e); + } + } + + private void onPlayerHandshake(PlayerHandshakeMessage message) { + MinecraftVersion minecraftVersion = message.getMinecraftVersion(); + + LunarClientVersion lunarClientVersion = message.getLunarClientVersion(); + String gitBranch = lunarClientVersion.getGitBranch(); + String gitCommit = lunarClientVersion.getGitCommit(); + String semVer = lunarClientVersion.getSemver(); + + List installedMods = message.getInstalledModsList(); + for (ModMessage mod : installedMods) { + String modId = mod.getId(); + String displayName = mod.getName(); + String version = mod.getVersion(); + ModMessage.Type type = mod.getType(); + } + } + + private void onPlayerAttack(PlayerAttackMessage message) { + long instantiationTimeMs = ProtobufUtil.toJavaTimestamp(message.getPacketInfo().getInstantiationTime()); + + PlayerInfo targetInfo = message.getTargetInfo(); + PlayerInfo attackerInfo = message.getAttackerInfo(); + + this.onPlayerInfo(targetInfo); + this.onPlayerInfo(attackerInfo); + } + + private void onPlayerChatOpen(PlayerChatOpenMessage message) { + long instantiationTimeMs = ProtobufUtil.toJavaTimestamp(message.getPacketInfo().getInstantiationTime()); + + PlayerInfo playerInfo = message.getPlayerInfo(); + this.onPlayerInfo(playerInfo); + } + + private void onPlayerChatClose(PlayerChatCloseMessage message) { + long instantiationTimeMs = ProtobufUtil.toJavaTimestamp(message.getPacketInfo().getInstantiationTime()); + + PlayerInfo playerInfo = message.getPlayerInfo(); + this.onPlayerInfo(playerInfo); + } + + private void onPlayerUseItem(PlayerUseItemMessage message) { + long instantiationTimeMs = ProtobufUtil.toJavaTimestamp(message.getPacketInfo().getInstantiationTime()); + + PlayerInfo playerInfo = message.getPlayerInfo(); + this.onPlayerInfo(playerInfo); + + boolean mainHand = message.getMainHand(); + } + + private void onPlayerInfo(PlayerInfo info) { + UUID uuid = ProtobufUtil.toJavaUuid(info.getPlayerUuid()); + Location location = ProtobufUtil.toBukkitLocation(info.getLocation()); + boolean sneaking = info.getSneaking(); + boolean sprinting = info.getSprinting(); + boolean jumping = info.getJumping(); + float forwardSpeed = info.getForwardSpeed(); + float strafeSpeed = info.getStrafeSpeed(); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloPlayerProtoListener.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloPlayerProtoListener.java new file mode 100644 index 00000000..1a6553ba --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloPlayerProtoListener.java @@ -0,0 +1,105 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.listeners; + +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.player.v1.UpdatePlayerWorldMessage; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerRegisterChannelEvent; +import org.bukkit.plugin.messaging.Messenger; + +public class ApolloPlayerProtoListener implements Listener { + + private final ApolloExamplePlugin plugin; + + private final Set playersRunningApollo = new HashSet<>(); + + public ApolloPlayerProtoListener(ApolloExamplePlugin plugin) { + this.plugin = plugin; + + Messenger messenger = Bukkit.getServer().getMessenger(); + messenger.registerOutgoingPluginChannel(plugin, "lunar:apollo"); + messenger.registerIncomingPluginChannel(plugin, "lunar:apollo", new ApolloRoundtripProtoListener(plugin)); + messenger.registerIncomingPluginChannel(plugin, "lunar:apollo", new ApolloPacketReceiveProtoListener(plugin)); + + Bukkit.getPluginManager().registerEvents(this, plugin); + } + + public void disable() { + this.playersRunningApollo.clear(); + + Messenger messenger = Bukkit.getServer().getMessenger(); + messenger.unregisterOutgoingPluginChannel(this.plugin, "lunar:apollo"); + messenger.unregisterIncomingPluginChannel(this.plugin, "lunar:apollo"); + + HandlerList.unregisterAll(this); + } + + @EventHandler + private void onRegisterChannel(PlayerRegisterChannelEvent event) { + if (!event.getChannel().equalsIgnoreCase("lunar:apollo")) { + return; + } + + this.onApolloRegister(event.getPlayer()); + } + + @EventHandler + private void onPlayerChangedWorld(PlayerChangedWorldEvent event) { + Player player = event.getPlayer(); + + // Sending the player's world name to the client is required for some modules + ProtobufPacketUtil.sendPacket(player, this.createUpdatePlayerWorldMessage(player)); + } + + private UpdatePlayerWorldMessage createUpdatePlayerWorldMessage(Player player) { + return UpdatePlayerWorldMessage.newBuilder() + .setWorld(player.getWorld().getName()) + .build(); + } + + private boolean isPlayerRunningApollo(Player player) { + return this.playersRunningApollo.contains(player.getUniqueId()); + } + + private void onApolloRegister(Player player) { + ProtobufPacketUtil.enableModules(player); + + // Sending the player's world name to the client is required for some modules + ProtobufPacketUtil.sendPacket(player, this.createUpdatePlayerWorldMessage(player)); + + this.playersRunningApollo.add(player.getUniqueId()); + player.sendMessage("You are using LunarClient!"); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloRoundtripProtoListener.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloRoundtripProtoListener.java new file mode 100644 index 00000000..3abd55f9 --- /dev/null +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloRoundtripProtoListener.java @@ -0,0 +1,110 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.listeners; + +import com.google.protobuf.Any; +import com.google.protobuf.GeneratedMessageV3; +import com.google.protobuf.InvalidProtocolBufferException; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.transfer.v1.PingResponse; +import com.lunarclient.apollo.transfer.v1.TransferResponse; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import lombok.Getter; +import org.bukkit.entity.Player; +import org.bukkit.plugin.messaging.PluginMessageListener; + +public class ApolloRoundtripProtoListener implements PluginMessageListener { + + @Getter + private static ApolloRoundtripProtoListener instance; + + private final Map>> roundTripPacketFutures = new ConcurrentHashMap<>(); + private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1); + + public ApolloRoundtripProtoListener(ApolloExamplePlugin plugin) { + instance = this; + } + + @Override + public void onPluginMessageReceived(String s, Player player, byte[] bytes) { + try { + Any any = Any.parseFrom(bytes); + + if (any.is(PingResponse.class)) { + PingResponse message = any.unpack(PingResponse.class); + UUID requestId = UUID.fromString(message.getRequestId().toStringUtf8()); + this.handleResponse(player, requestId, message); + } else if (any.is(TransferResponse.class)) { + TransferResponse message = any.unpack(TransferResponse.class); + UUID requestId = UUID.fromString(message.getRequestId().toStringUtf8()); + this.handleResponse(player, requestId, message); + } + + } catch (InvalidProtocolBufferException e) { + throw new RuntimeException(e); + } + } + + public CompletableFuture sendRequest(Player player, UUID requestId, + GeneratedMessageV3 request, + Class responseType) { + ProtobufPacketUtil.sendPacket(player, request); + + CompletableFuture future = new CompletableFuture<>(); + + this.roundTripPacketFutures + .computeIfAbsent(player.getUniqueId(), k -> new ConcurrentHashMap<>()) + .put(requestId, (CompletableFuture) future); + + ScheduledFuture timeoutTask = this.executorService.schedule(() -> + future.completeExceptionally(new TimeoutException("Response timed out")), + 10, TimeUnit.SECONDS + ); + + future.whenComplete((result, throwable) -> timeoutTask.cancel(false)); + return future; + } + + private void handleResponse(Player player, UUID requestId, T message) { + Map> futures = this.roundTripPacketFutures.get(player.getUniqueId()); + if (futures == null) { + return; + } + + CompletableFuture future = futures.remove(requestId); + if (future != null) { + future.complete(message); + } + } + +} diff --git a/bukkit-example/src/main/resources/plugin.yml b/bukkit-example/src/main/resources/plugin.yml index 36617cc9..9daf502d 100644 --- a/bukkit-example/src/main/resources/plugin.yml +++ b/bukkit-example/src/main/resources/plugin.yml @@ -1,11 +1,13 @@ name: Apollo-Example main: com.lunarclient.apollo.example.ApolloExamplePlugin -version: 1.1.5 +version: 1.1.6 author: Moonsworth -depend: [ Apollo-Bukkit ] +softdepend: [ Apollo-Bukkit ] api-version: 1.13 commands: + switch: + description: "Switch the implementation type!" beam: description: "Beams!" border: @@ -44,6 +46,8 @@ commands: description: "Stopwatch!" team: description: "Teams!" + tebex: + description: "Tebex!" title: description: "Titles!" tntcountdown: @@ -54,3 +58,5 @@ commands: description: "Vignette!" waypoint: description: "Waypoints!" + apollodebug: + description: "Apollo Debug!" diff --git a/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java b/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java index 215b165e..30c0e552 100644 --- a/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java +++ b/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java @@ -66,6 +66,8 @@ import com.lunarclient.apollo.module.stopwatch.StopwatchModuleImpl; import com.lunarclient.apollo.module.team.TeamModule; import com.lunarclient.apollo.module.team.TeamModuleImpl; +import com.lunarclient.apollo.module.tebex.TebexModule; +import com.lunarclient.apollo.module.tebex.TebexModuleImpl; import com.lunarclient.apollo.module.title.TitleModule; import com.lunarclient.apollo.module.title.TitleModuleImpl; import com.lunarclient.apollo.module.tntcountdown.TntCountdownModule; @@ -138,6 +140,7 @@ public void onEnable() { .addModule(StaffModModule.class, new StaffModModuleImpl()) .addModule(StopwatchModule.class, new StopwatchModuleImpl()) .addModule(TeamModule.class, new TeamModuleImpl()) + .addModule(TebexModule.class, new TebexModuleImpl()) .addModule(TitleModule.class, new TitleModuleImpl()) .addModule(TntCountdownModule.class, new TntCountdownModuleImpl()) .addModule(TransferModule.class, new TransferModuleImpl()) diff --git a/bukkit/src/platform-loader/resources/plugin.yml b/bukkit/src/platform-loader/resources/plugin.yml index 22314fbe..50226f2c 100644 --- a/bukkit/src/platform-loader/resources/plugin.yml +++ b/bukkit/src/platform-loader/resources/plugin.yml @@ -1,6 +1,6 @@ name: Apollo-Bukkit main: com.lunarclient.apollo.loader.BukkitPlatformLoader -version: 1.1.5 +version: 1.1.6 author: Moonsworth api-version: 1.13 soft-depend: [LunarClient-API] diff --git a/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java b/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java index e2f58683..f8c41af6 100644 --- a/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java +++ b/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java @@ -57,6 +57,8 @@ import com.lunarclient.apollo.module.stopwatch.StopwatchModuleImpl; import com.lunarclient.apollo.module.team.TeamModule; import com.lunarclient.apollo.module.team.TeamModuleImpl; +import com.lunarclient.apollo.module.tebex.TebexModule; +import com.lunarclient.apollo.module.tebex.TebexModuleImpl; import com.lunarclient.apollo.module.title.TitleModule; import com.lunarclient.apollo.module.title.TitleModuleImpl; import com.lunarclient.apollo.module.transfer.TransferModule; @@ -120,6 +122,7 @@ public void onEnable() { .addModule(StaffModModule.class, new StaffModModuleImpl()) .addModule(StopwatchModule.class, new StopwatchModuleImpl()) .addModule(TeamModule.class, new TeamModuleImpl()) + .addModule(TebexModule.class, new TebexModuleImpl()) .addModule(TitleModule.class, new TitleModuleImpl()) .addModule(TransferModule.class, new TransferModuleImpl()) .addModule(VignetteModule.class, new VignetteModuleImpl()) diff --git a/bungee/src/platform-loader/resources/plugin.yml b/bungee/src/platform-loader/resources/plugin.yml index c4a254dc..468d6693 100644 --- a/bungee/src/platform-loader/resources/plugin.yml +++ b/bungee/src/platform-loader/resources/plugin.yml @@ -1,4 +1,4 @@ name: Apollo-Bungee main: com.lunarclient.apollo.loader.BungeePlatformLoader -version: 1.1.5 +version: 1.1.6 author: Moonsworth 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 new file mode 100644 index 00000000..902773b8 --- /dev/null +++ b/common/src/main/java/com/lunarclient/apollo/module/tebex/TebexModuleImpl.java @@ -0,0 +1,56 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 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.tebex; + +import com.lunarclient.apollo.player.AbstractApolloPlayer; +import com.lunarclient.apollo.recipients.Recipients; +import com.lunarclient.apollo.tebex.v1.OpenTebexEmbeddedCheckoutMessage; +import lombok.NonNull; + +/** + * Provides the tebex module. + * + * @since 1.1.6 + */ +public final class TebexModuleImpl extends TebexModule { + + @Override + public void displayTebexEmbeddedCheckout(@NonNull Recipients recipients, @NonNull String basketIdent) { + this.displayTebexEmbeddedCheckout(recipients, basketIdent, null); + } + + @Override + public void displayTebexEmbeddedCheckout(@NonNull Recipients recipients, @NonNull String basketIdent, String locale) { + OpenTebexEmbeddedCheckoutMessage.Builder builder = OpenTebexEmbeddedCheckoutMessage.newBuilder() + .setBasketIdent(basketIdent); + + if (locale != null) { + builder.setLocale(locale); + } + + OpenTebexEmbeddedCheckoutMessage message = builder.build(); + recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + } + +} diff --git a/common/src/main/java/com/lunarclient/apollo/player/AbstractApolloPlayer.java b/common/src/main/java/com/lunarclient/apollo/player/AbstractApolloPlayer.java index e804f93f..f1044b7a 100644 --- a/common/src/main/java/com/lunarclient/apollo/player/AbstractApolloPlayer.java +++ b/common/src/main/java/com/lunarclient/apollo/player/AbstractApolloPlayer.java @@ -28,19 +28,32 @@ import com.lunarclient.apollo.ApolloManager; import com.lunarclient.apollo.async.Future; import com.lunarclient.apollo.async.future.UncertainFuture; +import com.lunarclient.apollo.client.mod.LunarClientMod; +import com.lunarclient.apollo.client.version.LunarClientVersion; +import com.lunarclient.apollo.client.version.MinecraftVersion; import com.lunarclient.apollo.common.location.ApolloLocation; +import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport; import com.lunarclient.apollo.roundtrip.ApolloRequest; import com.lunarclient.apollo.roundtrip.ApolloResponse; import com.lunarclient.apollo.world.ApolloWorld; +import java.util.List; import java.util.Optional; +import lombok.Getter; +import lombok.Setter; /** * Provides convenience methods for sending packets to the client. * * @since 1.0.0 */ +@Getter @Setter public abstract class AbstractApolloPlayer implements ApolloPlayer { + private MinecraftVersion minecraftVersion; + private LunarClientVersion lunarClientVersion; + private List installedMods; + private TebexEmbeddedCheckoutSupport tebexEmbeddedCheckoutSupport; + @Override public Optional getWorld() { return Optional.empty(); diff --git a/common/src/main/java/com/lunarclient/apollo/player/ApolloPlayerManagerImpl.java b/common/src/main/java/com/lunarclient/apollo/player/ApolloPlayerManagerImpl.java index aca58ce9..ddb1f6ae 100644 --- a/common/src/main/java/com/lunarclient/apollo/player/ApolloPlayerManagerImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/player/ApolloPlayerManagerImpl.java @@ -32,6 +32,7 @@ import com.lunarclient.apollo.event.player.ApolloPlayerHandshakeEvent; import com.lunarclient.apollo.event.player.ApolloRegisterPlayerEvent; import com.lunarclient.apollo.event.player.ApolloUnregisterPlayerEvent; +import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport; import com.lunarclient.apollo.network.NetworkOptions; import com.lunarclient.apollo.player.v1.PlayerHandshakeMessage; import java.util.Collection; @@ -136,12 +137,25 @@ public void handlePlayerHandshake(@NotNull ApolloPlayer player, @NotNull PlayerH .build() ).collect(Collectors.toList()); + TebexEmbeddedCheckoutSupport checkoutSupportType; + try { + checkoutSupportType = TebexEmbeddedCheckoutSupport.values()[message.getEmbeddedCheckoutSupportValue() - 1]; + } catch (ArrayIndexOutOfBoundsException e) { + checkoutSupportType = TebexEmbeddedCheckoutSupport.UNSUPPORTED; + } + EventBus.EventResult result = EventBus.getBus() - .post(new ApolloPlayerHandshakeEvent(player, minecraftVersion, lunarClientVersion, mods)); + .post(new ApolloPlayerHandshakeEvent(player, minecraftVersion, lunarClientVersion, mods, checkoutSupportType)); for (Throwable throwable : result.getThrowing()) { throwable.printStackTrace(); } + + AbstractApolloPlayer apolloPlayer = ((AbstractApolloPlayer) player); + apolloPlayer.setMinecraftVersion(minecraftVersion); + apolloPlayer.setLunarClientVersion(lunarClientVersion); + apolloPlayer.setInstalledMods(mods); + apolloPlayer.setTebexEmbeddedCheckoutSupport(checkoutSupportType); } } diff --git a/deploy.sh b/deploy.sh index e7c059f2..78f0ec25 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,7 +1,7 @@ # Deploy apollo to the test server set -e ./gradlew clean build -scp bukkit/build/libs/apollo-bukkit-1.1.5.jar ubuntu@147.135.8.94:/home/ubuntu/apollo/plugins/ -scp bukkit-example/build/libs/apollo-bukkit-example-1.1.5.jar ubuntu@147.135.8.94:/home/ubuntu/apollo/plugins/ -scp bukkit/build/libs/apollo-bukkit-1.1.5.jar ubuntu@147.135.8.94:/home/ubuntu/lctest/plugins/ -scp bukkit-example/build/libs/apollo-bukkit-example-1.1.5.jar ubuntu@147.135.8.94:/home/ubuntu/lctest/plugins/ +scp bukkit/build/libs/apollo-bukkit-1.1.6.jar ubuntu@147.135.8.94:/home/ubuntu/apollo/plugins/ +scp bukkit-example/build/libs/apollo-bukkit-example-1.1.6.jar ubuntu@147.135.8.94:/home/ubuntu/apollo/plugins/ +scp bukkit/build/libs/apollo-bukkit-1.1.6.jar ubuntu@147.135.8.94:/home/ubuntu/lctest/plugins/ +scp bukkit-example/build/libs/apollo-bukkit-example-1.1.6.jar ubuntu@147.135.8.94:/home/ubuntu/lctest/plugins/ diff --git a/docs/developers/_meta.json b/docs/developers/_meta.json index f5f6cd1c..9a1ca48a 100644 --- a/docs/developers/_meta.json +++ b/docs/developers/_meta.json @@ -7,5 +7,6 @@ "mods": "Mods", "utilities": "Utilities", "platform-utilities": "Platform Utilities", - "adventure": "Adventure" + "adventure": "Adventure", + "lightweight": "Lightweight" } diff --git a/docs/developers/events.mdx b/docs/developers/events.mdx index 587ec632..29da98b5 100644 --- a/docs/developers/events.mdx +++ b/docs/developers/events.mdx @@ -339,3 +339,4 @@ public void callCoolApolloCancellableEvent(ApolloPlayer player) { } } ``` + diff --git a/docs/developers/lightweight/_meta.json b/docs/developers/lightweight/_meta.json new file mode 100644 index 00000000..88c256cf --- /dev/null +++ b/docs/developers/lightweight/_meta.json @@ -0,0 +1,5 @@ +{ + "introduction": "Introduction", + "protobuf": "Protobuf", + "json": "JSON" +} diff --git a/docs/developers/lightweight/introduction.mdx b/docs/developers/lightweight/introduction.mdx new file mode 100644 index 00000000..dc7b49ef --- /dev/null +++ b/docs/developers/lightweight/introduction.mdx @@ -0,0 +1,28 @@ +# Lightweight + +Our lightweight integration allows for Apollo features to be used, without the need for running the entire Apollo plugin. We will introduce you to two different methods that achieve the same goal, while utilizing separate approaches. Each method offers different trade-offs between complexity, flexibility, and performance. Choose the method that best fits your use case and environment. + +## Message format + +The message format used to communicate, follows a loosely structured JSON schema. The schema is defined using Protocol Buffers (protobuf) and includes various fields to achieve the end result, in this example-case displaying a waypoint. While the fields will change depending on the feature you're trying to implement, the `@type` will also remain. It should always be at the top, as shown. You can locate all the `@type` protos from this page: https://buf.build/lunarclient/apollo. +```JSON +{ + "@type": "type.googleapis.com/lunarclient.apollo.waypoint.v1.DisplayWaypointMessage", // The protobuf message type + "name": "KoTH", + "location": { + "world": "world", + "x": 150, + "y": 100, + "z": -150 + }, + "color": { + "color": 255 + }, + "preventRemoval": true +} +``` + +### Usage Methods + +🔗 [Protobuf](/apollo/developers/lightweight/protobuf/getting-started)
+🔗 [JSON](/apollo/developers/lightweight/json/getting-started)
diff --git a/docs/developers/lightweight/json/_meta.json b/docs/developers/lightweight/json/_meta.json new file mode 100644 index 00000000..38a14154 --- /dev/null +++ b/docs/developers/lightweight/json/_meta.json @@ -0,0 +1,7 @@ +{ + "getting-started": "Getting Started", + "player-detection": "Player Detection", + "packet-util": "Packet Util", + "object-util": "Object Util", + "adventure-util": "Adventure Util" +} diff --git a/docs/developers/lightweight/json/adventure-util.mdx b/docs/developers/lightweight/json/adventure-util.mdx new file mode 100644 index 00000000..2490a34b --- /dev/null +++ b/docs/developers/lightweight/json/adventure-util.mdx @@ -0,0 +1,13 @@ +# Adventure Util + +## Overview + +Provides a single method responsible for serializing the Adventure Component to a String + +## Integration + +```java +public static String toJson(@NonNull Component component) { + return GsonComponentSerializer.gson().serialize(component); +} +``` diff --git a/docs/developers/lightweight/json/getting-started.mdx b/docs/developers/lightweight/json/getting-started.mdx new file mode 100644 index 00000000..bed60847 --- /dev/null +++ b/docs/developers/lightweight/json/getting-started.mdx @@ -0,0 +1,22 @@ +import { Callout } from 'nextra-theme-docs' + +# Getting Started + +## Overview + +This method involves manually constructing JSON objects using a JSON library (e.g., Gson) and then converting these objects into byte arrays for transmission. It allows for dynamic and programmatic construction of JSON objects, offering flexibility in modifying the JSON structure. Available fields for each message, including their types, are available on the Buf Schema Registry at https://buf.build/lunarclient/apollo. +While constructing messages, note that the `@type` field isn't required if the message is being sent within a message. + + + Note that this method uses a different plugin channel for sending packets, + which is `apollo:json`, while still using the `lunar:apollo` for player detection. + + +## Integration Examples + +🔗 [Sending Apollo packets & Enabling Apollo modules](/apollo/developers/lightweight/json/packet-util)
+🔗 [Detecting players using LunarClient](/apollo/developers/lightweight/json/player-detection)
+🔗 [Common Apollo Objects](/apollo/developers/lightweight/json/object-util)
+🔗 [Adventure Util](/apollo/developers/lightweight/json/adventure-util)
+ +For examples of module integration, refer to the specific Module pages. Each page contains code samples under the `Manual JSON Object Construction` tab. For instance, you can find sample code for the `BorderModule` on its dedicated page [BorderModule](/apollo/developers/modules/border#sample-code) in the `Sample Code` section. diff --git a/docs/developers/lightweight/json/object-util.mdx b/docs/developers/lightweight/json/object-util.mdx new file mode 100644 index 00000000..1a79ade8 --- /dev/null +++ b/docs/developers/lightweight/json/object-util.mdx @@ -0,0 +1,129 @@ +# JSON Object Util + +## Overview + +These utilities facilitate the creation of Apollo objects, commonly used across various Apollo Modules. The utility methods are used for converting objects to and from their corresponding Protocol Buffers represented as a JSON Object. + +## Integration + +```java +public static JsonObject createEnableModuleObjectWithType(@NotNull String module, Map properties) { + JsonObject enableModuleObject = JsonPacketUtil.createEnableModuleObject(module, properties); + enableModuleObject.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.ConfigurableSettings"); + return enableModuleObject; +} + +public static JsonObject createUuidObject(@NotNull UUID uuid) { + JsonObject uuidObject = new JsonObject(); + uuidObject.addProperty("high64", Long.toUnsignedString(uuid.getMostSignificantBits())); + uuidObject.addProperty("low64", Long.toUnsignedString(uuid.getLeastSignificantBits())); + return uuidObject; +} + +public static JsonObject createColorObject(@NotNull Color color) { + JsonObject colorObject = new JsonObject(); + colorObject.addProperty("color", color.getRGB()); + return colorObject; +} + +public static String createDurationObject(@NotNull Duration duration) { + long seconds = duration.getSeconds(); + int nanos = duration.getNano(); + + String durationString; + if (nanos == 0) { + durationString = seconds + "s"; + } else { + durationString = String.format("%d.%09ds", seconds, nanos) + .replaceAll("0+$", "") + .replaceAll("\\.$", ""); + } + + return durationString; +} + +public static JsonObject createCuboid2DObject(double minX, double minZ, double maxX, double maxZ) { + JsonObject cuboid2DObject = new JsonObject(); + cuboid2DObject.addProperty("min_x", minX); + cuboid2DObject.addProperty("min_z", minZ); + cuboid2DObject.addProperty("max_x", maxX); + cuboid2DObject.addProperty("max_z", maxZ); + return cuboid2DObject; +} + +public static JsonObject createEntityIdObject(@NotNull Entity entity) { + JsonObject entityIdObject = new JsonObject(); + entityIdObject.addProperty("entity_id", entity.getEntityId()); + entityIdObject.add("entity_uuid", JsonUtil.createUuidObject(entity.getUniqueId())); + return entityIdObject; +} +``` + +Location-related methods + +```java +public static JsonObject createLocationObject(@NotNull Location location) { + JsonObject locationObject = new JsonObject(); + locationObject.addProperty("world", location.getWorld().getName()); + locationObject.addProperty("x", location.getX()); + locationObject.addProperty("y", location.getY()); + locationObject.addProperty("z", location.getZ()); + return locationObject; +} + +public static JsonObject createBlockLocationObject(@NotNull Location location) { + JsonObject locationObject = new JsonObject(); + locationObject.addProperty("world", location.getWorld().getName()); + locationObject.addProperty("x", location.getBlockX()); + locationObject.addProperty("y", location.getBlockY()); + locationObject.addProperty("z", location.getBlockZ()); + return locationObject; +} +``` + +Icon-related methods + +```java +public static JsonObject createItemStackIconObject(@Nullable String itemName, int itemId, int customModelData) { + JsonObject itemIconObject = new JsonObject(); + if (itemName != null) { + itemIconObject.addProperty("item_name", itemName); + } else { + itemIconObject.addProperty("item_id", itemId); + } + + itemIconObject.addProperty("custom_model_data", customModelData); + + JsonObject iconObject = new JsonObject(); + iconObject.add("item_stack", itemIconObject); + return iconObject; +} + +public static JsonObject createSimpleResourceLocationIconObject(@NotNull String resourceLocation, int size) { + JsonObject simpleIconObject = new JsonObject(); + simpleIconObject.addProperty("resource_location", resourceLocation); + simpleIconObject.addProperty("size", size); + + JsonObject iconObject = new JsonObject(); + iconObject.add("simple_resource_location", simpleIconObject); + + return iconObject; +} + +public static JsonObject createAdvancedResourceLocationIconObject(@NotNull String resourceLocation, float width, float height, + float minU, float maxU, float minV, float maxV) { + JsonObject advancedIcon = new JsonObject(); + advancedIcon.addProperty("resource_location", resourceLocation); + advancedIcon.addProperty("width", width); + advancedIcon.addProperty("height", height); + advancedIcon.addProperty("min_u", minU); + advancedIcon.addProperty("max_u", maxU); + advancedIcon.addProperty("min_v", minV); + advancedIcon.addProperty("max_v", maxV); + + JsonObject iconObject = new JsonObject(); + iconObject.add("advanced_resource_location", advancedIcon); + + return iconObject; +} +``` diff --git a/docs/developers/lightweight/json/packet-util.mdx b/docs/developers/lightweight/json/packet-util.mdx new file mode 100644 index 00000000..2bec4a69 --- /dev/null +++ b/docs/developers/lightweight/json/packet-util.mdx @@ -0,0 +1,124 @@ +import { Callout } from 'nextra-theme-docs' + +# JSON Packet Util + +## Overview + +These utilities are designed to handle packet transmission and creation for integrating and configuring Apollo modules with their respective properties. The utility class provides a list of most Apollo modules and their configuration options. + +The methods in this utility leverage the same plugin messaging channel as the Apollo API `lunar:apollo`. + +## Integration + +To utilize Apollo Modules, first define a list of the modules you want to use: + +```java +private static final List APOLLO_MODULES = Arrays.asList("limb", "beam", "border", "chat", "colored_fire", "combat", "cooldown", + "entity", "glow", "hologram", "mod_setting", "nametag", "nick_hider", "notification", "packet_enrichment", "rich_presence", + "server_rule", "staff_mod", "stopwatch", "team", "title", "tnt_countdown", "transfer", "vignette", "waypoint" +); +``` + +Next, specify the properties for these modules. These properties are included in the enable module packet. When using the Apollo plugin, this corresponds to modifying the `config.yml` + + + The example below does not encompass all available options and may not be up-to-date. + For the latest options, refer to the module documentation ([example](/apollo/developers/modules/serverrule#available-options)). + + +```java +// Module Id -> Option key -> Object +private static final Table CONFIG_MODULE_PROPERTIES = HashBasedTable.create(); + +static { + // Module Options that the client needs to notified about, these properties are sent with the enable module packet + // While using the Apollo plugin this would be equivalent to modifying the config.yml + CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", false); + 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); + CONFIG_MODULE_PROPERTIES.put("server_rule", "disable-chunk-reloading", false); + CONFIG_MODULE_PROPERTIES.put("server_rule", "disable-broadcasting", false); + CONFIG_MODULE_PROPERTIES.put("server_rule", "anti-portal-traps", true); + CONFIG_MODULE_PROPERTIES.put("server_rule", "override-brightness", false); + CONFIG_MODULE_PROPERTIES.put("server_rule", "brightness", 50); + CONFIG_MODULE_PROPERTIES.put("server_rule", "override-nametag-render-distance", false); + CONFIG_MODULE_PROPERTIES.put("server_rule", "nametag-render-distance", 64); + CONFIG_MODULE_PROPERTIES.put("server_rule", "override-max-chat-length", false); + CONFIG_MODULE_PROPERTIES.put("server_rule", "max-chat-length", 256); + CONFIG_MODULE_PROPERTIES.put("tnt_countdown", "tnt-ticks", 80); + CONFIG_MODULE_PROPERTIES.put("waypoint", "server-handles-waypoints", false); +} +``` + +Use the following methods to send packets either to a specific player or to all online players: + +```java +public static void sendPacket(Player player, JsonObject message) { + player.sendPluginMessage(ApolloExamplePlugin.getPlugin(), "apollo:json", message.toString().getBytes()); +} + +public static void broadcastPacket(JsonObject message) { + byte[] data = message.toString().getBytes(); + + Bukkit.getOnlinePlayers().forEach(player -> + player.sendPluginMessage(ApolloExamplePlugin.getPlugin(), "apollo:json", data)); +} +``` + +To create a Module packet, which is used for enabling modules (with or without properties) and for dynamically updating Apollo Options for modules such as the `Mod Settings Module` and `Server Rule Module`, use the following method: + +```java +public static JsonObject createEnableModuleObject(@NotNull String module, Map properties) { + JsonObject enableModuleObject = new JsonObject(); + enableModuleObject.addProperty("apollo_module", module); + enableModuleObject.addProperty("enable", true); + + if (properties != null) { + JsonObject propertiesObject = new JsonObject(); + for (Map.Entry entry : properties.entrySet()) { + propertiesObject.add(entry.getKey(), JsonPacketUtil.convertToJsonElement(entry.getValue())); + } + + enableModuleObject.add("properties", propertiesObject); + } + + return enableModuleObject; +} + +private static JsonElement convertToJsonElement(Object value) { + if (value == null) { + return JsonNull.INSTANCE; + } else if (value instanceof String) { + return new JsonPrimitive((String) value); + } else if (value instanceof Number) { + return new JsonPrimitive((Number) value); + } else if (value instanceof Boolean) { + return new JsonPrimitive((Boolean) value); + } else if (value instanceof List) { + JsonArray jsonArray = new JsonArray(); + for (Object item : (List) value) { + jsonArray.add(JsonPacketUtil.convertToJsonElement(item)); + } + return jsonArray; + } + + throw new RuntimeException("Unable to wrap value of type '" + value.getClass().getSimpleName() + "'!"); +} +``` + +Enable modules using the methods and fields defined above: + +```java +public static void enableModules(Player player) { + JsonArray settings = APOLLO_MODULES.stream() + .map(module -> JsonPacketUtil.createEnableModuleObject(module, CONFIG_MODULE_PROPERTIES.row(module))) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.OverrideConfigurableSettingsMessage"); + message.add("configurable_settings", settings); + + JsonPacketUtil.sendPacket(player, message); +} +``` diff --git a/docs/developers/lightweight/json/player-detection.mdx b/docs/developers/lightweight/json/player-detection.mdx new file mode 100644 index 00000000..ad182689 --- /dev/null +++ b/docs/developers/lightweight/json/player-detection.mdx @@ -0,0 +1,64 @@ +import { Callout } from 'nextra-theme-docs' + +# Player Detection + +## Overview + +This example demonstrates how to detect whether a player is using Lunar Client by listening for the `PlayerRegisterChannelEvent` on the `lunar:apollo` channel. Additionally, it showcases how to enable Apollo Modules using utility methods from [JsonPacketUtil](/apollo/developers/lightweight/json/packet-util) + + + Note that this method uses a different plugin channel for sending packets, + which is `apollo:json`, while still using the `lunar:apollo` for player detection. + + +## Integration + +```java +public class ApolloPlayerJsonListener implements Listener { + + private final Set playersRunningApollo = new HashSet<>(); + + public ApolloPlayerJsonListener(ApolloExamplePlugin plugin) { + Messenger messenger = Bukkit.getServer().getMessenger(); + messenger.registerIncomingPluginChannel(plugin, "lunar:apollo", (s, player, bytes) -> { }); + messenger.registerIncomingPluginChannel(plugin, "apollo:json", (s, player, bytes) -> { }); + messenger.registerOutgoingPluginChannel(plugin, "apollo:json"); + + Bukkit.getPluginManager().registerEvents(this, plugin); + } + + private boolean isPlayerRunningApollo(Player player) { + return this.playersRunningApollo.contains(player.getUniqueId()); + } + + @EventHandler + private void onRegisterChannel(PlayerRegisterChannelEvent event) { + if (!event.getChannel().equalsIgnoreCase("lunar:apollo")) { + return; + } + + JsonPacketUtil.enableModules(player); + + // Sending the player's world name to the client is required for some modules + JsonPacketUtil.sendPacket(player, this.createUpdatePlayerWorldMessage(player)); + + this.playersRunningApollo.add(player.getUniqueId()); + player.sendMessage("You are using LunarClient!"); + } + + @EventHandler + private void onPlayerChangedWorld(PlayerChangedWorldEvent event) { + Player player = event.getPlayer(); + + // Sending the player's world name to the client is required for some modules + JsonPacketUtil.sendPacket(player, this.createUpdatePlayerWorldMessage(player)); + } + + private JsonObject createUpdatePlayerWorldMessage(Player player) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.player.v1.UpdatePlayerWorldMessage"); + message.addProperty("world", player.getWorld().getName()); + return message; + } +} +``` diff --git a/docs/developers/lightweight/protobuf/_meta.json b/docs/developers/lightweight/protobuf/_meta.json new file mode 100644 index 00000000..83eb3d8b --- /dev/null +++ b/docs/developers/lightweight/protobuf/_meta.json @@ -0,0 +1,9 @@ +{ + "getting-started": "Getting Started", + "player-detection": "Player Detection", + "serverbound-packets": "Serverbound Packets", + "roundtrip-packets": "Roundtrip Packets", + "packet-util": "Packet Util", + "object-util": "Object Util", + "adventure-util": "Adventure Util" +} diff --git a/docs/developers/lightweight/protobuf/adventure-util.mdx b/docs/developers/lightweight/protobuf/adventure-util.mdx new file mode 100644 index 00000000..2490a34b --- /dev/null +++ b/docs/developers/lightweight/protobuf/adventure-util.mdx @@ -0,0 +1,13 @@ +# Adventure Util + +## Overview + +Provides a single method responsible for serializing the Adventure Component to a String + +## Integration + +```java +public static String toJson(@NonNull Component component) { + return GsonComponentSerializer.gson().serialize(component); +} +``` diff --git a/docs/developers/lightweight/protobuf/getting-started.mdx b/docs/developers/lightweight/protobuf/getting-started.mdx new file mode 100644 index 00000000..c06832c9 --- /dev/null +++ b/docs/developers/lightweight/protobuf/getting-started.mdx @@ -0,0 +1,74 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + +# Getting Started + +## Overview + +This guide will help you get started with the `apollo-protos` library, which is used to handle Apollo-related packets from Lunar Client in your Minecraft server. The `apollo-protos` library provides strong typing and schema validation for all Apollo messages, ensuring seamless communication between the client and the server. + +In this guide, you'll learn how to add the required repository and dependencies to your project. You'll also find links to various examples demonstrating how to integrate and work with Apollo packets, from detecting players using Lunar Client to handling advanced serverbound and roundtrip packets. + +Available fields for each message, including their types, are available on the Buf Schema Registry at https://buf.build/lunarclient/apollo. + +## Adding the repository and dependencies + + + + ```xml filename="pom.xml" + + + lunarclient + https://repo.lunarclient.dev + + + + + + com.lunarclient + apollo-protos + 1.0-SNAPSHOT + + + ``` + + + ```groovy filename="build.gradle" + repositories { + maven { + name = 'lunarclient' + url = 'https://repo.lunarclient.dev' + } + } + + dependencies { + api 'com.lunarclient:apollo-protos:1.0-SNAPSHOT' + } + ``` + + + ```kotlin filename="build.gradle.kts" + repositories { + maven { + name = "lunarclient" + url = uri("https://repo.lunarclient.dev") + } + } + + dependencies { + api("com.lunarclient:apollo-protos:1.0-SNAPSHOT") + } + ``` + + + +## Integration Examples + +🔗 [Sending Apollo packets & Enabling Apollo modules](/apollo/developers/lightweight/protobuf/packet-util)
+🔗 [Detecting players using LunarClient](/apollo/developers/lightweight/protobuf/player-detection)
+🔗 [Common Apollo Objects](/apollo/developers/lightweight/protobuf/object-util)
+🔗 [Adventure Util](/apollo/developers/lightweight/protobuf/adventure-util)
+🔗 [Apollo Serverbound packets](/apollo/developers/lightweight/protobuf/serverbound-packets)
+🔗 [Apollo Roundtrip packets](/apollo/developers/lightweight/protobuf/roundtrip-packets)
+ +For examples of module integration, refer to the specific Module pages. Each page contains code samples under the `apollo-protos library` tab. For instance, you can find sample code for the `BorderModule` on its dedicated page [BorderModule](/apollo/developers/modules/border#sample-code) in the `Sample Code` section. + diff --git a/docs/developers/lightweight/protobuf/object-util.mdx b/docs/developers/lightweight/protobuf/object-util.mdx new file mode 100644 index 00000000..51fb3278 --- /dev/null +++ b/docs/developers/lightweight/protobuf/object-util.mdx @@ -0,0 +1,126 @@ +# Protobuf Object Util + +## Overview + +These utilities facilitate the creation of Apollo objects, commonly used across various Apollo Modules. The utility methods are used for converting objects to and from their corresponding Protocol Buffers representations. + +## Integration + +```java +public static UUID toJavaUuid(Uuid message) { + return new UUID(message.getHigh64(), message.getLow64()); +} + +public static long toJavaTimestamp(Timestamp message) { + return message.getSeconds() * 1000 + message.getNanos() / 1000000; +} + +public static Uuid createUuidProto(UUID object) { + return Uuid.newBuilder() + .setHigh64(object.getMostSignificantBits()) + .setLow64(object.getLeastSignificantBits()) + .build(); +} + +public static com.lunarclient.apollo.common.v1.Color createColorProto(Color object) { + return com.lunarclient.apollo.common.v1.Color.newBuilder() + .setColor(object.getRGB()) + .build(); +} + +public static com.google.protobuf.Duration createDurationProto(Duration object) { + return com.google.protobuf.Duration.newBuilder() + .setSeconds(object.getSeconds()) + .setNanos(object.getNano()) + .build(); +} + +public static Cuboid2D createCuboid2DProto(double minX, double minZ, double maxX, double maxZ) { + return Cuboid2D.newBuilder() + .setMinX(minX) + .setMinZ(minZ) + .setMaxX(maxX) + .setMaxZ(maxZ) + .build(); +} + +public static EntityId createEntityIdProto(int id, UUID uuid) { + return EntityId.newBuilder() + .setEntityId(id) + .setEntityUuid(ProtobufUtil.createUuidProto(uuid)) + .build(); +} +``` + +Location-related methods + +```java +public static com.lunarclient.apollo.common.v1.Location createLocationProto(Location location) { + return com.lunarclient.apollo.common.v1.Location.newBuilder() + .setWorld(location.getWorld().getName()) + .setX(location.getX()) + .setY(location.getY()) + .setZ(location.getZ()) + .build(); +} + +public static BlockLocation createBlockLocationProto(Location location) { + return BlockLocation.newBuilder() + .setWorld(location.getWorld().getName()) + .setX(location.getBlockX()) + .setY(location.getBlockY()) + .setZ(location.getBlockZ()) + .build(); +} + +public static Location toBukkitLocation(com.lunarclient.apollo.common.v1.Location message) { + return new Location(Bukkit.getWorld(message.getWorld()), message.getX(), message.getY(), message.getZ()); +} + +public static Location toBukkitLocation(com.lunarclient.apollo.common.v1.PlayerLocation message) { + Location location = ProtobufUtil.toBukkitLocation(message.getLocation()); + location.setYaw(message.getYaw()); + location.setPitch(message.getPitch()); + return location; +} +``` + +Icon-related methods + +```java +public static Icon createItemStackIconProto(@Nullable String itemName, int itemId, int customModelData) { + ItemStackIcon.Builder iconBuilder = ItemStackIcon.newBuilder() + .setItemId(itemId) + .setCustomModelData(customModelData); + + if (itemName != null) { + iconBuilder.setItemName(itemName); + } + + return Icon.newBuilder().setItemStack(iconBuilder.build()).build(); +} + +public static Icon createSimpleResourceLocationIconProto(String resourceLocation, int size) { + SimpleResourceLocationIcon icon = SimpleResourceLocationIcon.newBuilder() + .setResourceLocation(resourceLocation) + .setSize(size) + .build(); + + return Icon.newBuilder().setSimpleResourceLocation(icon).build(); +} + +public static Icon createAdvancedResourceLocationIconProto(String resourceLocation, float width, float height, + float minU, float maxU, float minV, float maxV) { + AdvancedResourceLocationIcon icon = AdvancedResourceLocationIcon.newBuilder() + .setResourceLocation(resourceLocation) + .setWidth(width) + .setHeight(height) + .setMinU(minU) + .setMaxU(maxU) + .setMinV(minV) + .setMaxV(maxV) + .build(); + + return Icon.newBuilder().setAdvancedResourceLocation(icon).build(); +} +``` diff --git a/docs/developers/lightweight/protobuf/packet-util.mdx b/docs/developers/lightweight/protobuf/packet-util.mdx new file mode 100644 index 00000000..fcac5c9b --- /dev/null +++ b/docs/developers/lightweight/protobuf/packet-util.mdx @@ -0,0 +1,105 @@ +import { Callout } from 'nextra-theme-docs' + +# Protobuf Packet Util + +## Overview + +These utilities are designed to handle packet transmission and creation for integrating and configuring Apollo modules with their respective properties. The utility class provides a list of most Apollo modules and their configuration options. + +The methods in this utility leverage the same plugin messaging channel as the Apollo API `lunar:apollo`. + +## Integration + +To utilize Apollo Modules, first define a list of the modules you want to use: + +```java +private static final List APOLLO_MODULES = Arrays.asList("limb", "beam", "border", "chat", "colored_fire", "combat", "cooldown", + "entity", "glow", "hologram", "mod_setting", "nametag", "nick_hider", "notification", "packet_enrichment", "rich_presence", + "server_rule", "staff_mod", "stopwatch", "team", "title", "tnt_countdown", "transfer", "vignette", "waypoint" +); +``` + +Next, specify the properties for these modules. These properties are included in the enable module packet. When using the Apollo plugin, this corresponds to modifying the `config.yml` + + + The example below does not encompass all available options and may not be up-to-date. + For the latest options, refer to the module documentation ([example](/apollo/developers/modules/serverrule#available-options)). + + +```java +// Module Id -> Option key -> Value +private static final Table CONFIG_MODULE_PROPERTIES = HashBasedTable.create(); + +static { + CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", Value.newBuilder().setBoolValue(false).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( + Value.newBuilder().setStringValue("/server").build(), + Value.newBuilder().setStringValue("/servers").build(), + Value.newBuilder().setStringValue("/hub").build())) + .build() + ).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "disable-shaders", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "disable-chunk-reloading", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "disable-broadcasting", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "anti-portal-traps", Value.newBuilder().setBoolValue(true).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "override-brightness", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "brightness", Value.newBuilder().setNumberValue(50).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "override-nametag-render-distance", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "nametag-render-distance", Value.newBuilder().setNumberValue(64).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "override-max-chat-length", Value.newBuilder().setBoolValue(false).build()); + CONFIG_MODULE_PROPERTIES.put("server_rule", "max-chat-length", Value.newBuilder().setNumberValue(256).build()); + CONFIG_MODULE_PROPERTIES.put("tnt_countdown", "tnt-ticks", Value.newBuilder().setNumberValue(80).build()); + CONFIG_MODULE_PROPERTIES.put("waypoint", "server-handles-waypoints", Value.newBuilder().setBoolValue(false).build()); +} +``` + +Use the following methods to send packets either to a specific player or to all online players: + +```java +public static void sendPacket(Player player, GeneratedMessageV3 message) { + byte[] bytes = Any.pack(message).toByteArray(); + player.sendPluginMessage(ApolloExamplePlugin.getPlugin(), "lunar:apollo", bytes); +} + +public static void broadcastPacket(GeneratedMessageV3 message) { + byte[] bytes = Any.pack(message).toByteArray(); + + Bukkit.getOnlinePlayers().forEach(player -> + player.sendPluginMessage(ApolloExamplePlugin.getPlugin(), "lunar:apollo", bytes)); +} +``` + +To create a Module packet, which is used for enabling modules (with or without properties) and for dynamically updating Apollo Options for modules such as the `Mod Settings Module` and `Server Rule Module`, use the following method: + +```java +public static ConfigurableSettings createModuleMessage(String module, Map properties) { + ConfigurableSettings.Builder moduleBuilder = ConfigurableSettings.newBuilder() + .setApolloModule(module) + .setEnable(true); + + if (properties != null) { + moduleBuilder.putAllProperties(properties); + } + + return moduleBuilder.build(); +} +``` + +Enable modules using the methods and fields defined above: + +```java +public static void enableModules(Player player) { + List settings = APOLLO_MODULES.stream() + .map(module -> createModuleMessage(module, CONFIG_MODULE_PROPERTIES.row(module))) + .collect(Collectors.toList()); + + OverrideConfigurableSettingsMessage message = OverrideConfigurableSettingsMessage + .newBuilder() + .addAllConfigurableSettings(settings) + .build(); + + ProtobufPacketUtil.sendPacket(player, message); +} +``` diff --git a/docs/developers/lightweight/protobuf/player-detection.mdx b/docs/developers/lightweight/protobuf/player-detection.mdx new file mode 100644 index 00000000..12d59a6a --- /dev/null +++ b/docs/developers/lightweight/protobuf/player-detection.mdx @@ -0,0 +1,53 @@ +# Player Detection + +## Overview + +This example demonstrates how to detect whether a player is using Lunar Client by listening for the `PlayerRegisterChannelEvent` on the `lunar:apollo` channel. Additionally, it showcases how to enable Apollo Modules using utility methods from [ProtobufPacketUtil](/apollo/developers/lightweight/protobuf/packet-util) + +## Integration + +```java +public class ApolloPlayerProtoListener implements Listener { + + private final Set playersRunningApollo = new HashSet<>(); + + public ApolloPlayerProtoListener(ApolloExamplePlugin plugin) { + Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "lunar:apollo"); + Bukkit.getServer().getMessenger().registerIncomingPluginChannel(plugin, "lunar:apollo", (s, player, bytes) -> { }); + Bukkit.getPluginManager().registerEvents(this, plugin); + } + + private boolean isPlayerRunningApollo(Player player) { + return this.playersRunningApollo.contains(player.getUniqueId()); + } + + @EventHandler + private void onRegisterChannel(PlayerRegisterChannelEvent event) { + if (!event.getChannel().equalsIgnoreCase("lunar:apollo")) { + return; + } + + ProtobufPacketUtil.enableModules(player); + + // Sending the player's world name to the client is required for some modules + ProtobufPacketUtil.sendPacket(player, this.createUpdatePlayerWorldMessage(player)); + + this.playersRunningApollo.add(player.getUniqueId()); + player.sendMessage("You are using LunarClient!"); + } + + @EventHandler + private void onPlayerChangedWorld(PlayerChangedWorldEvent event) { + Player player = event.getPlayer(); + + // Sending the player's world name to the client is required for some modules + ProtobufPacketUtil.sendPacket(player, this.createUpdatePlayerWorldMessage(player)); + } + + private UpdatePlayerWorldMessage createUpdatePlayerWorldMessage(Player player) { + return UpdatePlayerWorldMessage.newBuilder() + .setWorld(player.getWorld().getName()) + .build(); + } +} +``` diff --git a/docs/developers/lightweight/protobuf/roundtrip-packets.mdx b/docs/developers/lightweight/protobuf/roundtrip-packets.mdx new file mode 100644 index 00000000..0bc35d0b --- /dev/null +++ b/docs/developers/lightweight/protobuf/roundtrip-packets.mdx @@ -0,0 +1,111 @@ +# Roundtrip Packets + +## Overview + +This example demonstrates how to handle roundtrip packets between the server and the Lunar Client. These packets are sent from the server, expecting a corresponding response from the client. The example utilizes a map to track the requests and their corresponding responses. For instance, this pattern is common in modules like `TransferModule` where a request packet is sent and a response is awaited. + +## Integration + +```java +public class ApolloRoundtripProtoListener implements PluginMessageListener { + + @Getter + private static ApolloRoundtripProtoListener instance; + + private final Map>> roundTripPacketFutures = new ConcurrentHashMap<>(); + private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1); + + public ApolloRoundtripProtoListener(ApolloExamplePlugin plugin) { + instance = this; + Bukkit.getServer().getMessenger().registerIncomingPluginChannel(plugin, "lunar:apollo", this); + } + + @Override + public void onPluginMessageReceived(String s, Player player, byte[] bytes) { + try { + Any any = Any.parseFrom(bytes); + + if (any.is(PingResponse.class)) { + PingResponse message = any.unpack(PingResponse.class); + UUID requestId = UUID.fromString(message.getRequestId().toStringUtf8()); + this.handleResponse(player, requestId, message); + } else if (any.is(TransferResponse.class)) { + TransferResponse message = any.unpack(TransferResponse.class); + UUID requestId = UUID.fromString(message.getRequestId().toStringUtf8()); + this.handleResponse(player, requestId, message); + } + + } catch (InvalidProtocolBufferException e) { + throw new RuntimeException(e); + } + } + + public CompletableFuture sendRequest(Player player, UUID requestId, + GeneratedMessageV3 request, + Class responseType) { + ProtobufPacketUtil.sendPacket(player, request); + + CompletableFuture future = new CompletableFuture<>(); + + this.roundTripPacketFutures + .computeIfAbsent(player.getUniqueId(), k -> new ConcurrentHashMap<>()) + .put(requestId, (CompletableFuture) future); + + ScheduledFuture timeoutTask = this.executorService.schedule(() -> + future.completeExceptionally(new TimeoutException("Response timed out")), + 10, TimeUnit.SECONDS + ); + + future.whenComplete((result, throwable) -> timeoutTask.cancel(false)); + return future; + } + + private void handleResponse(Player player, UUID requestId, T message) { + Map> futures = this.roundTripPacketFutures.get(player.getUniqueId()); + if (futures == null) { + return; + } + + CompletableFuture future = futures.remove(requestId); + if (future != null) { + future.complete(message); + } + } +} +``` + +Here's an example demonstrating how to use the code to handle a server-to-client `TransferModule` transfer, where the client responds with a status (`accepted` or `rejected`). + +```java +public void transferExample(Player player) { + UUID requestId = UUID.randomUUID(); + + TransferRequest transferRequestMessage = TransferRequest.newBuilder() + .setRequestId(ByteString.copyFromUtf8(requestId.toString())) + .setServerIp("mc.hypixel.net") + .build(); + + ApolloRoundtripProtoListener.getInstance() + .sendRequest(player, requestId, transferRequestMessage, TransferResponse.class) + .thenAccept(response -> { + String message = ""; + + switch (response.getStatus()) { + case STATUS_ACCEPTED: { + message = "Transfer accepted! Goodbye!"; + break; + } + + case STATUS_REJECTED: { + message = "Transfer rejected by client!"; + break; + } + } + + player.sendMessage(message); + }).exceptionally(throwable -> { + player.sendMessage("Failed to receive a response in time."); + return null; + }); +} +``` diff --git a/docs/developers/lightweight/protobuf/serverbound-packets.mdx b/docs/developers/lightweight/protobuf/serverbound-packets.mdx new file mode 100644 index 00000000..c7dc9ab3 --- /dev/null +++ b/docs/developers/lightweight/protobuf/serverbound-packets.mdx @@ -0,0 +1,102 @@ +# Serverbound Packets + +## Overview + +Players using Lunar Client may send packets to the server for specific Apollo modules, such as the `PacketEnrichment Module` and/or when the player is joining the server. This example demonstrates how to handle packets sent from the client that are related to Apollo. + +Additionally, the `Transfer Module` expects a response packet from the client after the server sends a request. For an example of how to handle roundtrip packets, visit [Packet Roundtrip Example](/apollo/developers/lightweight/protobuf/roundtrip-packets) + +## Integration + +```java +public class ApolloPacketReceiveProtoListener implements PluginMessageListener { + + public ApolloPacketReceiveProtoListener(ApolloExamplePlugin plugin) { + Bukkit.getServer().getMessenger().registerIncomingPluginChannel(plugin, "lunar:apollo", this); + } + + @Override + public void onPluginMessageReceived(String s, Player player, byte[] bytes) { + try { + Any any = Any.parseFrom(bytes); + + if (any.is(PlayerHandshakeMessage.class)) { + this.onPlayerHandshake(any.unpack(PlayerHandshakeMessage.class)); + } + + // Packet Enrichment Module + if (any.is(PlayerAttackMessage.class)) { + this.onPlayerAttack(any.unpack(PlayerAttackMessage.class)); + } else if (any.is(PlayerChatOpenMessage.class)) { + this.onPlayerChatOpen(any.unpack(PlayerChatOpenMessage.class)); + } else if (any.is(PlayerChatCloseMessage.class)) { + this.onPlayerChatClose(any.unpack(PlayerChatCloseMessage.class)); + } else if (any.is(PlayerUseItemMessage.class)) { + this.onPlayerUseItem(any.unpack(PlayerUseItemMessage.class)); + } + } catch (InvalidProtocolBufferException e) { + throw new RuntimeException(e); + } + } + + private void onPlayerHandshake(PlayerHandshakeMessage message) { + MinecraftVersion minecraftVersion = message.getMinecraftVersion(); + + LunarClientVersion lunarClientVersion = message.getLunarClientVersion(); + String gitBranch = lunarClientVersion.getGitBranch(); + String gitCommit = lunarClientVersion.getGitCommit(); + String semVer = lunarClientVersion.getSemver(); + + List installedMods = message.getInstalledModsList(); + for (ModMessage mod : installedMods) { + String modId = mod.getId(); + String displayName = mod.getName(); + String version = mod.getVersion(); + ModMessage.Type type = mod.getType(); + } + } + + private void onPlayerAttack(PlayerAttackMessage message) { + long instantiationTimeMs = ProtobufUtil.toJavaTimestamp(message.getPacketInfo().getInstantiationTime()); + + PlayerInfo targetInfo = message.getTargetInfo(); + PlayerInfo attackerInfo = message.getAttackerInfo(); + + this.onPlayerInfo(targetInfo); + this.onPlayerInfo(attackerInfo); + } + + private void onPlayerChatOpen(PlayerChatOpenMessage message) { + long instantiationTimeMs = ProtobufUtil.toJavaTimestamp(message.getPacketInfo().getInstantiationTime()); + + PlayerInfo playerInfo = message.getPlayerInfo(); + this.onPlayerInfo(playerInfo); + } + + private void onPlayerChatClose(PlayerChatCloseMessage message) { + long instantiationTimeMs = ProtobufUtil.toJavaTimestamp(message.getPacketInfo().getInstantiationTime()); + + PlayerInfo playerInfo = message.getPlayerInfo(); + this.onPlayerInfo(playerInfo); + } + + private void onPlayerUseItem(PlayerUseItemMessage message) { + long instantiationTimeMs = ProtobufUtil.toJavaTimestamp(message.getPacketInfo().getInstantiationTime()); + + PlayerInfo playerInfo = message.getPlayerInfo(); + this.onPlayerInfo(playerInfo); + + boolean mainHand = message.getMainHand(); + } + + private void onPlayerInfo(PlayerInfo info) { + UUID uuid = ProtobufUtil.toJavaUuid(info.getPlayerUuid()); + Location location = ProtobufUtil.toBukkitLocation(info.getLocation()); + boolean sneaking = info.getSneaking(); + boolean sprinting = info.getSprinting(); + boolean jumping = info.getJumping(); + float forwardSpeed = info.getForwardSpeed(); + float strafeSpeed = info.getStrafeSpeed(); + } +} +``` diff --git a/docs/developers/mods/chat.mdx b/docs/developers/mods/chat.mdx index 4008e9d6..4c935322 100644 --- a/docs/developers/mods/chat.mdx +++ b/docs/developers/mods/chat.mdx @@ -67,6 +67,14 @@ public void toggleChatExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`CHAT_PING_EXACT_MATCH`__ + - Requires the ping message to exactly contain your name. +For example, if your name is Notch, this will ping on Notch but not Notch123. + - Config Key: `chat-ping-exact-match` + - Values + - Type: `Boolean` + - Default: `false` + - __`COPY_CHAT`__ - Copies the hovered chat message when holding the keybind and clicking. - Config Key: `copy-chat` diff --git a/docs/developers/mods/clock.mdx b/docs/developers/mods/clock.mdx index 22326655..917c4e51 100644 --- a/docs/developers/mods/clock.mdx +++ b/docs/developers/mods/clock.mdx @@ -35,6 +35,18 @@ public void toggleClockExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BRACKETS`__ + - Config Key: `brackets` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BRACKET_COLOR`__ + - Config Key: `bracket-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + - __`BACKGROUND`__ - Config Key: `background` - Values @@ -48,6 +60,13 @@ public void toggleClockExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`STATIC_BACKGROUND_HEIGHT`__ + - If this is disabled the background will change size with the text. + - Config Key: `static-background-height` + - Values + - Type: `Boolean` + - Default: `true` + - __`BACKGROUND_WIDTH`__ - Config Key: `background-width` - Values @@ -64,12 +83,6 @@ public void toggleClockExample(Player viewer, boolean value) { - Minimum: `10` - Maximum: `22` -- __`BRACKETS`__ - - Config Key: `brackets` - - Values - - Type: `Boolean` - - Default: `true` - - __`BORDER`__ - Config Key: `border` - Values @@ -84,11 +97,11 @@ public void toggleClockExample(Player viewer, boolean value) { - Minimum: `0.5F` - Maximum: `3.0F` -- __`TEXT_COLOR`__ - - Config Key: `text-color` +- __`BORDER_COLOR`__ + - Config Key: `border-color` - Values - Type: `String` - - Default: `#FFFFFFFF` + - Default: `#9F000000` - __`BACKGROUND_COLOR`__ - Config Key: `background-color` @@ -96,11 +109,11 @@ public void toggleClockExample(Player viewer, boolean value) { - Type: `String` - Default: `#6F000000` -- __`BORDER_COLOR`__ - - Config Key: `border-color` +- __`TEXT_COLOR`__ + - Config Key: `text-color` - Values - Type: `String` - - Default: `#9F000000` + - Default: `#FFFFFFFF` - __`MILITARY_TIME`__ - Config Key: `military-time` diff --git a/docs/developers/mods/combo.mdx b/docs/developers/mods/combo.mdx index 199a7407..b59061b6 100644 --- a/docs/developers/mods/combo.mdx +++ b/docs/developers/mods/combo.mdx @@ -35,6 +35,18 @@ public void toggleComboCounterExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BRACKETS`__ + - Config Key: `brackets` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BRACKET_COLOR`__ + - Config Key: `bracket-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + - __`BACKGROUND`__ - Config Key: `background` - Values @@ -48,6 +60,13 @@ public void toggleComboCounterExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`STATIC_BACKGROUND_HEIGHT`__ + - If this is disabled the background will change size with the text. + - Config Key: `static-background-height` + - Values + - Type: `Boolean` + - Default: `true` + - __`BACKGROUND_WIDTH`__ - Config Key: `background-width` - Values @@ -64,12 +83,6 @@ public void toggleComboCounterExample(Player viewer, boolean value) { - Minimum: `10` - Maximum: `22` -- __`BRACKETS`__ - - Config Key: `brackets` - - Values - - Type: `Boolean` - - Default: `true` - - __`BORDER`__ - Config Key: `border` - Values @@ -84,11 +97,11 @@ public void toggleComboCounterExample(Player viewer, boolean value) { - Minimum: `0.5F` - Maximum: `3.0F` -- __`TEXT_COLOR`__ - - Config Key: `text-color` +- __`BORDER_COLOR`__ + - Config Key: `border-color` - Values - Type: `String` - - Default: `#FFFFFFFF` + - Default: `#9F000000` - __`BACKGROUND_COLOR`__ - Config Key: `background-color` @@ -96,9 +109,9 @@ public void toggleComboCounterExample(Player viewer, boolean value) { - Type: `String` - Default: `#6F000000` -- __`BORDER_COLOR`__ - - Config Key: `border-color` +- __`TEXT_COLOR`__ + - Config Key: `text-color` - Values - Type: `String` - - Default: `#9F000000` + - Default: `#FFFFFFFF` diff --git a/docs/developers/mods/cps.mdx b/docs/developers/mods/cps.mdx index aa3a2807..e6087cda 100644 --- a/docs/developers/mods/cps.mdx +++ b/docs/developers/mods/cps.mdx @@ -35,6 +35,18 @@ public void toggleCPSExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BRACKETS`__ + - Config Key: `brackets` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BRACKET_COLOR`__ + - Config Key: `bracket-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + - __`BACKGROUND`__ - Config Key: `background` - Values @@ -48,6 +60,13 @@ public void toggleCPSExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`STATIC_BACKGROUND_HEIGHT`__ + - If this is disabled the background will change size with the text. + - Config Key: `static-background-height` + - Values + - Type: `Boolean` + - Default: `true` + - __`BACKGROUND_WIDTH`__ - Config Key: `background-width` - Values @@ -64,12 +83,6 @@ public void toggleCPSExample(Player viewer, boolean value) { - Minimum: `10` - Maximum: `22` -- __`BRACKETS`__ - - Config Key: `brackets` - - Values - - Type: `Boolean` - - Default: `true` - - __`BORDER`__ - Config Key: `border` - Values @@ -84,11 +97,11 @@ public void toggleCPSExample(Player viewer, boolean value) { - Minimum: `0.5F` - Maximum: `3.0F` -- __`TEXT_COLOR`__ - - Config Key: `text-color` +- __`BORDER_COLOR`__ + - Config Key: `border-color` - Values - Type: `String` - - Default: `#FFFFFFFF` + - Default: `#9F000000` - __`BACKGROUND_COLOR`__ - Config Key: `background-color` @@ -96,11 +109,11 @@ public void toggleCPSExample(Player viewer, boolean value) { - Type: `String` - Default: `#6F000000` -- __`BORDER_COLOR`__ - - Config Key: `border-color` +- __`TEXT_COLOR`__ + - Config Key: `text-color` - Values - Type: `String` - - Default: `#9F000000` + - Default: `#FFFFFFFF` - __`RIGHT_CLICK`__ - Config Key: `right-click` @@ -108,15 +121,15 @@ public void toggleCPSExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `false` -- __`SHOW_CPSTEXT`__ - - Config Key: `show-c-p-s-text` - - Values - - Type: `Boolean` - - Default: `true` - - __`LINE_COLOR`__ - Config Key: `line-color` - Values - Type: `String` - Default: `#FF202020` +- __`SHOW_CPSTEXT`__ + - Config Key: `show-c-p-s-text` + - Values + - Type: `Boolean` + - Default: `true` + diff --git a/docs/developers/mods/daycounter.mdx b/docs/developers/mods/daycounter.mdx index a73ed42a..84208afa 100644 --- a/docs/developers/mods/daycounter.mdx +++ b/docs/developers/mods/daycounter.mdx @@ -35,6 +35,18 @@ public void toggleDayCounterExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BRACKETS`__ + - Config Key: `brackets` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BRACKET_COLOR`__ + - Config Key: `bracket-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + - __`BACKGROUND`__ - Config Key: `background` - Values @@ -48,6 +60,13 @@ public void toggleDayCounterExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`STATIC_BACKGROUND_HEIGHT`__ + - If this is disabled the background will change size with the text. + - Config Key: `static-background-height` + - Values + - Type: `Boolean` + - Default: `true` + - __`BACKGROUND_WIDTH`__ - Config Key: `background-width` - Values @@ -64,12 +83,6 @@ public void toggleDayCounterExample(Player viewer, boolean value) { - Minimum: `10` - Maximum: `22` -- __`BRACKETS`__ - - Config Key: `brackets` - - Values - - Type: `Boolean` - - Default: `true` - - __`BORDER`__ - Config Key: `border` - Values @@ -84,11 +97,11 @@ public void toggleDayCounterExample(Player viewer, boolean value) { - Minimum: `0.5F` - Maximum: `3.0F` -- __`TEXT_COLOR`__ - - Config Key: `text-color` +- __`BORDER_COLOR`__ + - Config Key: `border-color` - Values - Type: `String` - - Default: `#FFFFFFFF` + - Default: `#9F000000` - __`BACKGROUND_COLOR`__ - Config Key: `background-color` @@ -96,11 +109,11 @@ public void toggleDayCounterExample(Player viewer, boolean value) { - Type: `String` - Default: `#6F000000` -- __`BORDER_COLOR`__ - - Config Key: `border-color` +- __`TEXT_COLOR`__ + - Config Key: `text-color` - Values - Type: `String` - - Default: `#9F000000` + - Default: `#FFFFFFFF` - __`USE_WORLD_TYPE`__ - Config Key: `use-world-type` diff --git a/docs/developers/mods/fps.mdx b/docs/developers/mods/fps.mdx index 72d78478..32b413f0 100644 --- a/docs/developers/mods/fps.mdx +++ b/docs/developers/mods/fps.mdx @@ -35,6 +35,18 @@ public void toggleFPSExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BRACKETS`__ + - Config Key: `brackets` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BRACKET_COLOR`__ + - Config Key: `bracket-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + - __`BACKGROUND`__ - Config Key: `background` - Values @@ -48,6 +60,13 @@ public void toggleFPSExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`STATIC_BACKGROUND_HEIGHT`__ + - If this is disabled the background will change size with the text. + - Config Key: `static-background-height` + - Values + - Type: `Boolean` + - Default: `true` + - __`BACKGROUND_WIDTH`__ - Config Key: `background-width` - Values @@ -64,12 +83,6 @@ public void toggleFPSExample(Player viewer, boolean value) { - Minimum: `10` - Maximum: `22` -- __`BRACKETS`__ - - Config Key: `brackets` - - Values - - Type: `Boolean` - - Default: `true` - - __`BORDER`__ - Config Key: `border` - Values @@ -84,11 +97,11 @@ public void toggleFPSExample(Player viewer, boolean value) { - Minimum: `0.5F` - Maximum: `3.0F` -- __`TEXT_COLOR`__ - - Config Key: `text-color` +- __`BORDER_COLOR`__ + - Config Key: `border-color` - Values - Type: `String` - - Default: `#FFFFFFFF` + - Default: `#9F000000` - __`BACKGROUND_COLOR`__ - Config Key: `background-color` @@ -96,9 +109,9 @@ public void toggleFPSExample(Player viewer, boolean value) { - Type: `String` - Default: `#6F000000` -- __`BORDER_COLOR`__ - - Config Key: `border-color` +- __`TEXT_COLOR`__ + - Config Key: `text-color` - Values - Type: `String` - - Default: `#9F000000` + - Default: `#FFFFFFFF` diff --git a/docs/developers/mods/hypixelbedwars.mdx b/docs/developers/mods/hypixelbedwars.mdx index 70c21290..8f4f0436 100644 --- a/docs/developers/mods/hypixelbedwars.mdx +++ b/docs/developers/mods/hypixelbedwars.mdx @@ -19,7 +19,7 @@ public void toggleHypixelBedwarsExample(Player viewer, boolean value) { - Config Key: `enabled` - Values - Type: `Boolean` - - Default: `false` + - Default: `true` - __`COLORED_BEDS`__ - Recolor the beds in-game according to the team's color diff --git a/docs/developers/mods/hypixelmod.mdx b/docs/developers/mods/hypixelmod.mdx index bdd246ac..e36f8b73 100644 --- a/docs/developers/mods/hypixelmod.mdx +++ b/docs/developers/mods/hypixelmod.mdx @@ -19,7 +19,7 @@ public void toggleHypixelModsExample(Player viewer, boolean value) { - Config Key: `enabled` - Values - Type: `Boolean` - - Default: `false` + - Default: `true` - __`REMOVE_GUILD_ON_TAB`__ - Config Key: `remove-guild-on-tab` diff --git a/docs/developers/mods/memory.mdx b/docs/developers/mods/memory.mdx index 8aa8f65d..eba8b925 100644 --- a/docs/developers/mods/memory.mdx +++ b/docs/developers/mods/memory.mdx @@ -35,6 +35,18 @@ public void toggleMemoryUsageExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BRACKETS`__ + - Config Key: `brackets` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BRACKET_COLOR`__ + - Config Key: `bracket-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + - __`BACKGROUND`__ - Config Key: `background` - Values @@ -48,6 +60,13 @@ public void toggleMemoryUsageExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`STATIC_BACKGROUND_HEIGHT`__ + - If this is disabled the background will change size with the text. + - Config Key: `static-background-height` + - Values + - Type: `Boolean` + - Default: `true` + - __`BACKGROUND_WIDTH`__ - Config Key: `background-width` - Values @@ -64,12 +83,6 @@ public void toggleMemoryUsageExample(Player viewer, boolean value) { - Minimum: `10` - Maximum: `22` -- __`BRACKETS`__ - - Config Key: `brackets` - - Values - - Type: `Boolean` - - Default: `true` - - __`BORDER`__ - Config Key: `border` - Values @@ -84,11 +97,11 @@ public void toggleMemoryUsageExample(Player viewer, boolean value) { - Minimum: `0.5F` - Maximum: `3.0F` -- __`TEXT_COLOR`__ - - Config Key: `text-color` +- __`BORDER_COLOR`__ + - Config Key: `border-color` - Values - Type: `String` - - Default: `#FFFFFFFF` + - Default: `#9F000000` - __`BACKGROUND_COLOR`__ - Config Key: `background-color` @@ -96,11 +109,11 @@ public void toggleMemoryUsageExample(Player viewer, boolean value) { - Type: `String` - Default: `#6F000000` -- __`BORDER_COLOR`__ - - Config Key: `border-color` +- __`TEXT_COLOR`__ + - Config Key: `text-color` - Values - Type: `String` - - Default: `#9F000000` + - Default: `#FFFFFFFF` - __`COLOR_BASED_ON_USAGE`__ - Config Key: `color-based-on-usage` diff --git a/docs/developers/mods/momentum.mdx b/docs/developers/mods/momentum.mdx index e75150a1..7b4dc3d7 100644 --- a/docs/developers/mods/momentum.mdx +++ b/docs/developers/mods/momentum.mdx @@ -35,6 +35,18 @@ public void toggleMomentumModExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BRACKETS`__ + - Config Key: `brackets` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BRACKET_COLOR`__ + - Config Key: `bracket-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + - __`BACKGROUND`__ - Config Key: `background` - Values @@ -48,6 +60,13 @@ public void toggleMomentumModExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`STATIC_BACKGROUND_HEIGHT`__ + - If this is disabled the background will change size with the text. + - Config Key: `static-background-height` + - Values + - Type: `Boolean` + - Default: `true` + - __`BACKGROUND_WIDTH`__ - Config Key: `background-width` - Values @@ -64,12 +83,6 @@ public void toggleMomentumModExample(Player viewer, boolean value) { - Minimum: `10` - Maximum: `22` -- __`BRACKETS`__ - - Config Key: `brackets` - - Values - - Type: `Boolean` - - Default: `true` - - __`BORDER`__ - Config Key: `border` - Values @@ -84,11 +97,11 @@ public void toggleMomentumModExample(Player viewer, boolean value) { - Minimum: `0.5F` - Maximum: `3.0F` -- __`TEXT_COLOR`__ - - Config Key: `text-color` +- __`BORDER_COLOR`__ + - Config Key: `border-color` - Values - Type: `String` - - Default: `#FFFFFFFF` + - Default: `#9F000000` - __`BACKGROUND_COLOR`__ - Config Key: `background-color` @@ -96,11 +109,11 @@ public void toggleMomentumModExample(Player viewer, boolean value) { - Type: `String` - Default: `#6F000000` -- __`BORDER_COLOR`__ - - Config Key: `border-color` +- __`TEXT_COLOR`__ + - Config Key: `text-color` - Values - Type: `String` - - Default: `#9F000000` + - Default: `#FFFFFFFF` - __`USE_GROUND_SPEED`__ - If enabled then Y velocity is not used in the final speed. diff --git a/docs/developers/mods/neu.mdx b/docs/developers/mods/neu.mdx index 08a8cd9d..919c12a6 100644 --- a/docs/developers/mods/neu.mdx +++ b/docs/developers/mods/neu.mdx @@ -19,5 +19,5 @@ public void toggleNotEnoughUpdatesExample(Player viewer, boolean value) { - Config Key: `enabled` - Values - Type: `Boolean` - - Default: `false` + - Default: `true` diff --git a/docs/developers/mods/onesevenvisuals.mdx b/docs/developers/mods/onesevenvisuals.mdx index 917ff16e..a6eec985 100644 --- a/docs/developers/mods/onesevenvisuals.mdx +++ b/docs/developers/mods/onesevenvisuals.mdx @@ -19,5 +19,5 @@ public void toggle17VisualsExample(Player viewer, boolean value) { - Config Key: `enabled` - Values - Type: `Boolean` - - Default: `false` + - Default: `true` diff --git a/docs/developers/mods/packdisplay.mdx b/docs/developers/mods/packdisplay.mdx index 6e8569fd..38ed2e04 100644 --- a/docs/developers/mods/packdisplay.mdx +++ b/docs/developers/mods/packdisplay.mdx @@ -35,6 +35,18 @@ public void togglePackDisplayExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BRACKETS`__ + - Config Key: `brackets` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BRACKET_COLOR`__ + - Config Key: `bracket-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + - __`BACKGROUND`__ - Config Key: `background` - Values @@ -48,6 +60,13 @@ public void togglePackDisplayExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`STATIC_BACKGROUND_HEIGHT`__ + - If this is disabled the background will change size with the text. + - Config Key: `static-background-height` + - Values + - Type: `Boolean` + - Default: `true` + - __`BACKGROUND_WIDTH`__ - Config Key: `background-width` - Values @@ -64,12 +83,6 @@ public void togglePackDisplayExample(Player viewer, boolean value) { - Minimum: `12` - Maximum: `64` -- __`BRACKETS`__ - - Config Key: `brackets` - - Values - - Type: `Boolean` - - Default: `true` - - __`BORDER`__ - Config Key: `border` - Values @@ -84,11 +97,11 @@ public void togglePackDisplayExample(Player viewer, boolean value) { - Minimum: `0.5F` - Maximum: `3.0F` -- __`TEXT_COLOR`__ - - Config Key: `text-color` +- __`BORDER_COLOR`__ + - Config Key: `border-color` - Values - Type: `String` - - Default: `#FFFFFFFF` + - Default: `#9F000000` - __`BACKGROUND_COLOR`__ - Config Key: `background-color` @@ -96,11 +109,11 @@ public void togglePackDisplayExample(Player viewer, boolean value) { - Type: `String` - Default: `#6F000000` -- __`BORDER_COLOR`__ - - Config Key: `border-color` +- __`TEXT_COLOR`__ + - Config Key: `text-color` - Values - Type: `String` - - Default: `#9F000000` + - Default: `#FFFFFFFF` - __`PACK_ICON`__ - Config Key: `pack-icon` diff --git a/docs/developers/mods/playtime.mdx b/docs/developers/mods/playtime.mdx index a15b7451..296926bc 100644 --- a/docs/developers/mods/playtime.mdx +++ b/docs/developers/mods/playtime.mdx @@ -35,6 +35,18 @@ public void togglePlaytimeExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BRACKETS`__ + - Config Key: `brackets` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BRACKET_COLOR`__ + - Config Key: `bracket-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + - __`BACKGROUND`__ - Config Key: `background` - Values @@ -48,6 +60,13 @@ public void togglePlaytimeExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`STATIC_BACKGROUND_HEIGHT`__ + - If this is disabled the background will change size with the text. + - Config Key: `static-background-height` + - Values + - Type: `Boolean` + - Default: `true` + - __`BACKGROUND_WIDTH`__ - Config Key: `background-width` - Values @@ -64,12 +83,6 @@ public void togglePlaytimeExample(Player viewer, boolean value) { - Minimum: `10` - Maximum: `22` -- __`BRACKETS`__ - - Config Key: `brackets` - - Values - - Type: `Boolean` - - Default: `true` - - __`BORDER`__ - Config Key: `border` - Values @@ -84,11 +97,11 @@ public void togglePlaytimeExample(Player viewer, boolean value) { - Minimum: `0.5F` - Maximum: `3.0F` -- __`TEXT_COLOR`__ - - Config Key: `text-color` +- __`BORDER_COLOR`__ + - Config Key: `border-color` - Values - Type: `String` - - Default: `#FFFFFFFF` + - Default: `#9F000000` - __`BACKGROUND_COLOR`__ - Config Key: `background-color` @@ -96,9 +109,9 @@ public void togglePlaytimeExample(Player viewer, boolean value) { - Type: `String` - Default: `#6F000000` -- __`BORDER_COLOR`__ - - Config Key: `border-color` +- __`TEXT_COLOR`__ + - Config Key: `text-color` - Values - Type: `String` - - Default: `#9F000000` + - Default: `#FFFFFFFF` diff --git a/docs/developers/mods/reachdisplay.mdx b/docs/developers/mods/reachdisplay.mdx index 8df23182..f018f52e 100644 --- a/docs/developers/mods/reachdisplay.mdx +++ b/docs/developers/mods/reachdisplay.mdx @@ -35,6 +35,18 @@ public void toggleReachDisplayExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BRACKETS`__ + - Config Key: `brackets` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BRACKET_COLOR`__ + - Config Key: `bracket-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + - __`BACKGROUND`__ - Config Key: `background` - Values @@ -48,6 +60,13 @@ public void toggleReachDisplayExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`STATIC_BACKGROUND_HEIGHT`__ + - If this is disabled the background will change size with the text. + - Config Key: `static-background-height` + - Values + - Type: `Boolean` + - Default: `true` + - __`BACKGROUND_WIDTH`__ - Config Key: `background-width` - Values @@ -64,12 +83,6 @@ public void toggleReachDisplayExample(Player viewer, boolean value) { - Minimum: `10` - Maximum: `22` -- __`BRACKETS`__ - - Config Key: `brackets` - - Values - - Type: `Boolean` - - Default: `true` - - __`BORDER`__ - Config Key: `border` - Values @@ -84,11 +97,11 @@ public void toggleReachDisplayExample(Player viewer, boolean value) { - Minimum: `0.5F` - Maximum: `3.0F` -- __`TEXT_COLOR`__ - - Config Key: `text-color` +- __`BORDER_COLOR`__ + - Config Key: `border-color` - Values - Type: `String` - - Default: `#FFFFFFFF` + - Default: `#9F000000` - __`BACKGROUND_COLOR`__ - Config Key: `background-color` @@ -96,9 +109,9 @@ public void toggleReachDisplayExample(Player viewer, boolean value) { - Type: `String` - Default: `#6F000000` -- __`BORDER_COLOR`__ - - Config Key: `border-color` +- __`TEXT_COLOR`__ + - Config Key: `text-color` - Values - Type: `String` - - Default: `#9F000000` + - Default: `#FFFFFFFF` diff --git a/docs/developers/mods/serveraddress.mdx b/docs/developers/mods/serveraddress.mdx index a47ac851..2b7c184f 100644 --- a/docs/developers/mods/serveraddress.mdx +++ b/docs/developers/mods/serveraddress.mdx @@ -35,6 +35,18 @@ public void toggleServerAddressExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BRACKETS`__ + - Config Key: `brackets` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BRACKET_COLOR`__ + - Config Key: `bracket-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + - __`BACKGROUND`__ - Config Key: `background` - Values @@ -48,6 +60,13 @@ public void toggleServerAddressExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`STATIC_BACKGROUND_HEIGHT`__ + - If this is disabled the background will change size with the text. + - Config Key: `static-background-height` + - Values + - Type: `Boolean` + - Default: `true` + - __`BACKGROUND_WIDTH`__ - Config Key: `background-width` - Values @@ -64,12 +83,6 @@ public void toggleServerAddressExample(Player viewer, boolean value) { - Minimum: `10` - Maximum: `22` -- __`BRACKETS`__ - - Config Key: `brackets` - - Values - - Type: `Boolean` - - Default: `true` - - __`BORDER`__ - Config Key: `border` - Values @@ -84,11 +97,11 @@ public void toggleServerAddressExample(Player viewer, boolean value) { - Minimum: `0.5F` - Maximum: `3.0F` -- __`TEXT_COLOR`__ - - Config Key: `text-color` +- __`BORDER_COLOR`__ + - Config Key: `border-color` - Values - Type: `String` - - Default: `#FFFFFFFF` + - Default: `#9F000000` - __`BACKGROUND_COLOR`__ - Config Key: `background-color` @@ -96,11 +109,11 @@ public void toggleServerAddressExample(Player viewer, boolean value) { - Type: `String` - Default: `#6F000000` -- __`BORDER_COLOR`__ - - Config Key: `border-color` +- __`TEXT_COLOR`__ + - Config Key: `text-color` - Values - Type: `String` - - Default: `#9F000000` + - Default: `#FFFFFFFF` - __`SERVER_ICON`__ - Config Key: `server-icon` diff --git a/docs/developers/mods/shulkerpreview.mdx b/docs/developers/mods/shulkerpreview.mdx index d5d85b51..9d03686c 100644 --- a/docs/developers/mods/shulkerpreview.mdx +++ b/docs/developers/mods/shulkerpreview.mdx @@ -19,7 +19,7 @@ public void toggleShulkerPreviewExample(Player viewer, boolean value) { - Config Key: `enabled` - Values - Type: `Boolean` - - Default: `false` + - Default: `true` - __`ALWAYS_PREVIEW`__ - Config Key: `always-preview` diff --git a/docs/developers/mods/skyblock.mdx b/docs/developers/mods/skyblock.mdx index 98eb36fc..08b3dd8c 100644 --- a/docs/developers/mods/skyblock.mdx +++ b/docs/developers/mods/skyblock.mdx @@ -100,6 +100,24 @@ public void toggleHypixelSkyblockExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `false` +- __`SKY_BLOCK_WISHING_COMPASS`__ + - Config Key: `sky-block-wishing-compass` + - Values + - Type: `Boolean` + - Default: `false` + +- __`SKY_BLOCK_METAL_DETECTOR`__ + - Config Key: `sky-block-metal-detector` + - Values + - Type: `Boolean` + - Default: `false` + +- __`SKY_BLOCK_FINISHED_COMMISSIONS`__ + - Config Key: `sky-block-finished-commissions` + - Values + - Type: `Boolean` + - Default: `false` + - __`FIX_LAVA_BOBBER`__ - Fixes your fishing bobber sinking in lava. - Config Key: `fix-lava-bobber` diff --git a/docs/developers/mods/stopwatch.mdx b/docs/developers/mods/stopwatch.mdx index db4e4c72..d6a8edec 100644 --- a/docs/developers/mods/stopwatch.mdx +++ b/docs/developers/mods/stopwatch.mdx @@ -35,6 +35,18 @@ public void toggleStopwatchExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`BRACKETS`__ + - Config Key: `brackets` + - Values + - Type: `Boolean` + - Default: `true` + +- __`BRACKET_COLOR`__ + - Config Key: `bracket-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + - __`BACKGROUND`__ - Config Key: `background` - Values @@ -48,6 +60,13 @@ public void toggleStopwatchExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`STATIC_BACKGROUND_HEIGHT`__ + - If this is disabled the background will change size with the text. + - Config Key: `static-background-height` + - Values + - Type: `Boolean` + - Default: `true` + - __`BACKGROUND_WIDTH`__ - Config Key: `background-width` - Values @@ -64,12 +83,6 @@ public void toggleStopwatchExample(Player viewer, boolean value) { - Minimum: `10` - Maximum: `22` -- __`BRACKETS`__ - - Config Key: `brackets` - - Values - - Type: `Boolean` - - Default: `true` - - __`BORDER`__ - Config Key: `border` - Values @@ -84,11 +97,11 @@ public void toggleStopwatchExample(Player viewer, boolean value) { - Minimum: `0.5F` - Maximum: `3.0F` -- __`TEXT_COLOR`__ - - Config Key: `text-color` +- __`BORDER_COLOR`__ + - Config Key: `border-color` - Values - Type: `String` - - Default: `#FFFFFFFF` + - Default: `#9F000000` - __`BACKGROUND_COLOR`__ - Config Key: `background-color` @@ -96,11 +109,11 @@ public void toggleStopwatchExample(Player viewer, boolean value) { - Type: `String` - Default: `#6F000000` -- __`BORDER_COLOR`__ - - Config Key: `border-color` +- __`TEXT_COLOR`__ + - Config Key: `text-color` - Values - Type: `String` - - Default: `#9F000000` + - Default: `#FFFFFFFF` - __`RESET_EVERY_START`__ - Config Key: `reset-every-start` diff --git a/docs/developers/mods/tab.mdx b/docs/developers/mods/tab.mdx index 31850a9c..610a3a1d 100644 --- a/docs/developers/mods/tab.mdx +++ b/docs/developers/mods/tab.mdx @@ -125,23 +125,17 @@ public void toggleTabEditorExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `false` -- __`DYNAMIC_PING_COLOR`__ - - Config Key: `dynamic-ping-color` - - Values - - Type: `Boolean` - - Default: `false` - - __`PING_NUMBER_SHADOW`__ - Config Key: `ping-number-shadow` - Values - Type: `Boolean` - Default: `false` -- __`PING_NUMBER_COLOR`__ - - Config Key: `ping-number-color` +- __`DYNAMIC_PING_COLOR`__ + - Config Key: `dynamic-ping-color` - Values - - Type: `String` - - Default: `#FFFFFF55` + - Type: `Boolean` + - Default: `false` - __`LOW_PING_NUMBER_COLOR`__ - Config Key: `low-ping-number-color` @@ -167,3 +161,9 @@ public void toggleTabEditorExample(Player viewer, boolean value) { - Type: `String` - Default: `#FFAA0000` +- __`PING_NUMBER_COLOR`__ + - Config Key: `ping-number-color` + - Values + - Type: `String` + - Default: `#FFFFFF55` + diff --git a/docs/developers/mods/titles.mdx b/docs/developers/mods/titles.mdx index cdd9f836..5eb98f30 100644 --- a/docs/developers/mods/titles.mdx +++ b/docs/developers/mods/titles.mdx @@ -35,6 +35,24 @@ public void toggleTitlesExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `false` +- __`TITLE_COLOR`__ + - Config Key: `title-color` + - Values + - Type: `String` + - Default: `#FFFF5555` + +- __`SUBTITLE_COLOR`__ + - Config Key: `subtitle-color` + - Values + - Type: `String` + - Default: `#FFFFFFFF` + +- __`USE_MINECRAFT_GUISCALE`__ + - Config Key: `use-minecraft-g-u-i-scale` + - Values + - Type: `Boolean` + - Default: `true` + - __`KEEP_TITLE_CENTERED`__ - Keep the title centered around the center of the mod on-screen - Config Key: `keep-title-centered` @@ -55,21 +73,3 @@ public void toggleTitlesExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` -- __`TITLE_COLOR`__ - - Config Key: `title-color` - - Values - - Type: `String` - - Default: `#FFFF5555` - -- __`SUBTITLE_COLOR`__ - - Config Key: `subtitle-color` - - Values - - Type: `String` - - Default: `#FFFFFFFF` - -- __`USE_MINECRAFT_GUISCALE`__ - - Config Key: `use-minecraft-g-u-i-scale` - - Values - - Type: `Boolean` - - Default: `true` - diff --git a/docs/developers/mods/togglesneak.mdx b/docs/developers/mods/togglesneak.mdx index db8d2198..e6e17485 100644 --- a/docs/developers/mods/togglesneak.mdx +++ b/docs/developers/mods/togglesneak.mdx @@ -33,18 +33,18 @@ public void toggleToggleSneakSprintExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `false` -- __`DOUBLE_TAP`__ - - Config Key: `double-tap` - - Values - - Type: `Boolean` - - Default: `true` - - __`TOGGLE_SNEAK_CONTAINER`__ - Config Key: `toggle-sneak-container` - Values - Type: `Boolean` - Default: `false` +- __`DOUBLE_TAP`__ + - Config Key: `double-tap` + - Values + - Type: `Boolean` + - Default: `true` + - __`FLY_BOOST`__ - Config Key: `fly-boost` - Values diff --git a/docs/developers/mods/waypoints.mdx b/docs/developers/mods/waypoints.mdx index 30756b1e..24a60903 100644 --- a/docs/developers/mods/waypoints.mdx +++ b/docs/developers/mods/waypoints.mdx @@ -83,3 +83,9 @@ public void toggleWaypointsExample(Player viewer, boolean value) { - Minimum: `0.1F` - Maximum: `3.0F` +- __`ADD_WAYPOINTS_FROM_CHAT`__ + - Config Key: `add-waypoints-from-chat` + - Values + - Type: `Boolean` + - Default: `true` + diff --git a/docs/developers/modules/beam.mdx b/docs/developers/modules/beam.mdx index fd2b8b02..75a4e4c8 100644 --- a/docs/developers/modules/beam.mdx +++ b/docs/developers/modules/beam.mdx @@ -20,8 +20,16 @@ The beam module allows you to create custom beams resembling beacon beams, which ## Integration +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + ### Sample Code + + + + +### Displaying a Beam + ```java public void displayBeamExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -43,6 +51,24 @@ public void displayBeamExample(Player viewer) { } ``` +### Removing a Beam + +```java +public void removeBeamExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.beamModule.removeBeam(apolloPlayer, "spawn-beacon")); +} +``` + +### Resetting all Beams + +```java +public void resetBeamsExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.beamModule::resetBeams); +} +``` + ### `Beam` Options `.id(String)` should include a unique identifier for the beam. @@ -99,20 +125,90 @@ Custom colors can be created from any RGB values using `new Color(int red, int g ) ``` -### Removing a specific beam for a player + + + + +### Displaying a Beam + +```java +public void displayBeamExample(Player viewer) { + DisplayBeaconBeamMessage message = DisplayBeaconBeamMessage.newBuilder() + .setId("spawn-beacon") + .setColor(ProtobufUtil.createColorProto(Color.CYAN)) + .setLocation(ProtobufUtil.createBlockLocationProto(new Location(viewer.getWorld(), 0, 60, 0))) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Removing a Beam ```java public void removeBeamExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(apolloPlayer -> this.beamModule.removeBeam(apolloPlayer, "spawn-beacon")); + RemoveBeaconBeamMessage message = RemoveBeaconBeamMessage.newBuilder() + .setId("spawn-beacon") + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); } ``` -### Resetting all beams for a player +### Resetting all Beams ```java public void resetBeamsExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(this.beamModule::resetBeams); + ResetBeaconBeamsMessage message = ResetBeaconBeamsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); } ``` + + + + + +### Displaying a Beam + +```java +public void displayBeamExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.beam.v1.DisplayBeaconBeamMessage"); + message.addProperty("id", "spawn-beacon"); + message.add("location", JsonUtil.createBlockLocationObject( + new Location(Bukkit.getWorld("world"), 0, 60, 0) + )); + message.add("color", JsonUtil.createColorObject(Color.CYAN)); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Removing a Beam + +```java +public void removeBeamExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.beam.v1.RemoveBeaconBeamMessage"); + message.addProperty("id", "spawn-beacon"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Resetting all Beams + +```java +public void resetBeamsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.beam.v1.ResetBeaconBeamsMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + + + diff --git a/docs/developers/modules/border.mdx b/docs/developers/modules/border.mdx index 681e5c87..98f70da1 100644 --- a/docs/developers/modules/border.mdx +++ b/docs/developers/modules/border.mdx @@ -15,6 +15,13 @@ The border module not only enhances Minecraft's current world border system, but ## Integration ### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Displaying a Border ```java public void displayBorderExample(Player viewer) { @@ -42,6 +49,24 @@ public void displayBorderExample(Player viewer) { } ``` +### Removing a Border + +```java +public void removeBorderExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.borderModule.removeBorder(apolloPlayer, "pvp-tagged-spawn")); +} +``` + +### Resetting all Borders + +```java +public void resetBordersExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.borderModule::resetBorders); +} +``` + ### `Border` Options `.id(String)` should include a unique identifier for the border. It's important when you have multiple borders in a single world. @@ -128,20 +153,96 @@ Custom colors can be created from any RGB values using `new Color(int red, int g .durationTicks(0) ``` -### Removing a specific border for a player + + + + +### Displaying a Border + +```java +public void displayBorderExample(Player viewer) { + DisplayBorderMessage message = DisplayBorderMessage.newBuilder() + .setId("pvp-tagged-spawn") + .setWorld("world") + .setCancelEntry(true) + .setCancelExit(true) + .setCanShrinkOrExpand(false) + .setColor(ProtobufUtil.createColorProto(Color.RED)) + .setBounds(ProtobufUtil.createCuboid2DProto(-50, -50, 50, 50)) + .setDurationTicks(1000) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Removing a Border ```java public void removeBorderExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(apolloPlayer -> this.borderModule.removeBorder(apolloPlayer, "pvp-tagged-spawn")); + RemoveBorderMessage message = RemoveBorderMessage.newBuilder() + .setId("pvp-tagged-spawn") + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); } ``` -### Resetting all borders for a player +### Resetting all Borders ```java public void resetBordersExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(this.borderModule::resetBorders); + ResetBordersMessage message = ResetBordersMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + +### Displaying a Border + +```java +public void displayBorderExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.border.v1.DisplayBorderMessage"); + message.addProperty("id", "pvp-tagged-spawn"); + message.addProperty("world", "world"); + message.addProperty("cancel_entry", true); + message.addProperty("cancel_exit", true); + message.addProperty("can_shrink_or_expand", false); + message.add("color", JsonUtil.createColorObject(Color.RED)); + message.add("bounds", JsonUtil.createCuboid2DObject(-50, -50, 50, 50)); + message.addProperty("duration_ticks", 1000); + + JsonPacketUtil.sendPacket(viewer, message); } ``` + +### Removing a Border + +```java +public void removeBorderExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.border.v1.RemoveBorderMessage"); + message.addProperty("id", "pvp-tagged-spawn"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Resetting all Borders + +```java +public void resetBordersExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.border.v1.ResetBordersMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + diff --git a/docs/developers/modules/chat.mdx b/docs/developers/modules/chat.mdx index 99469f23..b73d70c4 100644 --- a/docs/developers/modules/chat.mdx +++ b/docs/developers/modules/chat.mdx @@ -1,3 +1,5 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + # Chat Module ## Overview @@ -15,15 +17,23 @@ The chat module allows you to interact with and modify users chat feeds. ## Integration +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Displaying a Live Chat Message + ```java -private final int messageId = ThreadLocalRandom.current().nextInt(100); private int countdown = 5; -public void displayLiveMessageExample() { +public void displayLiveChatMessageExample() { this.chatModule.displayLiveChatMessage(Recipients.ofEveryone(), Component.text("Game starting in ", NamedTextColor.GREEN) .append(Component.text(this.countdown, NamedTextColor.BLUE)), - this.messageId + 13 ); if (--this.countdown == 0) { @@ -32,10 +42,91 @@ public void displayLiveMessageExample() { } ``` -### Removing a specific live message for a player +### Removing a Live Chat Message ```java -public void removeLiveMessageExample() { - this.chatModule.removeLiveChatMessage(Recipients.ofEveryone(), this.messageId); +public void removeLiveChatMessageExample() { + this.chatModule.removeLiveChatMessage(Recipients.ofEveryone(), 13); +} +``` + + + + + +### Displaying a Live Chat Message + +```java +private int countdown = 5; + +public void displayLiveChatMessageExample() { + DisplayLiveChatMessageMessage message = DisplayLiveChatMessageMessage.newBuilder() + .setAdventureJsonLines(AdventureUtil.toJson( + Component.text("Game starting in ", NamedTextColor.GREEN) + .append(Component.text(this.countdown, NamedTextColor.BLUE))) + ) + .setMessageId(13) + .build(); + + if (--this.countdown == 0) { + this.countdown = 5; + } + + ProtobufPacketUtil.broadcastPacket(message); +} +``` + +### Removing a Live Chat Message + +```java +public void removeLiveChatMessageExample() { + RemoveLiveChatMessageMessage message = RemoveLiveChatMessageMessage.newBuilder() + .setMessageId(13) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); } ``` + + + + + +### Displaying a Live Chat Message + +```java +private int countdown = 5; + +public void displayLiveChatMessageExample() { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.chat.v1.DisplayLiveChatMessageMessage"); + message.addProperty("message_id", 13); + message.addProperty("adventure_json_lines", AdventureUtil.toJson( + Component.text("Game starting in ", NamedTextColor.GREEN) + .append(Component.text(this.countdown, NamedTextColor.BLUE)) + )); + + if (--this.countdown == 0) { + this.countdown = 5; + } + + JsonPacketUtil.broadcastPacket(message); +} +``` + +### Removing a Live Chat Message + +```java +public void removeLiveChatMessageExample() { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.chat.v1.RemoveLiveChatMessageMessage"); + message.addProperty("message_id", 13); + + JsonPacketUtil.broadcastPacket(message); +} +``` + + + + + diff --git a/docs/developers/modules/coloredfire.mdx b/docs/developers/modules/coloredfire.mdx index fb49e213..5a70cbaf 100644 --- a/docs/developers/modules/coloredfire.mdx +++ b/docs/developers/modules/coloredfire.mdx @@ -1,3 +1,5 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + # Colored Fire Module ## Overview @@ -13,6 +15,13 @@ The colored fire module allows you to modify the color of the flames that appear ## Integration ### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Override a Fire Color ```java public void overrideColoredFireExample(UUID burningPlayer) { @@ -23,6 +32,23 @@ public void overrideColoredFireExample(UUID burningPlayer) { } ``` +### Removing a Fire Color + +```java +public void resetColoredFireExample(UUID burningPlayer) { + this.coloredFireModule.resetColoredFire(Recipients.ofEveryone(), burningPlayer); +} +``` + +### Resetting all Fire Colors + +```java +public void resetColoredFiresExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.coloredFireModule::resetColoredFires); +} +``` + ### `overrideColoredFire` Parameters 1. `Recipients recipients` @@ -32,19 +58,84 @@ public void overrideColoredFireExample(UUID burningPlayer) { 3. `Color flameColor` - How you'll dictate the color of the fire, see the [colors page](/apollo/developers/utilities/colors) for more. -### Removing a specific targets colored fire for viewers + + + + +### Override a Fire Color + +```java +public void overrideColoredFireExample(UUID burningPlayer) { + OverrideColoredFireMessage message = OverrideColoredFireMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(burningPlayer)) + .setColor(ProtobufUtil.createColorProto(Color.BLUE)) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); +} +``` + +### Removing a Fire Color ```java public void resetColoredFireExample(UUID burningPlayer) { - this.coloredFireModule.resetColoredFire(Recipients.ofEveryone(), burningPlayer); + ResetColoredFireMessage message = ResetColoredFireMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(burningPlayer)) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); } ``` -### Resetting all colored fires for all viewers +### Resetting all Fire Colors ```java public void resetColoredFiresExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(this.coloredFireModule::resetColoredFires); + ResetColoredFiresMessage message = ResetColoredFiresMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + +### Override a Fire Color + +```java +public void overrideColoredFireExample(UUID burningPlayer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.coloredfire.v1.OverrideColoredFireMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(burningPlayer)); + message.add("color", JsonUtil.createColorObject(Color.BLUE)); + + JsonPacketUtil.broadcastPacket(message); +} +``` + +### Removing a Fire Color + +```java +public void resetColoredFireExample(UUID burningPlayer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.coloredfire.v1.ResetColoredFireMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(burningPlayer)); + + JsonPacketUtil.broadcastPacket(message); +} +``` + +### Resetting all Fire Colors + +```java +public void resetColoredFiresExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.coloredfire.v1.ResetColoredFiresMessage"); + + JsonPacketUtil.sendPacket(viewer, message); } ``` + + + + diff --git a/docs/developers/modules/cooldown.mdx b/docs/developers/modules/cooldown.mdx index eb7fe96c..e0bf5edc 100644 --- a/docs/developers/modules/cooldown.mdx +++ b/docs/developers/modules/cooldown.mdx @@ -1,3 +1,5 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + # Cooldown Module ## Overview @@ -17,6 +19,13 @@ Apollo's cooldown module allows servers to interact with the Cooldown mod found ## Integration ### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Displaying a Cooldown with an item ```java public void displayCooldownItemExample(Player viewer) { @@ -34,7 +43,11 @@ public void displayCooldownItemExample(Player viewer) { ); }); } +``` + +### Displaying a Cooldown with a resource +```java public void displayCooldownResourceExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -53,6 +66,28 @@ public void displayCooldownResourceExample(Player viewer) { } ``` +### Removing a Cooldown + +```java +public void removeCooldownExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + this.cooldownModule.removeCooldown(apolloPlayer, "enderpearl-cooldown"); + this.cooldownModule.removeCooldown(apolloPlayer, "lunar-cooldown"); + }); +} +``` + +### Resetting all Cooldowns + +```java +public void resetCooldownsExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.cooldownModule::resetCooldowns); +} +``` + ### `Cooldown` Options `.name(String)` should include a unique identifier for the each cooldown. @@ -75,24 +110,114 @@ public void displayCooldownResourceExample(Player viewer) { .icon(SimpleResourceLocationIcon.builder().resourceLocation("lunar:logo/logo-200x182.svg").size(12).build()) ``` -### Removing a specific cooldown for a player + + + + +### Displaying a Cooldown with an item + +```java +public void displayCooldownItemExample(Player viewer) { + DisplayCooldownMessage message = DisplayCooldownMessage.newBuilder() + .setName("enderpearl-cooldown") + .setDuration(ProtobufUtil.createDurationProto(Duration.ofSeconds(15))) + .setIcon(ProtobufUtil.createItemStackIconProto("ENDER_PEARL", 0, 0)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Displaying a Cooldown with a resource + +```java +public void displayCooldownResourceExample(Player viewer) { + DisplayCooldownMessage message = DisplayCooldownMessage.newBuilder() + .setName("lunar-cooldown") + .setDuration(ProtobufUtil.createDurationProto(Duration.ofSeconds(15))) + .setIcon(ProtobufUtil.createSimpleResourceLocationIconProto("lunar:logo/logo-200x182.svg", 12)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Removing a Cooldown ```java public void removeCooldownExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + RemoveCooldownMessage enderpearlMessage = RemoveCooldownMessage.newBuilder() + .setName("enderpearl-cooldown") + .build(); - apolloPlayerOpt.ifPresent(apolloPlayer -> { - this.cooldownModule.removeCooldown(apolloPlayer, "enderpearl-cooldown"); - this.cooldownModule.removeCooldown(apolloPlayer, "lunar-cooldown"); - }); + ProtobufPacketUtil.sendPacket(viewer, enderpearlMessage); } ``` -### Resetting all cooldowns for a player +### Resetting all Cooldowns ```java public void resetCooldownsExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(this.cooldownModule::resetCooldowns); + ResetCooldownsMessage message = ResetCooldownsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); } ``` + + + + + +### Displaying a Cooldown with an item + +```java +public void displayCooldownItemExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cooldown.v1.DisplayCooldownMessage"); + message.addProperty("name", "enderpearl-cooldown"); + message.addProperty("duration", JsonUtil.createDurationObject(Duration.ofSeconds(15))); + message.add("icon", JsonUtil.createItemStackIconObject("ENDER_PEARL", 0, 0)); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Displaying a Cooldown with a resource + +```java +public void displayCooldownResourceExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cooldown.v1.DisplayCooldownMessage"); + message.addProperty("name", "lunar-cooldown"); + message.addProperty("duration", JsonUtil.createDurationObject(Duration.ofSeconds(15))); + message.add("icon", JsonUtil.createSimpleResourceLocationIconObject("lunar:logo/logo-200x182.svg", 12)); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Removing a Cooldown + +```java +public void removeCooldownExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cooldown.v1.RemoveCooldownMessage"); + message.addProperty("name", "enderpearl-cooldown"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Resetting all Cooldowns + +```java +public void resetCooldownsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cooldown.v1.ResetCooldownsMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + diff --git a/docs/developers/modules/entity.mdx b/docs/developers/modules/entity.mdx index 19fb8e2f..6ca479ba 100644 --- a/docs/developers/modules/entity.mdx +++ b/docs/developers/modules/entity.mdx @@ -1,3 +1,5 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + # Entity Module ## Overview @@ -9,7 +11,14 @@ The entity module allows you to interact with entities client-sided. ## Integration -### Override rainbow sheep for a player +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Override Sheep rainbow state ```java public void overrideRainbowSheepExample(Player viewer) { @@ -25,14 +34,7 @@ public void overrideRainbowSheepExample(Player viewer) { } ``` -#### `overrideRainbowSheep` Parameters - -1. `ApolloPlayer Viewer` - - The player you want to view the rainbow sheep. -2. `List sheepEntities` - - A list of all sheep entities you want to be rainbow. - -#### Resetting rainbow sheep for a player +### Reset Sheep rainbow state ```java public void resetRainbowSheepExample(Player viewer) { @@ -44,19 +46,12 @@ public void resetRainbowSheepExample(Player viewer) { .stream().map(sheep -> new ApolloEntity(sheep.getEntityId(), sheep.getUniqueId())) .collect(Collectors.toList()); - this.entityModule.overrideRainbowSheep(apolloPlayer, sheepEntities); + this.entityModule.resetRainbowSheep(apolloPlayer, sheepEntities); }); } ``` -#### `resetRainbowSheep` Parameters - -1. `ApolloPlayer Viewer` - - The player you want to reset the rainbow sheep for. -2. `List sheepEntities` - - A list of all sheep entities you want to remove the rainbow state from. - -### Flip entities for a player +### Override Entity flip state ```java public void flipEntityExample(Player viewer) { @@ -75,14 +70,7 @@ public void flipEntityExample(Player viewer) { } ``` -#### `flipEntity` Parameters - -1. `ApolloPlayer Viewer` - - The player you want to see the flipped entity. -2. `List entities` - - A list of all entities you want to flip. - -#### Resetting flipped entities for a player +### Reset Entity flip state ```java public void resetFlippedEntityExample(Player viewer) { @@ -101,9 +89,157 @@ public void resetFlippedEntityExample(Player viewer) { } ``` -#### `resetFlippedEntity` Parameters +#### `overrideRainbowSheep`, `resetRainbowSheep`, `flipEntity` & `resetFlippedEntity` Parameters -1. `ApolloPlayer Viewer` - - The player you want to reset the flipped entity for. +1. `Recipients recipients` + - A list of all the player(s) you want to be able to see the updated entities. 2. `List entities` - - A list of all entities you want to reset the flip state from. + - A list of all entities you want to reset the flip or colored sheep state from. + + + + + +### Override Sheep rainbow state + +```java +public void overrideRainbowSheepExample(Player viewer) { + Set sheepUuidsProto = viewer.getWorld().getEntitiesByClass(Sheep.class).stream() + .map(sheep -> ProtobufUtil.createEntityIdProto(sheep.getEntityId(), sheep.getUniqueId())) + .collect(Collectors.toSet()); + + OverrideRainbowSheepMessage message = OverrideRainbowSheepMessage.newBuilder() + .addAllEntityIds(sheepUuidsProto) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Sheep rainbow state + +```java +public void resetRainbowSheepExample(Player viewer) { + Set sheepUuidsProto = viewer.getWorld().getEntitiesByClass(Sheep.class).stream() + .map(sheep -> ProtobufUtil.createEntityIdProto(sheep.getEntityId(), sheep.getUniqueId())) + .collect(Collectors.toSet()); + + ResetRainbowSheepMessage message = ResetRainbowSheepMessage.newBuilder() + .addAllEntityIds(sheepUuidsProto) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Override Entity flip state + +```java +public void flipEntityExample(Player viewer) { + Set entityUuidsProto = viewer.getWorld() + .getNearbyEntities(viewer.getLocation(), 10, 10, 10) + .stream().filter(entity -> entity instanceof Cow) + .map(sheep -> ProtobufUtil.createEntityIdProto(sheep.getEntityId(), sheep.getUniqueId())) + .collect(Collectors.toSet()); + + FlipEntityMessage message = FlipEntityMessage.newBuilder() + .addAllEntityIds(entityUuidsProto) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Entity flip state + +```java +public void resetFlippedEntityExample(Player viewer) { + Set entityUuidsProto = viewer.getWorld() + .getNearbyEntities(viewer.getLocation(), 10, 10, 10) + .stream().filter(entity -> entity instanceof Cow) + .map(sheep -> ProtobufUtil.createEntityIdProto(sheep.getEntityId(), sheep.getUniqueId())) + .collect(Collectors.toSet()); + + ResetFlipedEntityMessage message = ResetFlipedEntityMessage.newBuilder() + .addAllEntityIds(entityUuidsProto) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + +### Override Sheep rainbow state + +```java +public void overrideRainbowSheepExample(Player viewer) { + JsonArray entityIds = viewer.getWorld().getEntitiesByClass(Sheep.class).stream() + .map(JsonUtil::createEntityIdObject) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.entity.v1.OverrideRainbowSheepMessage"); + message.add("entity_ids", entityIds); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Sheep rainbow state + +```java +public void resetRainbowSheepExample(Player viewer) { + JsonArray entityIds = viewer.getWorld().getEntitiesByClass(Sheep.class).stream() + .map(JsonUtil::createEntityIdObject) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.entity.v1.ResetRainbowSheepMessage"); + message.add("entity_ids", entityIds); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Override Entity flip state + +```java +public void flipEntityExample(Player viewer) { + JsonArray entityIds = viewer.getWorld() + .getNearbyEntities(viewer.getLocation(), 10, 10, 10) + .stream().filter(entity -> entity instanceof Cow) + .map(JsonUtil::createEntityIdObject) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.entity.v1.FlipEntityMessage"); + message.add("entity_ids", entityIds); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Entity flip state + +```java +public void resetFlippedEntityExample(Player viewer) { + JsonArray entityIds = viewer.getWorld() + .getNearbyEntities(viewer.getLocation(), 10, 10, 10) + .stream().filter(entity -> entity instanceof Cow) + .map(JsonUtil::createEntityIdObject) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.entity.v1.ResetFlipedEntityMessage"); + message.add("entity_ids", entityIds); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + diff --git a/docs/developers/modules/glow.mdx b/docs/developers/modules/glow.mdx index fc0e7c5b..38952b2d 100644 --- a/docs/developers/modules/glow.mdx +++ b/docs/developers/modules/glow.mdx @@ -1,3 +1,5 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + # Glow Module ## Overview @@ -17,6 +19,13 @@ The glow module allows you to take advantage of the vanilla Minecraft Glow Effec ## Integration ### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Override a Glow Effect ```java public void overrideGlowEffectExample(UUID glowingPlayer) { @@ -27,6 +36,23 @@ public void overrideGlowEffectExample(UUID glowingPlayer) { } ``` +### Removing a Glow Effect + +```java +public void resetGlowEffectExample(UUID glowingPlayer) { + this.glowModule.resetGlow(Recipients.ofEveryone(), glowingPlayer); +} +``` + +### Resetting all Glow Effects + +```java +public void resetGlowEffectsExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.glowModule::resetGlow); +} +``` + ### `overrideGlowEffectExample` Parameters 1. `Recipients recipients` @@ -36,19 +62,84 @@ public void overrideGlowEffectExample(UUID glowingPlayer) { 3. `Color glowColor` - How you'll dictate the color of the glow effect, see the [colors page](/apollo/developers/utilities/colors) for more. -### Removing a specific targets glow effect for viewers + + + + +### Override a Glow Effect + +```java +public void overrideGlowEffectExample(UUID glowingPlayer) { + OverrideGlowEffectMessage message = OverrideGlowEffectMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(glowingPlayer)) + .setColor(ProtobufUtil.createColorProto(Color.RED)) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); +} +``` + +### Removing a Glow Effect ```java public void resetGlowEffectExample(UUID glowingPlayer) { - this.glowModule.resetGlow(Recipients.ofEveryone(), glowingPlayer); + ResetGlowEffectMessage message = ResetGlowEffectMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(glowingPlayer)) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); } ``` -### Resetting all glow effects for all viewers +### Resetting all Glow Effects ```java public void resetGlowEffectsExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(this.glowModule::resetGlow); + ResetGlowEffectsMessage message = ResetGlowEffectsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + +### Override a Glow Effect + +```java +public void overrideGlowEffectExample(UUID glowingPlayer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.glow.v1.OverrideGlowEffectMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(glowingPlayer)); + message.add("color", JsonUtil.createColorObject(Color.RED)); + + JsonPacketUtil.broadcastPacket(message); +} +``` + +### Removing a Glow Effect + +```java +public void resetGlowEffectExample(UUID glowingPlayer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.glow.v1.ResetGlowEffectMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(glowingPlayer)); + + JsonPacketUtil.broadcastPacket(message); +} +``` + +### Resetting all Glow Effects + +```java +public void resetGlowEffectsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.glow.v1.ResetGlowEffectsMessage"); + + JsonPacketUtil.sendPacket(viewer, message); } ``` + + + + diff --git a/docs/developers/modules/hologram.mdx b/docs/developers/modules/hologram.mdx index 7aa64d6b..36259a35 100644 --- a/docs/developers/modules/hologram.mdx +++ b/docs/developers/modules/hologram.mdx @@ -1,3 +1,5 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + # Hologram Module ## Overview @@ -13,6 +15,13 @@ The hologram module enhances vanilla Minecraft's current system for holograms an ## Integration ### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Displaying a Hologram ```java public void displayHologramExample() { @@ -42,6 +51,23 @@ public void displayHologramExample() { } ``` +### Removing a Hologram + +```java +public void removeHologramExample() { + this.hologramModule.removeHologram(Recipients.ofEveryone(), "welcome-hologram"); +} +``` + +### Resetting all Holograms + +```java +public void resetHologramsExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.hologramModule::resetHolograms); +} +``` + ### `Hologram` Options `.id(String)` should include a unique identifier for the hologram. @@ -59,7 +85,7 @@ public void displayHologramExample() { .y(100) .z(0) .build() -) +) ``` `.lines(Component)` should be a string, or an Adventure `Component`. See the [chat components](https://docs.advntr.dev/text.html) page for more. @@ -95,20 +121,121 @@ public void displayHologramExample() { .showBackground(true) ``` + + + + +### Displaying a Hologram + +```java +public void displayHologramExample() { + List lines = Lists.newArrayList( + Component.text() + .content("Welcome to my server!") + .color(NamedTextColor.RED) + .decorate(TextDecoration.BOLD, TextDecoration.UNDERLINED) + .build(), + Component.text() + .content("Type /help to get started!") + .build() + ) + .stream().map(AdventureUtil::toJson) + .collect(Collectors.toList()); + + DisplayHologramMessage message = DisplayHologramMessage.newBuilder() + .setId("welcome-hologram") + .setLocation(ProtobufUtil.createLocationProto( + new Location(Bukkit.getWorld("world"), 5, 105, 0) + )) + .addAllAdventureJsonLines(lines) + .setShowThroughWalls(true) + .setShowShadow(false) + .setShowBackground(true) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); +} +``` + +### Removing a Hologram + +```java +public void removeHologramExample() { + RemoveHologramMessage message = RemoveHologramMessage.newBuilder() + .setId("welcome-hologram") + .build(); + + ProtobufPacketUtil.broadcastPacket(message); +} +``` + +### Resetting all Holograms + +```java +public void resetHologramsExample(Player viewer) { + ResetHologramsMessage message = ResetHologramsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + +### Displaying a Hologram + +```java +public void displayHologramExample() { + JsonArray lines = Lists.newArrayList( + Component.text() + .content("Welcome to my server!") + .color(NamedTextColor.RED) + .decorate(TextDecoration.BOLD, TextDecoration.UNDERLINED) + .build(), + Component.text() + .content("Type /help to get started!") + .build() + ).stream().map(AdventureUtil::toJson).map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.hologram.v1.DisplayHologramMessage"); + message.addProperty("id", "welcome-hologram"); + message.add("location", JsonUtil.createLocationObject( + new Location(Bukkit.getWorld("world"), 5, 105, 0) + )); + message.add("adventure_json_lines", lines); + message.addProperty("show_through_walls", true); + message.addProperty("show_shadow", false); + message.addProperty("show_background", true); + + JsonPacketUtil.broadcastPacket(message); +} +``` -### Removing a specific hologram for players +### Removing a Hologram ```java public void removeHologramExample() { - this.hologramModule.removeHologram(Recipients.ofEveryone(), "welcome-hologram"); + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.hologram.v1.RemoveHologramMessage"); + message.addProperty("id", "welcome-hologram"); + + JsonPacketUtil.broadcastPacket(message); } ``` -### Resetting all holograms for a player +### Resetting all Holograms ```java public void resetHologramsExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(this.hologramModule::resetHolograms); + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.hologram.v1.ResetHologramsMessage"); + + JsonPacketUtil.broadcastPacket(message); } ``` + + + + diff --git a/docs/developers/modules/limb.mdx b/docs/developers/modules/limb.mdx index 950107d1..a05d10c4 100644 --- a/docs/developers/modules/limb.mdx +++ b/docs/developers/modules/limb.mdx @@ -1,3 +1,5 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + # Limb Module ## Overview @@ -15,7 +17,14 @@ The limb module allows you to hide the `ArmorPiece` and `BodyPart` limbs of a pl ## Integration -### Hiding an armor piece of a player +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Hide Armor Pieces ```java public void hideArmorExample(Player viewer, Player target) { @@ -30,16 +39,7 @@ public void hideArmorExample(Player viewer, Player target) { } ``` -#### `hideArmorPieces` Parameters - -1. `ApolloPlayer Viewer` - - The player(s) that you wish to see the hidden armor piece. -2. `UUID Target` - - The player UUID you want to hide the armor piece of. -3. `ArmorPiece.TYPE` - - The armor piece types you wish to hide on the `target` player. See the [armor pieces](#armorpiece-types) section for more. - -### Resetting an armor piece of a player +### Reset Armor Pieces ```java public void resetArmorExample(Player viewer, Player target) { @@ -54,16 +54,7 @@ public void resetArmorExample(Player viewer, Player target) { } ``` -#### `resetArmorPieces` Parameters - -1. `ApolloPlayer Viewer` - - The player(s) that you want to reset the armor piece for. -2. `UUID Target` - - The players UUID you want to reset the armor piece of. -3. `ArmorPiece.TYPE` - - The type of armor piece(s) you want to reset on the `target` player. See the [armor pieces](#armorpiece-types) section for more. - -### Hiding a body part of a player +### Hide Body Parts ```java public void hideBodyExample(Player viewer, Player target) { @@ -78,18 +69,9 @@ public void hideBodyExample(Player viewer, Player target) { } ``` -#### `hideBodyParts` Parameters - -1. `ApolloPlayer Viewer` - - The player(s) you want to see the hidden body part. -2. `UUID Target` - - The players UUID you want to hide the body part of. -3. `BodyPart.TYPE` - - The type of body part(s) you want to hide on the `target` player. See the [body parts](#bodyparts-types) section for more. - -### Resetting a body part of a player +### Reset Body Parts -```java +```java public void resetBodyExample(Player viewer, Player target) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -102,10 +84,19 @@ public void resetBodyExample(Player viewer, Player target) { } ``` -#### `resetBodyParts` Parameters +#### `hideArmorPieces` & `resetArmorPieces` Parameters + +1. `Recipients recipients` + - A list of all the player(s) you want to be able to see the updated armor pieces. +2. `UUID Target` + - The player UUID you want to hide the armor piece of. +3. `ArmorPiece.TYPE` + - The armor piece types you wish to hide on the `target` player. See the [armor pieces](#armorpiece-types) section for more. + +#### `hideBodyParts` & `resetBodyParts` Parameters -1. `ApolloPlayer Viewer` - - The player(s) you want to reset the body part for. +1. `Recipients recipients` + - A list of all the player(s) you want to be able to see the updated armor pieces. 2. `UUID Target` - The players UUID you want to reset the body part of. 3. `BodyPart.TYPE` @@ -126,3 +117,139 @@ public void resetBodyExample(Player viewer, Player target) { * `RIGHT_ARM` * `LEFT_LEG` * `RIGHT_LEG` + + + + + +### Hide Armor Pieces + +```java +public void hideArmorExample(Player viewer, Player target) { + HideArmorPiecesMessage message = HideArmorPiecesMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(target.getUniqueId())) + .addAllArmorPieces(EnumSet.of(ArmorPiece.ARMOR_PIECE_HELMET, ArmorPiece.ARMOR_PIECE_LEGGINGS)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Armor Pieces + +```java +public void resetArmorExample(Player viewer, Player target) { + ResetArmorPiecesMessage message = ResetArmorPiecesMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(target.getUniqueId())) + .addAllArmorPieces(EnumSet.of(ArmorPiece.ARMOR_PIECE_HELMET, ArmorPiece.ARMOR_PIECE_LEGGINGS)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Hide Body Parts + +```java +public void hideBodyExample(Player viewer, Player target) { + HideBodyPartMessage message = HideBodyPartMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(target.getUniqueId())) + .addAllBodyParts(EnumSet.of(BodyPart.BODY_PART_HEAD, BodyPart.BODY_PART_RIGHT_ARM)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message);; +} +``` + +### Reset Body Parts + +```java +public void resetBodyExample(Player viewer, Player target) { + ResetBodyPartMessage message = ResetBodyPartMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(target.getUniqueId())) + .addAllBodyParts(EnumSet.of(BodyPart.BODY_PART_HEAD, BodyPart.BODY_PART_RIGHT_ARM)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message);; +} +``` + + + + + +### Hide Armor Pieces + +```java +public void hideArmorExample(Player viewer, Player target) { + // 1 = helmet, 2 = chestplate, 3 = leggings, 4 = boots + JsonArray armorPieces = Lists.newArrayList(1, 3) + .stream().map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.limb.v1.HideArmorPiecesMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(target.getUniqueId())); + message.add("armor_pieces", armorPieces); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Armor Pieces + +```java +public void resetArmorExample(Player viewer, Player target) { + // 1 = helmet, 2 = chestplate, 3 = leggings, 4 = boots + JsonArray armorPieces = Lists.newArrayList(1, 3) + .stream().map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.limb.v1.ResetArmorPiecesMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(target.getUniqueId())); + message.add("armor_pieces", armorPieces); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Hide Body Parts + +```java +public void hideBodyExample(Player viewer, Player target) { + // 1 = head, 2 = torso, 3 = left arm, 4 = right arm, 5 = left leg, 6 = right leg + JsonArray bodyParts = Lists.newArrayList(1, 4) + .stream().map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.limb.v1.HideBodyPartMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(target.getUniqueId())); + message.add("body_parts", bodyParts); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Body Parts + +```java +public void resetBodyExample(Player viewer, Player target) { + // 1 = head, 2 = torso, 3 = left arm, 4 = right arm, 5 = left leg, 6 = right leg + JsonArray bodyParts = Lists.newArrayList(1, 4) + .stream().map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.limb.v1.ResetBodyPartMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(target.getUniqueId())); + message.add("body_parts", bodyParts); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + diff --git a/docs/developers/modules/modsetting.mdx b/docs/developers/modules/modsetting.mdx index 6d05ccfc..7afb5de3 100644 --- a/docs/developers/modules/modsetting.mdx +++ b/docs/developers/modules/modsetting.mdx @@ -1,3 +1,5 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + # Mod Setting Module ## Overview @@ -19,29 +21,122 @@ You can find all available mods and their options under the mods section. ## Integration -### Interacting with a specific players `ModSetting` +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Disable Lighting Mod ```java -public void disableLightningModExample(Player viewer) { +public void disableLightingModExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(apolloPlayer -> this.modSettingModule.getOptions().set(apolloPlayer, ModLighting.ENABLED, false)); } ``` -### Resetting a specific players `ModSetting` +### Reset Lighting Mod to it's default value ```java -public void rollbackLightningModEnabledState(Player viewer) { +public void rollbackLightingModEnabledState(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); // To rollback the server override value of the setting, simply set the value to "null" apolloPlayerOpt.ifPresent(apolloPlayer -> this.modSettingModule.getOptions().set(apolloPlayer, ModLighting.ENABLED, null)); } ``` -### Broadcasting a `ModSettings` change to an entire server. +### Broadcast Disable Lighting Mod the an entire server ```java -public void broadcastDisableLightningModExample(Player viewer) { +public void broadcastDisableLightingModExample(Player viewer) { this.modSettingModule.getOptions().set(ModLighting.ENABLED, false); } ``` + + + + + +### Disable Lighting Mod + +```java +public void disableLightingModExample(Player viewer) { + Map properties = new HashMap<>(); + properties.put("lighting.enabled", Value.newBuilder().setBoolValue(false).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("mod_setting", properties); + ProtobufPacketUtil.sendPacket(viewer, settings); +} +``` + +### Reset Lighting Mod to it's default value + +```java +public void rollbackLightingModEnabledState(Player viewer) { + Map properties = new HashMap<>(); + // To rollback the server override value of the setting, simply set the value to "null" + properties.put("lighting.enabled", Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("mod_setting", properties); + ProtobufPacketUtil.sendPacket(viewer, settings); +} +``` + +### Broadcast Disable Lighting Mod the an entire server + +```java +public void broadcastDisableLightingModExample() { + Map properties = new HashMap<>(); + properties.put("lighting.enabled", Value.newBuilder().setBoolValue(false).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("mod_setting", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + + + + + +### Disable Lighting Mod + +```java +public void disableLightingModExample(Player viewer) { + Map properties = new HashMap<>(); + properties.put("lighting.enabled", false); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("mod_setting", properties); + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Lighting Mod to it's default value + +```java +public void rollbackLightingModEnabledState(Player viewer) { + // To rollback the server override value of the setting, simply set the value to "null" + Map properties = new HashMap<>(); + properties.put("lighting.enabled", null); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("mod_setting", properties); + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Broadcast Disable Lighting Mod the an entire server + +```java +public void broadcastDisableLightingModExample() { + Map properties = new HashMap<>(); + properties.put("lighting.enabled", false); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("mod_setting", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + + + + diff --git a/docs/developers/modules/nametag.mdx b/docs/developers/modules/nametag.mdx index e8dcebc2..bace711d 100644 --- a/docs/developers/modules/nametag.mdx +++ b/docs/developers/modules/nametag.mdx @@ -1,3 +1,4 @@ +import { Tab, Tabs } from 'nextra-theme-docs' import { Callout } from 'nextra-theme-docs' # Nametag Module @@ -24,6 +25,13 @@ The nametag module enhances the vanilla Minecraft nametag. ## Integration ### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Override a Nametag ```java public void overrideNametagExample(Player target) { @@ -44,6 +52,23 @@ public void overrideNametagExample(Player target) { } ``` +### Reset a Nametag + +```java +public void resetNametagExample(Player target) { + this.nametagModule.resetNametag(Recipients.ofEveryone(), target.getUniqueId()); +} +``` + +### Resetting all Nametags + +```java +public void resetNametagsExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.nametagModule::resetNametags); +} +``` + ### `overrideNametag` Parameters 1. `Recipients recipients` @@ -72,19 +97,112 @@ public void overrideNametagExample(Player target) { )) ``` -### Reset nametag for players + + + + +### Override a Nametag + +```java +public void overrideNametagExample(Player target) { + List lines = Lists.newArrayList( + Component.text() + .content("[StaffMode]") + .decorate(TextDecoration.ITALIC) + .color(NamedTextColor.GRAY) + .build(), + Component.text() + .content(target.getName()) + .color(NamedTextColor.RED) + .build() + ) + .stream().map(AdventureUtil::toJson) + .collect(Collectors.toList()); + + OverrideNametagMessage message = OverrideNametagMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(target.getUniqueId())) + .addAllAdventureJsonLines(lines) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); +} +``` + +### Reset a Nametag ```java public void resetNametagExample(Player target) { - this.nametagModule.resetNametag(Recipients.ofEveryone(), target.getUniqueId()); + ResetNametagMessage message = ResetNametagMessage.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(target.getUniqueId())) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); } ``` -### Resetting all nametags for a player +### Resetting all Nametags ```java public void resetNametagsExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(this.nametagModule::resetNametags); + ResetNametagsMessage message = ResetNametagsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + +### Override a Nametag + +```java +public void overrideNametagExample(Player target) { + JsonArray lines = Lists.newArrayList( + Component.text() + .content("[StaffMode]") + .decorate(TextDecoration.ITALIC) + .color(NamedTextColor.GRAY) + .build(), + Component.text() + .content(target.getName()) + .color(NamedTextColor.RED) + .build() + ) + .stream().map(AdventureUtil::toJson).map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.nametag.v1.OverrideNametagMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(target.getUniqueId())); + message.add("adventure_json_lines", lines); + + JsonPacketUtil.broadcastPacket(message); +} +``` + +### Reset a Nametag + +```java +public void resetNametagExample(Player target) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.nametag.v1.ResetNametagMessage"); + message.add("player_uuid", JsonUtil.createUuidObject(target.getUniqueId())); + + JsonPacketUtil.broadcastPacket(message); } ``` + +### Resetting all Nametags + +```java +public void resetNametagsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.nametag.v1.ResetNametagsMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + diff --git a/docs/developers/modules/nickhider.mdx b/docs/developers/modules/nickhider.mdx index 5f1c3751..4122158b 100644 --- a/docs/developers/modules/nickhider.mdx +++ b/docs/developers/modules/nickhider.mdx @@ -1,3 +1,5 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + # Nick Hider Module ## Overview @@ -8,7 +10,14 @@ The Nick Hider module allows you to interact with the Nick Hider mod. ## Integration -### Override the nick for a specific player +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Override a Nick ```java public void overrideNickExample(Player viewer) { @@ -17,7 +26,7 @@ public void overrideNickExample(Player viewer) { } ``` -### Reset the nick for a specific player +### Reset a Nick ```java public void resetNickExample(Player viewer) { @@ -25,3 +34,59 @@ public void resetNickExample(Player viewer) { apolloPlayerOpt.ifPresent(this.nickHiderModule::resetNick); } ``` + + + + + +### Override a Nick + +```java +public void overrideNickExample(Player viewer) { + OverrideNickHiderMessage message = OverrideNickHiderMessage.newBuilder() + .setNick("Notch") + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset a Nick + +```java +public void resetNickExample(Player viewer) { + ResetNickHiderMessage message = ResetNickHiderMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + +### Override a Nick + +```java +public void overrideNickExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.nickhider.v1.OverrideNickHiderMessage"); + message.addProperty("nick", "Notch"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset a Nick + +```java +public void resetNickExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.nickhider.v1.ResetNickHiderMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + diff --git a/docs/developers/modules/notification.mdx b/docs/developers/modules/notification.mdx index faad0aeb..81ed896d 100644 --- a/docs/developers/modules/notification.mdx +++ b/docs/developers/modules/notification.mdx @@ -1,3 +1,4 @@ +import { Tab, Tabs } from 'nextra-theme-docs' import { Callout } from 'nextra-theme-docs' # Notification Module @@ -18,20 +19,42 @@ The notification module allows you to send Lunar Client notifications to players ## Integration -### `Notification` Builder +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Displaying a Notification ```java -private final Notification uhcAnnouncement = Notification.builder() - .titleComponent(Component.text("UHC Announcement", NamedTextColor.GREEN)) - .descriptionComponent(Component.text("UHC starts in 5 minutes...", NamedTextColor.RED) - .appendNewline() - .append(Component.text("Get ready!", NamedTextColor.WHITE)) - .appendNewline() - .append(Component.text("Good luck!", NamedTextColor.GOLD)) - ) - .resourceLocation("icons/golden_apple.png") // This field is optional - .displayTime(Duration.ofSeconds(5)) - .build(); +public void displayNotificationExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + this.notificationModule.displayNotification(apolloPlayer, Notification.builder() + .titleComponent(Component.text("UHC Announcement", NamedTextColor.GREEN)) + .descriptionComponent(Component.text("UHC starts in 5 minutes...", NamedTextColor.RED) + .append(Component.newline()) + .append(Component.text("Get ready!", NamedTextColor.WHITE)) + .append(Component.newline()) + .append(Component.text("Good luck!", NamedTextColor.GOLD)) + ) + .resourceLocation("icons/golden_apple.png") // This field is optional + .displayTime(Duration.ofSeconds(5)) + .build()); + }); +} +``` + +### Resetting all Notifications + +```java +public void resetNotificationsExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.notificationModule::resetNotifications); +} ``` #### `Notification` Options @@ -82,20 +105,82 @@ If this field is left empty (null) it'll display a generic info icon, as display .description("UHC starts in 5 minutes...") ``` -### Displaying a Notification for a specific player + + + + +### Displaying a Notification ```java public void displayNotificationExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(apolloPlayer -> this.notificationModule.displayNotification(apolloPlayer, this.uhcAnnouncement)); + DisplayNotificationMessage message = DisplayNotificationMessage.newBuilder() + .setTitleAdventureJsonLines(AdventureUtil.toJson( + Component.text("UHC Announcement", NamedTextColor.GREEN) + )) + .setDescriptionAdventureJsonLines(AdventureUtil.toJson( + Component.text("UHC starts in 5 minutes...", NamedTextColor.RED) + .append(Component.newline()) + .append(Component.text("Get ready!", NamedTextColor.WHITE)) + .append(Component.newline()) + .append(Component.text("Good luck!", NamedTextColor.GOLD)) + ) + ) + .setResourceLocation("icons/golden_apple.png") // This field is optional + .setDisplayTime(ProtobufUtil.createDurationProto(Duration.ofSeconds(5))) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); } ``` -### Resetting all notifications for a player +### Resetting all Notifications ```java public void resetNotificationsExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(this.notificationModule::resetNotifications); + ResetNotificationsMessage message = ResetNotificationsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + +### Displaying a Notification + +```java +public void displayNotificationExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.notification.v1.DisplayNotificationMessage"); + message.addProperty("title_adventure_json_lines", AdventureUtil.toJson( + Component.text("UHC Announcement", NamedTextColor.GREEN) + )); + message.addProperty("description_adventure_json_lines", AdventureUtil.toJson( + Component.text("UHC starts in 5 minutes...", NamedTextColor.RED) + .append(Component.newline()) + .append(Component.text("Get ready!", NamedTextColor.WHITE)) + .append(Component.newline()) + .append(Component.text("Good luck!", NamedTextColor.GOLD)) + )); + + message.addProperty("display_time", JsonUtil.createDurationObject(Duration.ofSeconds(5))); + message.addProperty("resource_location", "icons/golden_apple.png"); + + JsonPacketUtil.sendPacket(viewer, message); } ``` + +### Resetting all Notifications + +```java +public void resetNotificationsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.notification.v1.ResetNotificationsMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + diff --git a/docs/developers/modules/packetenrichment.mdx b/docs/developers/modules/packetenrichment.mdx index 4234a7f2..ffa50b7c 100644 --- a/docs/developers/modules/packetenrichment.mdx +++ b/docs/developers/modules/packetenrichment.mdx @@ -13,6 +13,13 @@ The packet enrichment module provides servers with additional information about ## Integration +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + The majority of this module is handled through Apollo's [event system](/apollo/developers/events). The following events are related to the packet enrichment module, you can find more information about each event on the [events page](/apollo/developers/events). @@ -20,3 +27,14 @@ The following events are related to the packet enrichment module, you can find m * `ApolloPlayerChatOpenEvent` * `ApolloPlayerAttackEvent` * `ApolloPlayerUseItemEvent` + + + + + +Visit [Apollo Serverbound packets](/apollo/developers/lightweight/protobuf/serverbound-packets) + + + + + diff --git a/docs/developers/modules/richpresence.mdx b/docs/developers/modules/richpresence.mdx index 5fd58995..a144b6a7 100644 --- a/docs/developers/modules/richpresence.mdx +++ b/docs/developers/modules/richpresence.mdx @@ -1,3 +1,4 @@ +import { Tab, Tabs } from 'nextra-theme-docs' import { Callout } from 'nextra-theme-docs' # Rich Presence Module @@ -28,6 +29,13 @@ The rich presence module allows you to interact with Discord and Lunar Client's ## Integration ### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Override Rich Presence ```java public void overrideServerRichPresenceExample(Player viewer) { @@ -49,6 +57,15 @@ public void overrideServerRichPresenceExample(Player viewer) { } ``` +### Reset Rich Presence + +```java +public void resetServerRichPresenceExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.richPresenceModule::resetServerRichPresence); +} +``` + ### `ServerRichPresence` Options `.gameName(String)` the name of the game the player is playing on. @@ -99,11 +116,72 @@ public void overrideServerRichPresenceExample(Player viewer) { .teamMaxSize(4) ``` -### Resetting the server rich presence for a player + + + + +### Override Rich Presence + +```java +public void overrideServerRichPresenceExample(Player viewer) { + OverrideServerRichPresenceMessage message = OverrideServerRichPresenceMessage.newBuilder() + .setGameName("BedWars") + .setGameVariantName("Solo") + .setGameState("In Game") + .setPlayerState("Playing") + .setMapName("Winter") + .setSubServer("BW02") + .setTeamCurrentSize(3) + .setTeamMaxSize(4) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Rich Presence ```java public void resetServerRichPresenceExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(this.richPresenceModule::resetServerRichPresence); + ResetServerRichPresenceMessage message = ResetServerRichPresenceMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + +### Override Rich Presence + +```java +public void overrideServerRichPresenceExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.richpresence.v1.OverrideServerRichPresenceMessage"); + message.addProperty("game_name", "BedWars"); + message.addProperty("game_variant_name", "Solo"); + message.addProperty("game_state", "In Game"); + message.addProperty("player_state", "Playing"); + message.addProperty("map_name", "Winter"); + message.addProperty("sub_server", "BW02"); + message.addProperty("team_current_size", 3); + message.addProperty("team_max_size", 4); + + JsonPacketUtil.sendPacket(viewer, message); } ``` + +### Reset Rich Presence + +```java +public void resetServerRichPresenceExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.richpresence.v1.ResetServerRichPresenceMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + diff --git a/docs/developers/modules/serverrule.mdx b/docs/developers/modules/serverrule.mdx index 2272fcdc..7f1d6143 100644 --- a/docs/developers/modules/serverrule.mdx +++ b/docs/developers/modules/serverrule.mdx @@ -1,3 +1,4 @@ +import { Tab, Tabs } from 'nextra-theme-docs' import { Callout } from 'nextra-theme-docs' # Server Rule Module @@ -16,7 +17,14 @@ This module heavily integrates with our [Options API](/apollo/developers/options ## Integration -### How to toggle a specific server rule +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Toggle Anti Portal Traps ```java public void setAntiPortalTraps(boolean value) { @@ -24,7 +32,7 @@ public void setAntiPortalTraps(boolean value) { } ``` -### How to toggle a specific server rule for a specific player +### Override Nametag Render Distance ```java public void setOverrideNametagRenderDistance(Player viewer, boolean value) { @@ -36,7 +44,7 @@ public void setOverrideNametagRenderDistance(Player viewer, boolean value) { } ``` -### How to change a specific server rule value +### Broadcast Nametag Render Distance ```java public void setNametagRenderDistanceExample(int value) { @@ -44,6 +52,90 @@ public void setNametagRenderDistanceExample(int value) { } ``` + + + + +### Toggle Anti Portal Traps + +```java +public void setAntiPortalTraps(boolean value) { + Map properties = new HashMap<>(); + properties.put("anti-portal-traps", Value.newBuilder().setBoolValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_rule", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + +### Override Nametag Render Distance + +```java +public void setOverrideNametagRenderDistance(Player viewer, boolean value) { + Map properties = new HashMap<>(); + properties.put("override-nametag-render-distance", Value.newBuilder().setBoolValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_rule", properties); + ProtobufPacketUtil.sendPacket(viewer, settings); +} +``` + +### Broadcast Nametag Render Distance + +```java +public void setNametagRenderDistanceExample(int value) { + Map properties = new HashMap<>(); + properties.put("nametag-render-distance", Value.newBuilder().setNumberValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_rule", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + + + + + +### Toggle Anti Portal Traps + +```java +public void setAntiPortalTraps(boolean value) { + Map properties = new HashMap<>(); + properties.put("anti-portal-traps", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_rule", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + +### Override Nametag Render Distance + +```java +public void setOverrideNametagRenderDistance(Player viewer, boolean value) { + Map properties = new HashMap<>(); + properties.put("override-nametag-render-distance", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_rule", properties); + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Broadcast Nametag Render Distance + +```java +public void setNametagRenderDistanceExample(int value) { + Map properties = new HashMap<>(); + properties.put("nametag-render-distance", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_rule", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + + + + + ## Available options - __`COMPETITIVE_GAME`__ diff --git a/docs/developers/modules/staffmod.mdx b/docs/developers/modules/staffmod.mdx index e3fe3ca6..1be7c8af 100644 --- a/docs/developers/modules/staffmod.mdx +++ b/docs/developers/modules/staffmod.mdx @@ -1,3 +1,5 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + # Staff Mod Module ## Overview @@ -15,9 +17,16 @@ The staff mod module allows you to interact with Lunar Client's built in staff m ## Integration -### How to enable staff mods for a player +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Enable Staff Mods -```java +```java public void enableStaffModsExample(Player viewer) { if (!viewer.hasPermission("apollo.staff")) { return; @@ -28,14 +37,7 @@ public void enableStaffModsExample(Player viewer) { } ``` -#### `enableStaffMods` Parameters - -1. `ApolloPlayer` - - The player you want to enable the staff mod for. -2. `StaffMod.TYPE` - - The type of staff mod(s) you want to enable for the `ApolloPlayer` player. See the [staff mod types](#staffmod-types) section for more. - -### How to disable staff mods for a player +### Disable Staff Mods ```java public void disableStaffModsExample(Player viewer) { @@ -44,14 +46,91 @@ public void disableStaffModsExample(Player viewer) { } ``` -#### `disableStaffMods` Parameters +#### `enableStaffMods` & `disableStaffMods` Parameters -1. `ApolloPlayer` - - The player you want to disable the staff mod for. +1. `Recipients recipients` + - 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 disable for the `ApolloPlayer` player. See the [staff mod types](#staffmod-types) section for more. + - The type of staff mod(s) you want to enable for the `Recipients` player. See the [staff mod types](#staffmod-types) section for more. ## `StaffMod` Types * `XRAY` + + + + +### Enable Staff Mods + +```java +public void enableStaffModsExample(Player viewer) { + if (!viewer.hasPermission("apollo.staff")) { + return; + } + + EnableStaffModsMessage message = EnableStaffModsMessage.newBuilder() + .addAllStaffMods(Collections.singletonList(StaffMod.STAFF_MOD_XRAY)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Disable Staff Mods + +```java +public void disableStaffModsExample(Player viewer) { + DisableStaffModsMessage message = DisableStaffModsMessage.newBuilder() + .addAllStaffMods(Collections.singletonList(StaffMod.STAFF_MOD_XRAY)) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + +### Enable Staff Mods + +```java +public void enableStaffModsExample(Player viewer) { + if (!viewer.hasPermission("apollo.staff")) { + return; + } + + // 1 = xray + JsonArray staffMods = Stream.of(1) + .map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.staffmod.v1.EnableStaffModsMessage"); + message.add("staff_mods", staffMods); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Disable Staff Mods + +```java +public void disableStaffModsExample(Player viewer) { + // 1 = xray + JsonArray staffMods = Stream.of(1) + .map(JsonPrimitive::new) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.staffmod.v1.DisableStaffModsMessage"); + message.add("staff_mods", staffMods); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + diff --git a/docs/developers/modules/stopwatch.mdx b/docs/developers/modules/stopwatch.mdx index 46f91198..9412318b 100644 --- a/docs/developers/modules/stopwatch.mdx +++ b/docs/developers/modules/stopwatch.mdx @@ -1,3 +1,5 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + # Stopwatch Module ## Overview @@ -17,7 +19,14 @@ The stopwatch module allows you to control the stopwatch mod inside Lunar Client ## Integration -### How to start a player's stopwatch +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Start Stopwatch ```java public void startStopwatchExample(Player viewer) { @@ -26,7 +35,7 @@ public void startStopwatchExample(Player viewer) { } ``` -### How to stop a player's stopwatch +### Stop Stopwatch ```java public void stopStopwatchExample(Player viewer) { @@ -35,7 +44,7 @@ public void stopStopwatchExample(Player viewer) { } ``` -### How to reset a player's stopwatch +### Reset Stopwatch ```java public void resetStopwatchExample(Player viewer) { @@ -43,3 +52,75 @@ public void resetStopwatchExample(Player viewer) { apolloPlayerOpt.ifPresent(this.stopwatchModule::resetStopwatch); } ``` + + + + + +### Start Stopwatch + +```java +public void startStopwatchExample(Player viewer) { + StartStopwatchMessage message = StartStopwatchMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Stop Stopwatch + +```java +public void stopStopwatchExample(Player viewer) { + StopStopwatchMessage message = StopStopwatchMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Stopwatch + +```java +public void resetStopwatchExample(Player viewer) { + ResetStopwatchMessage message = ResetStopwatchMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + +### Start Stopwatch + +```java +public void startStopwatchExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.stopwatch.v1.StartStopwatchMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Stop Stopwatch + +```java +public void stopStopwatchExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.stopwatch.v1.StopStopwatchMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Stopwatch + +```java +public void resetStopwatchExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.stopwatch.v1.ResetStopwatchMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + diff --git a/docs/developers/modules/team.mdx b/docs/developers/modules/team.mdx index 282174b9..bd856ce1 100644 --- a/docs/developers/modules/team.mdx +++ b/docs/developers/modules/team.mdx @@ -20,6 +20,11 @@ The team module will allow you to interact with the Team View mod in Lunar Clien ## Integration ### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + ```java private final Map teamsByTeamId = Maps.newHashMap(); @@ -224,3 +229,292 @@ Custom colors can be created from any RGB values using `new Color(int red, int g .build() ) ``` + + + + + +```java +private final Map teamsByTeamId = Maps.newHashMap(); +private final Map teamsByPlayerUuid = Maps.newHashMap(); + +public TeamProtoExample() { + new TeamUpdateTask(); + + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); +} + +@EventHandler +private void onPlayerQuit(PlayerQuitEvent event) { + Player player = event.getPlayer(); + + this.getByPlayerUuid(player.getUniqueId()).ifPresent(team -> { + if (team.getMembers().size() == 1) { + this.deleteTeam(team.getTeamId()); + } + }); +} + +public Optional getByPlayerUuid(UUID playerUuid) { + return Optional.ofNullable(this.teamsByPlayerUuid.get(playerUuid)); +} + +public Optional getByTeamId(UUID teamId) { + return Optional.ofNullable(this.teamsByTeamId.get(teamId)); +} + +public Team createTeam() { + Team team = new Team(); + this.teamsByTeamId.put(team.getTeamId(), team); + + return team; +} + +public void deleteTeam(UUID teamId) { + Team team = this.teamsByTeamId.remove(teamId); + + if (team != null) { + team.getMembers().forEach(team::removeMember); + } +} + +public class Team { + + private final UUID teamId; + private final Set members; + + public Team() { + this.teamId = UUID.randomUUID(); + this.members = Sets.newHashSet(); + } + + public void addMember(Player player) { + this.members.add(player); + TeamProtoExample.this.teamsByPlayerUuid.put(player.getUniqueId(), this); + } + + public void removeMember(Player player) { + this.members.remove(player); + TeamProtoExample.this.teamsByPlayerUuid.remove(player.getUniqueId()); + + ResetTeamMembersMessage message = ResetTeamMembersMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(player, message); + } + + private TeamMember createTeamMember(Player member) { + return TeamMember.newBuilder() + .setPlayerUuid(ProtobufUtil.createUuidProto(member.getUniqueId())) + .setAdventureJsonPlayerName(AdventureUtil.toJson( + Component.text() + .content(member.getName()) + .color(NamedTextColor.WHITE) + .build() + )) + .setMarkerColor(ProtobufUtil.createColorProto(Color.WHITE)) + .setLocation(ProtobufUtil.createLocationProto(member.getLocation())) + .build(); + } + + // The refresh method used for updating members locations + public void refresh() { + List teammates = this.members.stream().filter(Player::isOnline) + .map(this::createTeamMember) + .collect(Collectors.toList()); + + UpdateTeamMembersMessage message = UpdateTeamMembersMessage.newBuilder() + .addAllMembers(teammates) + .build(); + + this.members.forEach(member -> ProtobufPacketUtil.sendPacket(member, message)); + } + + public UUID getTeamId() { + return this.teamId; + } + + public Set getMembers() { + return this.members; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + + if (other == null || other.getClass() != this.getClass()) { + return false; + } + + Team team = (Team) other; + return this.teamId.equals(team.getTeamId()); + } + + @Override + public int hashCode() { + return this.teamId.hashCode(); + } +} + +// Updates players location every 1 tick (50ms) +public class TeamUpdateTask extends BukkitRunnable { + + public TeamUpdateTask() { + this.runTaskTimerAsynchronously(ApolloExamplePlugin.getPlugin(), 1L, 1L); + } + + @Override + public void run() { + TeamProtoExample.this.teamsByTeamId.values().forEach(Team::refresh); + } +} +``` + + + + + +```java +private final Map teamsByTeamId = Maps.newHashMap(); +private final Map teamsByPlayerUuid = Maps.newHashMap(); + +public TeamJsonExample() { + new TeamUpdateTask(); + + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); +} + +@EventHandler +private void onPlayerQuit(PlayerQuitEvent event) { + Player player = event.getPlayer(); + + this.getByPlayerUuid(player.getUniqueId()).ifPresent(team -> { + if (team.getMembers().size() == 1) { + this.deleteTeam(team.getTeamId()); + } + }); +} + +public Optional getByPlayerUuid(UUID playerUuid) { + return Optional.ofNullable(this.teamsByPlayerUuid.get(playerUuid)); +} + +public Optional getByTeamId(UUID teamId) { + return Optional.ofNullable(this.teamsByTeamId.get(teamId)); +} + +public Team createTeam() { + Team team = new Team(); + this.teamsByTeamId.put(team.getTeamId(), team); + + return team; +} + +public void deleteTeam(UUID teamId) { + Team team = this.teamsByTeamId.remove(teamId); + + if (team != null) { + team.getMembers().forEach(team::removeMember); + } +} + +public class Team { + + private final UUID teamId; + private final Set members; + + public Team() { + this.teamId = UUID.randomUUID(); + this.members = Sets.newHashSet(); + } + + public void addMember(Player player) { + this.members.add(player); + TeamJsonExample.this.teamsByPlayerUuid.put(player.getUniqueId(), this); + } + + public void removeMember(Player player) { + this.members.remove(player); + TeamJsonExample.this.teamsByPlayerUuid.remove(player.getUniqueId()); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.team.v1.ResetTeamMembersMessage"); + + JsonPacketUtil.sendPacket(player, message); + } + + private JsonObject createTeamMember(Player member) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.team.v1.TeamMember"); + message.add("player_uuid", JsonUtil.createUuidObject(member.getUniqueId())); + message.addProperty("adventure_json_player_name", AdventureUtil.toJson( + Component.text() + .content(member.getName()) + .color(NamedTextColor.WHITE) + .build() + )); + message.add("marker_color", JsonUtil.createColorObject(Color.WHITE)); + message.add("location", JsonUtil.createLocationObject(member.getLocation())); + + return message; + } + + // The refresh method used for updating members locations + public void refresh() { + JsonArray teammates = this.members.stream().filter(Player::isOnline) + .map(this::createTeamMember) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.team.v1.UpdateTeamMembersMessage"); + message.add("members", teammates); + + this.members.forEach(member -> JsonPacketUtil.sendPacket(member, message)); + } + + public UUID getTeamId() { + return this.teamId; + } + + public Set getMembers() { + return this.members; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + + if (other == null || other.getClass() != this.getClass()) { + return false; + } + + Team team = (Team) other; + return this.teamId.equals(team.getTeamId()); + } + + @Override + public int hashCode() { + return this.teamId.hashCode(); + } +} + +// Updates players location every 1 tick (50ms) +public class TeamUpdateTask extends BukkitRunnable { + + public TeamUpdateTask() { + this.runTaskTimerAsynchronously(ApolloExamplePlugin.getPlugin(), 1L, 1L); + } + + @Override + public void run() { + TeamJsonExample.this.teamsByTeamId.values().forEach(Team::refresh); + } +} +``` + + + + + diff --git a/docs/developers/modules/title.mdx b/docs/developers/modules/title.mdx index 314c9c1c..21209901 100644 --- a/docs/developers/modules/title.mdx +++ b/docs/developers/modules/title.mdx @@ -1,4 +1,4 @@ -import { Callout } from 'nextra-theme-docs' +import { Tab, Tabs } from 'nextra-theme-docs' # Title Module @@ -10,44 +10,64 @@ The title module backports all vanilla `title` & `subtitle` features found in 1. - Display titles for 1.7 Lunar Client players. - Display subtitles for 1.7 Lunar Client players. - - This module is only useful for servers that support the 1.7 versions of Minecraft. - - ## Integration -### `Title` Builder +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Displaying a Title + +```java +public void displayTitleExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.titleModule.displayTitle(apolloPlayer, Title.builder() + .type(TitleType.TITLE) + .message(Component.text() + .content("Hello, player!") + .color(NamedTextColor.GREEN) + .decorate(TextDecoration.BOLD) + .build()) + .scale(1.0f) + .displayTime(Duration.ofMillis(1500L)) + .fadeInTime(Duration.ofMillis(250)) + .fadeOutTime(Duration.ofMillis(300)) + .build())); +} +``` + +### Displaying a Interpolated Title ```java -private final Title helloTitle = Title.builder() - .type(TitleType.TITLE) - .message(Component.text() - .content("Hello, player!") - .color(NamedTextColor.GREEN) - .decorate(TextDecoration.BOLD) - .build()) - .scale(1.0f) - .displayTime(Duration.ofMillis(1500L)) - .fadeInTime(Duration.ofMillis(250)) - .fadeOutTime(Duration.ofMillis(300)) - .build(); +public void displayTitleInterpolatedExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.titleModule.displayTitle(apolloPlayer, Title.builder() + .type(TitleType.TITLE) + .message(Component.text() + .content("This title expands!") + .color(NamedTextColor.GREEN) + .decorate(TextDecoration.BOLD) + .build()) + .scale(0.1f) + .interpolationScale(1.0f) + .interpolationRate(0.01f) + .displayTime(Duration.ofMillis(5000L)) + .fadeInTime(Duration.ofMillis(250)) + .fadeOutTime(Duration.ofMillis(300)) + .build())); +} ``` +### Resetting all Titles + ```java -private final Title interpolatedTitle = Title.builder() - .type(TitleType.TITLE) - .message(Component.text() - .content("This title expands!") - .color(NamedTextColor.GREEN) - .decorate(TextDecoration.BOLD) - .build()) - .scale(0.1f) - .interpolationScale(1.0f) - .interpolationRate(0.01f) - .displayTime(Duration.ofMillis(5000L)) - .fadeInTime(Duration.ofMillis(250)) - .fadeOutTime(Duration.ofMillis(300)) - .build(); +public void resetTitlesExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.titleModule::resetTitles); +} ``` #### `Title` Options @@ -104,26 +124,135 @@ private final Title interpolatedTitle = Title.builder() .interpolationRate(0.01f) ``` -### Displaying a title for a player +## `TitleType` Types + +* `TITLE` +* `SUBTITLE` + + + + + +### Displaying a Title ```java public void displayTitleExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + DisplayTitleMessage message = DisplayTitleMessage.newBuilder() + .setTitleType(TitleType.TITLE_TYPE_TITLE) + .setAdventureJsonMessage(AdventureUtil.toJson( + Component.text() + .content("Hello, player!") + .color(NamedTextColor.GREEN) + .decorate(TextDecoration.BOLD) + .build() + )) + .setScale(1.0f) + .setFadeInTime(ProtobufUtil.createDurationProto(Duration.ofMillis(1500))) + .setDisplayTime(ProtobufUtil.createDurationProto(Duration.ofMillis(250))) + .setFadeOutTime(ProtobufUtil.createDurationProto(Duration.ofMillis(300))) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` - apolloPlayerOpt.ifPresent(apolloPlayer -> this.titleModule.displayTitle(apolloPlayer, this.helloTitle)); +### Displaying a Interpolated Title + +```java +public void displayTitleInterpolatedExample(Player viewer) { + DisplayTitleMessage message = DisplayTitleMessage.newBuilder() + .setTitleType(TitleType.TITLE_TYPE_TITLE) + .setAdventureJsonMessage(AdventureUtil.toJson( + Component.text() + .content("This title expands!") + .color(NamedTextColor.GREEN) + .decorate(TextDecoration.BOLD) + .build() + )) + .setScale(0.1f) + .setInterpolationScale(1.0f) + .setInterpolationRate(0.01f) + .setFadeInTime(ProtobufUtil.createDurationProto(Duration.ofMillis(5000))) + .setDisplayTime(ProtobufUtil.createDurationProto(Duration.ofMillis(250))) + .setFadeOutTime(ProtobufUtil.createDurationProto(Duration.ofMillis(300))) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); } ``` -### Resetting all titles for a player +### Resetting all Titles ```java public void resetTitlesExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(this.titleModule::resetTitles); + ResetTitlesMessage message = ResetTitlesMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); } ``` -## `TitleType` Types + -* `TITLE` -* `SUBTITLE` + + +### Displaying a Title + +```java +public void displayTitleExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.title.v1.DisplayTitleMessage"); + message.addProperty("title_type", 1); // 1 = title, 2 = subtitle + message.addProperty("adventure_json_message", AdventureUtil.toJson( + Component.text() + .content("Hello, player!") + .color(NamedTextColor.GREEN) + .decorate(TextDecoration.BOLD) + .build() + )); + message.addProperty("scale", 1.0f); + message.addProperty("fade_in_time", JsonUtil.createDurationObject(Duration.ofMillis(1500))); + message.addProperty("display_time", JsonUtil.createDurationObject(Duration.ofMillis(250))); + message.addProperty("fade_out_time", JsonUtil.createDurationObject(Duration.ofMillis(300))); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Displaying a Interpolated Title + +```java +public void displayTitleInterpolatedExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.title.v1.DisplayTitleMessage"); + message.addProperty("title_type", 1); // 1 = title, 2 = subtitle + message.addProperty("adventure_json_message", AdventureUtil.toJson( + Component.text() + .content("This title expands!") + .color(NamedTextColor.GREEN) + .decorate(TextDecoration.BOLD) + .build() + )); + message.addProperty("scale", 0.1f); + message.addProperty("interpolation_scale", 1.0f); + message.addProperty("interpolation_rate", 0.01f); + message.addProperty("fade_in_time", JsonUtil.createDurationObject(Duration.ofMillis(5000))); + message.addProperty("display_time", JsonUtil.createDurationObject(Duration.ofMillis(250))); + message.addProperty("fade_out_time", JsonUtil.createDurationObject(Duration.ofMillis(300))); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Resetting all Titles + +```java +public void resetTitlesExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.title.v1.ResetTitlesMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + diff --git a/docs/developers/modules/tntcountdown.mdx b/docs/developers/modules/tntcountdown.mdx index ac62fb4d..18a2f598 100644 --- a/docs/developers/modules/tntcountdown.mdx +++ b/docs/developers/modules/tntcountdown.mdx @@ -1,3 +1,4 @@ +import { Tab, Tabs } from 'nextra-theme-docs' import { Callout } from 'nextra-theme-docs' # TNT Countdown Module @@ -14,23 +15,22 @@ The TNT Countdown module allows you to interact with and set custom TNT timers f ## Integration +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Set TNT Countdown Ticks Option + ```java -public void setTntCountdownExample(Player viewer, ApolloEntity tntEntity, int ticks) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(apolloPlayer -> this.tntCountdownModule.setTntCountdown(apolloPlayer, tntEntity, ticks)); +public void setTntCountdownExample() { + this.tntCountdownModule.getOptions().set(TntCountdownModule.TNT_TICKS, 160); } ``` -### `setTntCountdown` Parameters - -1. `ApolloPlayer` - - The player or viewer you want to display the countdown to. -2. `ApolloEntity` - - The TNT entity you want the custom countdown to be displayed above. -3. `ticks` - - The amount of ticks the TNT entity has before exploding. - -### Applying your custom `setTntCountdown` to a TNT. +### Spawn TNT with Custom Tick amount ```java public void overrideTntCountdownExample(Player viewer) { @@ -47,6 +47,241 @@ public void overrideTntCountdownExample(Player viewer) { } ``` +### Reset TNT Countdown Ticks Options + +```java +public void clearTntCountdownOptionExample() { + this.tntCountdownModule.getOptions().remove(TntCountdownModule.TNT_TICKS, 80); +} +``` + +### `setTntCountdown` Parameters + +1. `ApolloEntity` + - The TNT entity you want the custom countdown to be displayed above. +2. `ticks` + - The amount of ticks the TNT entity has before exploding. + + + + + +### Set TNT Countdown Ticks Option + +```java +public void setTntCountdownExample() { + Map properties = new HashMap<>(); + properties.put("tnt-ticks", Value.newBuilder().setNumberValue(160).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("tnt_countdown", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + +### Spawn TNT with Custom Tick amount + +```java +private static Method entityGetter; + +static { + try { + TntCountdownProtoExample.entityGetter = Bukkit.class.getDeclaredMethod("getEntity", UUID.class); + } catch (Throwable throwable) { + // Ignore for legacy versions. + } +} + +public void overrideTntCountdownExample(Player viewer) { + Location location = viewer.getLocation(); + TNTPrimed entity = viewer.getWorld().spawn(location, TNTPrimed.class); + int customTicks = 200; + + TNTPrimed target = null; + if (TntCountdownProtoExample.entityGetter != null) { + try { + target = (TNTPrimed) TntCountdownProtoExample.entityGetter.invoke(null, entity.getUniqueId()); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + } else { + for (World world : Bukkit.getWorlds()) { + for (TNTPrimed compare : world.getEntitiesByClass(TNTPrimed.class)) { + if (compare.getUniqueId().equals(entity.getUniqueId())) { + target = compare; + break; + } + } + } + } + + if (target != null) { + target.setFuseTicks(customTicks); + } + + SetTntCountdownMessage message = SetTntCountdownMessage.newBuilder() + .setEntityId(ProtobufUtil.createEntityIdProto(entity.getEntityId(), entity.getUniqueId())) + .setDurationTicks(customTicks) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset TNT Countdown Ticks Options + +```java +public void clearTntCountdownOptionExample() { + Map properties = new HashMap<>(); + properties.put("tnt-ticks", Value.newBuilder().setNumberValue(80).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("tnt_countdown", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + +### Modify Fuse Ticks on TNT Spawn + +```java +@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) +private void onTntSpawn(EntitySpawnEvent event) { + String entityName = event.getEntityType().name(); + if (!entityName.equals("PRIMED_TNT") && !entityName.equals("TNT")) { + return; + } + + TNTPrimed primed = (TNTPrimed) event.getEntity(); + int customTicks = 200; + int defaultTicks = 80; + int currentTicks = primed.getFuseTicks(); + + if (currentTicks != defaultTicks) { + customTicks = currentTicks; + + SetTntCountdownMessage message = SetTntCountdownMessage.newBuilder() + .setEntityId(ProtobufUtil.createEntityIdProto(primed.getEntityId(), primed.getUniqueId())) + .setDurationTicks(customTicks) + .build(); + + ProtobufPacketUtil.broadcastPacket(message); + } + + primed.setFuseTicks(customTicks); +} +``` + + + + + +### Create TNT Countdown Message + +```java +private JsonObject createTNTCountdownMessage(Entity entity, int ticks) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.tntcountdown.v1.SetTntCountdownMessage"); + message.add("entity_id", JsonUtil.createEntityIdObject(entity)); + message.addProperty("duration_ticks", ticks); + return message; +} +``` + +### Set TNT Countdown Ticks Option + +```java +public void setTntCountdownExample() { + Map properties = new HashMap<>(); + properties.put("tnt-ticks", 160); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("tnt_countdown", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + +### Spawn TNT with Custom Tick amount + +```java +private static Method entityGetter; + +static { + try { + TntCountdownJsonExample.entityGetter = Bukkit.class.getDeclaredMethod("getEntity", UUID.class); + } catch (Throwable throwable) { + // Ignore for legacy versions. + } +} + +public void overrideTntCountdownExample(Player viewer) { + Location location = viewer.getLocation(); + TNTPrimed entity = viewer.getWorld().spawn(location, TNTPrimed.class); + int customTicks = 200; + + TNTPrimed target = null; + if (TntCountdownJsonExample.entityGetter != null) { + try { + target = (TNTPrimed) TntCountdownJsonExample.entityGetter.invoke(null, entity.getUniqueId()); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + } else { + for (World world : Bukkit.getWorlds()) { + for (TNTPrimed compare : world.getEntitiesByClass(TNTPrimed.class)) { + if (compare.getUniqueId().equals(entity.getUniqueId())) { + target = compare; + break; + } + } + } + } + + if (target != null) { + target.setFuseTicks(customTicks); + } + + JsonPacketUtil.sendPacket(viewer, this.createTNTCountdownMessage(entity, customTicks)); +} +``` + +### Reset TNT Countdown Ticks Options + +```java +public void clearTntCountdownOptionExample() { + Map properties = new HashMap<>(); + properties.put("tnt-ticks", 80); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("tnt_countdown", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + +### Modify Fuse Ticks on TNT Spawn + +```java +@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) +private void onTntSpawn(EntitySpawnEvent event) { + String entityName = event.getEntityType().name(); + if (!entityName.equals("PRIMED_TNT") && !entityName.equals("TNT")) { + return; + } + + TNTPrimed primed = (TNTPrimed) event.getEntity(); + int customTicks = 200; + int defaultTicks = 80; + int currentTicks = primed.getFuseTicks(); + + if (currentTicks != defaultTicks) { + customTicks = currentTicks; + + JsonPacketUtil.broadcastPacket(this.createTNTCountdownMessage(primed, customTicks)); + } + + primed.setFuseTicks(customTicks); +} +``` + + + + + ## Available options - __`TNT_TICKS`__ diff --git a/docs/developers/modules/transfer.mdx b/docs/developers/modules/transfer.mdx index 974cd394..088a5602 100644 --- a/docs/developers/modules/transfer.mdx +++ b/docs/developers/modules/transfer.mdx @@ -1,3 +1,4 @@ +import { Tab, Tabs } from 'nextra-theme-docs' import { Callout } from 'nextra-theme-docs' # Transfer Module @@ -67,7 +68,14 @@ If you own `example.com` and `server.net`, and want to auto-accept transfers bet ## Integration -### Using the Transfer Packet +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Transfer Player ```java public void transferExample(Player viewer) { @@ -104,12 +112,13 @@ public void transferExample(Player viewer) { } ``` -### Using the Ping Packet +### Ping Servers You can provide up to `10` different addresses per ping packet. + ```java public void pingExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -148,3 +157,115 @@ public void pingExample(Player viewer) { }); } ``` + + + + + +### Transfer Player + +```java +public void transferExample(Player player) { + UUID requestId = UUID.randomUUID(); + + TransferRequest transferRequestMessage = TransferRequest.newBuilder() + .setRequestId(ByteString.copyFromUtf8(requestId.toString())) + .setServerIp("mc.hypixel.net") + .build(); + + ApolloRoundtripProtoListener.getInstance() + .sendRequest(player, requestId, transferRequestMessage, TransferResponse.class) + .thenAccept(response -> { + String message = ""; + + switch (response.getStatus()) { + case STATUS_ACCEPTED: { + message = "Transfer accepted! Goodbye!"; + break; + } + + case STATUS_REJECTED: { + message = "Transfer rejected by client!"; + break; + } + } + + player.sendMessage(message); + }).exceptionally(throwable -> { + player.sendMessage("Failed to receive a response in time."); + return null; + }); +} +``` + +### Ping Servers + + + You can provide up to `10` different addresses per ping packet. + + +```java +public void pingExample(Player player) { + UUID requestId = UUID.randomUUID(); + + PingRequest pingRequestMessage = PingRequest.newBuilder() + .setRequestId(ByteString.copyFromUtf8(requestId.toString())) + .addAllServerIps(Lists.newArrayList("mc.hypixel.net", "minehut.com")) + .build(); + + ApolloRoundtripProtoListener.getInstance() + .sendRequest(player, requestId, pingRequestMessage, PingResponse.class) + .thenAccept(response -> { + for (PingData pingData : response.getPingDataList()) { + String message = ""; + + switch (pingData.getStatus()) { + // Displays successful ping request to display the server IP and the players ping to that server. + case STATUS_SUCCESS: { + message = String.format("Ping to %s is %d ms.", pingData.getServerIp(), pingData.getPing()); + break; + } + + // If the ping request times-out + case STATUS_TIMED_OUT: { + message = String.format("Failed to ping %s", pingData.getServerIp()); + break; + } + } + + player.sendMessage(message); + } + }).exceptionally(throwable -> { + player.sendMessage("Failed to receive a response in time."); + return null; + }); +} +``` + + + + + + + This example is not implemented. + + +### Transfer Player + +```java +public void transferExample(Player player) { + +} +``` + +### Ping Servers + +```java +public void pingExample(Player player) { + +} +``` + + + + diff --git a/docs/developers/modules/vignette.mdx b/docs/developers/modules/vignette.mdx index 64b37218..3a0db638 100644 --- a/docs/developers/modules/vignette.mdx +++ b/docs/developers/modules/vignette.mdx @@ -1,3 +1,5 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + # Vignette Module ## Overview @@ -8,7 +10,14 @@ The vignette module gives the ability to apply a full-screen image overlay with ## Integration -### Display vignette to a player +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Display Vignette ```java public void displayVignetteExample(Player viewer) { @@ -24,6 +33,15 @@ public void displayVignetteExample(Player viewer) { } ``` +### Reset Vignette + +```java +public void resetVignetteExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.vignetteModule::resetVignette); +} +``` + #### `Vignette` Options `.resourceLocation(String)` is the resource location of the vignette. @@ -38,11 +56,60 @@ public void displayVignetteExample(Player viewer) { .opacity(0.75f) ``` -#### Resetting the vignette for a player + + + + +### Display Vignette + +```java +public void displayVignetteExample(Player viewer) { + DisplayVignetteMessage message = DisplayVignetteMessage.newBuilder() + .setResourceLocation("textures/misc/pumpkinblur.png") + .setOpacity(0.75f) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Vignette ```java public void resetVignetteExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(this.vignetteModule::resetVignette); + ResetVignetteMessage message = ResetVignetteMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + + + + + +### Display Vignette + +```java +public void displayVignetteExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.vignette.v1.DisplayVignetteMessage"); + message.addProperty("resource_location", "textures/misc/pumpkinblur.png"); + message.addProperty("opacity", 0.75f); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Reset Vignette + +```java +public void resetVignetteExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.vignette.v1.ResetVignetteMessage"); + + JsonPacketUtil.sendPacket(viewer, message); } ``` + + + + diff --git a/docs/developers/modules/waypoint.mdx b/docs/developers/modules/waypoint.mdx index 6458bde0..560cd1ac 100644 --- a/docs/developers/modules/waypoint.mdx +++ b/docs/developers/modules/waypoint.mdx @@ -1,4 +1,5 @@ import { Tab, Tabs } from 'nextra-theme-docs' +import { Callout } from 'nextra-theme-docs' # Waypoint Module @@ -21,6 +22,15 @@ The waypoint module allows you to interact with the Waypoints mod in Lunar Clien ## Integration +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Displaying a Waypoint + ```java public void displayWaypointExample(Player viewer) { Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); @@ -44,6 +54,24 @@ public void displayWaypointExample(Player viewer) { } ``` +### Removing a Waypoint + +```java +public void removeWaypointExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.waypointModule.removeWaypoint(apolloPlayer, "KoTH")); +} +``` + +### Resetting all Waypoints + +```java +public void resetWaypointsExample(Player viewer) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(this.waypointModule::resetWaypoints); +} +``` + ### `Waypoint` Options `.name(String)` is the name of the waypoint. Keep in mind this is displayed to players. @@ -112,24 +140,105 @@ Custom colors can be created from any RGB values using `new Color(int red, int g .hidden(false) ``` -### Removing specific waypoints for a player + + + + + + Make sure the server is sending the world name to the client as show in the [Player Detection](/apollo/developers/lightweight/protobuf/player-detection) example. + + +### Displaying a Waypoint + +```java +public void displayWaypointExample(Player viewer) { + DisplayWaypointMessage message = DisplayWaypointMessage.newBuilder() + .setName("KoTH") + .setLocation(ProtobufUtil.createBlockLocationProto(new Location(viewer.getWorld(), 500, 100, 500))) + .setColor(ProtobufUtil.createColorProto(Color.ORANGE)) + .setPreventRemoval(false) + .setHidden(false) + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); +} +``` + +### Removing a Waypoint ```java public void removeWaypointExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(apolloPlayer -> this.waypointModule.removeWaypoint(apolloPlayer, "KoTH")); + RemoveWaypointMessage message = RemoveWaypointMessage.newBuilder() + .setName("KoTH") + .build(); + + ProtobufPacketUtil.sendPacket(viewer, message); } ``` -### Resetting all waypoints for a player +### Resetting all Waypoints ```java public void resetWaypointsExample(Player viewer) { - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); - apolloPlayerOpt.ifPresent(this.waypointModule::resetWaypoints); + ResetWaypointsMessage message = ResetWaypointsMessage.getDefaultInstance(); + ProtobufPacketUtil.sendPacket(viewer, message); } ``` + + + + + + Make sure the server is sending the world name to the client as show in the [Player Detection](/apollo/developers/lightweight/protobuf/player-detection) example. + + +### Displaying a Waypoint + +```java +public void displayWaypointExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.waypoint.v1.DisplayWaypointMessage"); + message.addProperty("name", "KoTH"); + message.add("location", JsonUtil.createBlockLocationObject( + new Location(Bukkit.getWorld("world"), 500, 100, 500) + )); + message.add("color", JsonUtil.createColorObject(Color.ORANGE)); + message.addProperty("prevent_removal", false); + message.addProperty("hidden", false); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Removing a Waypoint + +```java +public void removeWaypointExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.waypoint.v1.RemoveWaypointMessage"); + message.addProperty("name", "KoTH"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + +### Resetting all Waypoints + +```java +public void resetWaypointsExample(Player viewer) { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.waypoint.v1.ResetWaypointsMessage"); + + JsonPacketUtil.sendPacket(viewer, message); +} +``` + + + + + + ## Available options - __`SERVER_HANDLES_WAYPOINTS`__ diff --git a/docs/internals/lightweight.mdx b/docs/internals/lightweight.mdx deleted file mode 100644 index eed9e0e9..00000000 --- a/docs/internals/lightweight.mdx +++ /dev/null @@ -1,232 +0,0 @@ -import { Tab, Tabs } from 'nextra-theme-docs' - -# Lightweight - -Our lightweight integration allows for Apollo features to be used, without the need for running the entire Apollo plugin. We will introduce you to three different methods that all achieve the same goal, while utilizing separate approaches. At the end of the day, all the methods displayed send the JSON message through the plugin messaging channel `apollo:json`. Each method offers different trade-offs between complexity, flexibility, and performance. Choose the method that best fits your use case and environment. - -## Message format - -The message format used to communicate, follows a loosely structured JSON schema. The schema is defined using Protocol Buffers (protobuf) and includes various fields to achieve the end result, in this example-case displaying a waypoint. While the fields will change depending on the feature you're trying to implement, the `@type` will also remain. It should always be at the top, as shown. You can locate all the `@type` protos from this page: https://buf.build/lunarclient/apollo. -```JSON -{ - "@type": "type.googleapis.com/lunarclient.apollo.waypoint.v1.DisplayWaypointMessage", // The protobuf message type - "name": "KoTH", - "location": { - "world": "world", - "x": 150, - "y": 100, - "z": -150 - }, - "color": { - "color": 255 - }, - "preventRemoval": true -} -``` - -### Usage Methods -Explore each method by cycling through each tab, to find the best fit for your requirements and needs. - - - - - -### Method 1: Using the `apollo-protos` & `protobuf-java-util` libraries - -This method leverages the apollo-protos library and protobuf's native serialization mechanism, which offers efficient serialization and maintains strong typing and schema validation. It involves creating a type registry, serializing messages into protobuf format, and then converting them into JSON for transmission. - -**Steps** - -1. **Create a TypeRegistry**: Register the message types you are using. - ```java - TypeRegistry registry = TypeRegistry.newBuilder() - .add(DisplayWaypointMessage.getDescriptor()) - .add(ConfigurableSettings.getDescriptor()) - .add(OverrideConfigurableSettingsMessage.getDescriptor()) - .build(); - ``` - -2. **Create the protobuf printer with the registry**: - ```java - JsonFormat.Printer printer = JsonFormat.printer().usingTypeRegistry(registry); - ``` - -3. **Construct the messages**: - - **Enable Module Message**: - ```java - OverrideConfigurableSettingsMessage enableModuleMessage = OverrideConfigurableSettingsMessage.newBuilder() - .addConfigurableSettings( - ConfigurableSettings.newBuilder() - .setApolloModule("waypoint") - .setEnable(true) - .build() - ).build(); - ``` - - - **Display Waypoint Message**: - ```java - DisplayWaypointMessage waypointMessage = DisplayWaypointMessage.newBuilder() - .setName("KoTH") - .setLocation( - BlockLocation.newBuilder() - .setWorld("world") - .setX(150) - .setY(100) - .setZ(-150) - .build()) - .setColor( - Color.newBuilder() - .setColor(255) - .build()) - .setPreventRemoval(true) - .build(); - ``` - -4. **Pack the messages into `Any` type and serialize**: - ```java - Any enableModuleAny = Any.pack(enableModuleMessage); - Any displayWaypointAny = Any.pack(waypointMessage); - - try { - byte[] enableModuleBytes = printer.print(enableModuleAny).getBytes(); - byte[] displayWaypointBytes = printer.print(displayWaypointAny).getBytes(); - - player.sendPluginMessage(this, "apollo:json", enableModuleBytes); - player.sendPluginMessage(this, "apollo:json", displayWaypointBytes); - } catch (InvalidProtocolBufferException e) { - throw new RuntimeException(e); - } - ``` - -## Adding the repository and dependencies - - - - ```xml filename="pom.xml" - - - lunarclient - https://repo.lunarclient.dev - - - - - - com.lunarclient - apollo-protos - 1.0-SNAPSHOT - - - com.google.protobuf - protobuf-java-util - 3.25.0 - - - ``` - - - ```groovy filename="build.gradle" - repositories { - maven { - name = 'lunarclient' - url = 'https://repo.lunarclient.dev' - } - } - - dependencies { - api 'com.lunarclient:apollo-protos:1.0-SNAPSHOT' - api 'com.google.protobuf:protobuf-java-util:3.25.0' - } - ``` - - - ```kotlin filename="build.gradle.kts" - repositories { - maven { - name = "lunarclient" - url = uri("https://repo.lunarclient.dev") - } - } - - dependencies { - api("com.lunarclient:apollo-protos:1.0-SNAPSHOT") - api("com.google.protobuf:protobuf-java-util:3.25.0") - } - ``` - - - - - - - -### Method 2: Manual JSON Object Construction - -This method involves manually constructing JSON objects using a JSON library (e.g., Gson) and then converting these objects into byte arrays for transmission. It allows for dynamic and programmatic construction of JSON objects, offering flexibility in modifying the JSON structure. Available fields for each message, including their types, are available on the Buf Schema Registry at https://buf.build/lunarclient/apollo. - -**Steps** - -1. **Create JSON objects**: - - **Enable Module Message**: - ```java - JsonObject configurableSetting = new JsonObject(); - configurableSetting.addProperty("apolloModule", "waypoint"); - configurableSetting.addProperty("enable", true); - - JsonArray configurableSettingsArray = new JsonArray(); - configurableSettingsArray.add(configurableSetting); - - JsonObject settingsObject = new JsonObject(); - settingsObject.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.OverrideConfigurableSettingsMessage"); - settingsObject.add("configurableSettings", configurableSettingsArray); - - player.sendPluginMessage(this, "apollo:json", settingsObject.toString().getBytes()); - ``` - - - **Display Waypoint Message**: - ```java - JsonObject location = new JsonObject(); - location.addProperty("world", "world"); - location.addProperty("x", 150); - location.addProperty("y", 100); - location.addProperty("z", -150); - - JsonObject color = new JsonObject(); - color.addProperty("color", 255); - - JsonObject waypointObject = new JsonObject(); - waypointObject.addProperty("@type", "type.googleapis.com/lunarclient.apollo.waypoint.v1.DisplayWaypointMessage"); - waypointObject.addProperty("name", "KoTH"); - waypointObject.add("location", location); - waypointObject.add("color", color); - waypointObject.addProperty("preventRemoval", true); - - player.sendPluginMessage(this, "apollo:json", waypointObject.toString().getBytes()); - ``` - - - - - -### Method 3: Direct JSON String Serialization - -This method directly uses JSON strings to send the messages. The JSON strings are manually constructed to match the required format, offering a simple and straightforward approach without requiring external dependencies for serialization. Available fields for each message, including their types, are available on the Buf Schema Registry at https://buf.build/lunarclient/apollo. - -**Steps** - -1. **Construct JSON strings**: - ```java - String enableModuleData = "{\"@type\":\"type.googleapis.com/lunarclient.apollo.configurable.v1.OverrideConfigurableSettingsMessage\",\"configurableSettings\":[{\"apolloModule\":\"waypoint\",\"enable\":true}]}"; - String displayWaypointData = "{\"@type\":\"type.googleapis.com/lunarclient.apollo.waypoint.v1.DisplayWaypointMessage\",\"name\":\"KoTH\",\"location\":{\"world\":\"world\",\"x\":150,\"y\":100,\"z\":-150},\"color\":{\"color\":255},\"preventRemoval\":true}"; - ``` - -2. **Send the JSON strings as plugin messages**: - ```java - player.sendPluginMessage(this, "apollo:json", enableModuleData.getBytes()); - player.sendPluginMessage(this, "apollo:json", displayWaypointData.getBytes()); - ``` - - - - - diff --git a/docs/introduction.mdx b/docs/introduction.mdx index 90a5a0d8..f9ca50bb 100644 --- a/docs/introduction.mdx +++ b/docs/introduction.mdx @@ -1,3 +1,5 @@ +import { Callout } from 'nextra-theme-docs' + # Introduction Apollo is a powerful tool that allows developers to create custom integrations with Lunar Client. @@ -10,6 +12,10 @@ This documentation will provide you with all information you'll need to know to We'll cover the basics of Apollo, from changing the configuration file to integrating your own features using each module. Inside the module breakdowns, for developers, we'll include code snippets along with photos, videos and gifs related to the module to ensure you get the most out of Apollo. + + Need just the essentials? [Lightweight](/apollo/developers/lightweight/introduction) allows you to use Apollo features without the full plugin! + + ### Useful Links 🔗 [Lunar Client Website](https://www.lunarclient.com/)
diff --git a/gradle.properties b/gradle.properties index 5df2b938..e650d1e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=com.lunarclient -version=1.1.5 +version=1.1.6 description=The API for interacting with Lunar Client players. org.gradle.parallel=true diff --git a/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java b/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java index 0480a1ff..4c643033 100644 --- a/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java +++ b/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java @@ -57,6 +57,8 @@ import com.lunarclient.apollo.module.stopwatch.StopwatchModuleImpl; import com.lunarclient.apollo.module.team.TeamModule; import com.lunarclient.apollo.module.team.TeamModuleImpl; +import com.lunarclient.apollo.module.tebex.TebexModule; +import com.lunarclient.apollo.module.tebex.TebexModuleImpl; import com.lunarclient.apollo.module.title.TitleModule; import com.lunarclient.apollo.module.title.TitleModuleImpl; import com.lunarclient.apollo.module.transfer.TransferModule; @@ -92,7 +94,7 @@ @Plugin( id = "apollo", name = "Apollo-Velocity", - version = "1.1.5", + version = "1.1.6", url = "https://moonsworth.com", description = "Implementation of Apollo for Velocity", authors = {"Moonsworth"} @@ -177,6 +179,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) { .addModule(StaffModModule.class, new StaffModModuleImpl()) .addModule(StopwatchModule.class, new StopwatchModuleImpl()) .addModule(TeamModule.class, new TeamModuleImpl()) + .addModule(TebexModule.class, new TebexModuleImpl()) .addModule(TitleModule.class, new TitleModuleImpl()) .addModule(TransferModule.class, new TransferModuleImpl()) .addModule(VignetteModule.class, new VignetteModuleImpl())