Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "http://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<!-- don't require javadocs on platform modules -->
<suppress files="example[\\/]bukkit[\\/](api|json|proto|common)[\\/]src[\\/]main[\\/]java[\\/].*" checks="(FilteringWriteTag|MissingJavadoc.*)"/>
<suppress files="example[\\/](bukkit|minestom)[\\/](api|json|proto|common)[\\/]src[\\/]main[\\/]java[\\/].*" checks="(FilteringWriteTag|MissingJavadoc.*)"/>

<!-- ignore illegal import in loader -->
<suppress files="extra[\\/]loader[\\/]src[\\/]main[\\/]java[\\/].*" checks="(IllegalImport)"/>
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ body:
options:
- Spigot / Bukkit
- Folia
- Minestom
- BungeeCord
- Velocity
- Other
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ jobs:
bungee/build/libs/apollo-bungee-${{ env.VERSION }}.jar
velocity/build/libs/apollo-velocity-${{ env.VERSION }}.jar
folia/build/libs/apollo-folia-${{ env.VERSION }}.jar
minestom/build/libs/apollo-minestom-${{ env.VERSION }}.jar
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The output jars can be found in the `build/libs` directory relative to each plat

- Bukkit: `bukkit/plugin/build/libs`
- Folia: `folia/build/libs`
- Minestom: `minestom/build/libs`
- BungeeCord: `bungee/build/libs`
- Velocity: `velocity/build/libs`

Expand All @@ -42,7 +43,7 @@ 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, Folia, BungeeCord, Velocity** - Are modules that implement the common module for each respective platform.
- **Bukkit, Folia, Minestom, 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://lunarclient.dev/discord).
Expand Down
4 changes: 4 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ setupPlatformDependency("bukkit", "bukkitJar")
setupPlatformDependency("bungee", "bungeeJar")
setupPlatformDependency("velocity", "velocityJar", 17)
setupPlatformDependency("folia", "foliaJar", 21)
setupPlatformDependency("minestom", "minestomJar", 21)

val main by sourceSets

Expand All @@ -29,6 +30,9 @@ dependencies {

"folia"(main.output)
"folia"(libs.folia)

"minestom"(main.output)
"minestom"(libs.minestom)
}

