Compare commits
No commits in common. "develop" and "v1-alpha1" have entirely different histories.
20 changed files with 246 additions and 187 deletions
|
@ -34,7 +34,7 @@ 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 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))).
|
||||
This means that events have to be registered manually. You can do that by calling [`EventHelper#registerEvent`](https://jd.engine.staropensource.de/v1-alpha5/base/de/staropensource/sosengine/base/implementable/helper/EventHelper.html#registerEvent(java.lang.Class,de.staropensource.sosengine.base.implementable.EventListenerCode,de.staropensource.sosengine.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
|
||||
|
|
|
@ -98,8 +98,8 @@ allprojects {
|
|||
|
||||
// StarOpenSource Engine
|
||||
maven {
|
||||
name = "staropensource-engine"
|
||||
url = "https://mvn.staropensource.de/engine"
|
||||
name = "staropensource-sosengine"
|
||||
url = "https://mvn.staropensource.de/sosengine"
|
||||
}
|
||||
|
||||
// PaperMC
|
||||
|
|
|
@ -36,7 +36,7 @@ dependencies {
|
|||
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
|
||||
|
||||
// StarOpenSource Engine
|
||||
compileOnly("de.staropensource.engine:base:${dependencyStarOpenSourceEngine}")
|
||||
compileOnly("de.staropensource.sosengine:base:${dependencyStarOpenSourceEngine}")
|
||||
|
||||
// Adventure
|
||||
compileOnly("net.kyori:adventure-api:${dependencyAdventure}")
|
||||
|
@ -133,7 +133,7 @@ publishing {
|
|||
repositories {
|
||||
maven {
|
||||
name = "staropensource"
|
||||
url = uri("https://mvn.staropensource.de/engine")
|
||||
url = uri("https://mvn.staropensource.de/sosengine")
|
||||
credentials(org.gradle.api.credentials.PasswordCredentials)
|
||||
authentication {
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
|
|
|
@ -17,14 +17,15 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.engine.minecraft;
|
||||
package de.staropensource.sosengine.minecraft;
|
||||
|
||||
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 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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -33,6 +34,14 @@ 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.
|
||||
*
|
||||
|
@ -47,13 +56,12 @@ 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) throws Exception {
|
||||
public static void initialize(boolean disableMultithreading, boolean disableClasspathScanning, @NotNull ShutdownHandler shutdownHandler, @NotNull LoggingAdapter loggingAdapter) {
|
||||
overwriteSystemProperties(disableMultithreading, disableClasspathScanning); // Overwrites certain system properties to overwrite the engine configuration
|
||||
Logger.setLoggingAdapter(loggingAdapter); // Install logging adapter
|
||||
Engine.initialize(); // Initialize engine
|
||||
new Engine(); // 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
|
||||
|
@ -67,12 +75,13 @@ public final class EngineBootstrapper {
|
|||
* @since v1-alpha0
|
||||
*/
|
||||
private static void overwriteSystemProperties(boolean disableMultithreading, boolean disableClasspathScanning) {
|
||||
System.getProperties().setProperty("sosengine.base.logFeatures", "methodName,lineNumber");
|
||||
System.getProperties().setProperty("sosengine.base.loggerTemplate", "[%log_level% %log_path%%log_metadata%] %log_message_prefix%%log_message%");
|
||||
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.considerEnvironmentUnfriendlyToClasspathScanning", "true");
|
||||
System.getProperties().setProperty("sosengine.base.initialForceDisableClasspathScanning", "true");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,11 +92,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();
|
||||
|
@ -97,7 +106,7 @@ public final class EngineBootstrapper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Initializes all subsystems bundled with EngineMC.
|
||||
* Initializes all subsystems bundled with this subsystem.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
|
@ -17,12 +17,12 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.engine.minecraft;
|
||||
package de.staropensource.sosengine.minecraft;
|
||||
|
||||
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 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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
|
@ -17,15 +17,16 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.engine.minecraft;
|
||||
package de.staropensource.sosengine.minecraft;
|
||||
|
||||
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 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 lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -44,6 +45,14 @@ 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.
|
||||
*
|
||||
|
@ -288,14 +297,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;
|
||||
}
|
||||
|
||||
|
@ -303,7 +312,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;
|
||||
}
|
||||
|
||||
|
@ -312,7 +321,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");
|
||||
|
@ -330,7 +339,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;
|
||||
}
|
||||
}
|
|
@ -17,16 +17,15 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.engine.minecraft.command;
|
||||
package de.staropensource.sosengine.minecraft.command;
|
||||
|
||||
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 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 net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -38,7 +37,7 @@ import java.util.concurrent.TimeUnit;
|
|||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public final class Command {
|
||||
public class Command {
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
|
@ -68,34 +67,31 @@ public final class Command {
|
|||
message(player, Strings.errorTooFewArguments);
|
||||
else if (arguments.length == 2) {
|
||||
// Return configuration setting
|
||||
String value = null;
|
||||
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());
|
||||
|
||||
switch (arguments[1]) {
|
||||
case "debug" -> value = String.valueOf(EngineConfiguration.getInstance().isDebug());
|
||||
case "debugEvents" -> value = String.valueOf(EngineConfiguration.getInstance().isDebugEvents());
|
||||
case "initialPerformSubsystemInitialization" -> String.valueOf(EngineConfiguration.getInstance().isInitialPerformSubsystemInitialization());
|
||||
case "initialForceDisableClasspathScanning" -> String.valueOf(EngineConfiguration.getInstance().isInitialForceDisableClasspathScanning());
|
||||
case "initialIncludeSubsystemClasses" -> ListFormatter.formatSet(EngineConfiguration.getInstance().getInitialIncludeSubsystemClasses());
|
||||
|
||||
case "initialPerformSubsystemInitialization" -> value = String.valueOf(EngineConfiguration.getInstance().isInitialPerformSubsystemInitialization());
|
||||
case "initialIncludeSubsystemClasses" -> value = ListFormatter.formatSet(EngineConfiguration.getInstance().getInitialIncludeSubsystemClasses());
|
||||
case "errorShortcodeConverter" -> String.valueOf(EngineConfiguration.getInstance().isErrorShortcodeConverter());
|
||||
|
||||
case "errorShortcodeParser" -> value = String.valueOf(EngineConfiguration.getInstance().isErrorShortcodeParser());
|
||||
case "optimizeLogging" -> String.valueOf(EngineConfiguration.getInstance().isOptimizeLogging());
|
||||
case "optimizeEvents" -> String.valueOf(EngineConfiguration.getInstance().isOptimizeEvents());
|
||||
|
||||
case "optimizeLogging" -> value = String.valueOf(EngineConfiguration.getInstance().isOptimizeLogging());
|
||||
case "optimizeEvents" -> value = String.valueOf(EngineConfiguration.getInstance().isOptimizeEvents());
|
||||
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 "logLevel" -> value = "LogLevel." + EngineConfiguration.getInstance().getLogLevel().name();
|
||||
case "logFeatures" -> {
|
||||
StringBuilder features = new StringBuilder();
|
||||
case "hideFullTypePath" -> String.valueOf(EngineConfiguration.getInstance().isHideFullTypePath());
|
||||
|
||||
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());
|
||||
}
|
||||
default -> null;
|
||||
};
|
||||
|
||||
if (value == null)
|
||||
message(player, Strings.errorInvalidSetting.replace("%key%", arguments[1]));
|
||||
|
@ -114,8 +110,10 @@ public final 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));
|
||||
|
@ -123,10 +121,12 @@ public final 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 "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 "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 "hideFullTypePath" -> System.getProperties().setProperty("sosengine.base.hideFullTypePath", String.valueOf(newValue));
|
||||
|
||||
|
@ -224,7 +224,6 @@ public final class Command {
|
|||
|
||||
message(player, message);
|
||||
}
|
||||
case "crash" -> Logger.crash("Manually initiated crash (/enginemc crash)");
|
||||
default -> message(player, Strings.errorInvalidArgument);
|
||||
}
|
||||
}
|
||||
|
@ -271,8 +270,7 @@ public final 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>crash</bold>: Crashes the StarOpenSource Engine""";
|
||||
<red><bold>jvminfo</bold>: Displays information about the Java Virtual Machine""";
|
||||
|
||||
// Configuration
|
||||
public static final String configGet = "<red>The configuration setting \"%key%\" is set to '%value%'";
|
|
@ -17,7 +17,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.engine.minecraft.command;
|
||||
package de.staropensource.sosengine.minecraft.command;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
|
@ -23,4 +23,4 @@
|
|||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
package de.staropensource.engine.minecraft;
|
||||
package de.staropensource.sosengine.minecraft;
|
|
@ -11,10 +11,10 @@ module sosengine.minecraft {
|
|||
requires net.kyori.adventure.text.minimessage;
|
||||
|
||||
// API access
|
||||
exports de.staropensource.engine.minecraft;
|
||||
exports de.staropensource.engine.minecraft.command;
|
||||
exports de.staropensource.sosengine.minecraft;
|
||||
exports de.staropensource.sosengine.minecraft.command;
|
||||
|
||||
// Reflection access
|
||||
opens de.staropensource.engine.minecraft;
|
||||
opens de.staropensource.engine.minecraft.command;
|
||||
opens de.staropensource.sosengine.minecraft;
|
||||
opens de.staropensource.sosengine.minecraft.command;
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
# Versioning
|
||||
versioningCodename=Sugarcane
|
||||
versioningVersion=1
|
||||
versioningType=release
|
||||
versioningTyperelease=3
|
||||
versioningType=alpha
|
||||
versioningTyperelease=1
|
||||
versioningFork=
|
||||
|
||||
# Java
|
||||
javaSource=21
|
||||
javaSource=22
|
||||
javaTarget=21
|
||||
|
||||
# Minecraft
|
||||
|
@ -34,16 +34,16 @@ minecraftMinor=.1
|
|||
paperSnapshot=R0.1
|
||||
|
||||
# Plugins
|
||||
pluginShadow=8.1.8
|
||||
pluginLombok=8.10.2
|
||||
pluginShadow=8.1.7
|
||||
pluginLombok=8.6
|
||||
pluginGitProperties=2.4.2
|
||||
pluginRunTask=2.3.1
|
||||
|
||||
# Dependencies
|
||||
dependencyLombok=1.18.34
|
||||
dependencyJetbrainsAnnotations=26.0.1
|
||||
dependencyStarOpenSourceEngine=1-alpha8
|
||||
dependencyLombok=1.18.32
|
||||
dependencyJetbrainsAnnotations=24.1.0
|
||||
dependencyStarOpenSourceEngine=1-alpha5
|
||||
dependencyAdventure=4.17.0
|
||||
|
||||
# etc
|
||||
group = de.staropensource.enginemc
|
||||
group = de.staropensource.sosenginemc
|
||||
|
|
|
@ -36,7 +36,7 @@ dependencies {
|
|||
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
|
||||
|
||||
// StarOpenSource Engine
|
||||
implementation("de.staropensource.engine:base:${dependencyStarOpenSourceEngine}")
|
||||
implementation("de.staropensource.sosengine: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/engine")
|
||||
url = uri("https://mvn.staropensource.de/sosengine")
|
||||
credentials(org.gradle.api.credentials.PasswordCredentials)
|
||||
authentication {
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
|
|
|
@ -1,51 +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.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 "));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,12 +17,13 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.engine.minecraft.bukkit;
|
||||
package de.staropensource.sosengine.minecraft.bukkit;
|
||||
|
||||
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 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 lombok.Getter;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -30,6 +31,7 @@ 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;
|
||||
|
||||
|
@ -53,6 +55,14 @@ 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.
|
||||
*
|
||||
|
@ -74,30 +84,19 @@ public final class PlatformInitializer extends JavaPlugin {
|
|||
*/
|
||||
@Override
|
||||
public void onLoad() {
|
||||
try {
|
||||
EngineBootstrapper.initialize(
|
||||
true,
|
||||
true,
|
||||
exitcode -> {
|
||||
if (Bukkit.getWorlds().isEmpty()) {
|
||||
Logger.info("No worlds are loaded, halting JVM");
|
||||
logger.info("No worlds are loaded, halting JVM");
|
||||
Runtime.getRuntime().halt(exitcode);
|
||||
} else if (!Bukkit.isStopping())
|
||||
} else
|
||||
if (!Bukkit.isStopping())
|
||||
Bukkit.shutdown();
|
||||
},
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,7 +111,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +124,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 / | | | | | | | | | | | | | || \\| | | _ / / / /
|
||||
|
@ -142,7 +141,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."));
|
||||
|
@ -152,13 +151,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.flush(); // flush remaining log messages
|
||||
logger.info("Halting JVM");
|
||||
Logger.flushLogMessages(); // flush remaining log messages
|
||||
Runtime.getRuntime().halt(0);
|
||||
}
|
||||
|
|
@ -17,9 +17,9 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.engine.minecraft.bukkit.command;
|
||||
package de.staropensource.sosengine.minecraft.bukkit.command;
|
||||
|
||||
import de.staropensource.engine.minecraft.command.Command;
|
||||
import de.staropensource.sosengine.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 final class BukkitCommand implements CommandExecutor {
|
||||
public class BukkitCommand implements CommandExecutor {
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
|
@ -17,7 +17,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.engine.minecraft.bukkit.command;
|
||||
package de.staropensource.sosengine.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 final class BukkitPlayer extends de.staropensource.engine.minecraft.command.Player {
|
||||
public class BukkitPlayer extends de.staropensource.sosengine.minecraft.command.Player {
|
||||
/**
|
||||
* Contains the Bukkit player this instance refers to.
|
||||
*
|
|
@ -23,4 +23,4 @@
|
|||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
package de.staropensource.engine.minecraft.bukkit;
|
||||
package de.staropensource.sosengine.minecraft.bukkit;
|
23
platform-bukkit/src/main/java/module-info.java
Normal file
23
platform-bukkit/src/main/java/module-info.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* 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;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
name: "sosenginemc"
|
||||
version: "${version}"
|
||||
main: "de.staropensource.engine.minecraft.bukkit.PlatformInitializer"
|
||||
main: "de.staropensource.sosengine.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"
|
||||
|
|
Loading…
Reference in a new issue