Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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="bukkit-example[\\/]src[\\/]main[\\/]java[\\/].*" checks="(FilteringWriteTag|MissingJavadoc.*)"/>
<suppress files="bukkit-example-(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
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -94,6 +94,7 @@ body:
multiple: true
options:
- Spigot / Bukkit
- Folia
- BungeeCord
- Velocity
- Other
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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`

Expand All @@ -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

Expand Down
4 changes: 4 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ setupPlatforms()
setupPlatformDependency("bukkit", "bukkitJar")
setupPlatformDependency("bungee", "bungeeJar")
setupPlatformDependency("velocity", "velocityJar")
setupPlatformDependency("folia", "foliaJar", 21)

val main by sourceSets

Expand All @@ -25,6 +26,9 @@ dependencies {

"velocity"(main.output)
"velocity"(libs.velocity)

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

publishShadowJar()
206 changes: 206 additions & 0 deletions api/src/folia/java/com/lunarclient/apollo/FoliaApollo.java
Original file line number Diff line number Diff line change
@@ -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<ApolloPlayer> 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<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.1.8
*/
public static Recipients getRecipientsFrom(@NonNull Collection<Player> players) {
ApolloPlayerManager playerManager = Apollo.getPlayerManager();
List<ApolloPlayer> 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() {
}

}
2 changes: 2 additions & 0 deletions api/src/main/java/com/lunarclient/apollo/mods/Mods.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -175,6 +176,7 @@ public final class Mods {
ModFov.class,
ModFog.class,
ModAutoTextHotkey.class,
ModAutoTextActions.class,
ModMumbleLink.class,
Mod2dItems.class,
ModBossbar.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Boolean> ENABLED = SimpleOption.<Boolean>builder()
.node("auto-text-actions", "enabled").type(TypeToken.get(Boolean.class))
.notifyClient()
.build();

private ModAutoTextActions() {
}

}
Loading