From 127266cc6b5951d640eae34592fa9d6919620457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Bu=C4=8Dari=C4=87?= Date: Wed, 21 Feb 2024 19:02:32 +0100 Subject: [PATCH] Version - 1.1.0 (#127) --- .github/workflows/deploy.yml | 2 +- .../apollo/module/ApolloModule.java | 25 ++++++++++++++----- .../PacketEnrichmentModule.java | 4 +++ .../tntcountdown/TntCountdownModule.java | 14 ++++++++++- .../listeners/GeneralListenerExample.java | 4 +-- bukkit-example/src/main/resources/plugin.yml | 2 +- bukkit/build.gradle.kts | 1 + .../tntcountdown/TntCountdownModuleImpl.java | 21 +++++++++++----- .../src/platform-loader/resources/plugin.yml | 2 +- .../src/platform-loader/resources/plugin.yml | 2 +- .../module/ApolloModuleManagerImpl.java | 4 +-- deploy.sh | 4 +-- docs/developers/events.mdx | 4 +-- docs/developers/modules/packetenrichment.mdx | 5 ++++ docs/developers/modules/tntcountdown.mdx | 8 +++++- docs/developers/utilities/icons.mdx | 9 +++++++ gradle.properties | 2 +- .../apollo/ApolloVelocityPlatform.java | 2 +- 18 files changed, 87 insertions(+), 28 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 007cd28e..d1f2b077 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -52,7 +52,7 @@ jobs: run: ./gradlew publish - name: Gradle Release - if: "${{ github.ref == 'refs/heads/master' && env.STATUS == 'release' }}" + if: "${{ (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/version/')) && env.STATUS == 'release' }}" uses: softprops/action-gh-release@v1 with: draft: false diff --git a/api/src/main/java/com/lunarclient/apollo/module/ApolloModule.java b/api/src/main/java/com/lunarclient/apollo/module/ApolloModule.java index 8a1d4328..2e1fce1b 100644 --- a/api/src/main/java/com/lunarclient/apollo/module/ApolloModule.java +++ b/api/src/main/java/com/lunarclient/apollo/module/ApolloModule.java @@ -49,14 +49,27 @@ public abstract class ApolloModule implements ApolloListener { /** - * Whether to enable this module. + * Whether to enable this module builder. * - * @since 1.0.0 + * @since 1.1.0 */ - public static final SimpleOption ENABLE = Option.builder() + private static final SimpleOption.SimpleOptionBuilder ENABLE_OPTION_BUILDER = Option.builder() .comment("Set to 'true' to enable this module, otherwise set 'false'.") - .node("enable").type(TypeToken.get(Boolean.class)) - .defaultValue(true).build(); + .node("enable").type(TypeToken.get(Boolean.class)); + + /** + * Whether to enable this module with default value set to false. + * + * @since 1.1.0 + */ + public static final SimpleOption ENABLE_OPTION_OFF = ENABLE_OPTION_BUILDER.defaultValue(false).build(); + + /** + * Whether to enable this module with default value set to true. + * + * @since 1.0.0 + */ + public static final SimpleOption ENABLE_OPTION_ON = ENABLE_OPTION_BUILDER.defaultValue(true).build(); /** * Returns an array of {@link Option}s in this module. @@ -97,7 +110,7 @@ public abstract class ApolloModule implements ApolloListener { * @since 1.0.0 */ protected ApolloModule() { - this.registerOptions(ApolloModule.ENABLE); + this.registerOptions(ApolloModule.ENABLE_OPTION_ON); } /** diff --git a/api/src/main/java/com/lunarclient/apollo/module/packetenrichment/PacketEnrichmentModule.java b/api/src/main/java/com/lunarclient/apollo/module/packetenrichment/PacketEnrichmentModule.java index ad98dc7b..de359ec6 100644 --- a/api/src/main/java/com/lunarclient/apollo/module/packetenrichment/PacketEnrichmentModule.java +++ b/api/src/main/java/com/lunarclient/apollo/module/packetenrichment/PacketEnrichmentModule.java @@ -36,4 +36,8 @@ @ModuleDefinition(id = "packet_enrichment", name = "PacketEnrichment") public abstract class PacketEnrichmentModule extends ApolloModule { + protected PacketEnrichmentModule() { + this.registerOptions(ApolloModule.ENABLE_OPTION_OFF); + } + } diff --git a/api/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModule.java b/api/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModule.java index 0d179df8..f3a1ee79 100644 --- a/api/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModule.java +++ b/api/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModule.java @@ -27,6 +27,7 @@ import com.lunarclient.apollo.module.ApolloModule; import com.lunarclient.apollo.module.ModuleDefinition; import com.lunarclient.apollo.option.NumberOption; +import com.lunarclient.apollo.option.SimpleOption; import io.leangen.geantyref.TypeToken; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Range; @@ -51,9 +52,20 @@ public abstract class TntCountdownModule extends ApolloModule { .defaultValue(80).min(1).max(Integer.MAX_VALUE) .notifyClient().build(); + /** + * Whether to override the amount of ticks for TNT ignited by a plugin. + * + * @since 1.1.0 + */ + public static final SimpleOption OVERRIDE_CUSTOM_TICKS = SimpleOption.builder() + .comment("Whether to override custom TNT explosion ticks.") + .node("override-custom-ticks").type(TypeToken.get(Boolean.class)) + .defaultValue(false).notifyClient().build(); + TntCountdownModule() { this.registerOptions( - TntCountdownModule.TNT_TICKS + TntCountdownModule.TNT_TICKS, + TntCountdownModule.OVERRIDE_CUSTOM_TICKS ); } 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/listeners/GeneralListenerExample.java index fa54eca6..4b129839 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/listeners/GeneralListenerExample.java +++ b/bukkit-example/src/main/java/com/lunarclient/apollo/example/listeners/GeneralListenerExample.java @@ -43,7 +43,7 @@ public GeneralExample1() { @Listen public void onApolloRegister(ApolloRegisterPlayerEvent event) { - ((Player) event.getPlayer()).sendMessage("You have joined using LunarClient!"); + ((Player) event.getPlayer().getPlayer()).sendMessage("You have joined using LunarClient!"); } } @@ -55,7 +55,7 @@ public GeneralExample2() { } public void onApolloRegister(ApolloRegisterPlayerEvent event) { - ((Player) event.getPlayer()).sendMessage("You have joined using LunarClient!"); + ((Player) event.getPlayer().getPlayer()).sendMessage("You have joined using LunarClient!"); } } diff --git a/bukkit-example/src/main/resources/plugin.yml b/bukkit-example/src/main/resources/plugin.yml index 827fb7ce..cfe23c47 100644 --- a/bukkit-example/src/main/resources/plugin.yml +++ b/bukkit-example/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: Apollo-Example main: com.lunarclient.apollo.example.ApolloExamplePlugin -version: 1.0.9 +version: 1.1.0 author: Moonsworth depend: [ Apollo-Bukkit ] api-version: 1.13 diff --git a/bukkit/build.gradle.kts b/bukkit/build.gradle.kts index 4f588dcc..75a1a84c 100644 --- a/bukkit/build.gradle.kts +++ b/bukkit/build.gradle.kts @@ -9,6 +9,7 @@ setupDynamicDependency("adventure4", "shadowJarAdventure4", "adventure/4/", "dep dependencies { compileOnly(libs.bukkit) + compileOnly(libs.protobuf) api(project(path = ":apollo-api", configuration = "shadow")) api(project(path = ":apollo-common", configuration = "shadow")) diff --git a/bukkit/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModuleImpl.java b/bukkit/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModuleImpl.java index 73fca4c1..7c3052e8 100644 --- a/bukkit/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModuleImpl.java +++ b/bukkit/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModuleImpl.java @@ -103,20 +103,29 @@ public void setTntCountdown(ApolloEntity entity, int ticks) { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) private void onTntSpawn(EntitySpawnEvent event) { - // We only care about TNT if (event.getEntityType() != EntityType.PRIMED_TNT) { return; } TNTPrimed primed = (TNTPrimed) event.getEntity(); - int customFuse = this.getOptions().get(TntCountdownModule.TNT_TICKS); + int customTicks = this.getOptions().get(TntCountdownModule.TNT_TICKS); + int defaultTicks = TntCountdownModule.TNT_TICKS.getDefaultValue(); + int currentTicks = primed.getFuseTicks(); - // We only care about TNT with a non-standard fuse as well. - if (primed.getFuseTicks() == customFuse) { - return; + if (currentTicks != defaultTicks && !this.getOptions().get(TntCountdownModule.OVERRIDE_CUSTOM_TICKS)) { + customTicks = currentTicks; + + SetTntCountdownMessage message = SetTntCountdownMessage.newBuilder() + .setEntityId(NetworkTypes.toProtobuf(new ApolloEntity(primed.getEntityId(), primed.getUniqueId()))) + .setDurationTicks(customTicks) + .build(); + + for (ApolloPlayer viewer : Apollo.getPlayerManager().getPlayers()) { + ((AbstractApolloPlayer) viewer).sendPacket(message); + } } - primed.setFuseTicks(customFuse); + primed.setFuseTicks(customTicks); } } diff --git a/bukkit/src/platform-loader/resources/plugin.yml b/bukkit/src/platform-loader/resources/plugin.yml index e5631a73..834956ec 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.0.9 +version: 1.1.0 author: Moonsworth api-version: 1.13 soft-depend: [LunarClient-API] diff --git a/bungee/src/platform-loader/resources/plugin.yml b/bungee/src/platform-loader/resources/plugin.yml index e39fed33..d845b4a5 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.0.9 +version: 1.1.0 author: Moonsworth diff --git a/common/src/main/java/com/lunarclient/apollo/module/ApolloModuleManagerImpl.java b/common/src/main/java/com/lunarclient/apollo/module/ApolloModuleManagerImpl.java index fdb6ec99..3ee2c55b 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/ApolloModuleManagerImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/ApolloModuleManagerImpl.java @@ -83,7 +83,7 @@ public void enableModules() throws Throwable { this.loadConfiguration(module, options); // Enable the module if it is able to. - if (module.isEnabled() || module.getOptions().get(ApolloModule.ENABLE) == Boolean.FALSE) { + if (module.isEnabled() || module.getOptions().get(ApolloModule.ENABLE_OPTION_ON) == Boolean.FALSE) { continue; } @@ -106,7 +106,7 @@ public void reloadModules() throws Throwable { // Enable or disable the module depending on the setting. Boolean enable; - if ((enable = module.getOptions().get(ApolloModule.ENABLE)) != Boolean.valueOf(module.isEnabled())) { + if ((enable = module.getOptions().get(ApolloModule.ENABLE_OPTION_ON)) != Boolean.valueOf(module.isEnabled())) { if (enable == Boolean.TRUE) { EventBus.getBus().register(module); module.enable(); diff --git a/deploy.sh b/deploy.sh index 664beb25..67a44c45 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,5 +1,5 @@ # Deploy apollo to the test server set -e ./gradlew clean build -scp bukkit/build/libs/apollo-bukkit-1.0.9.jar ubuntu@build.moonsworth.com:/home/ubuntu/apollo/plugins/ -scp bukkit-example/build/libs/apollo-bukkit-example-1.0.9.jar ubuntu@build.moonsworth.com:/home/ubuntu/apollo/plugins/ +scp bukkit/build/libs/apollo-bukkit-1.1.0.jar ubuntu@build.moonsworth.com:/home/ubuntu/apollo/plugins/ +scp bukkit-example/build/libs/apollo-bukkit-example-1.1.0.jar ubuntu@build.moonsworth.com:/home/ubuntu/apollo/plugins/ diff --git a/docs/developers/events.mdx b/docs/developers/events.mdx index fa7a1d99..587ec632 100644 --- a/docs/developers/events.mdx +++ b/docs/developers/events.mdx @@ -246,7 +246,7 @@ public class GeneralExample1 implements ApolloListener { @Listen public void onApolloRegister(ApolloRegisterPlayerEvent event) { - ((Player) event.getPlayer()).sendMessage("You have joined using LunarClient!"); + ((Player) event.getPlayer().getPlayer()).sendMessage("You have joined using LunarClient!"); } } ``` @@ -261,7 +261,7 @@ public class GeneralExample2 implements ApolloListener { } public void onApolloRegister(ApolloRegisterPlayerEvent event) { - ((Player) event.getPlayer()).sendMessage("You have joined using LunarClient!"); + ((Player) event.getPlayer().getPlayer()).sendMessage("You have joined using LunarClient!"); } } ``` diff --git a/docs/developers/modules/packetenrichment.mdx b/docs/developers/modules/packetenrichment.mdx index 2068440e..4234a7f2 100644 --- a/docs/developers/modules/packetenrichment.mdx +++ b/docs/developers/modules/packetenrichment.mdx @@ -1,3 +1,4 @@ +import { Callout } from 'nextra-theme-docs' import { Tab, Tabs } from 'nextra-theme-docs' # Packet Enrichment Module @@ -6,6 +7,10 @@ import { Tab, Tabs } from 'nextra-theme-docs' The packet enrichment module provides servers with additional information about already existing packets and/or adds additional packets to provide servers with extra information about a player. + + This module is disabled by default, if you wish to use this module you will need to enable it in `config.yml`. + + ## Integration The majority of this module is handled through Apollo's [event system](/apollo/developers/events). diff --git a/docs/developers/modules/tntcountdown.mdx b/docs/developers/modules/tntcountdown.mdx index f859e988..ac62fb4d 100644 --- a/docs/developers/modules/tntcountdown.mdx +++ b/docs/developers/modules/tntcountdown.mdx @@ -9,7 +9,7 @@ The TNT Countdown module allows you to interact with and set custom TNT timers f - Adds the ability to set per TNT timers to be displayed for players using the TNT Countdown mod. - This module only changes the displayed TNT Countdown, you'll need to change the actual tnt-tick time server-side. + This module will change the actual TNT fuse time on the server, not just the countdown displayed on the client. ## Integration @@ -55,3 +55,9 @@ public void overrideTntCountdownExample(Player viewer) { - Type: `Integer` - Default: `80` - Minimum: `1` + +- __`OVERRIDE_CUSTOM_TICKS`__ + - Whether to override custom TNT explosion ticks. + - Values + - Type: `Boolean` + - Default: `false` diff --git a/docs/developers/utilities/icons.mdx b/docs/developers/utilities/icons.mdx index 4ea61539..7da8498b 100644 --- a/docs/developers/utilities/icons.mdx +++ b/docs/developers/utilities/icons.mdx @@ -9,6 +9,7 @@ Apollo adds three different icon builders, `ItemStackIcon`, `SimpleResourceLocat ## `ItemStackIcon` Builder The `ItemStackIcon` builder is used to assign an icon using a specified ItemStack name or ID. This will utilize the texture present in the player's resource pack as the icon. +If you're using a custom resource pack and want to make the icon appear as a model, you can set the `customModelData` to the models data value. On versions below 1.13 `customModelData` sets the durability instead. If your server accepts players on Minecraft versions higher than `1.8.8` then you need to use `itemName`. @@ -33,6 +34,14 @@ public final class ItemStackIcon extends Icon { */ int itemId; + /** + * Returns the icon {@link Integer} custom model data. + * + * @return the icon custom model data + * @since 1.0.7 + */ + int customModelData; + } ``` diff --git a/gradle.properties b/gradle.properties index f818001d..d8e68b8c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=com.lunarclient -version=1.0.9 +version=1.1.0 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 411ce783..7d46a50c 100644 --- a/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java +++ b/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java @@ -92,7 +92,7 @@ @Plugin( id = "apollo", name = "Apollo-Velocity", - version = "1.0.9", + version = "1.1.0", url = "https://moonsworth.com", description = "Implementation of Apollo for Velocity", authors = {"Moonsworth"}