publishShadowJar()
22 changes: 22 additions & 0 deletions api/src/main/java/com/lunarclient/apollo/ApolloPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public interface ApolloPlatform {
*/
Kind getKind();

/**
* Returns the platform type.
*
* @return the platform type
* @since 1.2.0
*/
Platform getPlatform();

/**
* Returns the platform options that don't belong to a specific module.
*
Expand Down Expand Up @@ -93,4 +101,18 @@ enum Kind {
SERVER,
PROXY
}

/**
* Represents the platform type.
*
* @since 1.2.0
*/
enum Platform {
BUKKIT,
FOLIA,
MINESTOM,
BUNGEE,
VELOCITY
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public interface ApolloStats {
List<ApolloPluginDescription> getPlugins();

/**
* Gets the servers platform subtype (Bukkit, BungeeCord, Velocity...).
* Gets the servers platform subtype (Bukkit, Folia, Minestom, BungeeCord, Velocity...).
*
* @return the servers platform subtype
* @since 1.0.0
Expand Down
102 changes: 102 additions & 0 deletions api/src/minestom/java/com/lunarclient/apollo/MinestomApollo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* 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.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 net.minestom.server.entity.Entity;
import net.minestom.server.entity.Player;

/**
* Utility class for converting objects to and from their corresponding Minestom
* representations with additional helper methods for easier integration.
*
* @since 1.2.0
*/
public final class MinestomApollo {

/**
* Runs a specified operation for a {@link Player}.
*
* @param player the player
* @param playerConsumer the operation to be performed
* @since 1.2.0
*/
public static void runForPlayer(@NonNull Player player, @NonNull Consumer<ApolloPlayer> playerConsumer) {
runForPlayer(player.getUuid(), 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.2.0
*/
public static void runForPlayer(@NonNull UUID playerUuid, @NonNull Consumer<ApolloPlayer> 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.2.0
*/
public static Recipients getRecipientsFrom(@NonNull Collection<Player> players) {
ApolloPlayerManager playerManager = Apollo.getPlayerManager();
List<ApolloPlayer> apolloPlayers = players.stream()
.map(player -> playerManager.getPlayer(player.getUuid()))
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());

return Recipients.of(apolloPlayers);
}

/**
* Converts a {@link Entity} to an {@link ApolloEntity} object.
*
* @param entity the entity
* @return the converted apollo entity object
* @since 1.2.0
*/
public static ApolloEntity toApolloEntity(@NonNull Entity entity) {
return new ApolloEntity(entity.getEntityId(), entity.getUuid());
}

private MinestomApollo() {
}

}
5 changes: 5 additions & 0 deletions build-logic/src/main/kotlin/extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ fun Project.setupPlatforms() {
tasks.named("javadoc", Javadoc::class) {
source(sourceSets.map { it.allJava })
classpath += sourceSets.map { it.compileClasspath }.reduce { first, second -> first + second }

val javaToolchains = project.extensions.getByType(JavaToolchainService::class.java)
javadocTool.set(javaToolchains.javadocToolFor {
languageVersion.set(JavaLanguageVersion.of(21))
})
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/
package com.lunarclient.apollo;

import com.lunarclient.apollo.command.impl.ApolloCommand;
import com.lunarclient.apollo.command.impl.LunarClientCommand;
import com.lunarclient.apollo.command.BukkitApolloCommand;
import com.lunarclient.apollo.command.BukkitLunarClientCommand;
import com.lunarclient.apollo.listener.ApolloMetadataListener;
import com.lunarclient.apollo.listener.ApolloPlayerListener;
import com.lunarclient.apollo.listener.ApolloWorldListener;
Expand Down Expand Up @@ -174,8 +174,8 @@ public void onEnable() {
(channel, player, bytes) -> ApolloManager.getNetworkManager().receivePacket(player.getUniqueId(), bytes)
);

this.plugin.getCommand("apollo").setExecutor(new ApolloCommand());
this.plugin.getCommand("lunarclient").setExecutor(new LunarClientCommand());
this.plugin.getCommand("apollo").setExecutor(new BukkitApolloCommand());
this.plugin.getCommand("lunarclient").setExecutor(new BukkitLunarClientCommand());

ApolloManager.getStatsManager().enable();
ApolloManager.getVersionManager().checkForUpdates();
Expand All @@ -195,6 +195,11 @@ public Kind getKind() {
return Kind.SERVER;
}

@Override
public Platform getPlatform() {
return Platform.BUKKIT;
}

@Override
public String getApolloVersion() {
return this.plugin.getDescription().getVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,51 +23,44 @@
*/
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;
import com.lunarclient.apollo.ApolloManager;
import com.lunarclient.apollo.ApolloPlatform;
import com.lunarclient.apollo.command.type.ApolloCommand;
import com.lunarclient.apollo.common.ApolloComponent;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

/**
* Provides common command functions for Bukkit.
* The general Apollo command.
*
* @param <T> the sender type
* @since 1.0.9
* @since 1.0.5
*/
public abstract class BukkitApolloCommand<T> extends AbstractApolloCommand<T> {
public final class BukkitApolloCommand extends ApolloCommand<CommandSender> implements CommandExecutor {

/**
* Returns a new instance of a Bukkit command.
* Returns a new instance of this command.
*
* @param textConsumer the consumer for sending messages to the sender
* @since 1.0.9
* @since 1.0.5
*/
public BukkitApolloCommand(BiConsumer<T, Component> textConsumer) {
super(textConsumer);
public BukkitApolloCommand() {
super((sender, component) -> sender.sendMessage(ApolloComponent.toLegacy(component)));
}

/**
* 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.0.9
*/
protected void handlePlayerArgument(@NonNull T sender, @NonNull String argument, @NonNull Consumer<Player> 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;
@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(
ApolloPlatform.Platform.BUKKIT,
message -> this.textConsumer.accept(sender, message)
);
}

playerConsumer.accept(player);
return true;
}

}
Loading