diff --git a/.checkstyle/suppressions.xml b/.checkstyle/suppressions.xml index 77286cb1..d13c7d9d 100644 --- a/.checkstyle/suppressions.xml +++ b/.checkstyle/suppressions.xml @@ -2,7 +2,7 @@ - + diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 566632a1..152c45f5 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -10,7 +10,7 @@ body: - type: markdown attributes: value: | - Thanks for taking the time to report this issue, if you want to request a feature join our [Discord](https://discord.gg/3T9Atyb6pf). + Thanks for taking the time to report this issue, if you want to request a feature join our [Discord](https://lunarclient.dev/discord). # Checklist - type: checkboxes @@ -94,6 +94,7 @@ body: multiple: true options: - Spigot / Bukkit + - Folia - BungeeCord - Velocity - Other diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index e36bf5cd..e9b54388 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,7 +1,7 @@ blank_issues_enabled: false contact_links: - name: ❓ Questions & Feature Request - url: https://discord.gg/3T9Atyb6pf + url: https://lunarclient.dev/discord about: Join our Discord to ask questions and request features for Apollo. - name: 📄 Documentation url: https://lunarclient.dev/apollo/introduction diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 37e11db8..d409c815 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -65,3 +65,4 @@ jobs: bukkit/build/libs/apollo-bukkit-${{ env.VERSION }}.jar bungee/build/libs/apollo-bungee-${{ env.VERSION }}.jar velocity/build/libs/apollo-velocity-${{ env.VERSION }}.jar + folia/build/libs/apollo-folia-${{ env.VERSION }}.jar diff --git a/README.md b/README.md index 6d554e82..baefb25d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Apollo -[![Discord](https://img.shields.io/discord/1080556677004271666?logo=discord&label=discord)](https://discord.gg/3T9Atyb6pf) +[![Discord](https://img.shields.io/discord/1080556677004271666?logo=discord&label=discord)](https://lunarclient.dev/discord) Apollo is a powerful tool that allows developers to create custom integrations with Lunar Client. @@ -27,6 +27,7 @@ Running the following will compile the Apollo source for Java 8. The output jars can be found in the `build/libs` directory relative to each platform. - Bukkit: `bukkit/plugin/build/libs` +- Folia: `folia/build/libs` - BungeeCord: `bungee/build/libs` - Velocity: `velocity/build/libs` @@ -41,10 +42,10 @@ The Apollo project is split into several modules. - **API** - The publicly available interface for developers wishing to create custom integrations with Lunar Client. - **Common** - The abstraction used by platform modules to reduce duplicate code and implement the protocol for Lunar Client. -- **Bukkit, BungeeCord, Velocity** - Are modules that implement the common module for each respective platform. +- **Bukkit, Folia, BungeeCord, Velocity** - Are modules that implement the common module for each respective platform. Contributions can be made to Apollo by creating a pull request for improvements or fixes. For new feature ideas please consider making a -suggestion by creating an [issue](https://github.com/LunarClient/Apollo/issues) or joining our [discord](https://discord.gg/3T9Atyb6pf). +suggestion by creating an [issue](https://github.com/LunarClient/Apollo/issues) or joining our [discord](https://lunarclient.dev/discord). ## License diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 71748864..38dd6aa9 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -8,6 +8,7 @@ setupPlatforms() setupPlatformDependency("bukkit", "bukkitJar") setupPlatformDependency("bungee", "bungeeJar") setupPlatformDependency("velocity", "velocityJar") +setupPlatformDependency("folia", "foliaJar", 21) val main by sourceSets @@ -25,6 +26,9 @@ dependencies { "velocity"(main.output) "velocity"(libs.velocity) + + "folia"(main.output) + "folia"(libs.folia) } publishShadowJar() diff --git a/api/src/folia/java/com/lunarclient/apollo/FoliaApollo.java b/api/src/folia/java/com/lunarclient/apollo/FoliaApollo.java new file mode 100644 index 00000000..846c89eb --- /dev/null +++ b/api/src/folia/java/com/lunarclient/apollo/FoliaApollo.java @@ -0,0 +1,206 @@ +/* + * 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; + +import com.lunarclient.apollo.common.ApolloEntity; +import com.lunarclient.apollo.common.location.ApolloBlockLocation; +import com.lunarclient.apollo.common.location.ApolloLocation; +import com.lunarclient.apollo.common.location.ApolloPlayerLocation; +import com.lunarclient.apollo.player.ApolloPlayer; +import com.lunarclient.apollo.player.ApolloPlayerManager; +import com.lunarclient.apollo.recipients.Recipients; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import lombok.NonNull; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +/** + * Utility class for converting objects to and from their corresponding Bukkit + * representations with additional helper methods for easier integration. + * + * @since 1.1.8 + */ +public final class FoliaApollo { + + /** + * Runs a specified operation for a {@link Player}. + * + * @param player the player + * @param playerConsumer the operation to be performed + * @since 1.1.8 + */ + public static void runForPlayer(@NonNull Player player, @NonNull Consumer playerConsumer) { + runForPlayer(player.getUniqueId(), playerConsumer); + } + + /** + * Runs a specified operation for a {@link ApolloPlayer} from the provided {@link UUID}. + * + * @param playerUuid the player + * @param playerConsumer the operation to be performed + * @since 1.1.8 + */ + public static void runForPlayer(@NonNull UUID playerUuid, @NonNull Consumer playerConsumer) { + Apollo.getPlayerManager().getPlayer(playerUuid).ifPresent(playerConsumer); + } + + /** + * Converts a {@link Collection} of {@link Player}s to an {@link Recipients}. + * + * @param players the players + * @return the recipients object containing the converted ApolloPlayer objects + * @since 1.1.8 + */ + public static Recipients getRecipientsFrom(@NonNull Collection players) { + ApolloPlayerManager playerManager = Apollo.getPlayerManager(); + List apolloPlayers = players.stream() + .map(player -> playerManager.getPlayer(player.getUniqueId())) + .filter(Optional::isPresent) + .map(Optional::get) + .collect(Collectors.toList()); + + return Recipients.of(apolloPlayers); + } + + /** + * Converts a {@link Location} to an {@link ApolloLocation} object. + * + * @param location the location + * @return the converted apollo location object + * @since 1.1.8 + */ + public static ApolloLocation toApolloLocation(@NonNull Location location) { + return ApolloLocation.builder() + .world(location.getWorld().getName()) + .x(location.getX()) + .y(location.getY()) + .z(location.getZ()) + .build(); + } + + /** + * Converts a {@link Location} to an {@link ApolloBlockLocation} object. + * + * @param location the location + * @return the converted apollo block location object + * @since 1.1.8 + */ + public static ApolloBlockLocation toApolloBlockLocation(@NonNull Location location) { + return ApolloBlockLocation.builder() + .world(location.getWorld().getName()) + .x(location.getBlockX()) + .y(location.getBlockY()) + .z(location.getBlockZ()) + .build(); + } + + /** + * Converts a {@link Location} to an {@link ApolloPlayerLocation} object. + * + * @param location the location + * @return the converted apollo player location object + * @since 1.1.8 + */ + public static ApolloPlayerLocation toApolloPlayerLocation(@NonNull Location location) { + return ApolloPlayerLocation.builder() + .location(FoliaApollo.toApolloLocation(location)) + .yaw(location.getYaw()) + .pitch(location.getPitch()) + .build(); + } + + /** + * Converts a {@link Entity} to an {@link ApolloEntity} object. + * + * @param entity the entity + * @return the converted apollo entity object + * @since 1.1.8 + */ + public static ApolloEntity toApolloEntity(@NonNull Entity entity) { + return new ApolloEntity(entity.getEntityId(), entity.getUniqueId()); + } + + /** + * Converts a {@link ApolloLocation} to an {@link Location} object. + * + * @param location the apollo location + * @return the converted location object + * @since 1.1.8 + */ + public static Location toBukkitLocation(@NonNull ApolloLocation location) { + return new Location( + Bukkit.getWorld(location.getWorld()), + location.getX(), + location.getY(), + location.getZ() + ); + } + + /** + * Converts a {@link ApolloBlockLocation} to an {@link Location} object. + * + * @param location the apollo block location + * @return the converted location object + * @since 1.1.8 + */ + public static Location toBukkitLocation(@NonNull ApolloBlockLocation location) { + return new Location( + Bukkit.getWorld(location.getWorld()), + location.getX(), + location.getY(), + location.getZ() + ); + } + + /** + * Converts a {@link ApolloPlayerLocation} to an {@link Location} object. + * + * @param location the apollo location + * @return the converted location object + * @since 1.1.8 + */ + public static Location toBukkitLocation(@NonNull ApolloPlayerLocation location) { + ApolloLocation apolloLocation = location.getLocation(); + + return new Location( + Bukkit.getWorld(apolloLocation.getWorld()), + apolloLocation.getX(), + apolloLocation.getY(), + apolloLocation.getZ(), + location.getYaw(), + location.getPitch() + ); + } + + private FoliaApollo() { + } + +} diff --git a/api/src/main/java/com/lunarclient/apollo/mods/Mods.java b/api/src/main/java/com/lunarclient/apollo/mods/Mods.java index e1afdde6..6ad84734 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/Mods.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/Mods.java @@ -26,6 +26,7 @@ import com.lunarclient.apollo.mods.impl.Mod2dItems; import com.lunarclient.apollo.mods.impl.Mod3dSkins; import com.lunarclient.apollo.mods.impl.ModArmorstatus; +import com.lunarclient.apollo.mods.impl.ModAutoTextActions; import com.lunarclient.apollo.mods.impl.ModAutoTextHotkey; import com.lunarclient.apollo.mods.impl.ModBlockOutline; import com.lunarclient.apollo.mods.impl.ModBossbar; @@ -175,6 +176,7 @@ public final class Mods { ModFov.class, ModFog.class, ModAutoTextHotkey.class, + ModAutoTextActions.class, ModMumbleLink.class, Mod2dItems.class, ModBossbar.class, diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModAutoTextActions.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModAutoTextActions.java new file mode 100644 index 00000000..2f5b7072 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModAutoTextActions.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.mods.impl; + +import com.lunarclient.apollo.option.SimpleOption; +import io.leangen.geantyref.TypeToken; + +/** + * Allows you to set up certain actions to be triggered on received chat messages. + * + * @since 1.1.8 + */ +public final class ModAutoTextActions { + + /** + * No documentation available. + * + * @since 1.1.8 + */ + public static final SimpleOption ENABLED = SimpleOption.builder() + .node("auto-text-actions", "enabled").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + private ModAutoTextActions() { + } + +} 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 a72f2526..1b817fa7 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 @@ -66,6 +66,48 @@ public final class ModChat { .notifyClient() .build(); + /** + * Choose whether or not you want to stack multiple of the same messages in chat within a timeframe. + * + * @since 1.1.8 + */ + public static final SimpleOption STACK_MESSAGES_TIME_BASED = SimpleOption.builder() + .comment("Choose whether or not you want to stack multiple of the same messages in chat within a timeframe") + .node("chat", "stack-messages-time-based").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.8 + */ + public static final NumberOption TIME_BASED_STACK_MESSAGES_TIMEFRAME = NumberOption.number() + .node("chat", "time-based-stack-messages-timeframe").type(TypeToken.get(Integer.class)) + .min(1).max(60) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.8 + */ + public static final SimpleOption CHAT_STACK_IGNORE_BLANK = SimpleOption.builder() + .node("chat", "chat-stack-ignore-blank").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.8 + */ + public static final SimpleOption CHAT_STACK_IGNORE_BREAK = SimpleOption.builder() + .node("chat", "chat-stack-ignore-break").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + /** * Moves the chat up 12 pixels so it doesn't block health bar. * 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 83b71afa..fc7ea735 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 @@ -221,6 +221,26 @@ public final class ModCps { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.1.8 + */ + public static final SimpleOption REVERSE_TEXT = SimpleOption.builder() + .node("cps", "reverse-text").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.8 + */ + public static final SimpleOption IGNORE_CANCELLED_CLICKS = SimpleOption.builder() + .node("cps", "ignore-cancelled-clicks").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + private ModCps() { } diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModHypixelMod.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModHypixelMod.java index b09e3186..1edc0fcc 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModHypixelMod.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModHypixelMod.java @@ -174,6 +174,16 @@ public final class ModHypixelMod { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.1.8 + */ + public static final SimpleOption USE_BEDWARS_LEVELS_FORMAT = SimpleOption.builder() + .node("hypixel-mod", "use-bedwars-levels-format").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + /** * No documentation available. * diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModMotionBlur.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModMotionBlur.java index 3b3a3b8f..6477c9ed 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModMotionBlur.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModMotionBlur.java @@ -49,8 +49,9 @@ public final class ModMotionBlur { * * @since 1.0.0 */ - public static final SimpleOption OLD_BLUR = SimpleOption.builder() - .node("motion-blur", "old-blur").type(TypeToken.get(Boolean.class)) + public static final NumberOption VALUE = NumberOption.number() + .node("motion-blur", "value").type(TypeToken.get(Integer.class)) + .min(1).max(10) .notifyClient() .build(); @@ -59,9 +60,9 @@ public final class ModMotionBlur { * * @since 1.0.0 */ - public static final NumberOption VALUE = NumberOption.number() - .node("motion-blur", "value").type(TypeToken.get(Integer.class)) - .min(1).max(10) + @Deprecated + public static final SimpleOption OLD_BLUR = SimpleOption.builder() + .node("motion-blur", "old-blur").type(TypeToken.get(Boolean.class)) .notifyClient() .build(); diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModOneSevenVisuals.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModOneSevenVisuals.java index d9ee957e..925ee711 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModOneSevenVisuals.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModOneSevenVisuals.java @@ -43,6 +43,17 @@ public final class ModOneSevenVisuals { .notifyClient() .build(); + /** + * Provides better visual feedback when attacking while keeping vanilla behavior. + * + * @since 1.1.8 + */ + public static final SimpleOption ALWAYS_SWING = SimpleOption.builder() + .comment("Provides better visual feedback when attacking while keeping vanilla behavior") + .node("one-seven-visuals", "always-swing").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + private ModOneSevenVisuals() { } 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 359241a5..fdae8cd0 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,26 @@ public final class ModSkyblock { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.1.8 + */ + public static final SimpleOption HIGHLIGHT_END_NODES = SimpleOption.builder() + .node("skyblock", "highlight-end-nodes").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.8 + */ + public static final SimpleOption HIGHLIGHT_GLOWING_MUSHROOMS = SimpleOption.builder() + .node("skyblock", "highlight-glowing-mushrooms").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + /** * Makes Giant HP more visible by showing their HP at their feet. * diff --git a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModTimeChanger.java b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModTimeChanger.java index 4eec6e93..ec209a13 100644 --- a/api/src/main/java/com/lunarclient/apollo/mods/impl/ModTimeChanger.java +++ b/api/src/main/java/com/lunarclient/apollo/mods/impl/ModTimeChanger.java @@ -51,7 +51,7 @@ public final class ModTimeChanger { */ public static final NumberOption TIME_CHANGER_TIME = NumberOption.number() .node("time-changer", "time-changer-time").type(TypeToken.get(Integer.class)) - .min(-18000).max(-6000) + .min(0).max(24000) .notifyClient() .build(); @@ -76,6 +76,27 @@ public final class ModTimeChanger { .notifyClient() .build(); + /** + * No documentation available. + * + * @since 1.1.8 + */ + public static final SimpleOption TIME_PASSAGE = SimpleOption.builder() + .node("time-changer", "time-passage").type(TypeToken.get(Boolean.class)) + .notifyClient() + .build(); + + /** + * No documentation available. + * + * @since 1.1.8 + */ + public static final NumberOption SPEED = NumberOption.number() + .node("time-changer", "speed").type(TypeToken.get(Integer.class)) + .min(0).max(20) + .notifyClient() + .build(); + private ModTimeChanger() { } diff --git a/api/src/main/java/com/lunarclient/apollo/module/autotexthotkey/AutoTextHotkeyModule.java b/api/src/main/java/com/lunarclient/apollo/module/autotexthotkey/AutoTextHotkeyModule.java new file mode 100644 index 00000000..00db4ea6 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/autotexthotkey/AutoTextHotkeyModule.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.module.autotexthotkey; + +import com.lunarclient.apollo.module.ApolloModule; +import com.lunarclient.apollo.module.ModuleDefinition; +import com.lunarclient.apollo.option.ListOption; +import com.lunarclient.apollo.option.Option; +import com.lunarclient.apollo.option.SimpleOption; +import io.leangen.geantyref.TypeToken; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Represents the auto text hotkey module. + * + * @since 1.1.8 + */ +@ModuleDefinition(id = "auto_text_hotkey", name = "Auto Text Hotkey") +public final class AutoTextHotkeyModule extends ApolloModule { + + /** + * Block text inputs. + * + * @since 1.1.8 + */ + public static final SimpleOption BLOCK_TEXT_INPUTS = Option.builder() + .comment("Set to 'true' to block certain text inputs, otherwise 'false'.") + .node("block-text-inputs").type(TypeToken.get(Boolean.class)) + .defaultValue(false).notifyClient().build(); + + /** + * A list of text inputs that are blocked and cannot be used by the user. + * + * @since 1.1.8 + */ + public static final ListOption BLOCKED_TEXT_INPUTS = Option.list() + .comment("A list of text inputs that are blocked and cannot be used by the user.") + .node("blocked-text-inputs").type(new TypeToken>() {}) + .defaultValue(new ArrayList<>(Arrays.asList("/sellall", "/msg", "/pay"))) + .notifyClient().build(); + + /** + * Block chat message text inputs. + * + * @since 1.1.8 + */ + public static final SimpleOption BLOCK_CHAT_MESSAGE_TEXT_INPUTS = Option.builder() + .comment("Set to 'true' to block chat message text inputs, otherwise 'false'.") + .node("block-chat-message-text-inputs").type(TypeToken.get(Boolean.class)) + .defaultValue(false).notifyClient().build(); + + AutoTextHotkeyModule() { + this.registerOptions( + AutoTextHotkeyModule.BLOCK_TEXT_INPUTS, + AutoTextHotkeyModule.BLOCKED_TEXT_INPUTS, + AutoTextHotkeyModule.BLOCK_CHAT_MESSAGE_TEXT_INPUTS + ); + } + + @Override + public boolean isClientNotify() { + return true; + } + +} 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 f3a1ee79..77aa5d45 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 @@ -28,6 +28,7 @@ import com.lunarclient.apollo.module.ModuleDefinition; import com.lunarclient.apollo.option.NumberOption; import com.lunarclient.apollo.option.SimpleOption; +import com.lunarclient.apollo.recipients.Recipients; import io.leangen.geantyref.TypeToken; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Range; @@ -85,4 +86,16 @@ public boolean isClientNotify() { */ public abstract void setTntCountdown(ApolloEntity entity, @Range(from = 0, to = Integer.MAX_VALUE) int ticks); + /** + * Set the amount of ticks before the specified TNT explodes. + * + *

The given ticks must be equal to or greater than 0.

+ * + * @param recipients the recipients that are receiving the packet + * @param entity the TNT entity + * @param ticks the ticks until explosion + * @since 1.1.8 + */ + public abstract void setTntCountdown(Recipients recipients, ApolloEntity entity, @Range(from = 0, to = Integer.MAX_VALUE) int ticks); + } diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 00bd646b..819e383a 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -7,6 +7,7 @@ dependencies { implementation(libs.idea) implementation(libs.spotless) implementation(libs.shadow) + implementation(libs.asm) } dependencies { diff --git a/build-logic/src/main/kotlin/extensions.kt b/build-logic/src/main/kotlin/extensions.kt index 6be6fa1d..5fb087bf 100644 --- a/build-logic/src/main/kotlin/extensions.kt +++ b/build-logic/src/main/kotlin/extensions.kt @@ -3,10 +3,12 @@ import org.gradle.api.Project import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPublication +import org.gradle.api.tasks.compile.JavaCompile import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.jvm.tasks.Jar import org.gradle.jvm.toolchain.JavaLanguageVersion import org.gradle.kotlin.dsl.* +import org.gradle.jvm.toolchain.JavaToolchainService fun JavaPluginExtension.javaTarget(version: Int) { toolchain.languageVersion.set(JavaLanguageVersion.of(version)) @@ -45,7 +47,9 @@ fun Project.setupPlatforms() { } } -fun Project.setupPlatformDependency(configurationName: String, jarTaskName: String) { +fun Project.setupPlatformDependency(configurationName: String, + jarTaskName: String, + javaVersion: Int? = 8) { extensions.configure { val configuration = configurations.register(configurationName) @@ -62,6 +66,17 @@ fun Project.setupPlatformDependency(configurationName: String, jarTaskName: Stri } } + if (javaVersion != null) { + val javaToolchains = project.extensions.getByType(JavaToolchainService::class.java) + tasks.named(source.compileJavaTaskName) { + javaCompiler.set(javaToolchains.compilerFor { + languageVersion.set(JavaLanguageVersion.of(javaVersion)) + }) + sourceCompatibility = javaVersion.toString() + targetCompatibility = javaVersion.toString() + } + } + val jarTask by tasks.register(jarTaskName, Jar::class) { archiveClassifier.set(configurationName) from(source.output) @@ -149,7 +164,14 @@ fun Project.setupDynamicLoader() { } } -fun Project.setupDynamicDependency(configurationName: String, shadowTaskName: String, jarPath: String, jarName: String, name: String = configurationName, classifier: String = "all") { +fun Project.setupDynamicDependency( + configurationName: String, + shadowTaskName: String, + jarPath: String, + jarName: String, + name: String = configurationName, + classifier: String = "all" +) { extensions.configure { val configuration = configurations.findByName(configurationName) ?: configurations.register(configurationName).get() @@ -161,6 +183,8 @@ fun Project.setupDynamicDependency(configurationName: String, shadowTaskName: St archiveClassifier.set("${name}-${classifier}") configurations = listOf(configuration) + mustRunAfter(":extra:apollo-extra-adventure4:shadowJar") + configureExclusions() } diff --git a/bukkit-example-api/build.gradle.kts b/bukkit-example-api/build.gradle.kts new file mode 100644 index 00000000..924ea690 --- /dev/null +++ b/bukkit-example-api/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + id("apollo.base-conventions") + id("apollo.shadow-conventions") +} + +java { + javaTarget(21) +} + +dependencies { + compileOnly(project(":extra:apollo-extra-adventure4")) + compileOnly(project(path = ":apollo-api", configuration = "bukkit")) + compileOnly(project(path = ":apollo-common", configuration = "shadow")) + + compileOnly(libs.folia) + implementation(project(":apollo-bukkit-example-common")) +} diff --git a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java new file mode 100644 index 00000000..a078c371 --- /dev/null +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java @@ -0,0 +1,121 @@ +/* + * 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; + +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.ApolloExampleType; +import com.lunarclient.apollo.example.api.debug.DebugManager; +import com.lunarclient.apollo.example.api.debug.command.ApolloDebugCommand; +import com.lunarclient.apollo.example.api.debug.impl.SpamPacketDebug; +import com.lunarclient.apollo.example.api.listener.ApolloPlayerApiListener; +import com.lunarclient.apollo.example.api.module.AutoTextHotkeyApiExample; +import com.lunarclient.apollo.example.api.module.BeamApiExample; +import com.lunarclient.apollo.example.api.module.BorderApiExample; +import com.lunarclient.apollo.example.api.module.ChatApiExample; +import com.lunarclient.apollo.example.api.module.ColoredFireApiExample; +import com.lunarclient.apollo.example.api.module.CombatApiExample; +import com.lunarclient.apollo.example.api.module.CooldownApiExample; +import com.lunarclient.apollo.example.api.module.EntityApiExample; +import com.lunarclient.apollo.example.api.module.GlowApiExample; +import com.lunarclient.apollo.example.api.module.HologramApiExample; +import com.lunarclient.apollo.example.api.module.LimbApiExample; +import com.lunarclient.apollo.example.api.module.ModSettingsApiExample; +import com.lunarclient.apollo.example.api.module.NametagApiExample; +import com.lunarclient.apollo.example.api.module.NickHiderApiExample; +import com.lunarclient.apollo.example.api.module.NotificationApiExample; +import com.lunarclient.apollo.example.api.module.RichPresenceApiExample; +import com.lunarclient.apollo.example.api.module.ServerRuleApiExample; +import com.lunarclient.apollo.example.api.module.StaffModApiExample; +import com.lunarclient.apollo.example.api.module.StopwatchApiExample; +import com.lunarclient.apollo.example.api.module.TeamApiExample; +import com.lunarclient.apollo.example.api.module.TebexApiExample; +import com.lunarclient.apollo.example.api.module.TitleApiExample; +import com.lunarclient.apollo.example.api.module.TntCountdownApiExample; +import com.lunarclient.apollo.example.api.module.TransferApiExample; +import com.lunarclient.apollo.example.api.module.VignetteApiExample; +import com.lunarclient.apollo.example.api.module.WaypointApiExample; +import lombok.Getter; + +@Getter +public class ApolloApiExamplePlatform extends ApolloExamplePlugin { + + @Getter + private static ApolloApiExamplePlatform instance; + + private SpamPacketDebug spamPacketDebug; + + @Override + public void enable() { + instance = this; + } + + @Override + public void registerCommands() { + this.getCommand("apollodebug").setExecutor(new ApolloDebugCommand()); + } + + @Override + public void registerModuleExamples() { + this.setAutoTextHotkeyExample(new AutoTextHotkeyApiExample()); + this.setBeamExample(new BeamApiExample()); + this.setBorderExample(new BorderApiExample()); + this.setChatExample(new ChatApiExample()); + this.setColoredFireExample(new ColoredFireApiExample()); + this.setCombatExample(new CombatApiExample()); + this.setCooldownExample(new CooldownApiExample()); + this.setEntityExample(new EntityApiExample()); + this.setGlowExample(new GlowApiExample()); + this.setHologramExample(new HologramApiExample()); + this.setLimbExample(new LimbApiExample()); + this.setModSettingsExample(new ModSettingsApiExample()); + this.setNametagExample(new NametagApiExample()); + this.setNickHiderExample(new NickHiderApiExample()); + this.setNotificationExample(new NotificationApiExample()); + this.setRichPresenceExample(new RichPresenceApiExample()); + this.setServerRuleExample(new ServerRuleApiExample()); + this.setStaffModExample(new StaffModApiExample()); + this.setStopwatchExample(new StopwatchApiExample()); + this.setTeamExample(new TeamApiExample()); + this.setTebexExample(new TebexApiExample()); + this.setTitleExample(new TitleApiExample()); + this.setTntCountdownExample(new TntCountdownApiExample()); + this.setTransferExample(new TransferApiExample()); + this.setVignetteExample(new VignetteApiExample()); + this.setWaypointExample(new WaypointApiExample()); + } + + @Override + public void registerListeners() { + this.spamPacketDebug = new SpamPacketDebug(); + + new DebugManager(); + new ApolloPlayerApiListener(this); + } + + @Override + public ApolloExampleType getType() { + return ApolloExampleType.API; + } + +} diff --git a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/Debug.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/Debug.java new file mode 100644 index 00000000..0b4f4c9a --- /dev/null +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/Debug.java @@ -0,0 +1,108 @@ +/* + * 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.debug; + +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import java.util.List; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; + +public abstract class Debug implements Listener { + + public static final World DEBUG_WORLD = Bukkit.getWorld("world"); + + protected final Player player; + + private List steps; + private int phase; + protected boolean failed; + + public Debug(Player player) { + this.player = player; + this.steps = this.steps(); + this.phase = 1; + + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getInstance()); + } + + public abstract List steps(); + + public abstract Location startingLocation(); + + public abstract double allowedOffset(); + + public void start() { + this.player.teleport(this.startingLocation()); + + Bukkit.getScheduler().runTaskLater( + ApolloExamplePlugin.getInstance(), + () -> this.nextStepOrEnd(), 20L + ); + } + + public void nextStepOrEnd() { + if (this.steps.isEmpty()) { + this.end(false); + return; + } + + DebugTask activeTask = this.steps.remove(0); + if (activeTask == null) { + this.end(false); + return; + } + + this.player.sendMessage("Phase " + ++this.phase); + activeTask.run(this.player); + + Bukkit.getScheduler().runTaskLater( + ApolloExamplePlugin.getInstance(), + () -> this.nextStepOrEnd(), activeTask.getDurationTicks() + ); + } + + public void fail() { + this.failed = true; + this.player.sendMessage(ChatColor.RED + "Failed testing at phase " + this.phase); + } + + public void end(boolean forced) { + if (forced) { + this.player.sendMessage(ChatColor.DARK_RED + "Stopped testing..."); + } else if (this.failed) { + this.player.sendMessage(ChatColor.RED + "Failed testing..."); + } else { + this.player.sendMessage(ChatColor.GREEN + "Passed testing..."); + } + + HandlerList.unregisterAll(this); + DebugManager.getInstance().remove(this.player); + } + +} diff --git a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/DebugManager.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/DebugManager.java new file mode 100644 index 00000000..5dc4208b --- /dev/null +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/DebugManager.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.api.debug; + +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.api.debug.payload.PayloadListener; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import lombok.Getter; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +public class DebugManager implements Listener { + + @Getter + private static DebugManager instance; + + private final Map players; + + public DebugManager() { + instance = this; + + this.players = new HashMap<>(); + + new PayloadListener(); + + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getInstance()); + } + + public void remove(Player player) { + this.players.remove(player.getUniqueId()); + } + + public void start(Player player, Debug debug) { + if (this.players.containsKey(player.getUniqueId())) { + player.sendMessage("Already debugging!"); + return; + } + + this.players.put(player.getUniqueId(), debug); + debug.start(); + + player.sendMessage("Starting debug!"); + } + + public void stop(Player player) { + Debug debug = this.players.remove(player.getUniqueId()); + + if (debug == null) { + player.sendMessage("Not debugging!"); + return; + } + + debug.end(true); + } + +} diff --git a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/DebugTask.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/DebugTask.java new file mode 100644 index 00000000..568f0776 --- /dev/null +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/DebugTask.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.api.debug; + +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.player.ApolloPlayer; +import java.util.function.BiConsumer; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.bukkit.entity.Player; + +@Getter +@RequiredArgsConstructor +public class DebugTask { + + private final int durationTicks; + private final BiConsumer action; + private final String message; + + public void run(Player player) { + Apollo.getPlayerManager().getPlayer(player.getUniqueId()) + .ifPresent(apolloPlayer -> { + player.sendMessage(this.message); + this.action.accept(player, apolloPlayer); + }); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/debug/ApolloDebugCommand.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/command/ApolloDebugCommand.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/debug/ApolloDebugCommand.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/command/ApolloDebugCommand.java index 77373e72..b7d71911 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/debug/ApolloDebugCommand.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/command/ApolloDebugCommand.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.common.commands.debug; +package com.lunarclient.apollo.example.api.debug.command; import com.lunarclient.apollo.common.ApolloComponent; import net.kyori.adventure.text.Component; @@ -51,13 +51,19 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command .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("/apollodebug borders [start|stop] ", NamedTextColor.WHITE)) + .append(Component.text("# Border collision test.", 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); + } else if (args[0].equalsIgnoreCase("borders")) { + return new BordersCommand().onCommand(sender, command, label, args); } return true; } + } diff --git a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/command/BordersCommand.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/command/BordersCommand.java new file mode 100644 index 00000000..093b7704 --- /dev/null +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/command/BordersCommand.java @@ -0,0 +1,90 @@ +/* + * 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.debug.command; + +import com.lunarclient.apollo.common.ApolloComponent; +import com.lunarclient.apollo.example.api.debug.DebugManager; +import com.lunarclient.apollo.example.api.debug.impl.BorderCollisionTest; +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 BordersCommand 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; + DebugManager debugManager = DebugManager.getInstance(); + + if (args.length < 2) { + this.sendUsage(player); + return true; + } + + switch (args[1].toLowerCase()) { + case "start": { + debugManager.start(player, new BorderCollisionTest(player)); + break; + } + + case "stop": { + debugManager.stop(player); + 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 borders start", NamedTextColor.WHITE)) + .append(Component.text("# Starts the borders collision test, bouncing you towards the border walls", NamedTextColor.GREEN)) + .appendNewline() + .append(Component.text("/apollodebug borders stop ", NamedTextColor.WHITE)) + .append(Component.text("# Stop the borders collision test.", NamedTextColor.GREEN)) + .appendNewline() + .append(Component.text("-------------------------------------", NamedTextColor.GRAY, TextDecoration.STRIKETHROUGH)) + .build() + )); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/debug/SpamPacketsCommand.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/command/SpamPacketsCommand.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/debug/SpamPacketsCommand.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/command/SpamPacketsCommand.java index 8c2379f9..57f90b28 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/debug/SpamPacketsCommand.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/command/SpamPacketsCommand.java @@ -21,11 +21,11 @@ * 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; +package com.lunarclient.apollo.example.api.debug.command; import com.lunarclient.apollo.common.ApolloComponent; -import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.debug.SpamPacketDebug; +import com.lunarclient.apollo.example.api.ApolloApiExamplePlatform; +import com.lunarclient.apollo.example.api.debug.impl.SpamPacketDebug; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; @@ -37,7 +37,7 @@ public class SpamPacketsCommand implements CommandExecutor { - private final SpamPacketDebug spamPacketDebug = ApolloExamplePlugin.getPlugin().getSpamPacketDebug(); + private final SpamPacketDebug spamPacketDebug = ApolloApiExamplePlatform.getInstance().getSpamPacketDebug(); @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { @@ -101,4 +101,5 @@ private void sendUsage(Player player) { .build() )); } + } diff --git a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/impl/BorderCollisionTest.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/impl/BorderCollisionTest.java new file mode 100644 index 00000000..aa1f39b3 --- /dev/null +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/impl/BorderCollisionTest.java @@ -0,0 +1,201 @@ +/* + * 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.debug.impl; + +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.common.cuboid.Cuboid2D; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.api.debug.Debug; +import com.lunarclient.apollo.example.api.debug.DebugTask; +import com.lunarclient.apollo.module.border.Border; +import com.lunarclient.apollo.module.border.BorderModule; +import java.awt.Color; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.NumberConversions; +import org.bukkit.util.Vector; + +public class BorderCollisionTest extends Debug { + + private final BorderModule borderModule = Apollo.getModuleManager().getModule(BorderModule.class); + private final Cuboid2D border = Cuboid2D.builder() + .minX(200).minZ(200) + .maxX(200).maxZ(200) + .build(); + + public BorderCollisionTest(Player player) { + super(player); + } + + @Override + public Location startingLocation() { + return new Location(DEBUG_WORLD, 200.5D, 100D, 200.5D); + } + + @Override + public double allowedOffset() { + return 1.0D; + } + + @Override + public List steps() { + List tasks = new LinkedList<>(); + + tasks.add(new DebugTask(1, (player, apolloPlayer) -> { + this.borderModule.displayBorder(apolloPlayer, this.createBorder() + .id("border-debug") + .bounds(this.border) + .build()); + }, "Displaying 1x1 Border")); + + tasks.add(new DebugTask(60, (player, apolloPlayer) -> { + new BounceTask(10, 3); + }, "Boucning Player")); + + tasks.add(new DebugTask(10, (player, apolloPlayer) -> { + this.borderModule.removeBorder(apolloPlayer, "border-debug"); + }, "Clear Border")); + + tasks.add(new DebugTask(10, (player, apolloPlayer) -> { + player.teleport(this.startingLocation()); + }, "Teleporting to starting location")); + + tasks.add(new DebugTask(1, (player, apolloPlayer) -> { + this.borderModule.displayBorder(apolloPlayer, this.createBorder() + .id("border-debug-north") + .bounds(Cuboid2D.builder() + .minX(200).maxX(200) + .minZ(199).maxZ(199) + .build()) + .build()); + + this.borderModule.displayBorder(apolloPlayer, this.createBorder() + .id("border-debug-east") + .bounds(Cuboid2D.builder() + .minX(201).maxX(201) + .minZ(200).maxZ(200) + .build()) + .build()); + + this.borderModule.displayBorder(apolloPlayer, this.createBorder() + .id("border-debug-south") + .bounds(Cuboid2D.builder() + .minX(200).maxX(200) + .minZ(201).maxZ(201) + .build()) + .build()); + + this.borderModule.displayBorder(apolloPlayer, this.createBorder() + .id("border-debug-west") + .bounds(Cuboid2D.builder() + .minX(199).maxX(199) + .minZ(200).maxZ(200) + .build()) + .build()); + }, "Displaying 4 1x1 Borders")); + + tasks.add(new DebugTask(60, (player, apolloPlayer) -> { + new BounceTask(10, 3); + }, "Boucning Player")); + + tasks.add(new DebugTask(10, (player, apolloPlayer) -> { + this.borderModule.removeBorder(apolloPlayer, "border-debug-north"); + this.borderModule.removeBorder(apolloPlayer, "border-debug-east"); + this.borderModule.removeBorder(apolloPlayer, "border-debug-south"); + this.borderModule.removeBorder(apolloPlayer, "border-debug-west"); + }, "Clear Borders")); + + return tasks; + } + + private Border.BorderBuilder createBorder() { + return Border.builder() + .world(DEBUG_WORLD.getName()) + .cancelEntry(true) + .cancelExit(true) + .canShrinkOrExpand(false) + .color(Color.RED) + .durationTicks(1000); + } + + private void bouncePlayer(Player player) { + ThreadLocalRandom random = ThreadLocalRandom.current(); + + double x = (random.nextDouble() - 0.5) * 2; + double y = random.nextDouble() * 1.2 + 0.1; + double z = (random.nextDouble() - 0.5) * 2; + + Vector velocity = new Vector(x, y, z); + player.setVelocity(velocity); + } + + @EventHandler(ignoreCancelled = true) + private void onPlayerMove(PlayerMoveEvent event) { + Player player = event.getPlayer(); + if (player != this.player || this.failed) { + return; + } + + Location location = player.getLocation(); + + Location startingLocation = this.startingLocation(); + double distance = Math.sqrt(NumberConversions.square(location.getX() - startingLocation.getX()) + + NumberConversions.square(location.getZ() - startingLocation.getZ())); + + if (distance > this.allowedOffset()) { + this.fail(); + } + } + + private class BounceTask extends BukkitRunnable { + + private final int amount; + + private int bounces; + + BounceTask(int amount, int ticks) { + this.amount = amount; + + this.runTaskTimer( + ApolloExamplePlugin.getInstance(), + ticks, ticks + ); + } + + @Override + public void run() { + BorderCollisionTest.this.bouncePlayer(player); + + if (++this.bounces == this.amount) { + this.cancel(); + } + } + } +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/debug/SpamPacketDebug.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/impl/SpamPacketDebug.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/debug/SpamPacketDebug.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/impl/SpamPacketDebug.java index 5d9de7e2..279b6163 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/debug/SpamPacketDebug.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/impl/SpamPacketDebug.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.debug; +package com.lunarclient.apollo.example.api.debug.impl; import com.google.common.collect.Maps; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.api.ApolloApiExamplePlatform; import com.lunarclient.apollo.network.NetworkOptions; import java.util.Map; import java.util.UUID; @@ -40,7 +40,7 @@ public class SpamPacketDebug implements Listener { private final Map players = Maps.newConcurrentMap(); public SpamPacketDebug() { - Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); + Bukkit.getPluginManager().registerEvents(this, ApolloApiExamplePlatform.getInstance()); } @EventHandler diff --git a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/payload/PayloadListener.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/payload/PayloadListener.java new file mode 100644 index 00000000..18993c0b --- /dev/null +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/debug/payload/PayloadListener.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.api.debug.payload; + +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.event.ApolloListener; +import com.lunarclient.apollo.event.EventBus; +import com.lunarclient.apollo.event.Listen; +import com.lunarclient.apollo.event.player.ApolloPlayerHandshakeEvent; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.scheduler.BukkitTask; + +public class PayloadListener implements Listener, ApolloListener { + + private final Set handshakeUuids; + private final Map tasks; + + public PayloadListener() { + this.handshakeUuids = new HashSet<>(); + this.tasks = new HashMap<>(); + + EventBus.getBus().register(this); + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getInstance()); + } + + private void checkReceivedPackets(Player player) { + UUID uuid = player.getUniqueId(); + BukkitTask task = Bukkit.getScheduler().runTaskLater(ApolloExamplePlugin.getInstance(), () -> { + boolean register = Apollo.getPlayerManager().hasSupport(uuid); + boolean handshake = this.handshakeUuids.contains(uuid); + + if (register && !handshake) { + player.sendMessage(ChatColor.RED + "Received Apollo register but not the handshake!"); + } else if (!register && !handshake) { + player.sendMessage(ChatColor.RED + "Failed to receive Apollo register and handshake!"); + } + }, 20 * 10); + + this.tasks.put(player.getUniqueId(), task); + } + + @EventHandler + private void onPlayerJoin(PlayerJoinEvent event) { + this.checkReceivedPackets(event.getPlayer()); + } + + @EventHandler + private void onPlayerQuit(PlayerQuitEvent event) { + UUID uuid = event.getPlayer().getUniqueId(); + BukkitTask task = this.tasks.remove(uuid); + + if (task != null) { + task.cancel(); + } + + this.handshakeUuids.remove(uuid); + } + + @Listen + private void onApolloPlayerHandshake(ApolloPlayerHandshakeEvent event) { + this.handshakeUuids.add(event.getPlayer().getUniqueId()); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/listeners/ApolloGeneralApiListener.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/general/ApolloEventListenerExample.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/listeners/ApolloGeneralApiListener.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/general/ApolloEventListenerExample.java index afe1c0c1..f3291270 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/listeners/ApolloGeneralApiListener.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/general/ApolloEventListenerExample.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.api.listeners; +package com.lunarclient.apollo.example.api.general; 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 ApolloGeneralApiListener { +public class ApolloEventListenerExample { // Method 1 public class GeneralExample1 implements ApolloListener { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/ApolloGeneralExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/general/ApolloGeneralExample.java similarity index 98% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/ApolloGeneralExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/general/ApolloGeneralExample.java index 1be6f101..8469de98 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/ApolloGeneralExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/general/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.api; +package com.lunarclient.apollo.example.api.general; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.module.border.BorderModule; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/listeners/ApolloPlayerApiListener.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/listener/ApolloPlayerApiListener.java similarity index 74% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/listeners/ApolloPlayerApiListener.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/listener/ApolloPlayerApiListener.java index 47e7bf04..53a89c20 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/listeners/ApolloPlayerApiListener.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/listener/ApolloPlayerApiListener.java @@ -21,25 +21,25 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.api.listeners; +package com.lunarclient.apollo.example.api.listener; 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.api.examples.TeamApiExample; +import com.lunarclient.apollo.example.api.module.TeamApiExample; import com.lunarclient.apollo.player.ApolloPlayer; import org.bukkit.entity.Player; public class ApolloPlayerApiListener implements ApolloListener { - private final ApolloExamplePlugin plugin; + private final ApolloExamplePlugin example; private final TeamApiExample.Team defaultTeam; - public ApolloPlayerApiListener(ApolloExamplePlugin plugin) { - this.plugin = plugin; - this.defaultTeam = ((TeamApiExample) this.plugin.getTeamExample()).createTeam(); + public ApolloPlayerApiListener(ApolloExamplePlugin example) { + this.example = example; + this.defaultTeam = ((TeamApiExample) this.example.getTeamExample()).createTeam(); EventBus.getBus().register(this); } @@ -56,11 +56,11 @@ private void onApolloRegister(ApolloRegisterPlayerEvent event) { // Default team view markers this.defaultTeam.addMember(player); - this.plugin.getBeamExample().displayBeamExample(player); - this.plugin.getBorderExample().displayBorderExample(player); - this.plugin.getCooldownExample().displayCooldownItemExample(player); - this.plugin.getNametagExample().overrideNametagExample(player); - this.plugin.getWaypointExample().displayWaypointExample(player); + this.example.getBeamExample().displayBeamExample(player); + this.example.getBorderExample().displayBorderExample(player); + this.example.getCooldownExample().displayCooldownItemExample(player); + this.example.getNametagExample().overrideNametagExample(player); + this.example.getWaypointExample().displayWaypointExample(player); } } diff --git a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/AutoTextHotkeyApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/AutoTextHotkeyApiExample.java new file mode 100644 index 00000000..c907e572 --- /dev/null +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/AutoTextHotkeyApiExample.java @@ -0,0 +1,48 @@ +/* + * 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.module; + +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample; +import com.lunarclient.apollo.module.autotexthotkey.AutoTextHotkeyModule; +import com.lunarclient.apollo.option.Options; +import java.util.List; + +public class AutoTextHotkeyApiExample extends AutoTextHotkeyExample { + + private final AutoTextHotkeyModule autoTextHotkeyModule = Apollo.getModuleManager().getModule(AutoTextHotkeyModule.class); + + @Override + public void setBlockedTextInputs(List blockedTextInputs) { + Options options = this.autoTextHotkeyModule.getOptions(); + options.set(AutoTextHotkeyModule.BLOCK_TEXT_INPUTS, true); + options.set(AutoTextHotkeyModule.BLOCKED_TEXT_INPUTS, blockedTextInputs); + } + + @Override + public void setBlockChatMesssageTextInputs(boolean value) { + this.autoTextHotkeyModule.getOptions().set(AutoTextHotkeyModule.BLOCK_CHAT_MESSAGE_TEXT_INPUTS, value); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/BeamApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/BeamApiExample.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/BeamApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/BeamApiExample.java index c0abd96a..26ba3416 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/BeamApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/BeamApiExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.api.examples; +package com.lunarclient.apollo.example.api.module; 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.example.module.impl.BeamExample; import com.lunarclient.apollo.module.beam.Beam; import com.lunarclient.apollo.module.beam.BeamModule; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/BorderApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/BorderApiExample.java similarity index 96% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/BorderApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/BorderApiExample.java index 1df60349..2bc7803e 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/BorderApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/BorderApiExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.api.examples; +package com.lunarclient.apollo.example.api.module; 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.example.module.impl.BorderExample; import com.lunarclient.apollo.module.border.Border; import com.lunarclient.apollo.module.border.BorderModule; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ChatApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/ChatApiExample.java similarity index 66% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ChatApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/ChatApiExample.java index 317d2826..802f43ee 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ChatApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/ChatApiExample.java @@ -21,15 +21,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.ChatExample; +import com.lunarclient.apollo.example.module.impl.ChatExample; +import com.lunarclient.apollo.example.util.ServerUtil; import com.lunarclient.apollo.module.chat.ChatModule; import com.lunarclient.apollo.recipients.Recipients; +import java.util.concurrent.atomic.AtomicInteger; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.Bukkit; import org.bukkit.scheduler.BukkitRunnable; public class ChatApiExample extends ChatExample { @@ -38,6 +41,14 @@ public class ChatApiExample extends ChatExample { @Override public void displayLiveChatMessageExample() { + if (ServerUtil.isFolia()) { + this.runFoliaChatMessageTask(); + } else { + this.runBukkitChatMessageTask(); + } + } + + private void runBukkitChatMessageTask() { BukkitRunnable runnable = new BukkitRunnable() { private int countdown = 5; @@ -63,7 +74,29 @@ public void run() { } }; - runnable.runTaskTimer(ApolloExamplePlugin.getPlugin(), 0L, 20L); + runnable.runTaskTimer(ApolloExamplePlugin.getInstance(), 1L, 20L); + } + + private void runFoliaChatMessageTask() { + AtomicInteger countdown = new AtomicInteger(5); + + Bukkit.getGlobalRegionScheduler().runAtFixedRate(ApolloExamplePlugin.getInstance(), task -> { + int seconds = countdown.getAndDecrement(); + if (seconds > 0) { + ChatApiExample.this.chatModule.displayLiveChatMessage(Recipients.ofEveryone(), + Component.text("Game starting in ", NamedTextColor.GREEN) + .append(Component.text(seconds, NamedTextColor.BLUE)), + 13 + ); + } else { + ChatApiExample.this.chatModule.displayLiveChatMessage(Recipients.ofEveryone(), + Component.text("Game started! ", NamedTextColor.GREEN), + 13 + ); + + task.cancel(); + } + }, 1L, 20L); } @Override diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ColoredFireApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/ColoredFireApiExample.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ColoredFireApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/ColoredFireApiExample.java index bfc16dde..87437218 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ColoredFireApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/ColoredFireApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.ColoredFireExample; +import com.lunarclient.apollo.example.module.impl.ColoredFireExample; import com.lunarclient.apollo.module.coloredfire.ColoredFireModule; import com.lunarclient.apollo.player.ApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/CombatApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/CombatApiExample.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/CombatApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/CombatApiExample.java index 7d48b4ca..72623091 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/CombatApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/CombatApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.CombatExample; +import com.lunarclient.apollo.example.module.impl.CombatExample; import com.lunarclient.apollo.module.combat.CombatModule; public class CombatApiExample extends CombatExample { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/CooldownApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/CooldownApiExample.java similarity index 96% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/CooldownApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/CooldownApiExample.java index 9c44d982..a58aec78 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/CooldownApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/CooldownApiExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.api.examples; +package com.lunarclient.apollo.example.api.module; 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.example.module.impl.CooldownExample; import com.lunarclient.apollo.module.cooldown.Cooldown; import com.lunarclient.apollo.module.cooldown.CooldownModule; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/EntityApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/EntityApiExample.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/EntityApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/EntityApiExample.java index 4b69d44b..682bc6ea 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/EntityApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/EntityApiExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.common.ApolloEntity; -import com.lunarclient.apollo.example.common.modules.impl.EntityExample; +import com.lunarclient.apollo.example.module.impl.EntityExample; import com.lunarclient.apollo.module.entity.EntityModule; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.List; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/GlowApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/GlowApiExample.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/GlowApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/GlowApiExample.java index a42af2c3..77ce08b9 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/GlowApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/GlowApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.GlowExample; +import com.lunarclient.apollo.example.module.impl.GlowExample; import com.lunarclient.apollo.module.glow.GlowModule; import com.lunarclient.apollo.player.ApolloPlayer; import com.lunarclient.apollo.recipients.Recipients; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/HologramApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/HologramApiExample.java similarity index 96% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/HologramApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/HologramApiExample.java index fd71257f..9cb3ddd4 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/HologramApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/HologramApiExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.api.examples; +package com.lunarclient.apollo.example.api.module; 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.example.module.impl.HologramExample; import com.lunarclient.apollo.module.hologram.Hologram; import com.lunarclient.apollo.module.hologram.HologramModule; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/LimbApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/LimbApiExample.java similarity index 96% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/LimbApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/LimbApiExample.java index a4704fda..b9a75504 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/LimbApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/LimbApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.LimbExample; +import com.lunarclient.apollo.example.module.impl.LimbExample; import com.lunarclient.apollo.module.limb.ArmorPiece; import com.lunarclient.apollo.module.limb.BodyPart; import com.lunarclient.apollo.module.limb.LimbModule; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ModSettingsApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/ModSettingsApiExample.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ModSettingsApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/ModSettingsApiExample.java index 9d4fbbdc..e9c5dc31 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ModSettingsApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/ModSettingsApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.ModSettingsExample; +import com.lunarclient.apollo.example.module.impl.ModSettingsExample; import com.lunarclient.apollo.mods.impl.ModLighting; import com.lunarclient.apollo.module.modsetting.ModSettingModule; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NametagApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/NametagApiExample.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NametagApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/NametagApiExample.java index b6bcd544..f3ded5b8 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NametagApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/NametagApiExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.api.examples; +package com.lunarclient.apollo.example.api.module; import com.google.common.collect.Lists; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.NametagExample; +import com.lunarclient.apollo.example.module.impl.NametagExample; import com.lunarclient.apollo.module.nametag.Nametag; import com.lunarclient.apollo.module.nametag.NametagModule; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NickHiderApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/NickHiderApiExample.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NickHiderApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/NickHiderApiExample.java index 30341d00..9f0ceeb8 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NickHiderApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/NickHiderApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.NickHiderExample; +import com.lunarclient.apollo.example.module.impl.NickHiderExample; import com.lunarclient.apollo.module.nickhider.NickHiderModule; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.Optional; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NotificationApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/NotificationApiExample.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NotificationApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/NotificationApiExample.java index 54ede6f2..dd172b5a 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/NotificationApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/NotificationApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.NotificationExample; +import com.lunarclient.apollo.example.module.impl.NotificationExample; import com.lunarclient.apollo.module.notification.Notification; import com.lunarclient.apollo.module.notification.NotificationModule; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/RichPresenceApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/RichPresenceApiExample.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/RichPresenceApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/RichPresenceApiExample.java index 53673969..819d37be 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/RichPresenceApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/RichPresenceApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.RichPresenceExample; +import com.lunarclient.apollo.example.module.impl.RichPresenceExample; import com.lunarclient.apollo.module.richpresence.RichPresenceModule; import com.lunarclient.apollo.module.richpresence.ServerRichPresence; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ServerRuleApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/ServerRuleApiExample.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ServerRuleApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/ServerRuleApiExample.java index 7f1e7a87..8658f41c 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/ServerRuleApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/ServerRuleApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.ServerRuleExample; +import com.lunarclient.apollo.example.module.impl.ServerRuleExample; import com.lunarclient.apollo.module.serverrule.ServerRuleModule; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.Optional; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/StaffModApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/StaffModApiExample.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/StaffModApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/StaffModApiExample.java index 67db3782..11d6a833 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/StaffModApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/StaffModApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.StaffModExample; +import com.lunarclient.apollo.example.module.impl.StaffModExample; import com.lunarclient.apollo.module.staffmod.StaffMod; import com.lunarclient.apollo.module.staffmod.StaffModModule; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/StopwatchApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/StopwatchApiExample.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/StopwatchApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/StopwatchApiExample.java index 1a5bd858..5bcaf6fe 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/StopwatchApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/StopwatchApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.StopwatchExample; +import com.lunarclient.apollo.example.module.impl.StopwatchExample; import com.lunarclient.apollo.module.stopwatch.StopwatchModule; import com.lunarclient.apollo.player.ApolloPlayer; import java.util.Optional; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TeamApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TeamApiExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TeamApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TeamApiExample.java index 943099be..c25a5fa9 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TeamApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TeamApiExample.java @@ -21,14 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.api.examples; +package com.lunarclient.apollo.example.api.module; 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.example.module.impl.TeamExample; +import com.lunarclient.apollo.example.util.ServerUtil; import com.lunarclient.apollo.module.team.TeamMember; import com.lunarclient.apollo.module.team.TeamModule; import java.awt.Color; @@ -37,6 +38,7 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -46,7 +48,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.scheduler.BukkitRunnable; public class TeamApiExample extends TeamExample implements Listener { @@ -56,9 +57,13 @@ public class TeamApiExample extends TeamExample implements Listener { private final Map teamsByPlayerUuid = Maps.newHashMap(); public TeamApiExample() { - new TeamUpdateTask(); + if (ServerUtil.isFolia()) { + this.runFoliaTeamUpdateTask(); + } else { + this.runBukkitTeamUpdateTask(); + } - Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getInstance()); } @EventHandler @@ -95,6 +100,18 @@ public void deleteTeam(UUID teamId) { } } + private void runBukkitTeamUpdateTask() { + Bukkit.getScheduler().runTaskTimerAsynchronously(ApolloExamplePlugin.getInstance(), () -> { + this.teamsByTeamId.values().forEach(Team::refresh); + }, 1L, 1L); + } + + private void runFoliaTeamUpdateTask() { + Bukkit.getAsyncScheduler().runAtFixedRate(ApolloExamplePlugin.getInstance(), task -> { + this.teamsByTeamId.values().forEach(Team::refresh); + }, 50L, 50L, TimeUnit.MILLISECONDS); + } + public class Team { private final UUID teamId; @@ -175,19 +192,6 @@ public int 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() { - TeamApiExample.this.teamsByTeamId.values().forEach(Team::refresh); - } - } - @Override public void createTeam(Player player) { Optional teamOpt = this.getByPlayerUuid(player.getUniqueId()); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TebexApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TebexApiExample.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TebexApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TebexApiExample.java index c318a3e1..37695905 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TebexApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TebexApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.TebexExample; +import com.lunarclient.apollo.example.module.impl.TebexExample; import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport; import com.lunarclient.apollo.module.tebex.TebexModule; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TitleApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TitleApiExample.java similarity index 96% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TitleApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TitleApiExample.java index e57bcff7..78e884c0 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TitleApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TitleApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.TitleExample; +import com.lunarclient.apollo.example.module.impl.TitleExample; import com.lunarclient.apollo.module.title.Title; import com.lunarclient.apollo.module.title.TitleModule; import com.lunarclient.apollo.module.title.TitleType; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TntCountdownApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TntCountdownApiExample.java similarity index 51% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TntCountdownApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TntCountdownApiExample.java index d2f8a609..c72a1796 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TntCountdownApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TntCountdownApiExample.java @@ -21,24 +21,30 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.common.ApolloEntity; -import com.lunarclient.apollo.example.common.modules.impl.TntCountdownExample; +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.module.impl.TntCountdownExample; import com.lunarclient.apollo.module.tntcountdown.TntCountdownModule; -import com.lunarclient.apollo.player.ApolloPlayer; -import java.util.Optional; -import org.bukkit.Location; -import org.bukkit.World; +import com.lunarclient.apollo.recipients.Recipients; +import org.bukkit.Bukkit; 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 TntCountdownApiExample extends TntCountdownExample implements Listener { private final TntCountdownModule tntCountdownModule = Apollo.getModuleManager().getModule(TntCountdownModule.class); + public TntCountdownApiExample() { + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getInstance()); + } + @Override public void setTntCountdownExample() { this.tntCountdownModule.getOptions().set(TntCountdownModule.TNT_TICKS, 160); @@ -46,21 +52,42 @@ public void setTntCountdownExample() { @Override public void overrideTntCountdownExample(Player viewer) { - Location location = viewer.getLocation(); - World world = viewer.getWorld(); - TNTPrimed entity = world.spawn(location, TNTPrimed.class); + int customTicks = 200; - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + TNTPrimed entity = viewer.getWorld().spawn(viewer.getLocation(), TNTPrimed.class); + entity.setFuseTicks(customTicks); - apolloPlayerOpt.ifPresent(apolloPlayer -> { - ApolloEntity apolloEntity = new ApolloEntity(entity.getEntityId(), entity.getUniqueId()); - this.tntCountdownModule.setTntCountdown(apolloEntity, 200); - }); + ApolloEntity apolloEntity = new ApolloEntity(entity.getEntityId(), entity.getUniqueId()); + this.tntCountdownModule.setTntCountdown(Recipients.ofEveryone(), apolloEntity, customTicks); } @Override public void clearTntCountdownOptionExample() { - this.tntCountdownModule.getOptions().remove(TntCountdownModule.TNT_TICKS, 80); + this.tntCountdownModule.getOptions().remove(TntCountdownModule.TNT_TICKS, 160); + } + + @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 = this.tntCountdownModule.getOptions().get(TntCountdownModule.TNT_TICKS); + int defaultTicks = TntCountdownModule.TNT_TICKS.getDefaultValue(); + int currentTicks = primed.getFuseTicks(); + + if (currentTicks != defaultTicks && !this.tntCountdownModule.getOptions().get(TntCountdownModule.OVERRIDE_CUSTOM_TICKS)) { + customTicks = currentTicks; + + this.tntCountdownModule.setTntCountdown(Recipients.ofEveryone(), + new ApolloEntity(primed.getEntityId(), primed.getUniqueId()), + customTicks + ); + } + + primed.setFuseTicks(customTicks); } } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TransferApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TransferApiExample.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TransferApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TransferApiExample.java index 252dc74d..8ac1fce1 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TransferApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/TransferApiExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.api.examples; +package com.lunarclient.apollo.example.api.module; import com.google.common.collect.Lists; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.TransferExample; +import com.lunarclient.apollo.example.module.impl.TransferExample; import com.lunarclient.apollo.module.transfer.PingResponse; import com.lunarclient.apollo.module.transfer.TransferModule; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/VignetteApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/VignetteApiExample.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/VignetteApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/VignetteApiExample.java index 36c1edef..d914f323 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/VignetteApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/VignetteApiExample.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.api.examples; +package com.lunarclient.apollo.example.api.module; import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.example.common.modules.impl.VignetteExample; +import com.lunarclient.apollo.example.module.impl.VignetteExample; import com.lunarclient.apollo.module.vignette.Vignette; import com.lunarclient.apollo.module.vignette.VignetteModule; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/WaypointApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/WaypointApiExample.java similarity index 96% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/WaypointApiExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/WaypointApiExample.java index eb5b8e6a..f404c503 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/WaypointApiExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/WaypointApiExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.api.examples; +package com.lunarclient.apollo.example.api.module; 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.example.module.impl.WaypointExample; import com.lunarclient.apollo.module.waypoint.Waypoint; import com.lunarclient.apollo.module.waypoint.WaypointModule; import com.lunarclient.apollo.player.ApolloPlayer; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/BukkitApolloExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/BukkitApolloExample.java similarity index 98% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/BukkitApolloExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/BukkitApolloExample.java index 12abb7b4..32f37478 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/BukkitApolloExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/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.api.utilities; +package com.lunarclient.apollo.example.api.util; import com.google.common.collect.Lists; import com.lunarclient.apollo.Apollo; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/ComponentExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/ComponentExample.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/ComponentExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/ComponentExample.java index f9bfc005..a401c88c 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/ComponentExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/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.api.utilities; +package com.lunarclient.apollo.example.api.util; import com.google.common.collect.Lists; import net.kyori.adventure.text.Component; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/CuboidExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/CuboidExample.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/CuboidExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/CuboidExample.java index 241a27e6..fe1df4c1 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/CuboidExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/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.api.utilities; +package com.lunarclient.apollo.example.api.util; 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/api/utilities/IconExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/IconExample.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/IconExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/IconExample.java index f7bfe085..15596020 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/IconExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/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.api.utilities; +package com.lunarclient.apollo.example.api.util; 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/api/utilities/LocationExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/LocationExample.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/LocationExample.java rename to bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/LocationExample.java index f8d3486d..9a35bf92 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/api/utilities/LocationExample.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/util/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.api.utilities; +package com.lunarclient.apollo.example.api.util; import com.lunarclient.apollo.common.location.ApolloBlockLocation; import com.lunarclient.apollo.common.location.ApolloLocation; diff --git a/bukkit-example-api/src/main/resources/plugin.yml b/bukkit-example-api/src/main/resources/plugin.yml new file mode 100644 index 00000000..0c9392a2 --- /dev/null +++ b/bukkit-example-api/src/main/resources/plugin.yml @@ -0,0 +1,69 @@ +name: Apollo-API-Example +main: com.lunarclient.apollo.example.api.ApolloApiExamplePlatform +version: 1.1.8 +author: Moonsworth +softdepend: [ Apollo-Bukkit, Apollo-Folia ] +api-version: 1.13 +folia-supported: true + +commands: + apollodebug: + description: "Apollo Debug!" + autotexthotkey: + description: "Auto Text Hotkey!" + beam: + description: "Beams!" + border: + description: "Borders!" + chat: + description: "Chat!" + coloredfire: + description: "Colored Fires!" + combat: + description: "Combat!" + cooldown: + description: "Cooldowns!" + entity: + description: "Entity!" + glint: + description: "Glint!" + glow: + description: "Glow!" + hologram: + description: "Holograms!" + inventory: + description: "Inventory!" + limb: + description: "Limb!" + modsettings: + description: "ModSettings!" + nametag: + description: "Nametags!" + nickhider: + description: "Nick Hider!" + notification: + description: "Notifications!" + richpresence: + description: "Rich Presence!" + saturation: + description: "Saturation!" + serverrule: + description: "Server Rule!" + staffmod: + description: "Staff Mods!" + stopwatch: + description: "Stopwatch!" + team: + description: "Teams!" + tebex: + description: "Tebex!" + title: + description: "Titles!" + tntcountdown: + description: "TNT Countdown!" + transfer: + description: "Transfer!" + vignette: + description: "Vignette!" + waypoint: + description: "Waypoints!" diff --git a/bukkit-example-common/build.gradle.kts b/bukkit-example-common/build.gradle.kts new file mode 100644 index 00000000..97bed6a3 --- /dev/null +++ b/bukkit-example-common/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + id("apollo.base-conventions") + id("apollo.shadow-conventions") +} + +java { + javaTarget(21) +} + +dependencies { + compileOnly(libs.bukkit) + compileOnly(libs.bukkit.api) +} diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java new file mode 100644 index 00000000..996c9472 --- /dev/null +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java @@ -0,0 +1,198 @@ +/* + * 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; + +import com.lunarclient.apollo.example.command.AutoTextHotkeyCommand; +import com.lunarclient.apollo.example.command.BeamCommand; +import com.lunarclient.apollo.example.command.BorderCommand; +import com.lunarclient.apollo.example.command.ChatCommand; +import com.lunarclient.apollo.example.command.ColoredFireCommand; +import com.lunarclient.apollo.example.command.CombatCommand; +import com.lunarclient.apollo.example.command.CooldownCommand; +import com.lunarclient.apollo.example.command.EntityCommand; +import com.lunarclient.apollo.example.command.GlintCommand; +import com.lunarclient.apollo.example.command.GlowCommand; +import com.lunarclient.apollo.example.command.HologramCommand; +import com.lunarclient.apollo.example.command.InventoryCommand; +import com.lunarclient.apollo.example.command.LimbCommand; +import com.lunarclient.apollo.example.command.ModSettingsCommand; +import com.lunarclient.apollo.example.command.NametagCommand; +import com.lunarclient.apollo.example.command.NickHiderCommand; +import com.lunarclient.apollo.example.command.NotificationCommand; +import com.lunarclient.apollo.example.command.RichPresenceCommand; +import com.lunarclient.apollo.example.command.SaturationCommand; +import com.lunarclient.apollo.example.command.ServerRuleCommand; +import com.lunarclient.apollo.example.command.StaffModCommand; +import com.lunarclient.apollo.example.command.StopwatchCommand; +import com.lunarclient.apollo.example.command.TeamCommand; +import com.lunarclient.apollo.example.command.TebexCommand; +import com.lunarclient.apollo.example.command.TitleCommand; +import com.lunarclient.apollo.example.command.TntCountdownCommand; +import com.lunarclient.apollo.example.command.TransferCommand; +import com.lunarclient.apollo.example.command.VignetteCommand; +import com.lunarclient.apollo.example.command.WaypointCommand; +import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample; +import com.lunarclient.apollo.example.module.impl.BeamExample; +import com.lunarclient.apollo.example.module.impl.BorderExample; +import com.lunarclient.apollo.example.module.impl.ChatExample; +import com.lunarclient.apollo.example.module.impl.ColoredFireExample; +import com.lunarclient.apollo.example.module.impl.CombatExample; +import com.lunarclient.apollo.example.module.impl.CooldownExample; +import com.lunarclient.apollo.example.module.impl.EntityExample; +import com.lunarclient.apollo.example.module.impl.GlintExample; +import com.lunarclient.apollo.example.module.impl.GlowExample; +import com.lunarclient.apollo.example.module.impl.HologramExample; +import com.lunarclient.apollo.example.module.impl.InventoryExample; +import com.lunarclient.apollo.example.module.impl.LimbExample; +import com.lunarclient.apollo.example.module.impl.ModSettingsExample; +import com.lunarclient.apollo.example.module.impl.NametagExample; +import com.lunarclient.apollo.example.module.impl.NickHiderExample; +import com.lunarclient.apollo.example.module.impl.NotificationExample; +import com.lunarclient.apollo.example.module.impl.RichPresenceExample; +import com.lunarclient.apollo.example.module.impl.SaturationExample; +import com.lunarclient.apollo.example.module.impl.ServerRuleExample; +import com.lunarclient.apollo.example.module.impl.StaffModExample; +import com.lunarclient.apollo.example.module.impl.StopwatchExample; +import com.lunarclient.apollo.example.module.impl.TeamExample; +import com.lunarclient.apollo.example.module.impl.TebexExample; +import com.lunarclient.apollo.example.module.impl.TitleExample; +import com.lunarclient.apollo.example.module.impl.TntCountdownExample; +import com.lunarclient.apollo.example.module.impl.TransferExample; +import com.lunarclient.apollo.example.module.impl.VignetteExample; +import com.lunarclient.apollo.example.module.impl.WaypointExample; +import lombok.Getter; +import lombok.Setter; +import org.bukkit.plugin.java.JavaPlugin; + +@Getter @Setter +public abstract class ApolloExamplePlugin extends JavaPlugin { + + @Getter + private static ApolloExamplePlugin instance; + + private AutoTextHotkeyExample autoTextHotkeyExample; + private BeamExample beamExample; + private BorderExample borderExample; + private ChatExample chatExample; + private ColoredFireExample coloredFireExample; + private CombatExample combatExample; + private CooldownExample cooldownExample; + private EntityExample entityExample; + private GlintExample glintExample; + private GlowExample glowExample; + private HologramExample hologramExample; + private InventoryExample inventoryExample; + private LimbExample limbExample; + private ModSettingsExample modSettingsExample; + private NametagExample nametagExample; + private NickHiderExample nickHiderExample; + private NotificationExample notificationExample; + private RichPresenceExample richPresenceExample; + private SaturationExample saturationExample; + private ServerRuleExample serverRuleExample; + 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; + + @Override + public void onEnable() { + instance = this; + + this.registerCommonCommands(); + this.registerCommonModulesExamples(); + + this.enable(); + this.registerCommands(); + this.registerModuleExamples(); + this.registerListeners(); + } + + @Override + public void onDisable() { + + } + + private void registerCommonCommands() { + this.getCommand("autotexthotkey").setExecutor(new AutoTextHotkeyCommand()); + this.getCommand("beam").setExecutor(new BeamCommand()); + this.getCommand("border").setExecutor(new BorderCommand()); + this.getCommand("chat").setExecutor(new ChatCommand()); + this.getCommand("coloredfire").setExecutor(new ColoredFireCommand()); + this.getCommand("combat").setExecutor(new CombatCommand()); + this.getCommand("cooldown").setExecutor(new CooldownCommand()); + this.getCommand("entity").setExecutor(new EntityCommand()); + this.getCommand("glint").setExecutor(new GlintCommand()); + this.getCommand("glow").setExecutor(new GlowCommand()); + this.getCommand("hologram").setExecutor(new HologramCommand()); + this.getCommand("inventory").setExecutor(new InventoryCommand()); + this.getCommand("limb").setExecutor(new LimbCommand()); + this.getCommand("modsettings").setExecutor(new ModSettingsCommand()); + this.getCommand("nametag").setExecutor(new NametagCommand()); + this.getCommand("nickhider").setExecutor(new NickHiderCommand()); + this.getCommand("notification").setExecutor(new NotificationCommand()); + this.getCommand("richpresence").setExecutor(new RichPresenceCommand()); + this.getCommand("saturation").setExecutor(new SaturationCommand()); + this.getCommand("serverrule").setExecutor(new ServerRuleCommand()); + 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()); + this.getCommand("vignette").setExecutor(new VignetteCommand()); + this.getCommand("waypoint").setExecutor(new WaypointCommand()); + } + + private void registerCommonModulesExamples() { + this.glintExample = new GlintExample(); + this.inventoryExample = new InventoryExample(); + this.saturationExample = new SaturationExample(); + } + + public void enable() { + + } + + public void registerCommands() { + + } + + public void registerModuleExamples() { + + } + + public void registerListeners() { + + } + + public abstract ApolloExampleType getType(); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/ApolloExampleType.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExampleType.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/ApolloExampleType.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExampleType.java index 9eedd2e3..0e96b3fe 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/ApolloExampleType.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExampleType.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.common.modules; +package com.lunarclient.apollo.example; public enum ApolloExampleType { diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/AutoTextHotkeyCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/AutoTextHotkeyCommand.java new file mode 100644 index 00000000..e99fc825 --- /dev/null +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/AutoTextHotkeyCommand.java @@ -0,0 +1,81 @@ +/* + * 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.command; + +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample; +import java.util.Arrays; +import java.util.List; +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 AutoTextHotkeyCommand 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("/autotexthotkey blockedTextInputs "); + player.sendMessage("/autotexthotkey blockChatMessageTextInputs "); + return true; + } + + AutoTextHotkeyExample autoTextHotkeyExample = ApolloExamplePlugin.getInstance().getAutoTextHotkeyExample(); + + switch (args[0].toLowerCase()) { + case "blockedtextinputs": { + List blockedInputs = Arrays.asList(Arrays.copyOfRange(args, 1, args.length)); + autoTextHotkeyExample.setBlockedTextInputs(blockedInputs); + + player.sendMessage("Blocked text inputs have been set to: " + String.join(", ", blockedInputs)); + break; + } + + case "blockchatmessagetextinputs": { + boolean value = Boolean.parseBoolean(args[1]); + autoTextHotkeyExample.setBlockChatMesssageTextInputs(value); + + player.sendMessage("Block chat message text inputs has been set to " + value); + break; + } + + default: { + player.sendMessage("/autotexthotkey blockedTextInputs "); + player.sendMessage("/autotexthotkey blockChatMessageTextInputs "); + break; + } + } + + return true; + } +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/BeamCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/BeamCommand.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/BeamCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/BeamCommand.java index d070d7e2..3414d293 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/BeamCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.BeamExample; +import com.lunarclient.apollo.example.module.impl.BeamExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - BeamExample beamExample = ApolloExamplePlugin.getPlugin().getBeamExample(); + BeamExample beamExample = ApolloExamplePlugin.getInstance().getBeamExample(); switch (args[0].toLowerCase()) { case "display": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/BorderCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/BorderCommand.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/BorderCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/BorderCommand.java index da532482..1bfbfd28 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/BorderCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.BorderExample; +import com.lunarclient.apollo.example.module.impl.BorderExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - BorderExample borderExample = ApolloExamplePlugin.getPlugin().getBorderExample(); + BorderExample borderExample = ApolloExamplePlugin.getInstance().getBorderExample(); switch (args[0].toLowerCase()) { case "display": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ChatCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/ChatCommand.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ChatCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/ChatCommand.java index 6c0dff5d..e0c376c5 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ChatCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.ChatExample; +import com.lunarclient.apollo.example.module.impl.ChatExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - ChatExample chatExample = ApolloExamplePlugin.getPlugin().getChatExample(); + ChatExample chatExample = ApolloExamplePlugin.getInstance().getChatExample(); switch (args[0].toLowerCase()) { case "display": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ColoredFireCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/ColoredFireCommand.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ColoredFireCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/ColoredFireCommand.java index cd61c305..af983253 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ColoredFireCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.ColoredFireExample; +import com.lunarclient.apollo.example.module.impl.ColoredFireExample; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -42,7 +42,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } Player player = (Player) sender; - ColoredFireExample coloredFireExample = ApolloExamplePlugin.getPlugin().getColoredFireExample(); + ColoredFireExample coloredFireExample = ApolloExamplePlugin.getInstance().getColoredFireExample(); if (args.length == 1 && args[0].equalsIgnoreCase("clear")) { coloredFireExample.resetColoredFiresExample(player); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/CombatCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/CombatCommand.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/CombatCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/CombatCommand.java index b6f9e839..2a408685 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/CombatCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.CombatExample; +import com.lunarclient.apollo.example.module.impl.CombatExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - CombatExample combatExample = ApolloExamplePlugin.getPlugin().getCombatExample(); + CombatExample combatExample = ApolloExamplePlugin.getInstance().getCombatExample(); if (args[0].equalsIgnoreCase("disablemisspenalty")) { boolean value = Boolean.parseBoolean(args[1]); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/CooldownCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/CooldownCommand.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/CooldownCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/CooldownCommand.java index 36535ee0..62de3bbb 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/CooldownCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.CooldownExample; +import com.lunarclient.apollo.example.module.impl.CooldownExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - CooldownExample cooldownExample = ApolloExamplePlugin.getPlugin().getCooldownExample(); + CooldownExample cooldownExample = ApolloExamplePlugin.getInstance().getCooldownExample(); switch (args[0].toLowerCase()) { case "displayitem": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/EntityCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/EntityCommand.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/EntityCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/EntityCommand.java index 64c0db1a..47a78bd8 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/EntityCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.EntityExample; +import com.lunarclient.apollo.example.module.impl.EntityExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - EntityExample entityExample = ApolloExamplePlugin.getPlugin().getEntityExample(); + EntityExample entityExample = ApolloExamplePlugin.getInstance().getEntityExample(); switch (args[0].toLowerCase()) { case "overridesheep": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/GlintCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/GlintCommand.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/GlintCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/GlintCommand.java index 8f0578dc..9ccb22ff 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/GlintCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/GlintCommand.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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.GlintExample; +import com.lunarclient.apollo.example.module.impl.GlintExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -41,7 +41,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } Player player = (Player) sender; - GlintExample glintExample = ApolloExamplePlugin.getPlugin().getGlintExample(); + GlintExample glintExample = ApolloExamplePlugin.getInstance().getGlintExample(); if (glintExample.glintModuleExample(player)) { player.sendMessage("Giving items..."); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/GlowCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/GlowCommand.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/GlowCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/GlowCommand.java index abff7295..0ca3fd3f 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/GlowCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.GlowExample; +import com.lunarclient.apollo.example.module.impl.GlowExample; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -42,7 +42,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } Player player = (Player) sender; - GlowExample glowExample = ApolloExamplePlugin.getPlugin().getGlowExample(); + GlowExample glowExample = ApolloExamplePlugin.getInstance().getGlowExample(); if (args.length == 1 && args[0].equalsIgnoreCase("clear")) { glowExample.resetGlowEffectsExample(player); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/HologramCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/HologramCommand.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/HologramCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/HologramCommand.java index 62c9dea6..583198af 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/HologramCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.HologramExample; +import com.lunarclient.apollo.example.module.impl.HologramExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - HologramExample hologramExample = ApolloExamplePlugin.getPlugin().getHologramExample(); + HologramExample hologramExample = ApolloExamplePlugin.getInstance().getHologramExample(); switch (args[0].toLowerCase()) { case "display": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/InventoryCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/InventoryCommand.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/InventoryCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/InventoryCommand.java index 2059a63d..4367bb92 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/InventoryCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/InventoryCommand.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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.InventoryExample; +import com.lunarclient.apollo.example.module.impl.InventoryExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -41,7 +41,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } Player player = (Player) sender; - InventoryExample inventoryExample = ApolloExamplePlugin.getPlugin().getInventoryExample(); + InventoryExample inventoryExample = ApolloExamplePlugin.getInstance().getInventoryExample(); if (inventoryExample.inventoryModuleExample(player)) { player.sendMessage("Giving items..."); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/LimbCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/LimbCommand.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/LimbCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/LimbCommand.java index 19df9cd8..8d9f8ac8 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/LimbCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.LimbExample; +import com.lunarclient.apollo.example.module.impl.LimbExample; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -55,7 +55,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - LimbExample limbExample = ApolloExamplePlugin.getPlugin().getLimbExample(); + LimbExample limbExample = ApolloExamplePlugin.getInstance().getLimbExample(); switch (args[0].toLowerCase()) { case "hidearmor": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ModSettingsCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/ModSettingsCommand.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ModSettingsCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/ModSettingsCommand.java index 1346054d..0aac6178 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ModSettingsCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.ModSettingsExample; +import com.lunarclient.apollo.example.module.impl.ModSettingsExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - ModSettingsExample modSettingsExample = ApolloExamplePlugin.getPlugin().getModSettingsExample(); + ModSettingsExample modSettingsExample = ApolloExamplePlugin.getInstance().getModSettingsExample(); switch (args[0].toLowerCase()) { case "disable": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NametagCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/NametagCommand.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NametagCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/NametagCommand.java index a1443cd2..215c8756 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NametagCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.NametagExample; +import com.lunarclient.apollo.example.module.impl.NametagExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - NametagExample nametagExample = ApolloExamplePlugin.getPlugin().getNametagExample(); + NametagExample nametagExample = ApolloExamplePlugin.getInstance().getNametagExample(); switch (args[0].toLowerCase()) { case "override": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NickHiderCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/NickHiderCommand.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NickHiderCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/NickHiderCommand.java index 5e42f6a8..8a62e3ab 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NickHiderCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.NickHiderExample; +import com.lunarclient.apollo.example.module.impl.NickHiderExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - NickHiderExample nickHiderExample = ApolloExamplePlugin.getPlugin().getNickHiderExample(); + NickHiderExample nickHiderExample = ApolloExamplePlugin.getInstance().getNickHiderExample(); switch (args[0].toLowerCase()) { case "override": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NotificationCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/NotificationCommand.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NotificationCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/NotificationCommand.java index bb4eb8f4..b6f8342a 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/NotificationCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.NotificationExample; +import com.lunarclient.apollo.example.module.impl.NotificationExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - NotificationExample notificationExample = ApolloExamplePlugin.getPlugin().getNotificationExample(); + NotificationExample notificationExample = ApolloExamplePlugin.getInstance().getNotificationExample(); switch (args[0].toLowerCase()) { case "display": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/RichPresenceCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/RichPresenceCommand.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/RichPresenceCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/RichPresenceCommand.java index 30b547e2..185cd868 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/RichPresenceCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.RichPresenceExample; +import com.lunarclient.apollo.example.module.impl.RichPresenceExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - RichPresenceExample richPresenceExample = ApolloExamplePlugin.getPlugin().getRichPresenceExample(); + RichPresenceExample richPresenceExample = ApolloExamplePlugin.getInstance().getRichPresenceExample(); switch (args[0].toLowerCase()) { case "override": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/SaturationCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/SaturationCommand.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/SaturationCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/SaturationCommand.java index f909a727..eb91e56a 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/SaturationCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/SaturationCommand.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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.SaturationExample; +import com.lunarclient.apollo.example.module.impl.SaturationExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -41,7 +41,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } Player player = (Player) sender; - SaturationExample saturationExample = ApolloExamplePlugin.getPlugin().getSaturationExample(); + SaturationExample saturationExample = ApolloExamplePlugin.getInstance().getSaturationExample(); if (saturationExample.saturationModuleExample(player)) { player.sendMessage("Giving items..."); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ServerRuleCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/ServerRuleCommand.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ServerRuleCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/ServerRuleCommand.java index beac095e..4793914d 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/ServerRuleCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.ServerRuleExample; +import com.lunarclient.apollo.example.module.impl.ServerRuleExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - ServerRuleExample serverRuleExample = ApolloExamplePlugin.getPlugin().getServerRuleExample(); + ServerRuleExample serverRuleExample = ApolloExamplePlugin.getInstance().getServerRuleExample(); switch (args[0].toLowerCase()) { case "antiportaltraps": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/StaffModCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/StaffModCommand.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/StaffModCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/StaffModCommand.java index 2ffaf2bc..7ff3826b 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/StaffModCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.StaffModExample; +import com.lunarclient.apollo.example.module.impl.StaffModExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - StaffModExample staffModExample = ApolloExamplePlugin.getPlugin().getStaffModExample(); + StaffModExample staffModExample = ApolloExamplePlugin.getInstance().getStaffModExample(); switch (args[0].toLowerCase()) { case "enable": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/StopwatchCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/StopwatchCommand.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/StopwatchCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/StopwatchCommand.java index 86cb2c50..b4ef9a19 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/StopwatchCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.StopwatchExample; +import com.lunarclient.apollo.example.module.impl.StopwatchExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - StopwatchExample stopwatchExample = ApolloExamplePlugin.getPlugin().getStopwatchExample(); + StopwatchExample stopwatchExample = ApolloExamplePlugin.getInstance().getStopwatchExample(); switch (args[0].toLowerCase()) { case "start": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TeamCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/TeamCommand.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TeamCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/TeamCommand.java index d62ad942..c8442182 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TeamCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/TeamCommand.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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.TeamExample; +import com.lunarclient.apollo.example.module.impl.TeamExample; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -42,7 +42,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } Player player = (Player) sender; - TeamExample teamExample = ApolloExamplePlugin.getPlugin().getTeamExample(); + TeamExample teamExample = ApolloExamplePlugin.getInstance().getTeamExample(); if (args.length == 1) { switch (args[0].toLowerCase()) { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TebexCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/TebexCommand.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TebexCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/TebexCommand.java index c26d2d34..f517373b 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TebexCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/TebexCommand.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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.TebexExample; +import com.lunarclient.apollo.example.module.impl.TebexExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - TebexExample tebexExample = ApolloExamplePlugin.getPlugin().getTebexExample(); + TebexExample tebexExample = ApolloExamplePlugin.getInstance().getTebexExample(); String locale = args.length == 3 ? args[2] : null; switch (args[0].toLowerCase()) { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TitleCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/TitleCommand.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TitleCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/TitleCommand.java index f8f191df..fa6d2423 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TitleCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.TitleExample; +import com.lunarclient.apollo.example.module.impl.TitleExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - TitleExample titleExample = ApolloExamplePlugin.getPlugin().getTitleExample(); + TitleExample titleExample = ApolloExamplePlugin.getInstance().getTitleExample(); switch (args[0].toLowerCase()) { case "display": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TntCountdownCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/TntCountdownCommand.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TntCountdownCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/TntCountdownCommand.java index 67871040..1da2caed 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TntCountdownCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.TntCountdownExample; +import com.lunarclient.apollo.example.module.impl.TntCountdownExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - TntCountdownExample tntCountdownExample = ApolloExamplePlugin.getPlugin().getTntCountdownExample(); + TntCountdownExample tntCountdownExample = ApolloExamplePlugin.getInstance().getTntCountdownExample(); switch (args[0].toLowerCase()) { case "override": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TransferCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/TransferCommand.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TransferCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/TransferCommand.java index 1e316472..ae3ec760 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/TransferCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.TransferExample; +import com.lunarclient.apollo.example.module.impl.TransferExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - TransferExample transferExample = ApolloExamplePlugin.getPlugin().getTransferExample(); + TransferExample transferExample = ApolloExamplePlugin.getInstance().getTransferExample(); switch (args[0].toLowerCase()) { case "transfer": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/VignetteCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/VignetteCommand.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/VignetteCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/VignetteCommand.java index b25fe357..4457ad42 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/VignetteCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.VignetteExample; +import com.lunarclient.apollo.example.module.impl.VignetteExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - VignetteExample vignetteExample = ApolloExamplePlugin.getPlugin().getVignetteExample(); + VignetteExample vignetteExample = ApolloExamplePlugin.getInstance().getVignetteExample(); switch (args[0].toLowerCase()) { case "display": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/WaypointCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/WaypointCommand.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/WaypointCommand.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/WaypointCommand.java index af4942d6..729eaf43 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/module/WaypointCommand.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/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.common.commands.module; +package com.lunarclient.apollo.example.command; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.WaypointExample; +import com.lunarclient.apollo.example.module.impl.WaypointExample; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - WaypointExample waypointExample = ApolloExamplePlugin.getPlugin().getWaypointExample(); + WaypointExample waypointExample = ApolloExamplePlugin.getInstance().getWaypointExample(); switch (args[0].toLowerCase()) { case "display": { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/ApolloExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/ApolloModuleExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/ApolloExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/ApolloModuleExample.java index f69f6a5a..58bde882 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/ApolloExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/ApolloModuleExample.java @@ -21,17 +21,17 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.common.modules; +package com.lunarclient.apollo.example.module; import com.lunarclient.apollo.example.ApolloExamplePlugin; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -public abstract class ApolloExample { +public abstract class ApolloModuleExample { protected void sendNotImplemented(Player player) { player.sendMessage(ChatColor.RED + "This command is not available with the " + - ApolloExamplePlugin.TYPE.name().toLowerCase() + " implementation!"); + ApolloExamplePlugin.getInstance().getType().name().toLowerCase() + " implementation!"); } } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NMSExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/NMSExample.java similarity index 77% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NMSExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/NMSExample.java index ad11f51f..c6984952 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NMSExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/NMSExample.java @@ -21,18 +21,21 @@ * 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; +package com.lunarclient.apollo.example.module; -import com.lunarclient.apollo.example.common.modules.ApolloExample; import org.bukkit.Bukkit; -public class NMSExample extends ApolloExample { +public class NMSExample extends ApolloModuleExample { public boolean isOneEight() { - return Bukkit.getServer().getClass() - .getPackage().getName() - .split("\\.")[3] - .startsWith("v1_8"); + try { + return Bukkit.getServer().getClass() + .getPackage().getName() + .split("\\.")[3] + .startsWith("v1_8"); + } catch (IndexOutOfBoundsException e) { + return false; + } } } diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/AutoTextHotkeyExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/AutoTextHotkeyExample.java new file mode 100644 index 00000000..31b3cbbc --- /dev/null +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/AutoTextHotkeyExample.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.module.impl; + +import com.lunarclient.apollo.example.module.ApolloModuleExample; +import java.util.List; + +public abstract class AutoTextHotkeyExample extends ApolloModuleExample { + + public abstract void setBlockedTextInputs(List blockedTextInputs); + + public abstract void setBlockChatMesssageTextInputs(boolean value); + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/BeamExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/BeamExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/BeamExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/BeamExample.java index 7dd40427..2327631e 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/BeamExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/BeamExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class BeamExample extends ApolloExample { +public abstract class BeamExample extends ApolloModuleExample { public abstract void displayBeamExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/BorderExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/BorderExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/BorderExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/BorderExample.java index d24c606c..4df2cf60 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/BorderExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/BorderExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class BorderExample extends ApolloExample { +public abstract class BorderExample extends ApolloModuleExample { public abstract void displayBorderExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ChatExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/ChatExample.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ChatExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/ChatExample.java index 9108a1d5..1200200e 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ChatExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/ChatExample.java @@ -21,11 +21,11 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; -public abstract class ChatExample extends ApolloExample { +public abstract class ChatExample extends ApolloModuleExample { public abstract void displayLiveChatMessageExample(); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ColoredFireExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/ColoredFireExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ColoredFireExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/ColoredFireExample.java index 88d2a92b..d3463938 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ColoredFireExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/ColoredFireExample.java @@ -21,13 +21,13 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import java.util.UUID; import org.bukkit.entity.Player; -public abstract class ColoredFireExample extends ApolloExample { +public abstract class ColoredFireExample extends ApolloModuleExample { public abstract void overrideColoredFireExample(UUID burningPlayer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/CombatExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/CombatExample.java similarity index 86% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/CombatExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/CombatExample.java index 4d3bfc50..8d1673e6 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/CombatExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/CombatExample.java @@ -21,11 +21,11 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; -public abstract class CombatExample extends ApolloExample { +public abstract class CombatExample extends ApolloModuleExample { 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-common/src/main/java/com/lunarclient/apollo/example/module/impl/CooldownExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/CooldownExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/CooldownExample.java index b68190ef..bf108776 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/CooldownExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/CooldownExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class CooldownExample extends ApolloExample { +public abstract class CooldownExample extends ApolloModuleExample { public abstract void displayCooldownItemExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/EntityExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/EntityExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/EntityExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/EntityExample.java index bfd12ce1..90ea7708 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/EntityExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/EntityExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class EntityExample extends ApolloExample { +public abstract class EntityExample extends ApolloModuleExample { public abstract void overrideRainbowSheepExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/GlintExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/GlintExample.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/GlintExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/GlintExample.java index 60a3a54a..12108c99 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/GlintExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/GlintExample.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.common.modules.impl; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.ItemUtil; +import com.lunarclient.apollo.example.module.NMSExample; +import com.lunarclient.apollo.example.util.ItemUtil; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/GlowExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/GlowExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/GlowExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/GlowExample.java index d94bf83e..bbddc7c9 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/GlowExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/GlowExample.java @@ -21,13 +21,13 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import java.util.UUID; import org.bukkit.entity.Player; -public abstract class GlowExample extends ApolloExample { +public abstract class GlowExample extends ApolloModuleExample { public abstract void overrideGlowEffectExample(UUID glowingPlayer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/HologramExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/HologramExample.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/HologramExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/HologramExample.java index 47514208..7e69b408 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/HologramExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/HologramExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class HologramExample extends ApolloExample { +public abstract class HologramExample extends ApolloModuleExample { public abstract void displayHologramExample(); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/InventoryExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/InventoryExample.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/InventoryExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/InventoryExample.java index fe447983..acc3a923 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/InventoryExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/InventoryExample.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.common.modules.impl; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.ItemUtil; +import com.lunarclient.apollo.example.module.NMSExample; +import com.lunarclient.apollo.example.util.ItemUtil; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -86,7 +87,7 @@ public void inventoryModuleNMSExample(Player player) { inventory.setItem(29, ItemUtil.addTag(suggestCommandItem, "suggestCommand", "/apollo")); ItemStack runCommandItem = ItemUtil.itemWithName( - Material.BOOK_AND_QUILL, + Material.ENCHANTED_BOOK, ChatColor.LIGHT_PURPLE.toString() + ChatColor.BOLD + "RUN COMMAND" ); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/LimbExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/LimbExample.java similarity index 89% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/LimbExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/LimbExample.java index a7b1af2c..6bce7227 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/LimbExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/LimbExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class LimbExample extends ApolloExample { +public abstract class LimbExample extends ApolloModuleExample { public abstract void hideArmorExample(Player viewer, Player target); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ModSettingsExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/ModSettingsExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ModSettingsExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/ModSettingsExample.java index e5f39512..6121c57e 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ModSettingsExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/ModSettingsExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class ModSettingsExample extends ApolloExample { +public abstract class ModSettingsExample extends ApolloModuleExample { public abstract void disableLightingModExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NametagExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/NametagExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NametagExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/NametagExample.java index a1887109..02e27a40 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NametagExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/NametagExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class NametagExample extends ApolloExample { +public abstract class NametagExample extends ApolloModuleExample { public abstract void overrideNametagExample(Player target); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NickHiderExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/NickHiderExample.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NickHiderExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/NickHiderExample.java index 1a5dbdb5..841fff8d 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NickHiderExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/NickHiderExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class NickHiderExample extends ApolloExample { +public abstract class NickHiderExample extends ApolloModuleExample { public abstract void overrideNickExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NotificationExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/NotificationExample.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NotificationExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/NotificationExample.java index 3cdb8937..b6ecef80 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/NotificationExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/NotificationExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class NotificationExample extends ApolloExample { +public abstract class NotificationExample extends ApolloModuleExample { public abstract void displayNotificationExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/RichPresenceExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/RichPresenceExample.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/RichPresenceExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/RichPresenceExample.java index 221b2a58..06f590c3 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/RichPresenceExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/RichPresenceExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class RichPresenceExample extends ApolloExample { +public abstract class RichPresenceExample extends ApolloModuleExample { public abstract void overrideServerRichPresenceExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/SaturationExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/SaturationExample.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/SaturationExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/SaturationExample.java index 4d0b5924..c7f61292 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/SaturationExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/SaturationExample.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.common.modules.impl; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.ItemUtil; +import com.lunarclient.apollo.example.module.NMSExample; +import com.lunarclient.apollo.example.util.ItemUtil; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ServerRuleExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/ServerRuleExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ServerRuleExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/ServerRuleExample.java index a7ea8776..68c21446 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/ServerRuleExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/ServerRuleExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class ServerRuleExample extends ApolloExample { +public abstract class ServerRuleExample extends ApolloModuleExample { public abstract void setAntiPortalTraps(boolean value); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/StaffModExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/StaffModExample.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/StaffModExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/StaffModExample.java index 05c20f55..11400c7e 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/StaffModExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/StaffModExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class StaffModExample extends ApolloExample { +public abstract class StaffModExample extends ApolloModuleExample { public abstract void enableStaffModsExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/StopwatchExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/StopwatchExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/StopwatchExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/StopwatchExample.java index 92417caa..66f0a65d 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/StopwatchExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/StopwatchExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class StopwatchExample extends ApolloExample { +public abstract class StopwatchExample extends ApolloModuleExample { public abstract void startStopwatchExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TeamExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TeamExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TeamExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TeamExample.java index 3da27f9e..2398fc51 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TeamExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TeamExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class TeamExample extends ApolloExample { +public abstract class TeamExample extends ApolloModuleExample { public abstract void createTeam(Player player); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TebexExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TebexExample.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TebexExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TebexExample.java index ba23761e..054ba7f2 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TebexExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TebexExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class TebexExample extends ApolloExample { +public abstract class TebexExample extends ApolloModuleExample { 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-common/src/main/java/com/lunarclient/apollo/example/module/impl/TitleExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TitleExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TitleExample.java index 063afd4b..48fdc134 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TitleExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TitleExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class TitleExample extends ApolloExample { +public abstract class TitleExample extends ApolloModuleExample { public abstract void displayTitleExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TntCountdownExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TntCountdownExample.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TntCountdownExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TntCountdownExample.java index 46796516..0243c61e 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TntCountdownExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TntCountdownExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class TntCountdownExample extends ApolloExample { +public abstract class TntCountdownExample extends ApolloModuleExample { public abstract void setTntCountdownExample(); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TransferExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TransferExample.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TransferExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TransferExample.java index 5bdf38d1..47a82be7 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/TransferExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/TransferExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class TransferExample extends ApolloExample { +public abstract class TransferExample extends ApolloModuleExample { public abstract void transferExample(Player player); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/VignetteExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/VignetteExample.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/VignetteExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/VignetteExample.java index fc6b8520..159f335e 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/VignetteExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/VignetteExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class VignetteExample extends ApolloExample { +public abstract class VignetteExample extends ApolloModuleExample { public abstract void displayVignetteExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/WaypointExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/WaypointExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/WaypointExample.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/WaypointExample.java index 9859b498..8d41b546 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/modules/impl/WaypointExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/WaypointExample.java @@ -21,12 +21,12 @@ * 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; +package com.lunarclient.apollo.example.module.impl; -import com.lunarclient.apollo.example.common.modules.ApolloExample; +import com.lunarclient.apollo.example.module.ApolloModuleExample; import org.bukkit.entity.Player; -public abstract class WaypointExample extends ApolloExample { +public abstract class WaypointExample extends ApolloModuleExample { public abstract void displayWaypointExample(Player viewer); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/ItemUtil.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/util/ItemUtil.java similarity index 98% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/common/ItemUtil.java rename to bukkit-example-common/src/main/java/com/lunarclient/apollo/example/util/ItemUtil.java index a7070e1d..9bfc1eaa 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/ItemUtil.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/util/ItemUtil.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.common; +package com.lunarclient.apollo.example.util; import net.minecraft.server.v1_8_R3.NBTTagCompound; import org.bukkit.Material; diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/util/ServerUtil.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/util/ServerUtil.java new file mode 100644 index 00000000..dc91a5c4 --- /dev/null +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/util/ServerUtil.java @@ -0,0 +1,40 @@ +/* + * 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.util; + +public final class ServerUtil { + + public static boolean isFolia() { + try { + Class.forName("io.papermc.paper.threadedregions.RegionizedServer"); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } + + private ServerUtil() { + } + +} diff --git a/bukkit-example-json/build.gradle.kts b/bukkit-example-json/build.gradle.kts new file mode 100644 index 00000000..2f8ebbd5 --- /dev/null +++ b/bukkit-example-json/build.gradle.kts @@ -0,0 +1,20 @@ +plugins { + id("apollo.base-conventions") + id("apollo.shadow-conventions") +} + +java { + javaTarget(21) +} + +dependencies { + api(libs.bundles.adventure) { + exclude("org.checkerframework") + exclude("net.kyori", "adventure-api") + exclude("net.kyori", "adventure-bom") + } + + compileOnly(libs.bukkit) + compileOnly(libs.folia) + implementation(project(":apollo-bukkit-example-common")) +} diff --git a/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java new file mode 100644 index 00000000..e5c90754 --- /dev/null +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java @@ -0,0 +1,108 @@ +/* + * 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.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.ApolloExampleType; +import com.lunarclient.apollo.example.json.listener.ApolloPlayerJsonListener; +import com.lunarclient.apollo.example.json.module.AutoTextHotkeyJsonExample; +import com.lunarclient.apollo.example.json.module.BeamJsonExample; +import com.lunarclient.apollo.example.json.module.BorderJsonExample; +import com.lunarclient.apollo.example.json.module.ChatJsonExample; +import com.lunarclient.apollo.example.json.module.ColoredFireJsonExample; +import com.lunarclient.apollo.example.json.module.CombatJsonExample; +import com.lunarclient.apollo.example.json.module.CooldownJsonExample; +import com.lunarclient.apollo.example.json.module.EntityJsonExample; +import com.lunarclient.apollo.example.json.module.GlowJsonExample; +import com.lunarclient.apollo.example.json.module.HologramJsonExample; +import com.lunarclient.apollo.example.json.module.LimbJsonExample; +import com.lunarclient.apollo.example.json.module.ModSettingsJsonExample; +import com.lunarclient.apollo.example.json.module.NametagJsonExample; +import com.lunarclient.apollo.example.json.module.NickHiderJsonExample; +import com.lunarclient.apollo.example.json.module.NotificationJsonExample; +import com.lunarclient.apollo.example.json.module.RichPresenceJsonExample; +import com.lunarclient.apollo.example.json.module.ServerRuleJsonExample; +import com.lunarclient.apollo.example.json.module.StaffModJsonExample; +import com.lunarclient.apollo.example.json.module.StopwatchJsonExample; +import com.lunarclient.apollo.example.json.module.TeamJsonExample; +import com.lunarclient.apollo.example.json.module.TebexJsonExample; +import com.lunarclient.apollo.example.json.module.TitleJsonExample; +import com.lunarclient.apollo.example.json.module.TntCountdownJsonExample; +import com.lunarclient.apollo.example.json.module.TransferJsonExample; +import com.lunarclient.apollo.example.json.module.VignetteJsonExample; +import com.lunarclient.apollo.example.json.module.WaypointJsonExample; +import lombok.Getter; + +@Getter +public class ApolloJsonExamplePlatform extends ApolloExamplePlugin { + + @Getter + private static ApolloJsonExamplePlatform instance; + + @Override + public void enable() { + instance = this; + } + + @Override + public void registerModuleExamples() { + this.setAutoTextHotkeyExample(new AutoTextHotkeyJsonExample()); + this.setBeamExample(new BeamJsonExample()); + this.setBorderExample(new BorderJsonExample()); + this.setChatExample(new ChatJsonExample()); + this.setColoredFireExample(new ColoredFireJsonExample()); + this.setCombatExample(new CombatJsonExample()); + this.setCooldownExample(new CooldownJsonExample()); + this.setEntityExample(new EntityJsonExample()); + this.setGlowExample(new GlowJsonExample()); + this.setHologramExample(new HologramJsonExample()); + this.setLimbExample(new LimbJsonExample()); + this.setModSettingsExample(new ModSettingsJsonExample()); + this.setNametagExample(new NametagJsonExample()); + this.setNickHiderExample(new NickHiderJsonExample()); + this.setNotificationExample(new NotificationJsonExample()); + this.setRichPresenceExample(new RichPresenceJsonExample()); + this.setServerRuleExample(new ServerRuleJsonExample()); + this.setStaffModExample(new StaffModJsonExample()); + this.setStopwatchExample(new StopwatchJsonExample()); + this.setTeamExample(new TeamJsonExample()); + this.setTebexExample(new TebexJsonExample()); + this.setTitleExample(new TitleJsonExample()); + this.setTntCountdownExample(new TntCountdownJsonExample()); + this.setTransferExample(new TransferJsonExample()); + this.setVignetteExample(new VignetteJsonExample()); + this.setWaypointExample(new WaypointJsonExample()); + } + + @Override + public void registerListeners() { + new ApolloPlayerJsonListener(this); + } + + @Override + public ApolloExampleType getType() { + return ApolloExampleType.JSON; + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/listeners/ApolloPlayerJsonListener.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/listener/ApolloPlayerJsonListener.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/listeners/ApolloPlayerJsonListener.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/listener/ApolloPlayerJsonListener.java index 688378e8..3de23bfa 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/listeners/ApolloPlayerJsonListener.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/listener/ApolloPlayerJsonListener.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.listeners; +package com.lunarclient.apollo.example.json.listener; import com.google.gson.JsonObject; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; import java.util.HashSet; import java.util.Set; import java.util.UUID; diff --git a/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/AutoTextHotkeyJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/AutoTextHotkeyJsonExample.java new file mode 100644 index 00000000..e1bd38f9 --- /dev/null +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/AutoTextHotkeyJsonExample.java @@ -0,0 +1,55 @@ +/* + * 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.module; + +import com.google.gson.JsonObject; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class AutoTextHotkeyJsonExample extends AutoTextHotkeyExample { + + @Override + public void setBlockedTextInputs(List blockedTextInputs) { + Map properties = new HashMap<>(); + properties.put("block-text-inputs", true); + properties.put("blocked-text-inputs", blockedTextInputs); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("auto_text_hotkey", properties); + JsonPacketUtil.broadcastPacket(message); + } + + @Override + public void setBlockChatMesssageTextInputs(boolean value) { + Map properties = new HashMap<>(); + properties.put("block-chat-message-text-inputs", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("auto_text_hotkey", properties); + JsonPacketUtil.broadcastPacket(message); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/BeamJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/BeamJsonExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/BeamJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/BeamJsonExample.java index 2446e73c..d67010e0 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/BeamJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/BeamJsonExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.BeamExample; import java.awt.Color; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/BorderJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/BorderJsonExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/BorderJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/BorderJsonExample.java index 317f2856..92293510 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/BorderJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/BorderJsonExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.BorderExample; import java.awt.Color; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ChatJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/ChatJsonExample.java similarity index 62% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ChatJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/ChatJsonExample.java index cb6ae53f..b43359bc 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ChatJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/ChatJsonExample.java @@ -21,21 +21,32 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; import com.google.gson.JsonObject; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.ChatExample; -import com.lunarclient.apollo.example.json.AdventureUtil; -import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.AdventureUtil; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.module.impl.ChatExample; +import com.lunarclient.apollo.example.util.ServerUtil; +import java.util.concurrent.atomic.AtomicInteger; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.Bukkit; import org.bukkit.scheduler.BukkitRunnable; public class ChatJsonExample extends ChatExample { @Override public void displayLiveChatMessageExample() { + if (ServerUtil.isFolia()) { + this.runFoliaChatMessageTask(); + } else { + this.runBukkitChatMessageTask(); + } + } + + private void runBukkitChatMessageTask() { BukkitRunnable runnable = new BukkitRunnable() { private int countdown = 5; @@ -65,7 +76,34 @@ public void run() { } }; - runnable.runTaskTimer(ApolloExamplePlugin.getPlugin(), 0L, 20L); + runnable.runTaskTimer(ApolloExamplePlugin.getInstance(), 1L, 20L); + } + + private void runFoliaChatMessageTask() { + AtomicInteger countdown = new AtomicInteger(5); + + Bukkit.getGlobalRegionScheduler().runAtFixedRate(ApolloExamplePlugin.getInstance(), task -> { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.chat.v1.DisplayLiveChatMessageMessage"); + message.addProperty("message_id", 13); + + int seconds = countdown.getAndDecrement(); + if (seconds > 0) { + message.addProperty("adventure_json_lines", AdventureUtil.toJson( + Component.text("Game starting in ", NamedTextColor.GREEN) + .append(Component.text(seconds, NamedTextColor.BLUE)) + )); + + JsonPacketUtil.broadcastPacket(message); + } else { + message.addProperty("adventure_json_lines", AdventureUtil.toJson( + Component.text("Game started! ", NamedTextColor.GREEN) + )); + + JsonPacketUtil.broadcastPacket(message); + task.cancel(); + } + }, 1L, 20L); } @Override diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ColoredFireJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/ColoredFireJsonExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ColoredFireJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/ColoredFireJsonExample.java index 662335b0..3c146139 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ColoredFireJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/ColoredFireJsonExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.ColoredFireExample; import java.awt.Color; import java.util.UUID; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/CombatJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/CombatJsonExample.java similarity index 87% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/CombatJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/CombatJsonExample.java index 94e32230..31559640 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/CombatJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/CombatJsonExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.CombatExample; import java.util.HashMap; import java.util.Map; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/CooldownJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/CooldownJsonExample.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/CooldownJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/CooldownJsonExample.java index 2bf52d19..96393e8b 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/CooldownJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/CooldownJsonExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.CooldownExample; import java.time.Duration; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/EntityJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/EntityJsonExample.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/EntityJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/EntityJsonExample.java index 9094fc3b..c1f6c3d5 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/EntityJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/EntityJsonExample.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.EntityExample; import org.bukkit.entity.Cow; import org.bukkit.entity.Player; import org.bukkit.entity.Sheep; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/GlowJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/GlowJsonExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/GlowJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/GlowJsonExample.java index fef33533..dd1b8786 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/GlowJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/GlowJsonExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.GlowExample; import java.awt.Color; import java.util.UUID; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/HologramJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/HologramJsonExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/HologramJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/HologramJsonExample.java index 101e498b..c6692845 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/HologramJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/HologramJsonExample.java @@ -21,16 +21,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.AdventureUtil; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.HologramExample; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/LimbJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/LimbJsonExample.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/LimbJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/LimbJsonExample.java index 9790e81e..33ec2f5c 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/LimbJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/LimbJsonExample.java @@ -21,15 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.LimbExample; import org.bukkit.entity.Player; public class LimbJsonExample extends LimbExample { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ModSettingsJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/ModSettingsJsonExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ModSettingsJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/ModSettingsJsonExample.java index 6982ad1e..fc3b577b 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ModSettingsJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/ModSettingsJsonExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.ModSettingsExample; import java.util.HashMap; import java.util.Map; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NametagJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/NametagJsonExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NametagJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/NametagJsonExample.java index 74283938..c994179c 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NametagJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/NametagJsonExample.java @@ -21,16 +21,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.AdventureUtil; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.NametagExample; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NickHiderJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/NickHiderJsonExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NickHiderJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/NickHiderJsonExample.java index c93cca16..0b1dfd62 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NickHiderJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/NickHiderJsonExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; import com.google.gson.JsonObject; -import com.lunarclient.apollo.example.common.modules.impl.NickHiderExample; -import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.module.impl.NickHiderExample; import org.bukkit.entity.Player; public class NickHiderJsonExample extends NickHiderExample { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NotificationJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/NotificationJsonExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NotificationJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/NotificationJsonExample.java index 13c860ca..9a587a49 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/NotificationJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/NotificationJsonExample.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.AdventureUtil; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.NotificationExample; import java.time.Duration; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/RichPresenceJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/RichPresenceJsonExample.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/RichPresenceJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/RichPresenceJsonExample.java index 855f6283..b238fa47 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/RichPresenceJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/RichPresenceJsonExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; import com.google.gson.JsonObject; -import com.lunarclient.apollo.example.common.modules.impl.RichPresenceExample; -import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.module.impl.RichPresenceExample; import org.bukkit.entity.Player; public class RichPresenceJsonExample extends RichPresenceExample { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ServerRuleJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/ServerRuleJsonExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ServerRuleJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/ServerRuleJsonExample.java index ea6ab10d..e4b38ddb 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/ServerRuleJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/ServerRuleJsonExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.ServerRuleExample; import java.util.HashMap; import java.util.Map; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/StaffModJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/StaffModJsonExample.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/StaffModJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/StaffModJsonExample.java index 88c45481..73600ae5 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/StaffModJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/StaffModJsonExample.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.module.impl.StaffModExample; import java.util.stream.Stream; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/StopwatchJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/StopwatchJsonExample.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/StopwatchJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/StopwatchJsonExample.java index 3d64539c..64b7f332 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/StopwatchJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/StopwatchJsonExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; import com.google.gson.JsonObject; -import com.lunarclient.apollo.example.common.modules.impl.StopwatchExample; -import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.module.impl.StopwatchExample; import org.bukkit.entity.Player; public class StopwatchJsonExample extends StopwatchExample { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TeamJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TeamJsonExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TeamJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TeamJsonExample.java index 61d933e0..4aa4afba 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TeamJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TeamJsonExample.java @@ -21,22 +21,24 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.AdventureUtil; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.TeamExample; +import com.lunarclient.apollo.example.util.ServerUtil; import java.awt.Color; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.UUID; +import java.util.concurrent.TimeUnit; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; @@ -44,7 +46,6 @@ 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 { @@ -52,9 +53,13 @@ public class TeamJsonExample extends TeamExample implements Listener { private final Map teamsByPlayerUuid = Maps.newHashMap(); public TeamJsonExample() { - new TeamUpdateTask(); + if (ServerUtil.isFolia()) { + this.runFoliaTeamUpdateTask(); + } else { + this.runBukkitTeamUpdateTask(); + } - Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getInstance()); } @EventHandler @@ -91,6 +96,18 @@ public void deleteTeam(UUID teamId) { } } + private void runBukkitTeamUpdateTask() { + Bukkit.getScheduler().runTaskTimerAsynchronously(ApolloExamplePlugin.getInstance(), () -> { + this.teamsByTeamId.values().forEach(Team::refresh); + }, 1L, 1L); + } + + private void runFoliaTeamUpdateTask() { + Bukkit.getAsyncScheduler().runAtFixedRate(ApolloExamplePlugin.getInstance(), task -> { + this.teamsByTeamId.values().forEach(Team::refresh); + }, 50L, 50L, TimeUnit.MILLISECONDS); + } + public class Team { private final UUID teamId; @@ -118,7 +135,6 @@ public void removeMember(Player player) { 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() @@ -173,19 +189,6 @@ public int 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()); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TebexJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TebexJsonExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TebexJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TebexJsonExample.java index ff740125..a3a8920c 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TebexJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TebexJsonExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; import com.google.gson.JsonObject; -import com.lunarclient.apollo.example.common.modules.impl.TebexExample; -import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.module.impl.TebexExample; import org.bukkit.entity.Player; public class TebexJsonExample extends TebexExample { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TitleJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TitleJsonExample.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TitleJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TitleJsonExample.java index 184a6a89..31d4de8e 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TitleJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TitleJsonExample.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.AdventureUtil; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.TitleExample; import java.time.Duration; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TntCountdownJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TntCountdownJsonExample.java similarity index 70% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TntCountdownJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TntCountdownJsonExample.java index 6abac834..90483853 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TntCountdownJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TntCountdownJsonExample.java @@ -21,20 +21,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.TntCountdownExample; 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; @@ -45,18 +41,8 @@ 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()); + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getInstance()); } @Override @@ -70,31 +56,10 @@ public void setTntCountdownExample() { @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); - } + TNTPrimed entity = viewer.getWorld().spawn(viewer.getLocation(), TNTPrimed.class); + entity.setFuseTicks(customTicks); JsonPacketUtil.sendPacket(viewer, this.createTNTCountdownMessage(entity, customTicks)); } diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TransferJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TransferJsonExample.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TransferJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TransferJsonExample.java index 8fdc2719..340a4b7b 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/TransferJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/TransferJsonExample.java @@ -21,9 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; -import com.lunarclient.apollo.example.common.modules.impl.TransferExample; +import com.lunarclient.apollo.example.module.impl.TransferExample; import org.bukkit.entity.Player; public class TransferJsonExample extends TransferExample { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/VignetteJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/VignetteJsonExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/VignetteJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/VignetteJsonExample.java index 8a227562..d6720c4a 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/VignetteJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/VignetteJsonExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; import com.google.gson.JsonObject; -import com.lunarclient.apollo.example.common.modules.impl.VignetteExample; -import com.lunarclient.apollo.example.json.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.module.impl.VignetteExample; import org.bukkit.entity.Player; public class VignetteJsonExample extends VignetteExample { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/WaypointJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/WaypointJsonExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/WaypointJsonExample.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/WaypointJsonExample.java index 1d206699..8907f3bb 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/examples/WaypointJsonExample.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/WaypointJsonExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.json.examples; +package com.lunarclient.apollo.example.json.module; 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 com.lunarclient.apollo.example.json.util.JsonPacketUtil; +import com.lunarclient.apollo.example.json.util.JsonUtil; +import com.lunarclient.apollo.example.module.impl.WaypointExample; import java.awt.Color; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/AdventureUtil.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/util/AdventureUtil.java similarity index 96% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/AdventureUtil.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/util/AdventureUtil.java index 91e172d2..2efd4938 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/AdventureUtil.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/util/AdventureUtil.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.json; +package com.lunarclient.apollo.example.json.util; import lombok.NonNull; import net.kyori.adventure.text.Component; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/JsonPacketUtil.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/util/JsonPacketUtil.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/JsonPacketUtil.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/util/JsonPacketUtil.java index 585cf7d8..1ac6bd83 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/JsonPacketUtil.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/util/JsonPacketUtil.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.json; +package com.lunarclient.apollo.example.json.util; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Table; @@ -69,14 +69,14 @@ public final class JsonPacketUtil { } public static void sendPacket(Player player, JsonObject message) { - player.sendPluginMessage(ApolloExamplePlugin.getPlugin(), "apollo:json", message.toString().getBytes()); + player.sendPluginMessage(ApolloExamplePlugin.getInstance(), "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)); + player.sendPluginMessage(ApolloExamplePlugin.getInstance(), "apollo:json", data)); } public static JsonObject createEnableModuleObject(@NotNull String module, Map properties) { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/JsonUtil.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/util/JsonUtil.java similarity index 99% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/json/JsonUtil.java rename to bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/util/JsonUtil.java index bc494929..18966567 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/json/JsonUtil.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/util/JsonUtil.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.json; +package com.lunarclient.apollo.example.json.util; import com.google.gson.JsonObject; import java.awt.Color; diff --git a/bukkit-example/src/main/resources/plugin.yml b/bukkit-example-json/src/main/resources/plugin.yml similarity index 86% rename from bukkit-example/src/main/resources/plugin.yml rename to bukkit-example-json/src/main/resources/plugin.yml index a354a518..ba7d9d64 100644 --- a/bukkit-example/src/main/resources/plugin.yml +++ b/bukkit-example-json/src/main/resources/plugin.yml @@ -1,13 +1,14 @@ -name: Apollo-Example -main: com.lunarclient.apollo.example.ApolloExamplePlugin -version: 1.1.7 +name: Apollo-Json-Example +main: com.lunarclient.apollo.example.json.ApolloJsonExamplePlatform +version: 1.1.8 author: Moonsworth softdepend: [ Apollo-Bukkit ] api-version: 1.13 +folia-supported: true commands: - switch: - description: "Switch the implementation type!" + autotexthotkey: + description: "Auto Text Hotkey!" beam: description: "Beams!" border: @@ -64,5 +65,3 @@ commands: description: "Vignette!" waypoint: description: "Waypoints!" - apollodebug: - description: "Apollo Debug!" diff --git a/bukkit-example-proto/build.gradle.kts b/bukkit-example-proto/build.gradle.kts new file mode 100644 index 00000000..774562ed --- /dev/null +++ b/bukkit-example-proto/build.gradle.kts @@ -0,0 +1,22 @@ +plugins { + id("apollo.base-conventions") + id("apollo.shadow-conventions") +} + +java { + javaTarget(21) +} + +dependencies { + api(libs.protobuf) + + api(libs.bundles.adventure) { + exclude("org.checkerframework") + exclude("net.kyori", "adventure-api") + exclude("net.kyori", "adventure-bom") + } + + compileOnly(libs.bukkit) + compileOnly(libs.folia) + implementation(project(":apollo-bukkit-example-common")) +} diff --git a/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java new file mode 100644 index 00000000..97074a1b --- /dev/null +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java @@ -0,0 +1,108 @@ +/* + * 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.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.ApolloExampleType; +import com.lunarclient.apollo.example.proto.listener.ApolloPlayerProtoListener; +import com.lunarclient.apollo.example.proto.module.AutoTextHotkeyProtoExample; +import com.lunarclient.apollo.example.proto.module.BeamProtoExample; +import com.lunarclient.apollo.example.proto.module.BorderProtoExample; +import com.lunarclient.apollo.example.proto.module.ChatProtoExample; +import com.lunarclient.apollo.example.proto.module.ColoredFireProtoExample; +import com.lunarclient.apollo.example.proto.module.CombatProtoExample; +import com.lunarclient.apollo.example.proto.module.CooldownProtoExample; +import com.lunarclient.apollo.example.proto.module.EntityProtoExample; +import com.lunarclient.apollo.example.proto.module.GlowProtoExample; +import com.lunarclient.apollo.example.proto.module.HologramProtoExample; +import com.lunarclient.apollo.example.proto.module.LimbProtoExample; +import com.lunarclient.apollo.example.proto.module.ModSettingsProtoExample; +import com.lunarclient.apollo.example.proto.module.NametagProtoExample; +import com.lunarclient.apollo.example.proto.module.NickHiderProtoExample; +import com.lunarclient.apollo.example.proto.module.NotificationProtoExample; +import com.lunarclient.apollo.example.proto.module.RichPresenceProtoExample; +import com.lunarclient.apollo.example.proto.module.ServerRuleProtoExample; +import com.lunarclient.apollo.example.proto.module.StaffModProtoExample; +import com.lunarclient.apollo.example.proto.module.StopwatchProtoExample; +import com.lunarclient.apollo.example.proto.module.TeamProtoExample; +import com.lunarclient.apollo.example.proto.module.TebexProtoExample; +import com.lunarclient.apollo.example.proto.module.TitleProtoExample; +import com.lunarclient.apollo.example.proto.module.TntCountdownProtoExample; +import com.lunarclient.apollo.example.proto.module.TransferProtoExample; +import com.lunarclient.apollo.example.proto.module.VignetteProtoExample; +import com.lunarclient.apollo.example.proto.module.WaypointProtoExample; +import lombok.Getter; + +@Getter +public class ApolloProtoExamplePlatform extends ApolloExamplePlugin { + + @Getter + private static ApolloProtoExamplePlatform instance; + + @Override + public void enable() { + instance = this; + } + + @Override + public void registerModuleExamples() { + this.setAutoTextHotkeyExample(new AutoTextHotkeyProtoExample()); + this.setBeamExample(new BeamProtoExample()); + this.setBorderExample(new BorderProtoExample()); + this.setChatExample(new ChatProtoExample()); + this.setColoredFireExample(new ColoredFireProtoExample()); + this.setCombatExample(new CombatProtoExample()); + this.setCooldownExample(new CooldownProtoExample()); + this.setEntityExample(new EntityProtoExample()); + this.setGlowExample(new GlowProtoExample()); + this.setHologramExample(new HologramProtoExample()); + this.setLimbExample(new LimbProtoExample()); + this.setModSettingsExample(new ModSettingsProtoExample()); + this.setNametagExample(new NametagProtoExample()); + this.setNickHiderExample(new NickHiderProtoExample()); + this.setNotificationExample(new NotificationProtoExample()); + this.setRichPresenceExample(new RichPresenceProtoExample()); + this.setServerRuleExample(new ServerRuleProtoExample()); + this.setStaffModExample(new StaffModProtoExample()); + this.setStopwatchExample(new StopwatchProtoExample()); + this.setTeamExample(new TeamProtoExample()); + this.setTebexExample(new TebexProtoExample()); + this.setTitleExample(new TitleProtoExample()); + this.setTntCountdownExample(new TntCountdownProtoExample()); + this.setTransferExample(new TransferProtoExample()); + this.setVignetteExample(new VignetteProtoExample()); + this.setWaypointExample(new WaypointProtoExample()); + } + + @Override + public void registerListeners() { + new ApolloPlayerProtoListener(this); + } + + @Override + public ApolloExampleType getType() { + return ApolloExampleType.PROTO; + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloPacketReceiveProtoListener.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/listener/ApolloPacketReceiveProtoListener.java similarity index 98% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloPacketReceiveProtoListener.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/listener/ApolloPacketReceiveProtoListener.java index 214cd6fc..4fb6e2d7 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloPacketReceiveProtoListener.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/listener/ApolloPacketReceiveProtoListener.java @@ -21,14 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.listeners; +package com.lunarclient.apollo.example.proto.listener; 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.example.proto.util.ProtobufUtil; import com.lunarclient.apollo.packetenrichment.v1.PlayerAttackMessage; import com.lunarclient.apollo.packetenrichment.v1.PlayerChatCloseMessage; import com.lunarclient.apollo.packetenrichment.v1.PlayerChatOpenMessage; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloPlayerProtoListener.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/listener/ApolloPlayerProtoListener.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloPlayerProtoListener.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/listener/ApolloPlayerProtoListener.java index 07791f15..efcbcbe9 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloPlayerProtoListener.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/listener/ApolloPlayerProtoListener.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.proto.listeners; +package com.lunarclient.apollo.example.proto.listener; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; import com.lunarclient.apollo.player.v1.UpdatePlayerWorldMessage; import java.util.HashSet; import java.util.Set; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloRoundtripProtoListener.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/listener/ApolloRoundtripProtoListener.java similarity index 97% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloRoundtripProtoListener.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/listener/ApolloRoundtripProtoListener.java index 3abd55f9..66738d56 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/listeners/ApolloRoundtripProtoListener.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/listener/ApolloRoundtripProtoListener.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.listeners; +package com.lunarclient.apollo.example.proto.listener; 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.example.proto.util.ProtobufPacketUtil; import com.lunarclient.apollo.transfer.v1.PingResponse; import com.lunarclient.apollo.transfer.v1.TransferResponse; import java.util.Map; diff --git a/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/AutoTextHotkeyProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/AutoTextHotkeyProtoExample.java new file mode 100644 index 00000000..56776538 --- /dev/null +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/AutoTextHotkeyProtoExample.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.module; + +import com.google.protobuf.ListValue; +import com.google.protobuf.Value; +import com.lunarclient.apollo.configurable.v1.ConfigurableSettings; +import com.lunarclient.apollo.example.module.impl.AutoTextHotkeyExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class AutoTextHotkeyProtoExample extends AutoTextHotkeyExample { + + @Override + public void setBlockedTextInputs(List blockedTextInputs) { + ListValue listValue = ListValue.newBuilder().addAllValues( + blockedTextInputs.stream() + .map(input -> Value.newBuilder().setStringValue(input).build()) + .collect(Collectors.toList()) + ).build(); + + Map properties = new HashMap<>(); + properties.put("block-text-inputs", Value.newBuilder().setBoolValue(true).build()); + properties.put("blocked-text-inputs", Value.newBuilder().setListValue(listValue).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("auto_text_hotkey", properties); + ProtobufPacketUtil.broadcastPacket(settings); + } + + @Override + public void setBlockChatMesssageTextInputs(boolean value) { + Map properties = new HashMap<>(); + properties.put("block-chat-message-text-inputs", Value.newBuilder().setBoolValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("auto_text_hotkey", properties); + ProtobufPacketUtil.broadcastPacket(settings); + } + +} diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/BeamProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/BeamProtoExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/BeamProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/BeamProtoExample.java index 0eba19f7..21c4fe2f 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/BeamProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/BeamProtoExample.java @@ -21,14 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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 com.lunarclient.apollo.example.module.impl.BeamExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; import java.awt.Color; import org.bukkit.Location; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/BorderProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/BorderProtoExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/BorderProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/BorderProtoExample.java index 03f1d934..66809131 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/BorderProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/BorderProtoExample.java @@ -21,14 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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 com.lunarclient.apollo.example.module.impl.BorderExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; import java.awt.Color; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ChatProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/ChatProtoExample.java similarity index 63% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ChatProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/ChatProtoExample.java index 1ca24849..68778350 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ChatProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/ChatProtoExample.java @@ -21,22 +21,33 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; import com.lunarclient.apollo.chat.v1.DisplayLiveChatMessageMessage; import com.lunarclient.apollo.chat.v1.RemoveLiveChatMessageMessage; import com.lunarclient.apollo.example.ApolloExamplePlugin; -import com.lunarclient.apollo.example.common.modules.impl.ChatExample; -import com.lunarclient.apollo.example.proto.AdventureUtil; -import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.module.impl.ChatExample; +import com.lunarclient.apollo.example.proto.util.AdventureUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.util.ServerUtil; +import java.util.concurrent.atomic.AtomicInteger; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.Bukkit; import org.bukkit.scheduler.BukkitRunnable; public class ChatProtoExample extends ChatExample { @Override public void displayLiveChatMessageExample() { + if (ServerUtil.isFolia()) { + this.runFoliaChatMessageTask(); + } else { + this.runBukkitChatMessageTask(); + } + } + + private void runBukkitChatMessageTask() { BukkitRunnable runnable = new BukkitRunnable() { private int countdown = 5; @@ -65,7 +76,33 @@ public void run() { } }; - runnable.runTaskTimer(ApolloExamplePlugin.getPlugin(), 0L, 20L); + runnable.runTaskTimer(ApolloExamplePlugin.getInstance(), 1L, 20L); + } + + private void runFoliaChatMessageTask() { + AtomicInteger countdown = new AtomicInteger(5); + + Bukkit.getGlobalRegionScheduler().runAtFixedRate(ApolloExamplePlugin.getInstance(), task -> { + DisplayLiveChatMessageMessage.Builder builder = DisplayLiveChatMessageMessage.newBuilder() + .setMessageId(13); + + int seconds = countdown.getAndDecrement(); + if (seconds > 0) { + builder.setAdventureJsonLines(AdventureUtil.toJson( + Component.text("Game starting in ", NamedTextColor.GREEN) + .append(Component.text(seconds, NamedTextColor.BLUE))) + ); + + ProtobufPacketUtil.broadcastPacket(builder.build()); + } else { + builder.setAdventureJsonLines(AdventureUtil.toJson( + Component.text("Game started! ", NamedTextColor.GREEN)) + ); + + ProtobufPacketUtil.broadcastPacket(builder.build()); + task.cancel(); + } + }, 1L, 20L); } @Override diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ColoredFireProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/ColoredFireProtoExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ColoredFireProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/ColoredFireProtoExample.java index 7c201692..b3f98da1 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ColoredFireProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/ColoredFireProtoExample.java @@ -21,14 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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 com.lunarclient.apollo.example.module.impl.ColoredFireExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; import java.awt.Color; import java.util.UUID; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/CombatProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/CombatProtoExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/CombatProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/CombatProtoExample.java index 69d5b67f..ae4ce94d 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/CombatProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/CombatProtoExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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 com.lunarclient.apollo.example.module.impl.CombatExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; import java.util.HashMap; import java.util.Map; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/CooldownProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/CooldownProtoExample.java similarity index 92% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/CooldownProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/CooldownProtoExample.java index 9746ec35..91d15069 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/CooldownProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/CooldownProtoExample.java @@ -21,14 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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 com.lunarclient.apollo.example.module.impl.CooldownExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; import java.time.Duration; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/EntityProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/EntityProtoExample.java similarity index 94% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/EntityProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/EntityProtoExample.java index 80c450c9..d07b3a4e 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/EntityProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/EntityProtoExample.java @@ -21,16 +21,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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 com.lunarclient.apollo.example.module.impl.EntityExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; import java.util.Set; import java.util.stream.Collectors; import org.bukkit.entity.Cow; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/GlowProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/GlowProtoExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/GlowProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/GlowProtoExample.java index 94546c5a..19fa1a43 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/GlowProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/GlowProtoExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; -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.example.module.impl.GlowExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; import com.lunarclient.apollo.glow.v1.OverrideGlowEffectMessage; import com.lunarclient.apollo.glow.v1.ResetGlowEffectMessage; import com.lunarclient.apollo.glow.v1.ResetGlowEffectsMessage; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/HologramProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/HologramProtoExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/HologramProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/HologramProtoExample.java index 2756b97b..f9735318 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/HologramProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/HologramProtoExample.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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.example.module.impl.HologramExample; +import com.lunarclient.apollo.example.proto.util.AdventureUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; import com.lunarclient.apollo.hologram.v1.DisplayHologramMessage; import com.lunarclient.apollo.hologram.v1.RemoveHologramMessage; import com.lunarclient.apollo.hologram.v1.ResetHologramsMessage; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/LimbProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/LimbProtoExample.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/LimbProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/LimbProtoExample.java index ee22585d..4664a492 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/LimbProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/LimbProtoExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; -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.example.module.impl.LimbExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; import com.lunarclient.apollo.limb.v1.ArmorPiece; import com.lunarclient.apollo.limb.v1.BodyPart; import com.lunarclient.apollo.limb.v1.HideArmorPiecesMessage; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ModSettingsProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/ModSettingsProtoExample.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ModSettingsProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/ModSettingsProtoExample.java index e9056e7e..86265bcb 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ModSettingsProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/ModSettingsProtoExample.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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 com.lunarclient.apollo.example.module.impl.ModSettingsExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; import java.util.HashMap; import java.util.Map; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NametagProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/NametagProtoExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NametagProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/NametagProtoExample.java index 8bafd5f8..e553bf5d 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NametagProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/NametagProtoExample.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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.example.module.impl.NametagExample; +import com.lunarclient.apollo.example.proto.util.AdventureUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; import com.lunarclient.apollo.nametag.v1.OverrideNametagMessage; import com.lunarclient.apollo.nametag.v1.ResetNametagMessage; import com.lunarclient.apollo.nametag.v1.ResetNametagsMessage; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NickHiderProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/NickHiderProtoExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NickHiderProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/NickHiderProtoExample.java index 9fb7dc47..0e2df4c6 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NickHiderProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/NickHiderProtoExample.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.proto.examples; +package com.lunarclient.apollo.example.proto.module; -import com.lunarclient.apollo.example.common.modules.impl.NickHiderExample; -import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.module.impl.NickHiderExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; import com.lunarclient.apollo.nickhider.v1.OverrideNickHiderMessage; import com.lunarclient.apollo.nickhider.v1.ResetNickHiderMessage; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NotificationProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/NotificationProtoExample.java similarity index 89% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NotificationProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/NotificationProtoExample.java index 6ee666da..92f5c5ed 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/NotificationProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/NotificationProtoExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; -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.example.module.impl.NotificationExample; +import com.lunarclient.apollo.example.proto.util.AdventureUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; import com.lunarclient.apollo.notification.v1.DisplayNotificationMessage; import com.lunarclient.apollo.notification.v1.ResetNotificationsMessage; import java.time.Duration; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/RichPresenceProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/RichPresenceProtoExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/RichPresenceProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/RichPresenceProtoExample.java index d407941a..338dbcbb 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/RichPresenceProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/RichPresenceProtoExample.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.proto.examples; +package com.lunarclient.apollo.example.proto.module; -import com.lunarclient.apollo.example.common.modules.impl.RichPresenceExample; -import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.module.impl.RichPresenceExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; import com.lunarclient.apollo.richpresence.v1.OverrideServerRichPresenceMessage; import com.lunarclient.apollo.richpresence.v1.ResetServerRichPresenceMessage; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ServerRuleProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/ServerRuleProtoExample.java similarity index 93% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ServerRuleProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/ServerRuleProtoExample.java index 32f8c9a4..c6c39c7d 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/ServerRuleProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/ServerRuleProtoExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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 com.lunarclient.apollo.example.module.impl.ServerRuleExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; import java.util.HashMap; import java.util.Map; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/StaffModProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/StaffModProtoExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/StaffModProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/StaffModProtoExample.java index 9e6a8299..d3047d41 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/StaffModProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/StaffModProtoExample.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.proto.examples; +package com.lunarclient.apollo.example.proto.module; -import com.lunarclient.apollo.example.common.modules.impl.StaffModExample; -import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.module.impl.StaffModExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; import com.lunarclient.apollo.staffmod.v1.DisableStaffModsMessage; import com.lunarclient.apollo.staffmod.v1.EnableStaffModsMessage; import com.lunarclient.apollo.staffmod.v1.StaffMod; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/StopwatchProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/StopwatchProtoExample.java similarity index 91% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/StopwatchProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/StopwatchProtoExample.java index 67ea1840..53c3e829 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/StopwatchProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/StopwatchProtoExample.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.proto.examples; +package com.lunarclient.apollo.example.proto.module; -import com.lunarclient.apollo.example.common.modules.impl.StopwatchExample; -import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.module.impl.StopwatchExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; import com.lunarclient.apollo.stopwatch.v1.ResetStopwatchMessage; import com.lunarclient.apollo.stopwatch.v1.StartStopwatchMessage; import com.lunarclient.apollo.stopwatch.v1.StopStopwatchMessage; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TeamProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TeamProtoExample.java similarity index 88% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TeamProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TeamProtoExample.java index 5837c985..24f995b2 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TeamProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TeamProtoExample.java @@ -21,15 +21,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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.example.module.impl.TeamExample; +import com.lunarclient.apollo.example.proto.util.AdventureUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; +import com.lunarclient.apollo.example.util.ServerUtil; import com.lunarclient.apollo.team.v1.ResetTeamMembersMessage; import com.lunarclient.apollo.team.v1.TeamMember; import com.lunarclient.apollo.team.v1.UpdateTeamMembersMessage; @@ -39,6 +40,7 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -47,7 +49,6 @@ 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 { @@ -55,9 +56,13 @@ public class TeamProtoExample extends TeamExample implements Listener { private final Map teamsByPlayerUuid = Maps.newHashMap(); public TeamProtoExample() { - new TeamUpdateTask(); + if (ServerUtil.isFolia()) { + this.runFoliaTeamUpdateTask(); + } else { + this.runBukkitTeamUpdateTask(); + } - Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getInstance()); } @EventHandler @@ -94,6 +99,18 @@ public void deleteTeam(UUID teamId) { } } + private void runBukkitTeamUpdateTask() { + Bukkit.getScheduler().runTaskTimerAsynchronously(ApolloExamplePlugin.getInstance(), () -> { + this.teamsByTeamId.values().forEach(Team::refresh); + }, 1L, 1L); + } + + private void runFoliaTeamUpdateTask() { + Bukkit.getAsyncScheduler().runAtFixedRate(ApolloExamplePlugin.getInstance(), task -> { + this.teamsByTeamId.values().forEach(Team::refresh); + }, 50L, 50L, TimeUnit.MILLISECONDS); + } + public class Team { private final UUID teamId; @@ -172,19 +189,6 @@ public int 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()); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TebexProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TebexProtoExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TebexProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TebexProtoExample.java index d547ead0..bb3ab2ec 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TebexProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TebexProtoExample.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.proto.examples; +package com.lunarclient.apollo.example.proto.module; -import com.lunarclient.apollo.example.common.modules.impl.TebexExample; -import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.module.impl.TebexExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; import com.lunarclient.apollo.tebex.v1.OpenTebexEmbeddedCheckoutMessage; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TitleProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TitleProtoExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TitleProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TitleProtoExample.java index 705752a0..786e2c71 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TitleProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TitleProtoExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; -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.example.module.impl.TitleExample; +import com.lunarclient.apollo.example.proto.util.AdventureUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; import com.lunarclient.apollo.title.v1.DisplayTitleMessage; import com.lunarclient.apollo.title.v1.ResetTitlesMessage; import com.lunarclient.apollo.title.v1.TitleType; @@ -36,7 +36,7 @@ import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.entity.Player; -public class TitleProtoExample extends TitleJsonExample { +public class TitleProtoExample extends TitleExample { @Override public void displayTitleExample(Player viewer) { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TntCountdownProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TntCountdownProtoExample.java similarity index 70% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TntCountdownProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TntCountdownProtoExample.java index 16ef01c3..d68b2c5f 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TntCountdownProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TntCountdownProtoExample.java @@ -21,22 +21,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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.example.module.impl.TntCountdownExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.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; @@ -46,18 +42,8 @@ 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()); + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getInstance()); } @Override @@ -71,44 +57,23 @@ public void setTntCountdownExample() { @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); - } + TNTPrimed entity = viewer.getWorld().spawn(viewer.getLocation(), TNTPrimed.class); + entity.setFuseTicks(customTicks); SetTntCountdownMessage message = SetTntCountdownMessage.newBuilder() .setEntityId(ProtobufUtil.createEntityIdProto(entity.getEntityId(), entity.getUniqueId())) .setDurationTicks(customTicks) .build(); - ProtobufPacketUtil.sendPacket(viewer, message); + ProtobufPacketUtil.broadcastPacket(message); } @Override public void clearTntCountdownOptionExample() { Map properties = new HashMap<>(); - properties.put("tnt-ticks", Value.newBuilder().setNumberValue(80).build()); + properties.put("tnt-ticks", Value.newBuilder().setNumberValue(160).build()); ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("tnt_countdown", properties); ProtobufPacketUtil.broadcastPacket(settings); diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TransferProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TransferProtoExample.java similarity index 95% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TransferProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TransferProtoExample.java index f674601b..5e2b8c20 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/TransferProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/TransferProtoExample.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; 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.example.module.impl.TransferExample; +import com.lunarclient.apollo.example.proto.listener.ApolloRoundtripProtoListener; import com.lunarclient.apollo.transfer.v1.PingData; import com.lunarclient.apollo.transfer.v1.PingRequest; import com.lunarclient.apollo.transfer.v1.PingResponse; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/VignetteProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/VignetteProtoExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/VignetteProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/VignetteProtoExample.java index 3cb665c9..6fb59896 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/VignetteProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/VignetteProtoExample.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.proto.examples; +package com.lunarclient.apollo.example.proto.module; -import com.lunarclient.apollo.example.common.modules.impl.VignetteExample; -import com.lunarclient.apollo.example.proto.ProtobufPacketUtil; +import com.lunarclient.apollo.example.module.impl.VignetteExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; import com.lunarclient.apollo.vignette.v1.DisplayVignetteMessage; import com.lunarclient.apollo.vignette.v1.ResetVignetteMessage; import org.bukkit.entity.Player; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/WaypointProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/WaypointProtoExample.java similarity index 90% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/WaypointProtoExample.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/WaypointProtoExample.java index df457fa9..523f81c7 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/examples/WaypointProtoExample.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/WaypointProtoExample.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.lunarclient.apollo.example.proto.examples; +package com.lunarclient.apollo.example.proto.module; -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.example.module.impl.WaypointExample; +import com.lunarclient.apollo.example.proto.util.ProtobufPacketUtil; +import com.lunarclient.apollo.example.proto.util.ProtobufUtil; import com.lunarclient.apollo.waypoint.v1.DisplayWaypointMessage; import com.lunarclient.apollo.waypoint.v1.RemoveWaypointMessage; import com.lunarclient.apollo.waypoint.v1.ResetWaypointsMessage; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/AdventureUtil.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/util/AdventureUtil.java similarity index 96% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/AdventureUtil.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/util/AdventureUtil.java index aaab531d..ad4ec611 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/AdventureUtil.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/util/AdventureUtil.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.proto; +package com.lunarclient.apollo.example.proto.util; import lombok.NonNull; import net.kyori.adventure.text.Component; diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/ProtobufPacketUtil.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufPacketUtil.java similarity index 96% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/ProtobufPacketUtil.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufPacketUtil.java index 4810dfcb..97590deb 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/ProtobufPacketUtil.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufPacketUtil.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.proto; +package com.lunarclient.apollo.example.proto.util; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Table; @@ -102,14 +102,14 @@ public static ConfigurableSettings createModuleMessage(String module, Map - player.sendPluginMessage(ApolloExamplePlugin.getPlugin(), "lunar:apollo", bytes)); + player.sendPluginMessage(ApolloExamplePlugin.getInstance(), "lunar:apollo", bytes)); } private ProtobufPacketUtil() { diff --git a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/ProtobufUtil.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufUtil.java similarity index 99% rename from bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/ProtobufUtil.java rename to bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufUtil.java index a8ea6dfe..ff985cea 100644 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/proto/ProtobufUtil.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufUtil.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.proto; +package com.lunarclient.apollo.example.proto.util; import com.google.protobuf.Timestamp; import com.lunarclient.apollo.common.v1.AdvancedResourceLocationIcon; diff --git a/bukkit-example-proto/src/main/resources/plugin.yml b/bukkit-example-proto/src/main/resources/plugin.yml new file mode 100644 index 00000000..0ccac43d --- /dev/null +++ b/bukkit-example-proto/src/main/resources/plugin.yml @@ -0,0 +1,67 @@ +name: Apollo-Proto-Example +main: com.lunarclient.apollo.example.proto.ApolloProtoExamplePlatform +version: 1.1.8 +author: Moonsworth +softdepend: [ Apollo-Bukkit ] +api-version: 1.13 +folia-supported: true + +commands: + autotexthotkey: + description: "Auto Text Hotkey!" + beam: + description: "Beams!" + border: + description: "Borders!" + chat: + description: "Chat!" + coloredfire: + description: "Colored Fires!" + combat: + description: "Combat!" + cooldown: + description: "Cooldowns!" + entity: + description: "Entity!" + glint: + description: "Glint!" + glow: + description: "Glow!" + hologram: + description: "Holograms!" + inventory: + description: "Inventory!" + limb: + description: "Limb!" + modsettings: + description: "ModSettings!" + nametag: + description: "Nametags!" + nickhider: + description: "Nick Hider!" + notification: + description: "Notifications!" + richpresence: + description: "Rich Presence!" + saturation: + description: "Saturation!" + serverrule: + description: "Server Rule!" + staffmod: + description: "Staff Mods!" + stopwatch: + description: "Stopwatch!" + team: + description: "Teams!" + tebex: + description: "Tebex!" + title: + description: "Titles!" + tntcountdown: + description: "TNT Countdown!" + transfer: + description: "Transfer!" + vignette: + description: "Vignette!" + waypoint: + description: "Waypoints!" diff --git a/bukkit-example/build.gradle.kts b/bukkit-example/build.gradle.kts deleted file mode 100644 index 3f9240e3..00000000 --- a/bukkit-example/build.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index 3043153b..00000000 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * 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; - -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.GlintCommand; -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.InventoryCommand; -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.SaturationCommand; -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.GlintExample; -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.InventoryExample; -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.SaturationExample; -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; - -@Getter -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; - private ColoredFireExample coloredFireExample; - private CombatExample combatExample; - private CooldownExample cooldownExample; - private EntityExample entityExample; - private GlintExample glintExample; - private GlowExample glowExample; - private HologramExample hologramExample; - private InventoryExample inventoryExample; - private LimbExample limbExample; - private ModSettingsExample modSettingsExample; - private NametagExample nametagExample; - private NickHiderExample nickHiderExample; - private NotificationExample notificationExample; - private RichPresenceExample richPresenceExample; - private SaturationExample saturationExample; - private ServerRuleExample serverRuleExample; - 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.changeImplementationType(ApolloExampleType.API); - this.registerCommands(); - } - - @Override - public void onDisable() { - - } - - 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()); - this.getCommand("coloredfire").setExecutor(new ColoredFireCommand()); - this.getCommand("combat").setExecutor(new CombatCommand()); - this.getCommand("cooldown").setExecutor(new CooldownCommand()); - this.getCommand("entity").setExecutor(new EntityCommand()); - this.getCommand("glint").setExecutor(new GlintCommand()); - this.getCommand("glow").setExecutor(new GlowCommand()); - this.getCommand("hologram").setExecutor(new HologramCommand()); - this.getCommand("inventory").setExecutor(new InventoryCommand()); - this.getCommand("limb").setExecutor(new LimbCommand()); - this.getCommand("modsettings").setExecutor(new ModSettingsCommand()); - this.getCommand("nametag").setExecutor(new NametagCommand()); - this.getCommand("nickhider").setExecutor(new NickHiderCommand()); - this.getCommand("notification").setExecutor(new NotificationCommand()); - this.getCommand("richpresence").setExecutor(new RichPresenceCommand()); - this.getCommand("saturation").setExecutor(new SaturationCommand()); - this.getCommand("serverrule").setExecutor(new ServerRuleCommand()); - 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()); - this.getCommand("vignette").setExecutor(new VignetteCommand()); - 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(); - - this.glintExample = new GlintExample(); - this.inventoryExample = new InventoryExample(); - this.saturationExample = new SaturationExample(); - - 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() { - 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/common/commands/SwitchCommand.java b/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/SwitchCommand.java deleted file mode 100644 index 2a960e15..00000000 --- a/bukkit-example/src/main/java/com/lunarclient/apollo/example/common/commands/SwitchCommand.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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/build.gradle.kts b/bukkit/build.gradle.kts index 1acbb87e..5852bfbc 100644 --- a/bukkit/build.gradle.kts +++ b/bukkit/build.gradle.kts @@ -22,3 +22,7 @@ dependencies { "baseAdventure4"(libs.adventure.platform.bukkit) } + +tasks.named("compileJava") { + dependsOn(":extra:apollo-extra-adventure4:shadowJar") +} diff --git a/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java b/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java index f2be6e51..117e952d 100644 --- a/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java +++ b/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java @@ -29,6 +29,7 @@ import com.lunarclient.apollo.listener.ApolloWorldListener; import com.lunarclient.apollo.loader.PlatformPlugin; import com.lunarclient.apollo.module.ApolloModuleManagerImpl; +import com.lunarclient.apollo.module.autotexthotkey.AutoTextHotkeyModule; import com.lunarclient.apollo.module.beam.BeamModule; import com.lunarclient.apollo.module.beam.BeamModuleImpl; import com.lunarclient.apollo.module.border.BorderModule; @@ -123,6 +124,7 @@ public void onEnable() { new ApolloWorldListener(this.plugin); ((ApolloModuleManagerImpl) Apollo.getModuleManager()) + .addModule(AutoTextHotkeyModule.class) .addModule(BeamModule.class, new BeamModuleImpl()) .addModule(BorderModule.class, new BorderModuleImpl()) .addModule(ChatModule.class, new ChatModuleImpl()) 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 deleted file mode 100644 index 20c728b9..00000000 --- a/bukkit/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModuleImpl.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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.tntcountdown; - -import com.lunarclient.apollo.Apollo; -import com.lunarclient.apollo.ApolloBukkitPlatform; -import com.lunarclient.apollo.common.ApolloEntity; -import com.lunarclient.apollo.network.NetworkTypes; -import com.lunarclient.apollo.player.AbstractApolloPlayer; -import com.lunarclient.apollo.player.ApolloPlayer; -import com.lunarclient.apollo.tntcountdown.v1.SetTntCountdownMessage; -import java.lang.reflect.Method; -import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.World; -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; - -import static com.lunarclient.apollo.util.Ranges.checkPositive; - -/** - * Provides the tnt countdown module. - * - * @since 1.0.0 - */ -public final class TntCountdownModuleImpl extends TntCountdownModule implements Listener { - - private static Method entityGetter; - - static { - try { - TntCountdownModuleImpl.entityGetter = Bukkit.class.getDeclaredMethod("getEntity", UUID.class); - } catch (Throwable throwable) { - // Ignore for legacy versions. - } - } - - @Override - protected void onEnable() { - Bukkit.getPluginManager().registerEvents(this, ApolloBukkitPlatform.getInstance().getPlugin()); - } - - @Override - public void setTntCountdown(ApolloEntity entity, int ticks) { - checkPositive(ticks, "TntCountdown#ticks"); - - TNTPrimed target = null; - if (TntCountdownModuleImpl.entityGetter != null) { - try { - target = (TNTPrimed) TntCountdownModuleImpl.entityGetter.invoke(null, entity.getEntityUuid()); - } catch (Throwable throwable) { - throwable.printStackTrace(); - } - } else { - for (World world : Bukkit.getWorlds()) { - for (TNTPrimed compare : world.getEntitiesByClass(TNTPrimed.class)) { - if (compare.getUniqueId().equals(entity.getEntityUuid())) { - target = compare; - break; - } - } - } - } - - if (target != null) { - target.setFuseTicks(ticks); - } - - SetTntCountdownMessage message = SetTntCountdownMessage.newBuilder() - .setEntityId(NetworkTypes.toProtobuf(entity)) - .setDurationTicks(ticks) - .build(); - - for (ApolloPlayer viewer : Apollo.getPlayerManager().getPlayers()) { - ((AbstractApolloPlayer) viewer).sendPacket(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 = this.getOptions().get(TntCountdownModule.TNT_TICKS); - int defaultTicks = TntCountdownModule.TNT_TICKS.getDefaultValue(); - int currentTicks = primed.getFuseTicks(); - - 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(customTicks); - } - -} diff --git a/bukkit/src/platform-loader/resources/plugin.yml b/bukkit/src/platform-loader/resources/plugin.yml index 0b857350..251013ad 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.7 +version: 1.1.8 author: Moonsworth api-version: 1.13 soft-depend: [LunarClient-API] diff --git a/bungee/build.gradle.kts b/bungee/build.gradle.kts index fc8b3524..023bfcff 100644 --- a/bungee/build.gradle.kts +++ b/bungee/build.gradle.kts @@ -19,3 +19,7 @@ dependencies { "baseAdventure4"(libs.adventure.platform.bungee) } + +tasks.named("compileJava") { + dependsOn(":extra:apollo-extra-adventure4:shadowJar") +} diff --git a/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java b/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java index d5c8fb66..44fe00b0 100644 --- a/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java +++ b/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java @@ -28,6 +28,7 @@ import com.lunarclient.apollo.listener.ApolloPlayerListener; import com.lunarclient.apollo.loader.PlatformPlugin; import com.lunarclient.apollo.module.ApolloModuleManagerImpl; +import com.lunarclient.apollo.module.autotexthotkey.AutoTextHotkeyModule; import com.lunarclient.apollo.module.beam.BeamModule; import com.lunarclient.apollo.module.beam.BeamModuleImpl; import com.lunarclient.apollo.module.border.BorderModule; @@ -108,6 +109,7 @@ public void onEnable() { ApolloManager.bootstrap(this); ((ApolloModuleManagerImpl) Apollo.getModuleManager()) + .addModule(AutoTextHotkeyModule.class) .addModule(BeamModule.class, new BeamModuleImpl()) .addModule(BorderModule.class, new BorderModuleImpl()) .addModule(ChatModule.class, new ChatModuleImpl()) diff --git a/bungee/src/platform-loader/resources/plugin.yml b/bungee/src/platform-loader/resources/plugin.yml index 0f658e1b..6274a8dc 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.7 +version: 1.1.8 author: Moonsworth diff --git a/common/src/main/java/com/lunarclient/apollo/api/request/ServerStartRequest.java b/common/src/main/java/com/lunarclient/apollo/api/request/ServerStartRequest.java index 2cd2535c..3a23d670 100644 --- a/common/src/main/java/com/lunarclient/apollo/api/request/ServerStartRequest.java +++ b/common/src/main/java/com/lunarclient/apollo/api/request/ServerStartRequest.java @@ -78,7 +78,7 @@ public final class ServerStartRequest implements ApiRequest private final String platformType; /** - * The platform subtype (Bukkit, BungeeCord, Velocity...). + * The platform subtype (Bukkit, Folia, BungeeCord, Velocity...). * * @since 1.0.0 */ diff --git a/common/src/main/java/com/lunarclient/apollo/api/response/VersionResponse.java b/common/src/main/java/com/lunarclient/apollo/api/response/VersionResponse.java index 76b488d2..76fd9edc 100644 --- a/common/src/main/java/com/lunarclient/apollo/api/response/VersionResponse.java +++ b/common/src/main/java/com/lunarclient/apollo/api/response/VersionResponse.java @@ -82,6 +82,13 @@ public static final class Assets { */ String velocity; + /** + * Returns the latest version of apollo {@link String} Folia download URL. + * + * @return the apollo folia download url + * @since 1.1.8 + */ + String folia; } diff --git a/common/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModuleImpl.java new file mode 100644 index 00000000..d3629c20 --- /dev/null +++ b/common/src/main/java/com/lunarclient/apollo/module/tntcountdown/TntCountdownModuleImpl.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.module.tntcountdown; + +import com.lunarclient.apollo.common.ApolloEntity; +import com.lunarclient.apollo.network.NetworkTypes; +import com.lunarclient.apollo.player.AbstractApolloPlayer; +import com.lunarclient.apollo.recipients.Recipients; +import com.lunarclient.apollo.tntcountdown.v1.SetTntCountdownMessage; +import lombok.NonNull; + +import static com.lunarclient.apollo.util.Ranges.checkPositive; + +/** + * Provides the tnt countdown module. + * + * @since 1.1.8 + */ +public final class TntCountdownModuleImpl extends TntCountdownModule { + + @Override + public void setTntCountdown(@NonNull ApolloEntity entity, int ticks) { + this.setTntCountdown(Recipients.ofEveryone(), entity, ticks); + } + + @Override + public void setTntCountdown(@NonNull Recipients recipients, @NonNull ApolloEntity entity, int ticks) { + SetTntCountdownMessage message = SetTntCountdownMessage.newBuilder() + .setEntityId(NetworkTypes.toProtobuf(entity)) + .setDurationTicks(checkPositive(ticks, "TntCountdown#ticks")) + .build(); + + recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + } + +} diff --git a/common/src/main/java/com/lunarclient/apollo/version/ApolloVersionManager.java b/common/src/main/java/com/lunarclient/apollo/version/ApolloVersionManager.java index c01c3847..4b6e2b0a 100644 --- a/common/src/main/java/com/lunarclient/apollo/version/ApolloVersionManager.java +++ b/common/src/main/java/com/lunarclient/apollo/version/ApolloVersionManager.java @@ -203,6 +203,10 @@ private String getPlatformUrl(String platform) { case "velocity": { return this.assets.getVelocity(); } + + case "folia": { + return this.assets.getFolia(); + } } return null; diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 3dbb32ae..00000000 --- a/deploy.sh +++ /dev/null @@ -1,7 +0,0 @@ -# Deploy apollo to the test server -set -e -./gradlew clean build -scp bukkit/build/libs/apollo-bukkit-1.1.7.jar ubuntu@147.135.8.94:/home/ubuntu/apollo/plugins/ -scp bukkit-example/build/libs/apollo-bukkit-example-1.1.7.jar ubuntu@147.135.8.94:/home/ubuntu/apollo/plugins/ -scp bukkit/build/libs/apollo-bukkit-1.1.7.jar ubuntu@147.135.8.94:/home/ubuntu/lctest/plugins/ -scp bukkit-example/build/libs/apollo-bukkit-example-1.1.7.jar ubuntu@147.135.8.94:/home/ubuntu/lctest/plugins/ diff --git a/docs/acceptable-use.mdx b/docs/acceptable-use.mdx index bd0dde65..1ddf215c 100644 --- a/docs/acceptable-use.mdx +++ b/docs/acceptable-use.mdx @@ -20,7 +20,7 @@ to use. This would be done if a new module / feature is: ## Questions -If you have further questions about acceptable use, you can join the [Lunar Client Developers Discord](https://discord.gg/3T9Atyb6pf). +If you have further questions about acceptable use, you can join the [Lunar Client Developers Discord](https://lunarclient.dev/discord). _Disclaimer_: Our acceptable-use polices may be updated at any time to reflect changes in technology or legal requirements. Modules and features, both current and future, may require approval by Moonsworth, LLC for any reason. diff --git a/docs/developers/lightweight/json/packet-util.mdx b/docs/developers/lightweight/json/packet-util.mdx index 2bec4a69..0a740d1e 100644 --- a/docs/developers/lightweight/json/packet-util.mdx +++ b/docs/developers/lightweight/json/packet-util.mdx @@ -55,14 +55,14 @@ Use the following methods to send packets either to a specific player or to all ```java public static void sendPacket(Player player, JsonObject message) { - player.sendPluginMessage(ApolloExamplePlugin.getPlugin(), "apollo:json", message.toString().getBytes()); + player.sendPluginMessage(ApolloExamplePlugin.getInstance(), "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)); + player.sendPluginMessage(ApolloExamplePlugin.getInstance(), "apollo:json", data)); } ``` diff --git a/docs/developers/lightweight/protobuf/packet-util.mdx b/docs/developers/lightweight/protobuf/packet-util.mdx index fcac5c9b..3ea0b429 100644 --- a/docs/developers/lightweight/protobuf/packet-util.mdx +++ b/docs/developers/lightweight/protobuf/packet-util.mdx @@ -60,14 +60,14 @@ Use the following methods to send packets either to a specific player or to all ```java public static void sendPacket(Player player, GeneratedMessageV3 message) { byte[] bytes = Any.pack(message).toByteArray(); - player.sendPluginMessage(ApolloExamplePlugin.getPlugin(), "lunar:apollo", bytes); + player.sendPluginMessage(ApolloExamplePlugin.getInstance(), "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)); + player.sendPluginMessage(ApolloExamplePlugin.getInstance(), "lunar:apollo", bytes)); } ``` diff --git a/docs/developers/mods/_meta.json b/docs/developers/mods/_meta.json index 3fb09178..f4137431 100644 --- a/docs/developers/mods/_meta.json +++ b/docs/developers/mods/_meta.json @@ -2,6 +2,7 @@ "2ditems": "2dItems", "3dskins": "3dSkins", "armorstatus": "Armorstatus", + "autotextactions": "AutoTextActions", "autotexthotkey": "AutoTextHotkey", "blockoutline": "BlockOutline", "bossbar": "Bossbar", diff --git a/docs/developers/mods/autotextactions.mdx b/docs/developers/mods/autotextactions.mdx new file mode 100644 index 00000000..7e97473b --- /dev/null +++ b/docs/developers/mods/autotextactions.mdx @@ -0,0 +1,23 @@ +# Auto Text Actions + +Allows you to set up certain actions to be triggered on received chat messages. + +## Integration + +### How to toggle the mod + +```java +public void toggleAutoTextActionsExample(Player viewer, boolean value) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + apolloPlayerOpt.ifPresent(apolloPlayer -> this.modSettingModule.getOptions().set(apolloPlayer, ModAutoTextActions.ENABLED, value)); +} +``` + +## Available options + +- __`ENABLED`__ + - Config Key: `enabled` + - Values + - Type: `Boolean` + - Default: `false` + diff --git a/docs/developers/mods/chat.mdx b/docs/developers/mods/chat.mdx index 4c935322..c27fafe9 100644 --- a/docs/developers/mods/chat.mdx +++ b/docs/developers/mods/chat.mdx @@ -35,6 +35,33 @@ public void toggleChatExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `false` +- __`STACK_MESSAGES_TIME_BASED`__ + - Choose whether or not you want to stack multiple of the same messages in chat within a timeframe + - Config Key: `stack-messages-time-based` + - Values + - Type: `Boolean` + - Default: `true` + +- __`TIME_BASED_STACK_MESSAGES_TIMEFRAME`__ + - Config Key: `time-based-stack-messages-timeframe` + - Values + - Type: `Integer` + - Default: `10` + - Minimum: `1` + - Maximum: `60` + +- __`CHAT_STACK_IGNORE_BLANK`__ + - Config Key: `chat-stack-ignore-blank` + - Values + - Type: `Boolean` + - Default: `false` + +- __`CHAT_STACK_IGNORE_BREAK`__ + - Config Key: `chat-stack-ignore-break` + - Values + - Type: `Boolean` + - Default: `false` + - __`CHAT_HEIGHT`__ - Moves the chat up 12 pixels so it doesn't block health bar - Config Key: `chat-height` diff --git a/docs/developers/mods/cps.mdx b/docs/developers/mods/cps.mdx index e6087cda..3567c072 100644 --- a/docs/developers/mods/cps.mdx +++ b/docs/developers/mods/cps.mdx @@ -133,3 +133,15 @@ public void toggleCPSExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`REVERSE_TEXT`__ + - Config Key: `reverse-text` + - Values + - Type: `Boolean` + - Default: `false` + +- __`IGNORE_CANCELLED_CLICKS`__ + - Config Key: `ignore-cancelled-clicks` + - Values + - Type: `Boolean` + - Default: `false` + diff --git a/docs/developers/mods/hypixelmod.mdx b/docs/developers/mods/hypixelmod.mdx index e36f8b73..74d21371 100644 --- a/docs/developers/mods/hypixelmod.mdx +++ b/docs/developers/mods/hypixelmod.mdx @@ -99,6 +99,12 @@ public void toggleHypixelModsExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `false` +- __`USE_BEDWARS_LEVELS_FORMAT`__ + - Config Key: `use-bedwars-levels-format` + - Values + - Type: `Boolean` + - Default: `true` + - __`HIDE_PRIVATE_MESSAGES`__ - Config Key: `hide-private-messages` - Values diff --git a/docs/developers/mods/motionblur.mdx b/docs/developers/mods/motionblur.mdx index 89aa4931..00b0ab18 100644 --- a/docs/developers/mods/motionblur.mdx +++ b/docs/developers/mods/motionblur.mdx @@ -21,17 +21,11 @@ public void toggleMotionBlurExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `false` -- __`OLD_BLUR`__ - - Config Key: `old-blur` - - Values - - Type: `Boolean` - - Default: `false` - - __`VALUE`__ - Config Key: `value` - Values - Type: `Integer` - - Default: `1` + - Default: `5` - Minimum: `1` - Maximum: `10` diff --git a/docs/developers/mods/onesevenvisuals.mdx b/docs/developers/mods/onesevenvisuals.mdx index a6eec985..56083af3 100644 --- a/docs/developers/mods/onesevenvisuals.mdx +++ b/docs/developers/mods/onesevenvisuals.mdx @@ -21,3 +21,10 @@ public void toggle17VisualsExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `true` +- __`ALWAYS_SWING`__ + - Provides better visual feedback when attacking while keeping vanilla behavior + - Config Key: `always-swing` + - Values + - Type: `Boolean` + - Default: `true` + diff --git a/docs/developers/mods/skyblock.mdx b/docs/developers/mods/skyblock.mdx index a5e9963c..5b170560 100644 --- a/docs/developers/mods/skyblock.mdx +++ b/docs/developers/mods/skyblock.mdx @@ -100,6 +100,18 @@ public void toggleHypixelSkyblockExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `false` +- __`HIGHLIGHT_END_NODES`__ + - Config Key: `highlight-end-nodes` + - Values + - Type: `Boolean` + - Default: `false` + +- __`HIGHLIGHT_GLOWING_MUSHROOMS`__ + - Config Key: `highlight-glowing-mushrooms` + - Values + - Type: `Boolean` + - Default: `false` + - __`SHOW_GIANT_HPAT_FEET`__ - Makes Giant HP more visible by showing their HP at their feet. - Config Key: `show-giant-h-p-at-feet` diff --git a/docs/developers/mods/timechanger.mdx b/docs/developers/mods/timechanger.mdx index 35d5de92..9552c92d 100644 --- a/docs/developers/mods/timechanger.mdx +++ b/docs/developers/mods/timechanger.mdx @@ -25,9 +25,9 @@ public void toggleTimeChangerExample(Player viewer, boolean value) { - Config Key: `time-changer-time` - Values - Type: `Integer` - - Default: `-12000` - - Minimum: `-18000` - - Maximum: `-6000` + - Default: `12000` + - Minimum: `0` + - Maximum: `24000` - __`HORIZON_YLEVEL`__ - Config Key: `horizon-y-level` @@ -43,3 +43,17 @@ public void toggleTimeChangerExample(Player viewer, boolean value) { - Type: `Boolean` - Default: `false` +- __`TIME_PASSAGE`__ + - Config Key: `time-passage` + - Values + - Type: `Boolean` + - Default: `false` + +- __`SPEED`__ + - Config Key: `speed` + - Values + - Type: `Integer` + - Default: `1` + - Minimum: `0` + - Maximum: `20` + diff --git a/docs/developers/modules/_meta.json b/docs/developers/modules/_meta.json index 8d24bb7e..1ee0d74d 100644 --- a/docs/developers/modules/_meta.json +++ b/docs/developers/modules/_meta.json @@ -1,4 +1,5 @@ { + "autotexthotkey": "Auto Text Hotkey", "beam": "Beam", "border": "Border", "chat": "Chat", diff --git a/docs/developers/modules/autotexthotkey.mdx b/docs/developers/modules/autotexthotkey.mdx new file mode 100644 index 00000000..c154f013 --- /dev/null +++ b/docs/developers/modules/autotexthotkey.mdx @@ -0,0 +1,123 @@ +import { Tab, Tabs } from 'nextra-theme-docs' + +# Auto Text Hotkey Module + +## Overview + +The auto text hotkey module allows you to control the auto text hotkey mod inside Lunar Client. + +- Ability to prevent specific commands & chat messages from being used as hotkeys. +- Ability to prevent all chat messages from being used as hotkeys. + +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Set Blocked Text Inputs + +```java +public void setBlockedTextInputs(List blockedTextInputs) { + Options options = this.autoTextHotkeyModule.getOptions(); + options.set(AutoTextHotkeyModule.BLOCK_TEXT_INPUTS, true); + options.set(AutoTextHotkeyModule.BLOCKED_TEXT_INPUTS, blockedTextInputs); +} +``` + +### Block Chat Message Text Inputs + +```java +public void setBlockChatMesssageTextInputs(boolean value) { + this.autoTextHotkeyModule.getOptions().set(AutoTextHotkeyModule.BLOCK_CHAT_MESSAGE_TEXT_INPUTS, value); +} +``` + + + + + +### Set Blocked Text Inputs + +```java +public void setBlockedTextInputs(List blockedTextInputs) { + ListValue listValue = ListValue.newBuilder().addAllValues( + blockedTextInputs.stream() + .map(input -> Value.newBuilder().setStringValue(input).build()) + .collect(Collectors.toList()) + ).build(); + + Map properties = new HashMap<>(); + properties.put("block-text-inputs", Value.newBuilder().setBoolValue(true).build()); + properties.put("blocked-text-inputs", Value.newBuilder().setListValue(listValue).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("auto_text_hotkey", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + +### Block Chat Message Text Inputs + +```java +public void setBlockChatMesssageTextInputs(boolean value) { + Map properties = new HashMap<>(); + properties.put("block-chat-message-text-inputs", Value.newBuilder().setBoolValue(value).build()); + + ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("auto_text_hotkey", properties); + ProtobufPacketUtil.broadcastPacket(settings); +} +``` + + + + + +### Set Blocked Text Inputs + +```java +public void setBlockedTextInputs(List blockedTextInputs) { + Map properties = new HashMap<>(); + properties.put("block-text-inputs", true); + properties.put("blocked-text-inputs", blockedTextInputs); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("auto_text_hotkey", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + +### Block Chat Message Text Inputs + +```java +public void setBlockChatMesssageTextInputs(boolean value) { + Map properties = new HashMap<>(); + properties.put("block-chat-message-text-inputs", value); + + JsonObject message = JsonUtil.createEnableModuleObjectWithType("auto_text_hotkey", properties); + JsonPacketUtil.broadcastPacket(message); +} +``` + + + + + +## Available options + +- __`BLOCK_TEXT_INPUTS`__ + - Whether to use blocked text inputs in the `BLOCKED_TEXT_INPUTS` option. + - Values + - Type: `Boolean` + - Default: `false` + +- __`BLOCKED_TEXT_INPUTS`__ + - A list of text inputs that are blocked and cannot be used by the user. + - Values + - Type: `List` + - Default: `["/sellall", "/msg", "/pay"]` + +- __`BLOCK_CHAT_MESSAGE_TEXT_INPUTS`__ + - Whether to block all chat messages from being used as hotkeys. + - Values + - Type: `Boolean` + - Default: `false` diff --git a/docs/developers/modules/chat.mdx b/docs/developers/modules/chat.mdx index add6a7fc..d3a1831e 100644 --- a/docs/developers/modules/chat.mdx +++ b/docs/developers/modules/chat.mdx @@ -28,19 +28,29 @@ Explore each integration by cycling through each tab, to find the best fit for y ```java public void displayLiveChatMessageExample() { + if (ServerUtil.isFolia()) { + this.runFoliaChatMessageTask(); + } else { + this.runBukkitChatMessageTask(); + } +} + +private void runBukkitChatMessageTask() { BukkitRunnable runnable = new BukkitRunnable() { private int countdown = 5; @Override public void run() { - ChatApiExample.this.chatModule.displayLiveChatMessage(Recipients.ofEveryone(), - Component.text("Game starting in ", NamedTextColor.GREEN) - .append(Component.text(this.countdown, NamedTextColor.BLUE)), - 13 - ); + if (this.countdown > 0) { + ChatApiExample.this.chatModule.displayLiveChatMessage(Recipients.ofEveryone(), + Component.text("Game starting in ", NamedTextColor.GREEN) + .append(Component.text(this.countdown, NamedTextColor.BLUE)), + 13 + ); - if (--this.countdown == 0) { + this.countdown--; + } else { ChatApiExample.this.chatModule.displayLiveChatMessage(Recipients.ofEveryone(), Component.text("Game started! ", NamedTextColor.GREEN), 13 @@ -51,7 +61,29 @@ public void displayLiveChatMessageExample() { } }; - runnable.runTaskTimer(ApolloExamplePlugin.getPlugin(), 0L, 20L); + runnable.runTaskTimer(ApolloExamplePlugin.getInstance(), 1L, 20L); +} + +private void runFoliaChatMessageTask() { + AtomicInteger countdown = new AtomicInteger(5); + + Bukkit.getGlobalRegionScheduler().runAtFixedRate(ApolloExamplePlugin.getInstance(), task -> { + int seconds = countdown.getAndDecrement(); + if (seconds > 0) { + ChatApiExample.this.chatModule.displayLiveChatMessage(Recipients.ofEveryone(), + Component.text("Game starting in ", NamedTextColor.GREEN) + .append(Component.text(seconds, NamedTextColor.BLUE)), + 13 + ); + } else { + ChatApiExample.this.chatModule.displayLiveChatMessage(Recipients.ofEveryone(), + Component.text("Game started! ", NamedTextColor.GREEN), + 13 + ); + + task.cancel(); + } + }, 1L, 20L); } ``` @@ -70,8 +102,15 @@ public void removeLiveChatMessageExample() { **Displaying a Live Chat Message** ```java -@Override public void displayLiveChatMessageExample() { + if (ServerUtil.isFolia()) { + this.runFoliaChatMessageTask(); + } else { + this.runBukkitChatMessageTask(); + } +} + +private void runBukkitChatMessageTask() { BukkitRunnable runnable = new BukkitRunnable() { private int countdown = 5; @@ -100,7 +139,33 @@ public void displayLiveChatMessageExample() { } }; - runnable.runTaskTimer(ApolloExamplePlugin.getPlugin(), 0L, 20L); + runnable.runTaskTimer(ApolloExamplePlugin.getInstance(), 1L, 20L); +} + +private void runFoliaChatMessageTask() { + AtomicInteger countdown = new AtomicInteger(5); + + Bukkit.getGlobalRegionScheduler().runAtFixedRate(ApolloExamplePlugin.getInstance(), task -> { + DisplayLiveChatMessageMessage.Builder builder = DisplayLiveChatMessageMessage.newBuilder() + .setMessageId(13); + + int seconds = countdown.getAndDecrement(); + if (seconds > 0) { + builder.setAdventureJsonLines(AdventureUtil.toJson( + Component.text("Game starting in ", NamedTextColor.GREEN) + .append(Component.text(seconds, NamedTextColor.BLUE))) + ); + + ProtobufPacketUtil.broadcastPacket(builder.build()); + } else { + builder.setAdventureJsonLines(AdventureUtil.toJson( + Component.text("Game started! ", NamedTextColor.GREEN)) + ); + + ProtobufPacketUtil.broadcastPacket(builder.build()); + task.cancel(); + } + }, 1L, 20L); } ``` @@ -123,8 +188,15 @@ public void removeLiveChatMessageExample() { **Displaying a Live Chat Message** ```java -@Override public void displayLiveChatMessageExample() { + if (ServerUtil.isFolia()) { + this.runFoliaChatMessageTask(); + } else { + this.runBukkitChatMessageTask(); + } +} + +private void runBukkitChatMessageTask() { BukkitRunnable runnable = new BukkitRunnable() { private int countdown = 5; @@ -154,7 +226,34 @@ public void displayLiveChatMessageExample() { } }; - runnable.runTaskTimer(ApolloExamplePlugin.getPlugin(), 0L, 20L); + runnable.runTaskTimer(ApolloExamplePlugin.getInstance(), 1L, 20L); +} + +private void runFoliaChatMessageTask() { + AtomicInteger countdown = new AtomicInteger(5); + + Bukkit.getGlobalRegionScheduler().runAtFixedRate(ApolloExamplePlugin.getInstance(), task -> { + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.chat.v1.DisplayLiveChatMessageMessage"); + message.addProperty("message_id", 13); + + int seconds = countdown.getAndDecrement(); + if (seconds > 0) { + message.addProperty("adventure_json_lines", AdventureUtil.toJson( + Component.text("Game starting in ", NamedTextColor.GREEN) + .append(Component.text(seconds, NamedTextColor.BLUE)) + )); + + JsonPacketUtil.broadcastPacket(message); + } else { + message.addProperty("adventure_json_lines", AdventureUtil.toJson( + Component.text("Game started! ", NamedTextColor.GREEN) + )); + + JsonPacketUtil.broadcastPacket(message); + task.cancel(); + } + }, 1L, 20L); } ``` diff --git a/docs/developers/modules/inventory.mdx b/docs/developers/modules/inventory.mdx index 802b00d1..1cbfd74b 100644 --- a/docs/developers/modules/inventory.mdx +++ b/docs/developers/modules/inventory.mdx @@ -92,7 +92,7 @@ public void inventoryModuleNMSExample(Player player) { inventory.setItem(29, ItemUtil.addTag(suggestCommandItem, "suggestCommand", "/apollo")); ItemStack runCommandItem = ItemUtil.itemWithName( - Material.BOOK_AND_QUILL, + Material.ENCHANTED_BOOK, ChatColor.LIGHT_PURPLE.toString() + ChatColor.BOLD + "RUN COMMAND" ); diff --git a/docs/developers/modules/team.mdx b/docs/developers/modules/team.mdx index 431a6afc..7b4c7295 100644 --- a/docs/developers/modules/team.mdx +++ b/docs/developers/modules/team.mdx @@ -30,10 +30,14 @@ Explore each integration by cycling through each tab, to find the best fit for y private final Map teamsByTeamId = Maps.newHashMap(); private final Map teamsByPlayerUuid = Maps.newHashMap(); -public TeamExample() { - new TeamUpdateTask(); +public TeamApiExample() { + if (ServerUtil.isFolia()) { + this.runFoliaTeamUpdateTask(); + } else { + this.runBukkitTeamUpdateTask(); + } - Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getInstance()); } @EventHandler @@ -70,6 +74,18 @@ public void deleteTeam(UUID teamId) { } } +private void runBukkitTeamUpdateTask() { + Bukkit.getScheduler().runTaskTimerAsynchronously(ApolloExamplePlugin.getInstance(), () -> { + this.teamsByTeamId.values().forEach(Team::refresh); + }, 1L, 1L); +} + +private void runFoliaTeamUpdateTask() { + Bukkit.getAsyncScheduler().runAtFixedRate(ApolloExamplePlugin.getInstance(), task -> { + this.teamsByTeamId.values().forEach(Team::refresh); + }, 50L, 50L, TimeUnit.MILLISECONDS); +} + public class Team { private final UUID teamId; @@ -82,15 +98,15 @@ public class 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) { @@ -119,7 +135,7 @@ public class Team { .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() { @@ -149,19 +165,6 @@ public class Team { 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() { - TeamExample.this.teamsByTeamId.values().forEach(Team::refresh); - } -} ``` ### `TeamMember` Options @@ -239,9 +242,13 @@ private final Map teamsByTeamId = Maps.newHashMap(); private final Map teamsByPlayerUuid = Maps.newHashMap(); public TeamProtoExample() { - new TeamUpdateTask(); + if (ServerUtil.isFolia()) { + this.runFoliaTeamUpdateTask(); + } else { + this.runBukkitTeamUpdateTask(); + } - Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getInstance()); } @EventHandler @@ -278,6 +285,18 @@ public void deleteTeam(UUID teamId) { } } +private void runBukkitTeamUpdateTask() { + Bukkit.getScheduler().runTaskTimerAsynchronously(ApolloExamplePlugin.getInstance(), () -> { + this.teamsByTeamId.values().forEach(Team::refresh); + }, 1L, 1L); +} + +private void runFoliaTeamUpdateTask() { + Bukkit.getAsyncScheduler().runAtFixedRate(ApolloExamplePlugin.getInstance(), task -> { + this.teamsByTeamId.values().forEach(Team::refresh); + }, 50L, 50L, TimeUnit.MILLISECONDS); +} + public class Team { private final UUID teamId; @@ -355,19 +374,6 @@ public class Team { 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); - } -} ``` @@ -379,9 +385,13 @@ private final Map teamsByTeamId = Maps.newHashMap(); private final Map teamsByPlayerUuid = Maps.newHashMap(); public TeamJsonExample() { - new TeamUpdateTask(); + if (ServerUtil.isFolia()) { + this.runFoliaTeamUpdateTask(); + } else { + this.runBukkitTeamUpdateTask(); + } - Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getPlugin()); + Bukkit.getPluginManager().registerEvents(this, ApolloExamplePlugin.getInstance()); } @EventHandler @@ -418,6 +428,18 @@ public void deleteTeam(UUID teamId) { } } +private void runBukkitTeamUpdateTask() { + Bukkit.getScheduler().runTaskTimerAsynchronously(ApolloExamplePlugin.getInstance(), () -> { + this.teamsByTeamId.values().forEach(Team::refresh); + }, 1L, 1L); +} + +private void runFoliaTeamUpdateTask() { + Bukkit.getAsyncScheduler().runAtFixedRate(ApolloExamplePlugin.getInstance(), task -> { + this.teamsByTeamId.values().forEach(Team::refresh); + }, 50L, 50L, TimeUnit.MILLISECONDS); +} + public class Team { private final UUID teamId; @@ -498,19 +520,6 @@ public class Team { 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/tntcountdown.mdx b/docs/developers/modules/tntcountdown.mdx index ec36f708..c1d9ebfe 100644 --- a/docs/developers/modules/tntcountdown.mdx +++ b/docs/developers/modules/tntcountdown.mdx @@ -34,16 +34,13 @@ public void setTntCountdownExample() { ```java public void overrideTntCountdownExample(Player viewer) { - Location location = viewer.getLocation(); - World world = viewer.getWorld(); - TNTPrimed entity = world.spawn(location, TNTPrimed.class); + int customTicks = 200; - Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); + TNTPrimed entity = viewer.getWorld().spawn(viewer.getLocation(), TNTPrimed.class); + entity.setFuseTicks(customTicks); - apolloPlayerOpt.ifPresent(apolloPlayer -> { - ApolloEntity apolloEntity = new ApolloEntity(entity.getEntityId(), entity.getUniqueId()); - this.tntCountdownModule.setTntCountdown(apolloEntity, 200); - }); + ApolloEntity apolloEntity = new ApolloEntity(entity.getEntityId(), entity.getUniqueId()); + this.tntCountdownModule.setTntCountdown(Recipients.ofEveryone(), apolloEntity, customTicks); } ``` @@ -51,7 +48,35 @@ public void overrideTntCountdownExample(Player viewer) { ```java public void clearTntCountdownOptionExample() { - this.tntCountdownModule.getOptions().remove(TntCountdownModule.TNT_TICKS, 80); + this.tntCountdownModule.getOptions().remove(TntCountdownModule.TNT_TICKS, 160); +} +``` + +### 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 = this.tntCountdownModule.getOptions().get(TntCountdownModule.TNT_TICKS); + int defaultTicks = TntCountdownModule.TNT_TICKS.getDefaultValue(); + int currentTicks = primed.getFuseTicks(); + + if (currentTicks != defaultTicks && !this.tntCountdownModule.getOptions().get(TntCountdownModule.OVERRIDE_CUSTOM_TICKS)) { + customTicks = currentTicks; + + this.tntCountdownModule.setTntCountdown(Recipients.ofEveryone(), + new ApolloEntity(primed.getEntityId(), primed.getUniqueId()), + customTicks + ); + } + + primed.setFuseTicks(customTicks); } ``` @@ -81,49 +106,18 @@ public void setTntCountdownExample() { **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); - } + TNTPrimed entity = viewer.getWorld().spawn(viewer.getLocation(), TNTPrimed.class); + entity.setFuseTicks(customTicks); SetTntCountdownMessage message = SetTntCountdownMessage.newBuilder() .setEntityId(ProtobufUtil.createEntityIdProto(entity.getEntityId(), entity.getUniqueId())) .setDurationTicks(customTicks) .build(); - ProtobufPacketUtil.sendPacket(viewer, message); + ProtobufPacketUtil.broadcastPacket(message); } ``` @@ -132,7 +126,7 @@ public void overrideTntCountdownExample(Player viewer) { ```java public void clearTntCountdownOptionExample() { Map properties = new HashMap<>(); - properties.put("tnt-ticks", Value.newBuilder().setNumberValue(80).build()); + properties.put("tnt-ticks", Value.newBuilder().setNumberValue(160).build()); ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("tnt_countdown", properties); ProtobufPacketUtil.broadcastPacket(settings); @@ -200,42 +194,11 @@ public void setTntCountdownExample() { **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); - } + TNTPrimed entity = viewer.getWorld().spawn(viewer.getLocation(), TNTPrimed.class); + entity.setFuseTicks(customTicks); JsonPacketUtil.sendPacket(viewer, this.createTNTCountdownMessage(entity, customTicks)); } diff --git a/docs/developers/platform-utilities.mdx b/docs/developers/platform-utilities.mdx index 92292996..83d3b9ee 100644 --- a/docs/developers/platform-utilities.mdx +++ b/docs/developers/platform-utilities.mdx @@ -4,7 +4,7 @@ import { Callout } from 'nextra-theme-docs'; Platform utility classes provide helpful platform specific methods to improve your experience when creating an Apollo integration. -The following utility classes are available for each respective platform: `BukkitApollo`, `BungeeApollo`, `VelocityApollo` +The following utility classes are available for each respective platform: `BukkitApollo`, `FoliaApollo`, `BungeeApollo`, `VelocityApollo` You must ensure these methods are only used on the platform they're intended for, otherwise you will encounter errors from missing diff --git a/docs/downloads.mdx b/docs/downloads.mdx index 31b6bd98..afb6532a 100644 --- a/docs/downloads.mdx +++ b/docs/downloads.mdx @@ -1,94 +1,88 @@ -import { DownloadList } from "@lunarclient/marketing-download-list"; import { faWindows } from "@fortawesome/free-brands-svg-icons/faWindows"; +import { faDiscord } from "@fortawesome/free-brands-svg-icons/faDiscord"; +import { faDownload } from "@fortawesome/free-solid-svg-icons/faDownload"; +import { faQuestion } from "@fortawesome/free-solid-svg-icons/faQuestion"; +import { faBullhorn } from "@fortawesome/free-solid-svg-icons/faBullhorn"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Text } from "@moonsworth/text"; import router from "next/router"; +import styles from "./downloads.module.css"; Download Apollo - Below you can download the latest release of Apollo for Bukkit, BungeeCord, and Velocity. + Below you can download the latest release of Apollo for Bukkit, Folia, BungeeCord, and Velocity. -, - title: "Bukkit", - subtitle: "", - button: [ - { - text: "Download", - onClick: () => { - const asset = fetch("https://api.lunarclientprod.com/apollo/updates") - .then((res) => res.json()) - .then((res) => router.push(res.assets.bukkit)); - }, - }, - ], - CSS: { - "> svg:first-child": { - width: "112px", - }, - svg: { - width: "16px", - }, - }, - }, - { - backgroundImage: "/backgrounds/2.png", - customIcon: , - title: "Bungee", - subtitle: "", - button: [ - { - text: "Download", - onClick: () => { - const asset = fetch("https://api.lunarclientprod.com/apollo/updates") - .then((res) => res.json()) - .then((res) => router.push(res.assets.bungee)); - }, - }, - ], - CSS: { - "> svg:first-child": { - width: "112px", - }, - svg: { - width: "16px", - }, - }, - }, - { - backgroundImage: "/backgrounds/3.png", - customIcon: , - title: "Velocity", - subtitle: "", - button: [ - { - text: "Download", - onClick: () => { - const asset = fetch("https://api.lunarclientprod.com/apollo/updates") - .then((res) => res.json()) - .then((res) => router.push(res.assets.velocity)); - }, - }, - ], - CSS: { - "> svg:first-child": { - width: "112px", - }, - svg: { - width: "16px", - }, - }, - }, - ]} +
+
+ Bukkit + Bukkit + +
+
+ Folia + Folia + +
+
+ Bungee + Bungee + +
+
+ Velocity + Velocity + +
+
+ Sponge + Sponge + +
+
+ + Missing a platform? + +
+
-/> - - + For earlier releases of Apollo, please visit our [GitHub Releases page](https://github.com/LunarClient/Apollo/releases). diff --git a/docs/downloads.module.css b/docs/downloads.module.css new file mode 100644 index 00000000..4b834b40 --- /dev/null +++ b/docs/downloads.module.css @@ -0,0 +1,79 @@ +.downloadGrid { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 30px; + max-width: 800px; + margin: 40px auto; +} + +.downloadItem { + display: flex; + flex-direction: column; + align-items: center; + padding: 20px; + border-radius: 10px; + background: rgba(30, 41, 59, 0.5); + transition: all 0.3s ease; + cursor: pointer; +} + +.downloadItem:hover { + transform: translateY(-5px); + background: rgba(30, 41, 59, 0.8); + box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2); +} + +.downloadTitle { + font-size: 20px; + font-weight: 600; + color: #fff; + margin: 10px; + font-weight: 500; + white-space: nowrap; +} + +.downloadIcon { + width: 64px; + height: 64px; + object-fit: contain; +} + +.downloadButton { + display: flex; + align-items: center; + justify-content: center; + flex-direction: row; + gap: 8px; + margin-top: 10px; + width: 100%; + padding: 8px 16px; + background-color: #3B82F6; + color: white; + border-radius: 6px; + font-weight: 500; + transition: background-color 0.2s; + border: none; + cursor: pointer; +} + +.downloadButton:hover { + background-color: #2563EB; +} + +.downloadButtonIcon { + width: 16px; + height: 16px; + object-fit: contain; +} + +@media (max-width: 1060px) { + .downloadGrid { + grid-template-columns: repeat(2, 1fr); + } +} + +@media (max-width: 820px) { + .downloadGrid { + grid-template-columns: 1fr; + } +} diff --git a/docs/introduction.mdx b/docs/introduction.mdx index ea362b84..3c167a99 100644 --- a/docs/introduction.mdx +++ b/docs/introduction.mdx @@ -19,5 +19,5 @@ Inside the module breakdowns, for developers, we'll include code snippets along ## Useful Links 🔗 [Lunar Client Website](https://www.lunarclient.com/)
-🔗 [Lunar Client Developers Discord](https://discord.gg/3T9Atyb6pf)
+🔗 [Lunar Client Developers Discord](https://lunarclient.dev/discord)
🔗 [Apollo GitHub Repository](https://github.com/LunarClient/Apollo) diff --git a/docs/license.mdx b/docs/license.mdx index 209b8217..7629b3fb 100644 --- a/docs/license.mdx +++ b/docs/license.mdx @@ -2,4 +2,4 @@ You can view the Apollo license inside the Apollo [GitHub repository](https://github.com/LunarClient/Apollo) under the [license page](https://github.com/LunarClient/Apollo/blob/master/license.txt). -If you have further questions about the licensing, you can join the [Apollo discord](https://discord.gg/3T9Atyb6pf). +If you have further questions about the licensing, you can join the [Apollo discord](https://lunarclient.dev/discord). diff --git a/docs/public/backgrounds/1.png b/docs/public/backgrounds/1.png deleted file mode 100644 index f2d2ea0d..00000000 Binary files a/docs/public/backgrounds/1.png and /dev/null differ diff --git a/docs/public/backgrounds/2.png b/docs/public/backgrounds/2.png deleted file mode 100644 index 7e7e6f72..00000000 Binary files a/docs/public/backgrounds/2.png and /dev/null differ diff --git a/docs/public/backgrounds/3.png b/docs/public/backgrounds/3.png deleted file mode 100644 index a9c1b8cd..00000000 Binary files a/docs/public/backgrounds/3.png and /dev/null differ diff --git a/docs/public/bukkit.png b/docs/public/bukkit.png index 8afd48d0..ba912bb7 100644 Binary files a/docs/public/bukkit.png and b/docs/public/bukkit.png differ diff --git a/docs/public/bungee.png b/docs/public/bungee.png index 299435ca..807b317f 100644 Binary files a/docs/public/bungee.png and b/docs/public/bungee.png differ diff --git a/docs/public/folia.png b/docs/public/folia.png new file mode 100644 index 00000000..ba78b8d5 Binary files /dev/null and b/docs/public/folia.png differ diff --git a/docs/public/sponge.png b/docs/public/sponge.png new file mode 100644 index 00000000..206d3114 Binary files /dev/null and b/docs/public/sponge.png differ diff --git a/docs/public/velocity.png b/docs/public/velocity.png index fe06e04a..4b74c685 100644 Binary files a/docs/public/velocity.png and b/docs/public/velocity.png differ diff --git a/folia/build.gradle.kts b/folia/build.gradle.kts new file mode 100644 index 00000000..ec973e2d --- /dev/null +++ b/folia/build.gradle.kts @@ -0,0 +1,19 @@ +plugins { + id("apollo.shadow-conventions") +} + +java { + javaTarget(21) +} + +dependencies { + compileOnly(libs.folia) + compileOnly(libs.protobuf) + + api(project(path = ":apollo-api", configuration = "shadow")) + api(project(path = ":apollo-common", configuration = "shadow")) + + api(project(":extra:apollo-extra-adventure4")) + + annotationProcessor(libs.folia) +} diff --git a/folia/src/main/java/com/lunarclient/apollo/ApolloFoliaPlatform.java b/folia/src/main/java/com/lunarclient/apollo/ApolloFoliaPlatform.java new file mode 100644 index 00000000..f0341a7c --- /dev/null +++ b/folia/src/main/java/com/lunarclient/apollo/ApolloFoliaPlatform.java @@ -0,0 +1,197 @@ +/* + * 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; + +import com.lunarclient.apollo.command.impl.ApolloCommand; +import com.lunarclient.apollo.command.impl.LunarClientCommand; +import com.lunarclient.apollo.listener.ApolloPlayerListener; +import com.lunarclient.apollo.listener.ApolloWorldListener; +import com.lunarclient.apollo.module.ApolloModuleManagerImpl; +import com.lunarclient.apollo.module.autotexthotkey.AutoTextHotkeyModule; +import com.lunarclient.apollo.module.beam.BeamModule; +import com.lunarclient.apollo.module.beam.BeamModuleImpl; +import com.lunarclient.apollo.module.border.BorderModule; +import com.lunarclient.apollo.module.border.BorderModuleImpl; +import com.lunarclient.apollo.module.chat.ChatModule; +import com.lunarclient.apollo.module.chat.ChatModuleImpl; +import com.lunarclient.apollo.module.coloredfire.ColoredFireModule; +import com.lunarclient.apollo.module.coloredfire.ColoredFireModuleImpl; +import com.lunarclient.apollo.module.combat.CombatModule; +import com.lunarclient.apollo.module.cooldown.CooldownModule; +import com.lunarclient.apollo.module.cooldown.CooldownModuleImpl; +import com.lunarclient.apollo.module.entity.EntityModule; +import com.lunarclient.apollo.module.entity.EntityModuleImpl; +import com.lunarclient.apollo.module.glow.GlowModule; +import com.lunarclient.apollo.module.glow.GlowModuleImpl; +import com.lunarclient.apollo.module.hologram.HologramModule; +import com.lunarclient.apollo.module.hologram.HologramModuleImpl; +import com.lunarclient.apollo.module.limb.LimbModule; +import com.lunarclient.apollo.module.limb.LimbModuleImpl; +import com.lunarclient.apollo.module.modsetting.ModSettingModule; +import com.lunarclient.apollo.module.nametag.NametagModule; +import com.lunarclient.apollo.module.nametag.NametagModuleImpl; +import com.lunarclient.apollo.module.nickhider.NickHiderModule; +import com.lunarclient.apollo.module.nickhider.NickHiderModuleImpl; +import com.lunarclient.apollo.module.notification.NotificationModule; +import com.lunarclient.apollo.module.notification.NotificationModuleImpl; +import com.lunarclient.apollo.module.packetenrichment.PacketEnrichmentImpl; +import com.lunarclient.apollo.module.packetenrichment.PacketEnrichmentModule; +import com.lunarclient.apollo.module.richpresence.RichPresenceModule; +import com.lunarclient.apollo.module.richpresence.RichPresenceModuleImpl; +import com.lunarclient.apollo.module.serverrule.ServerRuleModule; +import com.lunarclient.apollo.module.staffmod.StaffModModule; +import com.lunarclient.apollo.module.staffmod.StaffModModuleImpl; +import com.lunarclient.apollo.module.stopwatch.StopwatchModule; +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; +import com.lunarclient.apollo.module.tntcountdown.TntCountdownModuleImpl; +import com.lunarclient.apollo.module.transfer.TransferModule; +import com.lunarclient.apollo.module.transfer.TransferModuleImpl; +import com.lunarclient.apollo.module.vignette.VignetteModule; +import com.lunarclient.apollo.module.vignette.VignetteModuleImpl; +import com.lunarclient.apollo.module.waypoint.WaypointModule; +import com.lunarclient.apollo.module.waypoint.WaypointModuleImpl; +import com.lunarclient.apollo.option.Options; +import com.lunarclient.apollo.option.OptionsImpl; +import com.lunarclient.apollo.stats.ApolloStats; +import com.lunarclient.apollo.wrapper.FoliaApolloStats; +import java.util.logging.Level; +import java.util.logging.Logger; +import lombok.Getter; +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.messaging.Messenger; + +/** + * The Folia platform plugin. + * + * @since 1.1.8 + */ +public final class ApolloFoliaPlatform extends JavaPlugin implements ApolloPlatform { + + @Getter private static ApolloFoliaPlatform instance; + + @Getter private final Options options = new OptionsImpl(null); + + private ApolloStats stats; + + @Override + public void onEnable() { + ApolloFoliaPlatform.instance = this; + + this.stats = new FoliaApolloStats(); + + ApolloManager.bootstrap(this); + + new ApolloPlayerListener(this); + new ApolloWorldListener(this); + + ((ApolloModuleManagerImpl) Apollo.getModuleManager()) + .addModule(AutoTextHotkeyModule.class) + .addModule(BeamModule.class, new BeamModuleImpl()) + .addModule(BorderModule.class, new BorderModuleImpl()) + .addModule(ChatModule.class, new ChatModuleImpl()) + .addModule(ColoredFireModule.class, new ColoredFireModuleImpl()) + .addModule(CombatModule.class) + .addModule(CooldownModule.class, new CooldownModuleImpl()) + .addModule(EntityModule.class, new EntityModuleImpl()) + .addModule(GlowModule.class, new GlowModuleImpl()) + .addModule(HologramModule.class, new HologramModuleImpl()) + .addModule(LimbModule.class, new LimbModuleImpl()) + .addModule(ModSettingModule.class) + .addModule(NametagModule.class, new NametagModuleImpl()) + .addModule(NickHiderModule.class, new NickHiderModuleImpl()) + .addModule(NotificationModule.class, new NotificationModuleImpl()) + .addModule(PacketEnrichmentModule.class, new PacketEnrichmentImpl()) + .addModule(RichPresenceModule.class, new RichPresenceModuleImpl()) + .addModule(ServerRuleModule.class) + .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()) + .addModule(VignetteModule.class, new VignetteModuleImpl()) + .addModule(WaypointModule.class, new WaypointModuleImpl()); + + try { + ApolloManager.setConfigPath(this.getDataFolder().toPath()); + ApolloManager.loadConfiguration(); + ((ApolloModuleManagerImpl) Apollo.getModuleManager()).enableModules(); + ApolloManager.saveConfiguration(); + } catch (Throwable throwable) { + this.getPlatformLogger().log(Level.SEVERE, "Unable to load Apollo configuration and modules!", throwable); + } + + Messenger messenger = this.getServer().getMessenger(); + messenger.registerOutgoingPluginChannel(this, ApolloManager.PLUGIN_MESSAGE_CHANNEL); + messenger.registerIncomingPluginChannel(this, ApolloManager.PLUGIN_MESSAGE_CHANNEL, + (channel, player, bytes) -> ApolloManager.getNetworkManager().receivePacket(player.getUniqueId(), bytes) + ); + + this.getCommand("apollo").setExecutor(new ApolloCommand()); + this.getCommand("lunarclient").setExecutor(new LunarClientCommand()); + + ApolloManager.getStatsManager().enable(); + ApolloManager.getVersionManager().checkForUpdates(); + } + + @Override + public void onDisable() { + ((ApolloModuleManagerImpl) Apollo.getModuleManager()).disableModules(); + } + + @Override + public Kind getKind() { + return Kind.SERVER; + } + + @Override + public String getApolloVersion() { + return this.getDescription().getVersion(); + } + + @Override + public ApolloStats getStats() { + return this.stats; + } + + @Override + public Object getPlugin() { + return getInstance(); + } + + @Override + public Logger getPlatformLogger() { + return Bukkit.getServer().getLogger(); + } + +} diff --git a/folia/src/main/java/com/lunarclient/apollo/command/FoliaApolloCommand.java b/folia/src/main/java/com/lunarclient/apollo/command/FoliaApolloCommand.java new file mode 100644 index 00000000..7567e5cf --- /dev/null +++ b/folia/src/main/java/com/lunarclient/apollo/command/FoliaApolloCommand.java @@ -0,0 +1,73 @@ +/* + * 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.command; + +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import lombok.NonNull; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +/** + * Provides common command functions for Folia. + * + * @param the sender type + * @since 1.1.8 + */ +public abstract class FoliaApolloCommand extends AbstractApolloCommand { + + /** + * Returns a new instance of a Folia command. + * + * @param textConsumer the consumer for sending messages to the sender + * @since 1.1.8 + */ + public FoliaApolloCommand(BiConsumer textConsumer) { + super(textConsumer); + } + + /** + * Handles a player argument; if the provided player doesn't exist, a not found message + * is sent to the sender. Otherwise, the player is passed to the provided player consumer. + * + * @param sender the command sender + * @param argument the argument passed from the command execution + * @param playerConsumer a consumer used for processing a desired action if the player is found + * @since 1.1.8 + */ + protected void handlePlayerArgument(@NonNull T sender, @NonNull String argument, @NonNull Consumer playerConsumer) { + Player player = Bukkit.getPlayer(argument); + + if (player == null) { + this.textConsumer.accept(sender, Component.text("Player '", NamedTextColor.RED) + .append(Component.text(argument, NamedTextColor.RED)) + .append(Component.text("' not found!", NamedTextColor.RED))); + return; + } + + playerConsumer.accept(player); + } +} diff --git a/folia/src/main/java/com/lunarclient/apollo/command/impl/ApolloCommand.java b/folia/src/main/java/com/lunarclient/apollo/command/impl/ApolloCommand.java new file mode 100644 index 00000000..a4b8bfce --- /dev/null +++ b/folia/src/main/java/com/lunarclient/apollo/command/impl/ApolloCommand.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.command.impl; + +import com.lunarclient.apollo.ApolloManager; +import com.lunarclient.apollo.command.FoliaApolloCommand; +import com.lunarclient.apollo.common.ApolloComponent; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +/** + * The general Apollo command. + * + * @since 1.1.8 + */ +public final class ApolloCommand extends FoliaApolloCommand implements CommandExecutor { + + /** + * Returns a new instance of this command. + * + * @since 1.1.8 + */ + public ApolloCommand() { + super((sender, component) -> sender.sendMessage(ApolloComponent.toLegacy(component))); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(args.length < 1) { + this.getCurrentVersion(sender); + } else if(args[0].equalsIgnoreCase("reload")) { + this.reloadConfiguration(sender); + } else if(args[0].equalsIgnoreCase("update")) { + ApolloManager.getVersionManager().forceUpdate( + "folia", + message -> this.textConsumer.accept(sender, message) + ); + } + + return true; + } + +} diff --git a/folia/src/main/java/com/lunarclient/apollo/command/impl/LunarClientCommand.java b/folia/src/main/java/com/lunarclient/apollo/command/impl/LunarClientCommand.java new file mode 100644 index 00000000..98c6aaff --- /dev/null +++ b/folia/src/main/java/com/lunarclient/apollo/command/impl/LunarClientCommand.java @@ -0,0 +1,78 @@ +/* + * 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.command.impl; + +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.command.FoliaApolloCommand; +import com.lunarclient.apollo.common.ApolloComponent; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +/** + * The general Lunar Client command. + * + * @since 1.1.8 + */ +public final class LunarClientCommand extends FoliaApolloCommand implements CommandExecutor { + + /** + * Returns a new instance of this command. + * + * @since 1.1.8 + */ + public LunarClientCommand() { + super((sender, component) -> sender.sendMessage(ApolloComponent.toLegacy(component))); + + this.setUsage("/lunarclient "); + } + + @Override + public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) { + if(args.length != 1) { + this.sendCommandUsage(commandSender); + return true; + } + + this.handlePlayerArgument(commandSender, args[0], player -> { + Component message = Component.text("Player ", NamedTextColor.GRAY) + .append(Component.text(player.getName(), NamedTextColor.AQUA)) + .append(Component.text(" is ", NamedTextColor.GRAY)); + + if (Apollo.getPlayerManager().hasSupport(player.getUniqueId())) { + message = message.append(Component.text("using ", NamedTextColor.GREEN)); + } else { + message = message.append(Component.text("not using ", NamedTextColor.RED)); + } + + message = message.append(Component.text("Lunar Client!", NamedTextColor.GRAY)); + this.textConsumer.accept(commandSender, message); + }); + + return true; + } + +} diff --git a/folia/src/main/java/com/lunarclient/apollo/listener/ApolloPlayerListener.java b/folia/src/main/java/com/lunarclient/apollo/listener/ApolloPlayerListener.java new file mode 100644 index 00000000..8c2c7fd3 --- /dev/null +++ b/folia/src/main/java/com/lunarclient/apollo/listener/ApolloPlayerListener.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.listener; + +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.ApolloManager; +import com.lunarclient.apollo.event.ApolloListener; +import com.lunarclient.apollo.event.ApolloReceivePacketEvent; +import com.lunarclient.apollo.event.EventBus; +import com.lunarclient.apollo.event.Listen; +import com.lunarclient.apollo.player.ApolloPlayerManagerImpl; +import com.lunarclient.apollo.player.v1.PlayerHandshakeMessage; +import com.lunarclient.apollo.version.ApolloVersionManager; +import com.lunarclient.apollo.wrapper.FoliaApolloPlayer; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRegisterChannelEvent; +import org.bukkit.event.player.PlayerUnregisterChannelEvent; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * Handles registration and un-registration of Apollo players. + * + * @since 1.1.8 + */ +public final class ApolloPlayerListener implements Listener, ApolloListener { + + /** + * Constructs the {@link ApolloPlayerListener}. + * + * @param plugin the plugin + * @since 1.1.8 + */ + public ApolloPlayerListener(JavaPlugin plugin) { + EventBus.getBus().register(this); + Bukkit.getPluginManager().registerEvents(this, plugin); + } + + @EventHandler + private void onRegisterChannel(PlayerRegisterChannelEvent event) { + if (!event.getChannel().equalsIgnoreCase(ApolloManager.PLUGIN_MESSAGE_CHANNEL)) { + return; + } + + ((ApolloPlayerManagerImpl) Apollo.getPlayerManager()).addPlayer(new FoliaApolloPlayer(event.getPlayer())); + } + + @EventHandler + private void onUnregisterChannel(PlayerUnregisterChannelEvent event) { + if (!event.getChannel().equalsIgnoreCase(ApolloManager.PLUGIN_MESSAGE_CHANNEL)) { + return; + } + + ((ApolloPlayerManagerImpl) Apollo.getPlayerManager()).removePlayer(event.getPlayer().getUniqueId()); + } + + @EventHandler + private void onPlayerQuit(PlayerQuitEvent event) { + ((ApolloPlayerManagerImpl) Apollo.getPlayerManager()).removePlayer(event.getPlayer().getUniqueId()); + } + + @EventHandler + private void onPlayerJoin(PlayerJoinEvent event) { + if (!ApolloVersionManager.NEEDS_UPDATE) { + return; + } + + Player player = event.getPlayer(); + if (player.isOp()) { + player.sendMessage(ChatColor.YELLOW + ApolloVersionManager.UPDATE_MESSAGE); + } + } + + @Listen + private void onApolloReceivePacket(ApolloReceivePacketEvent event) { + event.unpack(PlayerHandshakeMessage.class).ifPresent(message -> { + ((ApolloPlayerManagerImpl) Apollo.getPlayerManager()).handlePlayerHandshake(event.getPlayer(), message); + }); + } + +} diff --git a/folia/src/main/java/com/lunarclient/apollo/listener/ApolloWorldListener.java b/folia/src/main/java/com/lunarclient/apollo/listener/ApolloWorldListener.java new file mode 100644 index 00000000..3d79ca33 --- /dev/null +++ b/folia/src/main/java/com/lunarclient/apollo/listener/ApolloWorldListener.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.listener; + +import com.lunarclient.apollo.Apollo; +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.player.AbstractApolloPlayer; +import com.lunarclient.apollo.player.ApolloPlayer; +import com.lunarclient.apollo.player.v1.UpdatePlayerWorldMessage; +import com.lunarclient.apollo.world.ApolloWorldManagerImpl; +import com.lunarclient.apollo.wrapper.FoliaApolloWorld; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.world.WorldLoadEvent; +import org.bukkit.event.world.WorldUnloadEvent; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * Handles registration and un-registration of Apollo worlds. + * + * @since 1.1.8 + */ +public final class ApolloWorldListener implements Listener, ApolloListener { + + /** + * Constructs the {@link ApolloWorldListener}. + * + * @param plugin the plugin + * @since 1.1.8 + */ + public ApolloWorldListener(JavaPlugin plugin) { + EventBus.getBus().register(this); + Bukkit.getPluginManager().registerEvents(this, plugin); + + ApolloWorldManagerImpl worldManager = ((ApolloWorldManagerImpl) Apollo.getWorldManager()); + for (World world : Bukkit.getWorlds()) { + worldManager.addWorld(new FoliaApolloWorld(world)); + } + } + + @EventHandler + private void onWorldLoad(WorldLoadEvent event) { + ((ApolloWorldManagerImpl) Apollo.getWorldManager()).addWorld(new FoliaApolloWorld(event.getWorld())); + } + + @EventHandler + private void onWorldUnload(WorldUnloadEvent event) { + ((ApolloWorldManagerImpl) Apollo.getWorldManager()).removeWorld(event.getWorld().getName()); + } + + @EventHandler + private void onPlayerChangedWorld(PlayerChangedWorldEvent event) { + Player player = event.getPlayer(); + + Apollo.getPlayerManager().getPlayer(player.getUniqueId()).ifPresent(apolloPlayer -> { + UpdatePlayerWorldMessage message = UpdatePlayerWorldMessage.newBuilder() + .setWorld(player.getWorld().getName()) + .build(); + + ((AbstractApolloPlayer) apolloPlayer).sendPacket(message); + }); + } + + @Listen + private void onApolloRegisterPlayer(ApolloRegisterPlayerEvent event) { + ApolloPlayer apolloPlayer = event.getPlayer(); + + apolloPlayer.getWorld().ifPresent(world -> { + UpdatePlayerWorldMessage message = UpdatePlayerWorldMessage.newBuilder() + .setWorld(world.getName()) + .build(); + + ((AbstractApolloPlayer) apolloPlayer).sendPacket(message); + }); + } + +} diff --git a/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloPlayer.java b/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloPlayer.java new file mode 100644 index 00000000..e1ed0b0d --- /dev/null +++ b/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloPlayer.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.wrapper; + +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.ApolloFoliaPlatform; +import com.lunarclient.apollo.ApolloManager; +import com.lunarclient.apollo.common.location.ApolloLocation; +import com.lunarclient.apollo.player.AbstractApolloPlayer; +import com.lunarclient.apollo.player.ApolloPlayer; +import com.lunarclient.apollo.world.ApolloWorld; +import java.util.Optional; +import java.util.UUID; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import net.kyori.adventure.audience.Audience; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +/** + * The Folia implementation of {@link ApolloPlayer}. + * + * @since 1.1.8 + */ +@Getter +@RequiredArgsConstructor +public final class FoliaApolloPlayer extends AbstractApolloPlayer { + + private final Player player; + + @Override + public UUID getUniqueId() { + return this.player.getUniqueId(); + } + + @Override + public String getName() { + return this.player.getName(); + } + + @Override + public Optional getWorld() { + World world = this.player.getWorld(); + + return Apollo.getWorldManager().getWorld(world.getName()); + } + + @Override + public Optional getLocation() { + Location location = this.player.getLocation(); + + return Optional.of(ApolloLocation.builder() + .world(location.getWorld().getName()) + .x(location.getX()) + .y(location.getY()) + .z(location.getZ()) + .build()); + } + + @Override + public boolean hasPermission(String permissionNode) { + return this.player.hasPermission(permissionNode); + } + + @Override + public void sendPacket(byte[] messages) { + this.player.sendPluginMessage(ApolloFoliaPlatform.getInstance(), ApolloManager.PLUGIN_MESSAGE_CHANNEL, messages); + } + + @Override + public @NotNull Audience audience() { + return this.player; + } +} diff --git a/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloStats.java b/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloStats.java new file mode 100644 index 00000000..a0f9c14b --- /dev/null +++ b/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloStats.java @@ -0,0 +1,116 @@ +/* + * 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.wrapper; + +import com.lunarclient.apollo.stats.ApolloPluginDescription; +import com.lunarclient.apollo.stats.ApolloStats; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.Base64; +import java.util.List; +import java.util.stream.Collectors; +import javax.imageio.ImageIO; +import org.bukkit.Bukkit; +import org.bukkit.plugin.Plugin; + +/** + * The Folia implementation of {@link ApolloStats}. + * + * @since 1.1.8 + */ +public class FoliaApolloStats implements ApolloStats { + + @Override + public boolean isOnlineMode() { + return Bukkit.getServer().getOnlineMode(); + } + + @Override + public String getIcon() { + File icon = new File(new File("."), "server-icon.png"); + + if (!icon.isFile()) { + return null; + } + + BufferedImage image; + try { + image = ImageIO.read(icon); + } catch (IOException e) { + return null; + } + + if (image.getWidth() != 64 || image.getHeight() != 64) { + return null; + } + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + + try { + ImageIO.write(image, "PNG", outputStream); + } catch (IOException e) { + return null; + } + + byte[] bytes = outputStream.toByteArray(); + return Base64.getEncoder().encodeToString(bytes); + } + + @Override + public String getVersion() { + return Bukkit.getServer().getBukkitVersion(); + } + + @Override + public List getPlugins() { + return Arrays.stream(Bukkit.getPluginManager().getPlugins()) + .map(Plugin::getDescription) + .map(description -> ApolloPluginDescription.builder() + .name(description.getName()) + .description(description.getDescription()) + .authors(description.getAuthors()) + .version(description.getVersion()) + .build()) + .collect(Collectors.toList()); + } + + @Override + public String getPlatformSubtype() { + return "Folia"; + } + + @Override + public String getPlatformVersion() { + return Bukkit.getServer().getVersion(); + } + + @Override + public int getTotalPlayers() { + return Bukkit.getOnlinePlayers().size(); + } + +} diff --git a/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloWorld.java b/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloWorld.java new file mode 100644 index 00000000..074f7329 --- /dev/null +++ b/folia/src/main/java/com/lunarclient/apollo/wrapper/FoliaApolloWorld.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.wrapper; + +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.player.ApolloPlayer; +import com.lunarclient.apollo.recipients.ForwardingRecipients; +import com.lunarclient.apollo.recipients.Recipients; +import com.lunarclient.apollo.world.ApolloWorld; +import java.util.Collection; +import java.util.Optional; +import java.util.stream.Collectors; +import lombok.AllArgsConstructor; +import org.bukkit.World; + +/** + * The Folia implementation of {@link ApolloWorld}. + * + * @since 1.1.8 + */ +@AllArgsConstructor +public final class FoliaApolloWorld implements ApolloWorld, ForwardingRecipients { + + private final World world; + + @Override + public String getName() { + return this.world.getName(); + } + + @Override + public Collection getPlayers() { + return this.world.getPlayers().stream() + .map(player -> Apollo.getPlayerManager().getPlayer(player.getUniqueId())) + .filter(Optional::isPresent) + .map(Optional::get) + .collect(Collectors.toList()); + } + + @Override + public Iterable recipients() { + return this.getPlayers(); + } + +} diff --git a/folia/src/main/resources/plugin.yml b/folia/src/main/resources/plugin.yml new file mode 100644 index 00000000..a8047db0 --- /dev/null +++ b/folia/src/main/resources/plugin.yml @@ -0,0 +1,17 @@ +name: Apollo-Folia +main: com.lunarclient.apollo.ApolloFoliaPlatform +version: 1.1.7 +author: Moonsworth +api-version: 1.13 +folia-supported: true + +commands: + apollo: + description: The main Apollo command. + usage: /apollo + permission: apollo.command + lunarclient: + aliases: [lc] + description: The command to check whether the player is using Lunar Client. + usage: /lunarclient + permission: apollo.lunarclient diff --git a/gradle.properties b/gradle.properties index 15ff62e7..e00f89ab 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=com.lunarclient -version=1.1.7 +version=1.1.8 description=The API for interacting with Lunar Client players. org.gradle.parallel=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 32d6507c..4ac0dc24 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,12 +10,14 @@ configurate = "4.2.0+lunar.5" geantyref = "1.3.11" idea = "1.1.7" jetbrains = "24.0.1" -lombok = "1.18.26" +lombok = "1.18.38" protobuf = "1.0-SNAPSHOT" gson = "2.10.1" shadow = "8.1.1" spotless = "6.13.0" velocity = "3.0.1" +folia = "1.20.1-R0.1-SNAPSHOT" +asm = "9.7.1" [libraries] jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "jetbrains" } @@ -42,6 +44,9 @@ configurate-yaml = { module = "org.spongepowered:configurate-yaml", version.ref bukkit-api = { module = "org.spigotmc:spigot-api", version.ref = "bukkit" } bukkit = { module = "org.spigotmc:spigot", version.ref = "bukkit" } +# folia +folia = { module = "dev.folia:folia-api", version.ref = "folia" } + # bungee bungee = { module = "net.md-5:bungeecord-api", version.ref = "bungee" } @@ -53,6 +58,7 @@ artifactregistry = { module = "gradle.plugin.com.google.cloud.artifactregistry:a spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" } shadow = { module = "com.github.johnrengelman:shadow", version.ref = "shadow" } idea = { module = "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext", version.ref = "idea" } +asm = { module = "org.ow2.asm:asm", version.ref = "asm" } stylecheck = "ca.stellardrift:stylecheck:0.1" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ac72c34e..37f853b1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100755 index 00000000..e78c0132 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,98 @@ +#!/bin/bash +set -eo pipefail + +VERSION="1.1.8" +REMOTE_USER="ubuntu" +REMOTE_HOST="147.135.8.94" + +usage() { + echo "Usage: $0 [api|json|proto]" + echo "Available servers: apollo, test, folia" + echo "Optional module (for bukkit servers only): api (default), json, proto" + exit 1 +} + +validate_server() { + case "$1" in + apollo|test|folia) ;; + *) + echo "Unknown server: $1" + usage + ;; + esac +} + +validate_module() { + case "$1" in + api|json|proto) ;; + *) + echo "Unknown module: $1" + usage + ;; + esac +} + +deploy_files() { + local server="$1" + shift + local -a files=("${@:1:$#-1}") + local destination="${!#}" + + if [ -n "$MODULE" ]; then + echo "Deploying to $server server (module: $MODULE)..." + else + echo "Deploying to $server server..." + fi + + for file in "${files[@]}"; do + if [ ! -f "$file" ]; then + echo "Error: File $file not found!" + exit 1 + fi + scp "$file" "$REMOTE_USER@$REMOTE_HOST:$destination" + done +} + + +# Main script execution +[ $# -lt 1 ] && usage + +SERVER="$1" +MODULE="${2:-api}" # Default to "api" if not provided + +validate_module "$MODULE" +validate_server "$SERVER" + +echo "Building project..." +./gradlew clean build + +declare -a files_to_copy +declare destination_path + +case "$SERVER" in + apollo) + files_to_copy=( + "bukkit/build/libs/apollo-bukkit-${VERSION}.jar" + "bukkit-example-${MODULE}/build/libs/apollo-bukkit-example-${MODULE}-${VERSION}.jar" + ) + destination_path="/home/ubuntu/apollo/plugins/" + ;; + test) + files_to_copy=( + "bukkit/build/libs/apollo-bukkit-${VERSION}.jar" + "bukkit-example-${MODULE}/build/libs/apollo-bukkit-example-${MODULE}-${VERSION}.jar" + ) + destination_path="/home/ubuntu/lctest/plugins/" + ;; + folia) + files_to_copy=( + "folia/build/libs/apollo-folia-${VERSION}.jar" + "bukkit-example-${MODULE}/build/libs/apollo-bukkit-example-${MODULE}-${VERSION}.jar" + ) + destination_path="/home/ubuntu/apollo-folia/plugins/" + ;; +esac + +deploy_files "$SERVER" "${files_to_copy[@]}" "$destination_path" + +echo "Deployment to $SERVER completed successfully." diff --git a/settings.gradle.kts b/settings.gradle.kts index ecb0d4e8..9a815b02 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -36,9 +36,13 @@ listOfNotNull( "api", "common", "bukkit", - "bukkit-example", + "bukkit-example-common", + "bukkit-example-api", + "bukkit-example-json", + "bukkit-example-proto", if (loadAllVersions) "bungee" else null, - if (loadAllVersions) "velocity" else null + if (loadAllVersions) "velocity" else null, + if (loadAllVersions) "folia" else null ).forEach { include(it) findProject(":$it")?.name = "apollo-${it.replace(':', '-')}" diff --git a/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java b/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java index 59c409da..926d96f1 100644 --- a/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java +++ b/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java @@ -28,6 +28,7 @@ import com.lunarclient.apollo.command.impl.LunarClientCommand; import com.lunarclient.apollo.listener.ApolloPlayerListener; import com.lunarclient.apollo.module.ApolloModuleManagerImpl; +import com.lunarclient.apollo.module.autotexthotkey.AutoTextHotkeyModule; import com.lunarclient.apollo.module.beam.BeamModule; import com.lunarclient.apollo.module.beam.BeamModuleImpl; import com.lunarclient.apollo.module.border.BorderModule; @@ -96,7 +97,7 @@ @Plugin( id = "apollo", name = "Apollo-Velocity", - version = "1.1.7", + version = "1.1.8", url = "https://moonsworth.com", description = "Implementation of Apollo for Velocity", authors = {"Moonsworth"} @@ -165,6 +166,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) { ApolloManager.bootstrap(this); ((ApolloModuleManagerImpl) Apollo.getModuleManager()) + .addModule(AutoTextHotkeyModule.class) .addModule(BeamModule.class, new BeamModuleImpl()) .addModule(BorderModule.class, new BorderModuleImpl()) .addModule(ChatModule.class, new ChatModuleImpl())