From 123f276b482ec4212e54256685b7049a68a23370 Mon Sep 17 00:00:00 2001 From: kento2 Date: Mon, 6 Jul 2026 16:43:18 +0200 Subject: [PATCH] . --- .idea/runConfigurations/core__runServer_.xml | 29 ++++ .idea/workspace.xml | 135 +++++++++++------- README.md | 5 +- core-bukkit-impl/run/eula.txt | 3 + .../kentoj/scrow/bukkit/CoreImplPlugin.java | 2 +- .../kentoj/scrow/bukkit/ScrowAPISurface.java | 16 ++- .../bukkit/command/economy/CoinsCommand.java | 4 - .../de/kentoj/scrowlib/utils/EnvUtils.java | 3 + gradle/libs.versions.toml | 2 +- 9 files changed, 128 insertions(+), 71 deletions(-) create mode 100644 .idea/runConfigurations/core__runServer_.xml create mode 100644 core-bukkit-impl/run/eula.txt diff --git a/.idea/runConfigurations/core__runServer_.xml b/.idea/runConfigurations/core__runServer_.xml new file mode 100644 index 0000000..4d1d34f --- /dev/null +++ b/.idea/runConfigurations/core__runServer_.xml @@ -0,0 +1,29 @@ + + + + + + + + true + true + false + false + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e48235d..421822b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,9 +4,16 @@ - - - - - - - true - true - false - false - - - - - - - - true - true - false - false - - + - + + + + + + + true + true + false + false + + @@ -319,13 +337,20 @@ + + + + + + + - - + - - + + + @@ -367,9 +392,9 @@ - - \ No newline at end of file diff --git a/README.md b/README.md index 06b9087..c64c694 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ TODO -- fix publishing - fix kencommandapi greedy strings & arguments: probably issue with shading - make core-lib-impl: a library -> avoid shading massive core-lib - logging in general, log some exceptions to game chat - notification: Friend is now offline/online - /ignore command -environment ------------ +modules +------- - **core-lib**: stateless library - **core-bukkit-api** stateful api, for minecraft development, depends on core-lib diff --git a/core-bukkit-impl/run/eula.txt b/core-bukkit-impl/run/eula.txt new file mode 100644 index 0000000..2ceee4f --- /dev/null +++ b/core-bukkit-impl/run/eula.txt @@ -0,0 +1,3 @@ +#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA). +#Mon Jul 06 16:35:59 CEST 2026 +eula=true \ No newline at end of file diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/CoreImplPlugin.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/CoreImplPlugin.java index b8dd3ea..97c21da 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/CoreImplPlugin.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/CoreImplPlugin.java @@ -18,7 +18,7 @@ public class CoreImplPlugin extends JavaPlugin { @Override public void onEnable() { - ScrowAPISurface.initScrowAPI(this, true); + ScrowAPISurface.initScrowAPI(this); { ScrowAPI.getCommandApi().register(new CoinsCommand().getRootNode()); ScrowAPI.getCommandApi().register(FriendCommand.create()); diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/ScrowAPISurface.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/ScrowAPISurface.java index f3b2ac1..a684854 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/ScrowAPISurface.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/ScrowAPISurface.java @@ -19,16 +19,18 @@ import io.nats.client.Nats; import io.nats.client.Options; import lombok.AccessLevel; import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.bukkit.plugin.Plugin; import org.jdbi.v3.core.Jdbi; import java.io.IOException; import java.util.Properties; +@Slf4j @NoArgsConstructor(access = AccessLevel.NONE) public class ScrowAPISurface { - public static void initScrowAPI(Plugin plugin, boolean enableDatabase) { + public static void initScrowAPI(Plugin plugin) { ScrowAPI.setCorePlugin(plugin); try { @@ -42,15 +44,15 @@ public class ScrowAPISurface { throw new RuntimeException(e); } - if (enableDatabase) { - try { - Class.forName("org.postgresql.Driver", true, ScrowAPISurface.class.getClassLoader()); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } + try { + Class.forName("org.postgresql.Driver", true, ScrowAPISurface.class.getClassLoader()); var props = new Properties(); props.setProperty("user", "postgres"); ScrowAPI.setJdbi(Jdbi.create(EnvUtils.envOrThrow("HOST_POSTGRES"), props)); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } catch (IllegalStateException e) { + log.error("HOST_POSTGRES not set -> Using in-memory database"); } ScrowAPI.setPlayerFactory(playerId -> new NetworkPlayerImpl(ScrowAPI.getMessageBroker(), playerId)); diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsCommand.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsCommand.java index b11b3a6..6690ac5 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsCommand.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsCommand.java @@ -10,15 +10,12 @@ import de.kentoj.kencommandapi.api.platform.MessageStyle; import de.kentoj.scrow.bukkit.ScrowAPI; import de.kentoj.scrow.bukkit.scheduler.Tasks; import de.kentoj.scrowlib.convention.ScrowMessageStyle; -import lombok.AccessLevel; import lombok.Getter; -import lombok.NoArgsConstructor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.concurrent.CompletableFuture; -@NoArgsConstructor(access = AccessLevel.NONE) public class CoinsCommand implements CommandExecutor { @Getter private final RootCommandNode rootNode; @@ -39,7 +36,6 @@ public class CoinsCommand implements CommandExecutor { rootNode.addLiteral(getLiteral); } - @Override public CompletableFuture> execute(CommandContext ctx) { var player = ((Player) ctx.getSender()); diff --git a/core-lib/src/main/java/de/kentoj/scrowlib/utils/EnvUtils.java b/core-lib/src/main/java/de/kentoj/scrowlib/utils/EnvUtils.java index 2a6570b..bdf63c9 100644 --- a/core-lib/src/main/java/de/kentoj/scrowlib/utils/EnvUtils.java +++ b/core-lib/src/main/java/de/kentoj/scrowlib/utils/EnvUtils.java @@ -5,6 +5,9 @@ import lombok.NoArgsConstructor; @NoArgsConstructor(access = AccessLevel.NONE) public class EnvUtils { + /** + * @throws IllegalStateException if the var is not set + */ public static String envOrThrow(String name) { var env = System.getenv(name); if (env == null) throw new IllegalStateException("environment variable " + name + " not set"); diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3f8689d..6d98f84 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] shadow = "9.2.0" run-paper = "2.3.1" -scrow-commandapi = "0.31" +scrow-commandapi = "0.32" postgress = "42.7.12" nats = "2.25.2" papermc = "1.21.11-rc3-R0.1-SNAPSHOT"