Compare commits

...

14 commits

Author SHA1 Message Date
65b8d79ada
Fix engine initialization crash
All checks were successful
push-build-apidoc / build (push) Successful in 1m4s
push-build-apidoc / generate-javadoc (push) Successful in 1m5s
2024-11-10 14:23:33 +01:00
156b027ff2
Add crash operation to command
All checks were successful
push-build-apidoc / build (push) Successful in 1m42s
push-build-apidoc / generate-javadoc (push) Successful in 1m52s
2024-11-09 22:46:20 +01:00
5c4b4beedf
Update sos!engine to v1-alpha8 2024-11-09 22:45:58 +01:00
c78af0e80e
Update sos!engine to v1-alpha7
All checks were successful
push-build-apidoc / build (push) Successful in 54s
push-build-apidoc / generate-javadoc (push) Successful in 52s
2024-10-16 13:39:28 +02:00
78b025fbed
Bump version
All checks were successful
push-build-apidoc / build (push) Successful in 41s
push-build-apidoc / generate-javadoc (push) Successful in 52s
2024-10-16 02:15:40 +02:00
d6c7ff0aa6
Bump version (release!)
All checks were successful
push-build-apidoc / build (push) Successful in 41s
push-build-apidoc / generate-javadoc (push) Successful in 51s
2024-10-16 01:46:53 +02:00
c55cff04a8
Update to sos!engine v1-alpha6 + more
All checks were successful
push-build-apidoc / generate-javadoc (push) Successful in 1m4s
push-build-apidoc / build (push) Successful in 1m8s
This commit not only updates the engine, but also adds/changes the following things:
- repository to download from
- engine initialization failures are now properly caught and complained about
- rename package to reflect v1-alpha6's package changes
- update links in README.md
2024-10-16 01:45:40 +02:00
8f8db4e357
Bump version
All checks were successful
push-build-apidoc / build (push) Successful in 1m3s
push-build-apidoc / generate-javadoc (push) Successful in 1m11s
2024-10-03 22:18:03 +02:00
3c4c8813ba
Update gradle wrapper
All checks were successful
push-build-apidoc / generate-javadoc (push) Successful in 4m11s
push-build-apidoc / build (push) Successful in 4m18s
2024-10-03 21:38:20 +02:00
a4830b5ce8
[noci] Wrap "EventHelper#registerEvent" in ` 2024-10-03 21:34:44 +02:00
d6e56f8dd9
Update "Reflection is broken" section
Some checks failed
push-build-apidoc / build (push) Has been cancelled
push-build-apidoc / generate-javadoc (push) Has been cancelled
2024-10-03 21:33:24 +02:00
b694a33180
Update dependencies in 'common' subproject
All checks were successful
push-build-apidoc / build (push) Successful in 1m8s
push-build-apidoc / generate-javadoc (push) Successful in 1m10s
This change was made to allow platform implementations to decide how (certain) dependencies should be handled.
2024-10-03 21:24:45 +02:00
6a4d4e6e7b
Fix String[] to String conversion 2024-10-03 21:22:36 +02:00
1c1c1ea86f
Update project name 2024-10-03 21:22:06 +02:00
22 changed files with 197 additions and 253 deletions

View file

@ -34,9 +34,8 @@ It can do the following things:
## Known issues
### Reflection is broken
Due to how the mod and plugin loaders load JAR files, scanning the classpath for annotations does not work.
This means that the entire event system and automatic subsystem detection is broken.
We're waiting for sos!engine developers to implement methods for manually registering subsystems and event listeners.
Until then, use other methods for initializing subsystems and sending events and data around.
This means that events have to be registered manually. You can do that by calling [`EventHelper#registerEvent`](https://jd.engine.staropensource.de/v1-alpha6/base/de/staropensource/engine/base/implementable/helper/EventHelper.html#registerEvent(java.lang.Class,de.staropensource.engine.base.implementable.EventListenerCode,de.staropensource.engine.base.type.EventPriority))).
If you want to use a specific subsystem, either find or make a plugin/mod porting that subsystem to Minecraft (best option), or shade and include the subsystem in your final JAR and hope nothing breaks. Only do that if you have no other choice or the subsystem is specific to your plugin or modification.
## Contributing
Please see [sos!engine's contributing section](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/README.md#contributing)

View file

@ -98,8 +98,8 @@ allprojects {
// StarOpenSource Engine
maven {
name = "staropensource-sosengine"
url = "https://mvn.staropensource.de/sosengine"
name = "staropensource-engine"
url = "https://mvn.staropensource.de/engine"
}
// PaperMC

View file

@ -36,11 +36,11 @@ dependencies {
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// StarOpenSource Engine
implementation("de.staropensource.sosengine:base:${dependencyStarOpenSourceEngine}")
compileOnly("de.staropensource.engine:base:${dependencyStarOpenSourceEngine}")
// Adventure
implementation("net.kyori:adventure-api:${dependencyAdventure}")
implementation("net.kyori:adventure-text-minimessage:${dependencyAdventure}")
compileOnly("net.kyori:adventure-api:${dependencyAdventure}")
compileOnly("net.kyori:adventure-text-minimessage:${dependencyAdventure}")
}
// Fix delombok task
@ -133,7 +133,7 @@ publishing {
repositories {
maven {
name = "staropensource"
url = uri("https://mvn.staropensource.de/sosengine")
url = uri("https://mvn.staropensource.de/engine")
credentials(org.gradle.api.credentials.PasswordCredentials)
authentication {
//noinspection GroovyAssignabilityCheck

View file

@ -17,15 +17,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.minecraft;
package de.staropensource.engine.minecraft;
import de.staropensource.sosengine.base.Engine;
import de.staropensource.sosengine.base.EngineInternals;
import de.staropensource.sosengine.base.implementable.LoggingAdapter;
import de.staropensource.sosengine.base.implementable.ShutdownHandler;
import de.staropensource.sosengine.base.logging.Logger;
import de.staropensource.sosengine.base.logging.LoggerInstance;
import de.staropensource.sosengine.base.type.InternalAccessArea;
import de.staropensource.engine.base.Engine;
import de.staropensource.engine.base.EngineInternals;
import de.staropensource.engine.base.implementable.LoggingAdapter;
import de.staropensource.engine.base.implementable.ShutdownHandler;
import de.staropensource.engine.base.logging.Logger;
import de.staropensource.engine.base.type.InternalAccessArea;
import org.jetbrains.annotations.NotNull;
/**
@ -34,14 +33,6 @@ import org.jetbrains.annotations.NotNull;
* @since v1-alpha0
*/
public final class EngineBootstrapper {
/**
* Contains the {@link LoggerInstance} for this instance.
*
* @see LoggerInstance
* @since v1-alpha0
*/
private static final LoggerInstance logger = new LoggerInstance.Builder().setClazz(EngineBootstrapper.class).setOrigin("ENGINEMC").build();
/**
* Constructs this class.
*
@ -56,12 +47,13 @@ public final class EngineBootstrapper {
* @param disableClasspathScanning disables classpath scanning support
* @param shutdownHandler {@link ShutdownHandler} implementation, which should ideally shutdown the server
* @param loggingAdapter {@link LoggingAdapter} implementation, for printing log messages into the server console
* @throws Exception on error
* @since v1-alpha0
*/
public static void initialize(boolean disableMultithreading, boolean disableClasspathScanning, @NotNull ShutdownHandler shutdownHandler, @NotNull LoggingAdapter loggingAdapter) {
public static void initialize(boolean disableMultithreading, boolean disableClasspathScanning, @NotNull ShutdownHandler shutdownHandler, @NotNull LoggingAdapter loggingAdapter) throws Exception {
overwriteSystemProperties(disableMultithreading, disableClasspathScanning); // Overwrites certain system properties to overwrite the engine configuration
Logger.setLoggingAdapter(loggingAdapter); // Install logging adapter
new Engine(); // Initialize engine
Engine.initialize(); // Initialize engine
configureEngineShutdown(shutdownHandler); // Configures how the engine shuts itself down
EngineInternals.getInstance().restrictAccess(InternalAccessArea.ALL_WRITE); // Restrict internal engine access to read-only
initializeSubystems(); // Initialize subsystems
@ -75,13 +67,12 @@ public final class EngineBootstrapper {
* @since v1-alpha0
*/
private static void overwriteSystemProperties(boolean disableMultithreading, boolean disableClasspathScanning) {
System.getProperties().setProperty("sosengine.base.loggerTemplate", "[%log_level% %log_path%%log_metadata%] %log_message_prefix%%log_message%");
System.getProperties().setProperty("sosengine.base.logFeatures", "methodName,lineNumber");
System.getProperties().setProperty("sosengine.base.optimizeLogging", "true");
System.getProperties().setProperty("sosengine.base.loggerImmediateShutdown", "false");
if (disableMultithreading)
System.getProperties().setProperty("sosengine.base.optimizeEvents", "false");
if (disableClasspathScanning)
System.getProperties().setProperty("sosengine.base.initialForceDisableClasspathScanning", "true");
System.getProperties().setProperty("sosengine.base.considerEnvironmentUnfriendlyToClasspathScanning", "true");
}
/**
@ -92,11 +83,11 @@ public final class EngineBootstrapper {
*/
private static void configureEngineShutdown(@NotNull ShutdownHandler shutdownHandler) {
EngineInternals.getInstance().setShutdownHandler(exitcode -> {
logger.diag("Invoking shutdown handler");
Logger.diag("Invoking shutdown handler");
try {
shutdownHandler.shutdown(exitcode);
} catch (Exception exception) {
logger.crash("Unable to shutdown server! Shutdown handler threw an exception. Hanging thread", exception, true);
Logger.crash("Unable to shutdown server (Shutdown handler threw an exception)! Hanging thread", exception, true);
//noinspection InfiniteLoopStatement // we want an infinite loop
while (true)
Thread.onSpinWait();
@ -106,7 +97,7 @@ public final class EngineBootstrapper {
}
/**
* Initializes all subsystems bundled with this subsystem.
* Initializes all subsystems bundled with EngineMC.
*
* @since v1-alpha0
*/

View file

@ -17,12 +17,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.minecraft;
package de.staropensource.engine.minecraft;
import de.staropensource.sosengine.base.annotation.EngineSubsystem;
import de.staropensource.sosengine.base.implementable.SubsystemClass;
import de.staropensource.sosengine.base.implementation.versioning.StarOpenSourceVersioningSystem;
import de.staropensource.sosengine.base.type.DependencyVector;
import de.staropensource.engine.base.annotation.EngineSubsystem;
import de.staropensource.engine.base.implementable.SubsystemClass;
import de.staropensource.engine.base.implementation.versioning.StarOpenSourceVersioningSystem;
import de.staropensource.engine.base.type.DependencyVector;
import org.jetbrains.annotations.NotNull;
/**

View file

@ -17,16 +17,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.minecraft;
package de.staropensource.engine.minecraft;
import de.staropensource.sosengine.base.Engine;
import de.staropensource.sosengine.base.logging.LoggerInstance;
import de.staropensource.sosengine.base.type.VersionType;
import de.staropensource.sosengine.base.utility.Miscellaneous;
import de.staropensource.sosengine.base.utility.PropertiesReader;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import de.staropensource.engine.base.Engine;
import de.staropensource.engine.base.logging.Logger;
import de.staropensource.engine.base.type.VersionType;
import de.staropensource.engine.base.utility.Miscellaneous;
import de.staropensource.engine.base.utility.PropertiesReader;
import de.staropensource.engine.base.utility.information.EngineInformation;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.io.InputStream;
@ -45,14 +44,6 @@ import java.util.Properties;
*/
@SuppressWarnings({ "JavadocDeclaration" })
public final class SubsystemInformation {
/**
* Contains the {@link LoggerInstance} for this instance.
*
* @see LoggerInstance
* @since v1-alpha0
*/
private static final @NotNull LoggerInstance logger = new LoggerInstance.Builder().setClazz(SubsystemInformation.class).setOrigin("ENGINEMC").build();
/**
* Contains the subsystem's version codename.
*
@ -297,14 +288,14 @@ public final class SubsystemInformation {
* @since v1-alpha0
*/
public static synchronized void update() {
logger.diag("Updating subsystem information");
Logger.diag("Updating subsystem information");
// Load properties from bundled gradle.properties
Properties gradleProperties = new Properties();
InputStream gradleStream = EngineInformation.class.getClassLoader().getResourceAsStream("sosenginemc-gradle.properties");
if (gradleStream == null) {
logger.crash("Unable to load build information: The bundled gradle.properties file could not be found.");
Logger.crash("Unable to load build information: The bundled gradle.properties file could not be found.");
return;
}
@ -312,7 +303,7 @@ public final class SubsystemInformation {
gradleProperties.load(gradleStream);
gradleStream.close();
} catch (IOException exception) {
logger.crash("Unable to load build information: InputStream 'gradleStream' failed", exception);
Logger.crash("Unable to load build information: InputStream 'gradleStream' failed", exception);
return;
}
@ -321,7 +312,7 @@ public final class SubsystemInformation {
Properties gitProperties = new Properties();
InputStream gitStream = EngineInformation.class.getClassLoader().getResourceAsStream("sosenginemc-git.properties");
if (gitStream == null) {
logger.error("Unable to load build information: The bundled git.properties file could not be found. Did you download a tarball?");
Logger.error("Unable to load build information: The bundled git.properties file could not be found. Did you download a tarball?");
// Fake information
gitProperties.setProperty("git.total.commit.count", "0");
@ -339,7 +330,7 @@ public final class SubsystemInformation {
gitProperties.load(gitStream);
gitStream.close();
} catch (IOException exception) {
logger.crash("Unable to load build information: InputStream 'gitStream' failed", exception);
Logger.crash("Unable to load build information: InputStream 'gitStream' failed", exception);
return;
}
}

View file

@ -17,15 +17,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.minecraft.command;
package de.staropensource.engine.minecraft.command;
import de.staropensource.sosengine.base.EngineConfiguration;
import de.staropensource.sosengine.base.utility.ListFormatter;
import de.staropensource.sosengine.base.utility.Miscellaneous;
import de.staropensource.sosengine.base.utility.PlaceholderEngine;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import de.staropensource.sosengine.base.utility.information.JvmInformation;
import de.staropensource.sosengine.minecraft.SubsystemInformation;
import de.staropensource.engine.base.EngineConfiguration;
import de.staropensource.engine.base.logging.Logger;
import de.staropensource.engine.base.utility.ListFormatter;
import de.staropensource.engine.base.utility.Miscellaneous;
import de.staropensource.engine.base.utility.PlaceholderEngine;
import de.staropensource.engine.base.utility.information.EngineInformation;
import de.staropensource.engine.base.utility.information.JvmInformation;
import de.staropensource.engine.minecraft.SubsystemInformation;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.jetbrains.annotations.NotNull;
@ -37,7 +38,7 @@ import java.util.concurrent.TimeUnit;
*
* @since v1-alpha0
*/
public class Command {
public final class Command {
/**
* Constructs this class.
*
@ -67,31 +68,34 @@ public class Command {
message(player, Strings.errorTooFewArguments);
else if (arguments.length == 2) {
// Return configuration setting
String value = switch (arguments[1]) {
case "debug" -> String.valueOf(EngineConfiguration.getInstance().isDebug());
case "debugEvents" -> String.valueOf(EngineConfiguration.getInstance().isDebugEvents());
case "debugShortcodeConverter" -> String.valueOf(EngineConfiguration.getInstance().isDebugShortcodeConverter());
String value = null;
case "initialPerformSubsystemInitialization" -> String.valueOf(EngineConfiguration.getInstance().isInitialPerformSubsystemInitialization());
case "initialForceDisableClasspathScanning" -> String.valueOf(EngineConfiguration.getInstance().isInitialForceDisableClasspathScanning());
case "initialIncludeSubsystemClasses" -> ListFormatter.formatSet(EngineConfiguration.getInstance().getInitialIncludeSubsystemClasses());
switch (arguments[1]) {
case "debug" -> value = String.valueOf(EngineConfiguration.getInstance().isDebug());
case "debugEvents" -> value = String.valueOf(EngineConfiguration.getInstance().isDebugEvents());
case "errorShortcodeConverter" -> String.valueOf(EngineConfiguration.getInstance().isErrorShortcodeConverter());
case "initialPerformSubsystemInitialization" -> value = String.valueOf(EngineConfiguration.getInstance().isInitialPerformSubsystemInitialization());
case "initialIncludeSubsystemClasses" -> value = ListFormatter.formatSet(EngineConfiguration.getInstance().getInitialIncludeSubsystemClasses());
case "optimizeLogging" -> String.valueOf(EngineConfiguration.getInstance().isOptimizeLogging());
case "optimizeEvents" -> String.valueOf(EngineConfiguration.getInstance().isOptimizeEvents());
case "errorShortcodeParser" -> value = String.valueOf(EngineConfiguration.getInstance().isErrorShortcodeParser());
case "loggerLevel" -> "LogLevel." + EngineConfiguration.getInstance().getLoggerLevel().name();
case "loggerTemplate" -> "\"" + EngineConfiguration.getInstance().getLoggerTemplate() + "\"";
case "loggerPollingSpeed" -> String.valueOf(EngineConfiguration.getInstance().getLoggerPollingSpeed());
case "loggerForceStandardOutput" -> String.valueOf(EngineConfiguration.getInstance().isLoggerForceStandardOutput());
case "loggerEnableNewlineSupport" -> String.valueOf(EngineConfiguration.getInstance().isLoggerEnableNewlineSupport());
case "loggerImmediateShutdown" -> String.valueOf(EngineConfiguration.getInstance().isLoggerImmediateShutdown());
case "optimizeLogging" -> value = String.valueOf(EngineConfiguration.getInstance().isOptimizeLogging());
case "optimizeEvents" -> value = String.valueOf(EngineConfiguration.getInstance().isOptimizeEvents());
case "hideFullTypePath" -> String.valueOf(EngineConfiguration.getInstance().isHideFullTypePath());
case "logLevel" -> value = "LogLevel." + EngineConfiguration.getInstance().getLogLevel().name();
case "logFeatures" -> {
StringBuilder features = new StringBuilder();
default -> null;
};
for (String feature : EngineConfiguration.getInstance().getLogFeatures())
features.append(feature);
value = features.toString();
}
case "logPollingSpeed" -> value = String.valueOf(EngineConfiguration.getInstance().getLogPollingSpeed());
case "logForceStandardOutput" -> value = String.valueOf(EngineConfiguration.getInstance().isLogForceStandardOutput());
case "hideFullTypePath" -> value = String.valueOf(EngineConfiguration.getInstance().isHideFullTypePath());
}
if (value == null)
message(player, Strings.errorInvalidSetting.replace("%key%", arguments[1]));
@ -110,10 +114,8 @@ public class Command {
switch (arguments[1]) {
case "debug" -> System.getProperties().setProperty("sosengine.base.debug", String.valueOf(newValue));
case "debugEvents" -> System.getProperties().setProperty("sosengine.base.debugEvents", String.valueOf(newValue));
case "debugShortcodeConverter" -> System.getProperties().setProperty("sosengine.base.debugShortcodeConverter", String.valueOf(newValue));
case "initialPerformSubsystemInitialization" -> System.getProperties().setProperty("sosengine.base.initialPerformSubsystemInitialization", String.valueOf(newValue));
case "initialForceDisableClasspathScanning" -> System.getProperties().setProperty("sosengine.base.initialForceDisableClasspathScanning", String.valueOf(newValue));
case "initialIncludeSubsystemClasses" -> System.getProperties().setProperty("sosengine.base.initialIncludeSubsystemClasses", String.valueOf(newValue));
case "errorShortcodeConverter" -> System.getProperties().setProperty("sosengine.base.errorShortcodeConverter", String.valueOf(newValue));
@ -121,12 +123,10 @@ public class Command {
case "optimizeLogging" -> System.getProperties().setProperty("sosengine.base.optimizeLogging", String.valueOf(newValue));
case "optimizeEvents" -> System.getProperties().setProperty("sosengine.base.optimizeEvents", String.valueOf(newValue));
case "loggerLevel" -> System.getProperties().setProperty("sosengine.base.loggerLevel", String.valueOf(newValue));
case "loggerTemplate" -> System.getProperties().setProperty("sosengine.base.loggerTemplate", String.valueOf(newValue));
case "loggerPollingSpeed" -> System.getProperties().setProperty("sosengine.base.loggerPollingSpeed", String.valueOf(newValue));
case "loggerForceStandardOutput" -> System.getProperties().setProperty("sosengine.base.loggerForceStandardOutput", String.valueOf(newValue));
case "loggerEnableNewlineSupport" -> System.getProperties().setProperty("sosengine.base.loggerEnableNewlineSupport", String.valueOf(newValue));
case "loggerImmediateShutdown" -> System.getProperties().setProperty("sosengine.base.loggerImmediateShutdown", String.valueOf(newValue));
case "logLevel" -> System.getProperties().setProperty("sosengine.base.logLevel", String.valueOf(newValue));
case "logFeatures" -> System.getProperties().setProperty("sosengine.base.logFeatures", String.valueOf(newValue));
case "logPollingSpeed" -> System.getProperties().setProperty("sosengine.base.logPollingSpeed", String.valueOf(newValue));
case "logForceStandardOutput" -> System.getProperties().setProperty("sosengine.base.logForceStandardOutput", String.valueOf(newValue));
case "hideFullTypePath" -> System.getProperties().setProperty("sosengine.base.hideFullTypePath", String.valueOf(newValue));
@ -149,8 +149,12 @@ public class Command {
}
StringBuilder args = new StringBuilder();
for (int index = 1; index < arguments.length; index++)
for (int index = 1; index < arguments.length; index++) {
if (!args.isEmpty())
args.append(" ");
args.append(arguments[index]);
}
message(player, "<reset>" + PlaceholderEngine.getInstance().process(args.toString()).replace("<", "\u200C\\<"));
}
@ -220,6 +224,7 @@ public class Command {
message(player, message);
}
case "crash" -> Logger.crash("Manually initiated crash (/enginemc crash)");
default -> message(player, Strings.errorInvalidArgument);
}
}
@ -266,7 +271,8 @@ public class Command {
<red><bold>config</bold> \\<key> [value]: Displays the value of a setting if <italic>value</italic> is unset, or sets it if it isn't
<red><bold>placeholder</bold> \\<message>: Runs the specified message through sos!engine's PlaceholderEngine and returns it's result
<red><bold>gc</bold>: Forcefully invokes the garbage collector
<red><bold>jvminfo</bold>: Displays information about the Java Virtual Machine""";
<red><bold>jvminfo</bold>: Displays information about the Java Virtual Machine
<red><bold>crash</bold>: Crashes the StarOpenSource Engine""";
// Configuration
public static final String configGet = "<red>The configuration setting \"%key%\" is set to '%value%'";

View file

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.minecraft.command;
package de.staropensource.engine.minecraft.command;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.NotNull;

View file

@ -23,4 +23,4 @@
*
* @since v1-alpha0
*/
package de.staropensource.sosengine.minecraft;
package de.staropensource.engine.minecraft;

View file

@ -11,10 +11,10 @@ module sosengine.minecraft {
requires net.kyori.adventure.text.minimessage;
// API access
exports de.staropensource.sosengine.minecraft;
exports de.staropensource.sosengine.minecraft.command;
exports de.staropensource.engine.minecraft;
exports de.staropensource.engine.minecraft.command;
// Reflection access
opens de.staropensource.sosengine.minecraft;
opens de.staropensource.sosengine.minecraft.command;
opens de.staropensource.engine.minecraft;
opens de.staropensource.engine.minecraft.command;
}

View file

@ -20,12 +20,12 @@
# Versioning
versioningCodename=Sugarcane
versioningVersion=1
versioningType=alpha
versioningTyperelease=0
versioningType=release
versioningTyperelease=3
versioningFork=
# Java
javaSource=22
javaSource=21
javaTarget=21
# Minecraft
@ -34,16 +34,16 @@ minecraftMinor=.1
paperSnapshot=R0.1
# Plugins
pluginShadow=8.1.7
pluginLombok=8.6
pluginShadow=8.1.8
pluginLombok=8.10.2
pluginGitProperties=2.4.2
pluginRunTask=2.3.1
# Dependencies
dependencyLombok=1.18.32
dependencyJetbrainsAnnotations=24.1.0
dependencyStarOpenSourceEngine=1-alpha5
dependencyLombok=1.18.34
dependencyJetbrainsAnnotations=26.0.1
dependencyStarOpenSourceEngine=1-alpha8
dependencyAdventure=4.17.0
# etc
group = de.staropensource.sosenginemc
group = de.staropensource.enginemc

View file

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

View file

@ -36,7 +36,7 @@ dependencies {
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// StarOpenSource Engine
implementation("de.staropensource.sosengine:base:${dependencyStarOpenSourceEngine}")
implementation("de.staropensource.engine:base:${dependencyStarOpenSourceEngine}")
// PaperMC
compileOnly("io.papermc.paper:paper-api:${minecraftMajor}${minecraftMinor}-${paperSnapshot}-SNAPSHOT")
@ -103,7 +103,7 @@ runServer {
systemProperty("com.mojang.eula.agree", "true")
jvmArguments = [
'-Xlog:gc'
//'-Xlog:gc'
]
doFirst {
@ -129,7 +129,7 @@ publishing {
repositories {
maven {
name = "staropensource"
url = uri("https://mvn.staropensource.de/sosengine")
url = uri("https://mvn.staropensource.de/engine")
credentials(org.gradle.api.credentials.PasswordCredentials)
authentication {
//noinspection GroovyAssignabilityCheck

View file

@ -0,0 +1,51 @@
/*
* STAROPENSOURCE ENGINEMC SOURCE FILE
* Copyright (c) 2024 The StarOpenSource EngineMC Authors
* Licensed under the GNU Affero General Public License v3
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.minecraft.bukkit;
import de.staropensource.engine.base.EngineConfiguration;
import de.staropensource.engine.base.implementable.LoggingAdapter;
import de.staropensource.engine.base.implementation.shortcode.EmptyShortcodeParser;
import de.staropensource.engine.base.type.logging.LogLevel;
import org.jetbrains.annotations.NotNull;
/**
* A {@link LoggingAdapter} for the Bukkit API.
*/
public final class BukkitLoggingAdapter implements LoggingAdapter {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public BukkitLoggingAdapter() {}
/** {@inheritDoc} */
@Override
public void print(@NotNull LogLevel level, @NotNull StackTraceElement issuer, @NotNull String message, @NotNull String format) {
// Remove any tags
if (EngineConfiguration.getInstance() != null && EngineConfiguration.getInstance().getLogFeatures().contains("formatting"))
format = new EmptyShortcodeParser(format, true).getClean();
switch (level) {
case DIAGNOSTIC, VERBOSE, SILENT_WARNING, INFORMATIONAL, WARNING -> PlatformInitializer.getInstance().getLogger().info(format.replace("\n", "\n "));
case ERROR, CRASH -> PlatformInitializer.getInstance().getLogger().severe(format.replace("\n", "\n "));
}
}
}

View file

@ -17,13 +17,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.minecraft.bukkit;
package de.staropensource.engine.minecraft.bukkit;
import de.staropensource.sosengine.base.Engine;
import de.staropensource.sosengine.base.logging.Logger;
import de.staropensource.sosengine.base.logging.LoggerInstance;
import de.staropensource.sosengine.minecraft.EngineBootstrapper;
import de.staropensource.sosengine.minecraft.bukkit.command.BukkitCommand;
import de.staropensource.engine.base.Engine;
import de.staropensource.engine.base.logging.Logger;
import de.staropensource.engine.minecraft.EngineBootstrapper;
import de.staropensource.engine.minecraft.bukkit.command.BukkitCommand;
import lombok.Getter;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit;
@ -31,7 +30,6 @@ import org.bukkit.World;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
@ -54,15 +52,7 @@ public final class PlatformInitializer extends JavaPlugin {
*/
@Getter
private static PlatformInitializer instance;
/**
* Contains the {@link LoggerInstance} for this instance.
*
* @see LoggerInstance
* @since v1-alpha0
*/
private static final @NotNull LoggerInstance logger = new LoggerInstance.Builder().setClazz(PlatformInitializer.class).setOrigin("ENGINEMC").build();
/**
* Constructs this class.
*
@ -84,19 +74,30 @@ public final class PlatformInitializer extends JavaPlugin {
*/
@Override
public void onLoad() {
EngineBootstrapper.initialize(
true,
true,
exitcode -> {
if (Bukkit.getWorlds().isEmpty()) {
logger.info("No worlds are loaded, halting JVM");
Runtime.getRuntime().halt(exitcode);
} else
if (!Bukkit.isStopping())
try {
EngineBootstrapper.initialize(
true,
true,
exitcode -> {
if (Bukkit.getWorlds().isEmpty()) {
Logger.info("No worlds are loaded, halting JVM");
Runtime.getRuntime().halt(exitcode);
} else if (!Bukkit.isStopping())
Bukkit.shutdown();
},
new BukkitLoggingAdapter()
);
},
new BukkitLoggingAdapter()
);
} catch (Exception exception) {
getLogger().severe("EngineMC failed to load the StarOpenSource Engine.");
getLogger().severe("Please see above for further information.");
getLogger().severe("The server will now be forcefully shut down to prevent damage.");
// Wait for 1s for log messages to be flushed
long waitTime = System.currentTimeMillis() + 1000;
while (System.currentTimeMillis() < waitTime)
Thread.onSpinWait();
Runtime.getRuntime().halt(0);
}
}
/**
@ -111,7 +112,7 @@ public final class PlatformInitializer extends JavaPlugin {
PluginCommand command = Objects.requireNonNull(Bukkit.getPluginCommand("enginemc"));
command.setExecutor(new BukkitCommand());
} catch (NullPointerException exception) {
logger.crash("Failed to register the /enginemc command", exception);
Logger.crash("Failed to register the /enginemc command", exception);
}
}
@ -124,7 +125,7 @@ public final class PlatformInitializer extends JavaPlugin {
public void onDisable() {
if (!Bukkit.isStopping()) {
// Server is reloading, print warning and shutdown server
logger.error("""
Logger.error("""
__ ___ _ _ _____ _ ____ _____ __ _____ _ _ ____ ___ ___ _ _ ____ ___ ___
\\ \\ / / | | | / \\|_ _| / \\ | _ \\| ____| \\ \\ / / _ \\| | | | | _ \\ / _ \\_ _| \\ | |/ ___|__ \\__ \\
\\ \\ /\\ / /| |_| | / _ \\ | | / _ \\ | |_) | _| \\ V / | | | | | | | | | | | | | || \\| | | _ / / / /
@ -141,7 +142,7 @@ For safety, EngineMC will now save player and world data and forcefully shutdown
// Save and kick players
for (Player player : Bukkit.getOnlinePlayers()) {
logger.info("Saving data for player \"" + player.getName() + "\" [" + player.getUniqueId() + "]");
Logger.info("Saving data for player \"" + player.getName() + "\" [" + player.getUniqueId() + "]");
player.saveData();
if (player.isOp())
player.kick(MiniMessage.miniMessage().deserialize("The server has been forcefully shut down as the server has been reloaded,\nwhich is known to be unsafe. Check your server console for more information."));
@ -151,13 +152,13 @@ For safety, EngineMC will now save player and world data and forcefully shutdown
// Save worlds
for (World world : Bukkit.getWorlds()) {
logger.info("Saving data for world \"" + world.getName() + "\"");
Logger.info("Saving data for world \"" + world.getName() + "\"");
world.save();
}
// Halt JVM
logger.info("Halting JVM");
Logger.flushLogMessages(); // flush remaining log messages
Logger.info("Halting JVM");
Logger.flush(); // flush remaining log messages
Runtime.getRuntime().halt(0);
}

View file

@ -17,9 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.minecraft.bukkit.command;
package de.staropensource.engine.minecraft.bukkit.command;
import de.staropensource.sosengine.minecraft.command.Command;
import de.staropensource.engine.minecraft.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
@ -29,7 +29,7 @@ import org.jetbrains.annotations.NotNull;
*
* @since v1-alpha0
*/
public class BukkitCommand implements CommandExecutor {
public final class BukkitCommand implements CommandExecutor {
/**
* Constructs this class.
*

View file

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.minecraft.bukkit.command;
package de.staropensource.engine.minecraft.bukkit.command;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
@ -30,7 +30,7 @@ import org.jetbrains.annotations.NotNull;
*
* @since v1-alpha0
*/
public class BukkitPlayer extends de.staropensource.sosengine.minecraft.command.Player {
public final class BukkitPlayer extends de.staropensource.engine.minecraft.command.Player {
/**
* Contains the Bukkit player this instance refers to.
*

View file

@ -23,4 +23,4 @@
*
* @since v1-alpha0
*/
package de.staropensource.sosengine.minecraft.bukkit;
package de.staropensource.engine.minecraft.bukkit;

View file

@ -1,72 +0,0 @@
/*
* STAROPENSOURCE ENGINEMC SOURCE FILE
* Copyright (c) 2024 The StarOpenSource EngineMC Authors
* Licensed under the GNU Affero General Public License v3
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.minecraft.bukkit;
import de.staropensource.sosengine.base.EngineConfiguration;
import de.staropensource.sosengine.base.implementable.LoggingAdapter;
import de.staropensource.sosengine.base.implementation.shortcode.EmptyShortcodeConverter;
import de.staropensource.sosengine.base.type.logging.LogLevel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* A {@link LoggingAdapter} for the Bukkit API.
*/
public class BukkitLoggingAdapter implements LoggingAdapter {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public BukkitLoggingAdapter() {}
/** {@inheritDoc} */
@Override
public @Nullable String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
return null;
}
/** {@inheritDoc} */
@Override
public @NotNull String postPlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
return format;
}
/** {@inheritDoc} */
@Override
public void print(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
// Remove any tags
format = new EmptyShortcodeConverter(format, true).getClean();
// Fix newlines
if (EngineConfiguration.getInstance().isLoggerEnableNewlineSupport()) {
String spaces = " ";
if (level == LogLevel.ERROR || level == LogLevel.CRASH)
spaces += " ";
format = format.replace("\n", "\n" + spaces);
}
switch (level) {
case DIAGNOSTIC, VERBOSE, SILENT_WARNING, INFORMATIONAL, WARNING -> PlatformInitializer.getInstance().getLogger().info(format);
case ERROR, CRASH -> PlatformInitializer.getInstance().getLogger().severe(format);
}
}
}

View file

@ -1,23 +0,0 @@
/**
* Bukkit (PaperMC implementation) port of the
* StarOpenSource Engine and EngineMC.
*
* @since v1-alpha0
*/
module sosengine.minecraft.bukkit {
// Dependencies
requires java.logging;
requires sosengine.base;
requires sosengine.minecraft;
requires org.bukkit;
requires net.kyori.adventure;
requires net.kyori.examination.api;
// API access
exports de.staropensource.sosengine.minecraft.bukkit;
exports de.staropensource.sosengine.minecraft.bukkit.command;
// Reflection access
opens de.staropensource.sosengine.minecraft.bukkit;
opens de.staropensource.sosengine.minecraft.bukkit.command;
}

View file

@ -1,6 +1,6 @@
name: "sosenginemc"
version: "${version}"
main: "de.staropensource.sosengine.minecraft.bukkit.PlatformInitializer"
main: "de.staropensource.engine.minecraft.bukkit.PlatformInitializer"
description: "A port of the StarOpenSource Engine to the Bukkit API."
authors: [ "The StarOpenSource EngineMC Authors" ]
website: "https://git.staropensource.de/StarOpenSource/EngineMC"

View file

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
rootProject.setName("sosengine-minecraft")
rootProject.setName("EngineMC")
include("common")
include("platform-bukkit")