Skip to content

Commit

Permalink
Create a standalone environment for use with a webpanel or CLI
Browse files Browse the repository at this point in the history
* Can now run the distribution jars (either the executable or the
  distributable) directly via the main class space.arim.libertybans
  .env.standalone.launcher.StandaloneApplication assuming the Gson
  and snakeyaml libraries are also added to the classpath.
* Create a usage example to show how the env-standalone module can
  be embedded inside a larger interface such as a webpanel.
* Cleanup some code in other platforms
  • Loading branch information
A248 committed Jul 29, 2023
1 parent d8b4564 commit 7b859fe
Show file tree
Hide file tree
Showing 32 changed files with 1,151 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public enum Category {
BUKKIT,
BUNGEE,
SPONGE,
VELOCITY
VELOCITY,
STANDALONE
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public static Platform velocity(ClassLoader platformClassLoader) {
.build("Velocity");
}

public static Platform standalone() {
return Platform.builderForCategory(Platform.Category.STANDALONE).build("Standalone");
}

// Used for testing purposes
public static Stream<Platform> allPossiblePlatforms(String platformName) {
Set<Platform> platforms = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* LibertyBans
* Copyright © 2022 Anand Beh
* Copyright © 2023 Anand Beh
*
* LibertyBans is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -55,7 +55,7 @@ public boolean hasDeleteFromJoin() {
return isMySQLLike();
}

boolean isRemote() {
public boolean isRemote() {
return isMySQLLike() || isPostgresLike();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* LibertyBans
* Copyright © 2022 Anand Beh
* Copyright © 2023 Anand Beh
*
* LibertyBans is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -28,7 +28,10 @@ public interface Environment {
PlatformListener createAliasCommand(String command);

/**
* Used for Sponge only; since Sponge requires early command registration and service provision
* Used for Sponge and the standalone application only. <br>
* <br>
* Sponge requires early command registration and service provision, while for the standalone application
* this usage is merely convenient.
*
* @return the platform accessors
*/
Expand Down
34 changes: 34 additions & 0 deletions bans-distribution/distributable/pom.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
<!--
~ LibertyBans
~ Copyright © 2023 Anand Beh
~
~ LibertyBans is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as
~ published by the Free Software Foundation, either version 3 of the
~ License, or (at your option) any later version.
~
~ LibertyBans is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Affero General Public License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with LibertyBans. If not, see <https://www.gnu.org/licenses/>
~ and navigate to version 3 of the GNU Affero General Public License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
Expand All @@ -15,6 +34,17 @@
<build>
<finalName>LibertyBans_Release-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>space.arim.libertybans.env.standalone.launcher.StandaloneApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down Expand Up @@ -89,5 +119,9 @@
<groupId>space.arim.libertybans</groupId>
<artifactId>bans-env-velocityplugin</artifactId>
</dependency>
<dependency>
<groupId>space.arim.libertybans</groupId>
<artifactId>bans-env-standalonelauncher</artifactId>
</dependency>
</dependencies>
</project>
23 changes: 23 additions & 0 deletions bans-distribution/download/pom.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
<!--
~ LibertyBans
~ Copyright © 2023 Anand Beh
~
~ LibertyBans is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as
~ published by the Free Software Foundation, either version 3 of the
~ License, or (at your option) any later version.
~
~ LibertyBans is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Affero General Public License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with LibertyBans. If not, see <https://www.gnu.org/licenses/>
~ and navigate to version 3 of the GNU Affero General Public License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
Expand Down Expand Up @@ -97,5 +116,9 @@
<groupId>space.arim.libertybans</groupId>
<artifactId>bans-env-velocity</artifactId>
</dependency>
<dependency>
<groupId>space.arim.libertybans</groupId>
<artifactId>bans-env-standalone</artifactId>
</dependency>
</dependencies>
</project>
32 changes: 32 additions & 0 deletions bans-distribution/executable/pom.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
<!--
~ LibertyBans
~ Copyright © 2023 Anand Beh
~
~ LibertyBans is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as
~ published by the Free Software Foundation, either version 3 of the
~ License, or (at your option) any later version.
~
~ LibertyBans is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Affero General Public License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with LibertyBans. If not, see <https://www.gnu.org/licenses/>
~ and navigate to version 3 of the GNU Affero General Public License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
Expand Down Expand Up @@ -49,6 +68,11 @@
<descriptors>
<descriptor>src/assembly/final-executable.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>space.arim.libertybans.env.standalone.launcher.StandaloneApplication</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -80,6 +104,10 @@
<groupId>space.arim.libertybans</groupId>
<artifactId>bans-env-velocityplugin</artifactId>
</dependency>
<dependency>
<groupId>space.arim.libertybans</groupId>
<artifactId>bans-env-standalonelauncher</artifactId>
</dependency>
<dependency>
<groupId>space.arim.libertybans</groupId>
<artifactId>bans-env-bungee</artifactId>
Expand All @@ -96,6 +124,10 @@
<groupId>space.arim.libertybans</groupId>
<artifactId>bans-env-velocity</artifactId>
</dependency>
<dependency>
<groupId>space.arim.libertybans</groupId>
<artifactId>bans-env-standalone</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<include>space.arim.libertybans:bans-env-spigotplugin</include>
<include>space.arim.libertybans:bans-env-spongeplugin</include>
<include>space.arim.libertybans:bans-env-velocityplugin</include>
<include>space.arim.libertybans:bans-env-standalonelauncher</include>
<include>space.arim.licenser:licenser-agpl3</include>
</includes>
<unpackOptions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<exclude>space.arim.libertybans:bans-env-spigotplugin</exclude>
<exclude>space.arim.libertybans:bans-env-spongeplugin</exclude>
<exclude>space.arim.libertybans:bans-env-velocityplugin</exclude>
<exclude>space.arim.libertybans:bans-env-standalonelauncher</exclude>
<exclude>space.arim.licenser:licenser-agpl3</exclude>
<!-- platform-provided -->
<exclude>org.yaml:snakeyaml</exclude>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* LibertyBans
* Copyright © 2022 Anand Beh
* Copyright © 2023 Anand Beh
*
* LibertyBans is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -80,11 +80,6 @@ private BaseFoundation initialize() {
.culpritFinder(new BungeeCulpritFinder(getLogger()))
.build();
ClassLoader launchLoader = launcher.attemptLaunch().join();

if (launchLoader == null) {
getLogger().warning("Failed to launch LibertyBans");
return null;
}
BaseFoundation base;
try {
base = new Instantiator("space.arim.libertybans.env.bungee.BungeeLauncher", launchLoader)
Expand Down
2 changes: 2 additions & 0 deletions bans-env/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<module>spongeplugin</module>
<module>velocity</module>
<module>velocityplugin</module>
<module>standalone</module>
<module>standalonelauncher</module>
</modules>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* LibertyBans
* Copyright © 2022 Anand Beh
* Copyright © 2023 Anand Beh
*
* LibertyBans is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -101,10 +101,6 @@ private BaseFoundation initialize() {
executor.shutdown();
assert executor.isTerminated();
}
if (launchLoader == null) {
getLogger().warning("Failed to launch LibertyBans");
return null;
}
BaseFoundation base;
try {
base = new Instantiator("space.arim.libertybans.env.spigot.SpigotLauncher", launchLoader)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* LibertyBans
* Copyright © 2022 Anand Beh
* Copyright © 2023 Anand Beh
*
* LibertyBans is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -139,10 +139,6 @@ private CompletableFuture<BaseFoundation> initialize() {
.culpritFinder(new SpongeCulpritFinder(game))
.build();
return launcher.attemptLaunch().thenApply((launchLoader) -> {
if (launchLoader == null) {
logger.warn("Failed to launch LibertyBans");
return null;
}
BaseFoundation base;
try {
base = new Instantiator("space.arim.libertybans.env.sponge.SpongeLauncher", launchLoader)
Expand Down
56 changes: 56 additions & 0 deletions bans-env/standalone/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!--
~ LibertyBans
~ Copyright © 2023 Anand Beh
~
~ LibertyBans is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as
~ published by the Free Software Foundation, either version 3 of the
~ License, or (at your option) any later version.
~
~ LibertyBans is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Affero General Public License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with LibertyBans. If not, see <https://www.gnu.org/licenses/>
~ and navigate to version 3 of the GNU Affero General Public License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>space.arim.libertybans</groupId>
<artifactId>bans-env</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>

<artifactId>bans-env-standalone</artifactId>

<dependencies>
<dependency>
<groupId>space.arim.libertybans</groupId>
<artifactId>bans-core</artifactId>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-plain</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
</dependency>
</dependencies>
</project>
13 changes: 13 additions & 0 deletions bans-env/standalone/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module space.arim.libertybans.env.standalone {
requires jakarta.inject;
requires net.kyori.adventure.text.serializer.plain;
requires org.checkerframework.checker.qual;
requires org.slf4j;
requires space.arim.api.env;
requires space.arim.api.jsonchat;
requires transitive space.arim.injector;
requires transitive space.arim.libertybans.bootstrap;
requires space.arim.libertybans.core;
exports space.arim.libertybans.env.standalone;
opens space.arim.libertybans.env.standalone to space.arim.injector;
}
Loading

0 comments on commit 7b859fe

Please sign in to comment.