|
| 1 | +import { Tab, Tabs } from 'nextra-theme-docs'; |
| 2 | + |
| 3 | +# Apollo for Minestom |
| 4 | + |
| 5 | +[Minestom](https://minestom.net/) is a modern, open-source Minecraft server that enables developers to build highly performant and flexible servers from the ground up. It operates as a library, rather than relying on a traditional plugin-based architecture. |
| 6 | + |
| 7 | +Integrating Apollo with your Minestom server is straightforward. Instead of installing a plugin, you'll simply add the `apollo-minestom` artifact as a library dependency to your project and initialize the `ApolloMinestomPlatform` within your server's startup sequence. |
| 8 | + |
| 9 | +## Adding the Repository |
| 10 | + |
| 11 | +First, you need to add the Lunar Client Maven repository to your build configuration. |
| 12 | + |
| 13 | +<Tabs items={['build.gradle.kts', 'build.gradle', 'pom.xml']}> |
| 14 | + <Tab> |
| 15 | + ```kotlin filename="build.gradle.kts" |
| 16 | + repositories { |
| 17 | + maven { |
| 18 | + name = "lunarclient" |
| 19 | + url = uri("https://repo.lunarclient.dev") |
| 20 | + } |
| 21 | + } |
| 22 | + ``` |
| 23 | + </Tab> |
| 24 | + <Tab> |
| 25 | + ```groovy filename="build.gradle" |
| 26 | + repositories { |
| 27 | + maven { |
| 28 | + name = 'lunarclient' |
| 29 | + url = 'https://repo.lunarclient.dev' |
| 30 | + } |
| 31 | + } |
| 32 | + ``` |
| 33 | + </Tab> |
| 34 | + <Tab> |
| 35 | + ```xml filename="pom.xml" |
| 36 | + <repositories> |
| 37 | + <repository> |
| 38 | + <id>lunarclient</id> |
| 39 | + <url>https://repo.lunarclient.dev</url> |
| 40 | + </repository> |
| 41 | + </repositories> |
| 42 | + ``` |
| 43 | + </Tab> |
| 44 | +</Tabs> |
| 45 | + |
| 46 | +## Adding the Dependency |
| 47 | + |
| 48 | +Next, add the `apollo-minestom` dependency to your project. |
| 49 | + |
| 50 | +<Tabs items={['build.gradle.kts', 'build.gradle', 'pom.xml']}> |
| 51 | + <Tab> |
| 52 | + ```kotlin filename="build.gradle.kts" |
| 53 | + dependencies { |
| 54 | + implementation("com.lunarclient:apollo-minestom:1.1.9") |
| 55 | + } |
| 56 | + ``` |
| 57 | + </Tab> |
| 58 | + <Tab> |
| 59 | + ```groovy filename="build.gradle" |
| 60 | + dependencies { |
| 61 | + implementation 'com.lunarclient:apollo-minestom:1.1.9' |
| 62 | + } |
| 63 | + ``` |
| 64 | + </Tab> |
| 65 | + <Tab> |
| 66 | + ```xml filename="pom.xml" |
| 67 | + <dependencies> |
| 68 | + <dependency> |
| 69 | + <groupId>com.lunarclient</groupId> |
| 70 | + <artifactId>apollo-minestom</artifactId> |
| 71 | + <version>1.1.9</version> |
| 72 | + <scope>compile</scope> |
| 73 | + </dependency> |
| 74 | + </dependencies> |
| 75 | + ``` |
| 76 | + </Tab> |
| 77 | +</Tabs> |
| 78 | + |
| 79 | +## Initialization |
| 80 | + |
| 81 | +To initialize Apollo, simply call `ApolloMinestomPlatform.init()` in your server's startup code, before you start the server. This will set up all the necessary listeners and modules. |
| 82 | + |
| 83 | +Here is an example of a simple Minestom server with Apollo integrated: |
| 84 | + |
| 85 | +```java filename="ApolloMinestomExample.java" |
| 86 | +package com.lunarclient.apollo.example; |
| 87 | + |
| 88 | +import com.lunarclient.apollo.Apollo; |
| 89 | +import com.lunarclient.apollo.ApolloMinestomPlatform; |
| 90 | +import com.lunarclient.apollo.common.location.ApolloBlockLocation; |
| 91 | +import com.lunarclient.apollo.event.EventBus; |
| 92 | +import com.lunarclient.apollo.event.player.ApolloRegisterPlayerEvent; |
| 93 | +import com.lunarclient.apollo.module.waypoint.Waypoint; |
| 94 | +import com.lunarclient.apollo.module.waypoint.WaypointModule; |
| 95 | +import com.lunarclient.apollo.player.ApolloPlayer; |
| 96 | +import java.awt.Color; |
| 97 | +import net.minestom.server.Auth; |
| 98 | +import net.minestom.server.MinecraftServer; |
| 99 | +import net.minestom.server.entity.GameMode; |
| 100 | +import net.minestom.server.entity.Player; |
| 101 | +import net.minestom.server.event.GlobalEventHandler; |
| 102 | +import net.minestom.server.event.player.AsyncPlayerConfigurationEvent; |
| 103 | +import net.minestom.server.event.player.PlayerSpawnEvent; |
| 104 | +import net.minestom.server.instance.InstanceContainer; |
| 105 | +import net.minestom.server.instance.block.Block; |
| 106 | + |
| 107 | +public final class ApolloMinestomExample { |
| 108 | + |
| 109 | + public static void main(String[] args) { |
| 110 | + MinecraftServer server = MinecraftServer.init(new Auth.Online()); |
| 111 | + |
| 112 | + InstanceContainer instance = MinecraftServer.getInstanceManager().createInstanceContainer(); |
| 113 | + instance.setGenerator(unit -> unit.modifier().fillHeight(-1, 0, Block.STONE)); |
| 114 | + |
| 115 | + GlobalEventHandler eventHandler = MinecraftServer.getGlobalEventHandler(); |
| 116 | + eventHandler.addListener(AsyncPlayerConfigurationEvent.class, event -> event.setSpawningInstance(instance)); |
| 117 | + |
| 118 | + // Initialize Apollo |
| 119 | + ApolloMinestomPlatform.init(); |
| 120 | + |
| 121 | + // Display a Apollo Waypoint example |
| 122 | + EventBus.getBus().register(ApolloRegisterPlayerEvent.class, event -> { |
| 123 | + ApolloPlayer player = event.getPlayer(); |
| 124 | + |
| 125 | + Apollo.getModuleManager().getModule(WaypointModule.class).displayWaypoint(player, Waypoint.builder() |
| 126 | + .name("KoTH") |
| 127 | + .location(ApolloBlockLocation.builder() |
| 128 | + .world(player.getWorld().get().getName()) |
| 129 | + .x(500) |
| 130 | + .y(100) |
| 131 | + .z(500) |
| 132 | + .build()) |
| 133 | + .color(Color.ORANGE) |
| 134 | + .preventRemoval(false) |
| 135 | + .hidden(false) |
| 136 | + .build() |
| 137 | + ); |
| 138 | + }); |
| 139 | + |
| 140 | + server.start("0.0.0.0", 25565); |
| 141 | + } |
| 142 | + |
| 143 | + private ApolloMinestomExample() { |
| 144 | + } |
| 145 | + |
| 146 | +} |
| 147 | +``` |
| 148 | + |
| 149 | +## Permissions |
| 150 | + |
| 151 | +Since Minestom does not have a traditional permissions system, Apollo uses Minestom's built-in permission levels. Here are the default permission levels required for various features: |
| 152 | + |
| 153 | +- **`/apollo <reload|update>`**: `level 2` |
| 154 | +- **`/lunarclient <player>`**: `level 2` |
| 155 | +- **Receive Apollo update notifications**: `level 4` |
0 commit comments