Update comments and javadoc

This commit is contained in:
JeremyStar™ 2024-06-27 20:29:08 +02:00
parent f39223b4da
commit 9cb5cbffd3
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
41 changed files with 155 additions and 147 deletions

View file

@ -92,7 +92,7 @@ public final class Engine implements SubsystemMainClass {
* @since 1-alpha0 * @since 1-alpha0
*/ */
public Engine() { public Engine() {
// Check if sos!engine is already loaded // Only allow one instance
if (instance == null) if (instance == null)
instance = this; instance = this;
else { else {
@ -201,15 +201,17 @@ public final class Engine implements SubsystemMainClass {
* @since 1-alpha0 * @since 1-alpha0
*/ */
public void precomputeEventListeners() { public void precomputeEventListeners() {
// Internal events
EventHelper.precomputeEventListeners(InternalEngineShutdownEvent.class); EventHelper.precomputeEventListeners(InternalEngineShutdownEvent.class);
// General events
EventHelper.precomputeEventListeners(EngineCrashEvent.class); EventHelper.precomputeEventListeners(EngineCrashEvent.class);
EventHelper.precomputeEventListeners(EngineShutdownEvent.class); EventHelper.precomputeEventListeners(EngineShutdownEvent.class);
EventHelper.precomputeEventListeners(LogEvent.class); EventHelper.precomputeEventListeners(LogEvent.class);
} }
/** /**
* Starts base engine threads. * Starts engine threads.
* *
* @since 1-alpha1 * @since 1-alpha1
*/ */
@ -220,18 +222,21 @@ public final class Engine implements SubsystemMainClass {
/** /**
* Shuts the engine and JVM down. * Shuts the engine and JVM down.
* *
* @param exitCode the code to exit with, from 0-255 * @param exitCode code to exit with, from 0-255
* @since 1-alpha0 * @since 1-alpha0
*/ */
public void shutdown(@Range(from = 0, to = 255) int exitCode) { public void shutdown(@Range(from = 0, to = 255) int exitCode) {
logger.info("Shutting engine down"); logger.info("Shutting engine down");
shuttingDown = true; shuttingDown = true;
logger.verb("Notifiying classes about shutdown"); logger.verb("Notifiying classes about shutdown");
new EngineShutdownEvent().callEvent(); new EngineShutdownEvent().callEvent();
logger.verb("Notifying subsystems about shutdown"); logger.verb("Notifying subsystems about shutdown");
new InternalEngineShutdownEvent().callEvent(); new InternalEngineShutdownEvent().callEvent();
logger.verb("Shutting down JVM with code " + exitCode); logger.verb("Shutting down JVM with code " + exitCode);
Logger.flushLogMessages(); Logger.flushLogMessages(); // Flush all log messages before exiting
Runtime.getRuntime().exit(exitCode); Runtime.getRuntime().exit(exitCode);
} }

View file

@ -252,6 +252,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
else else
Logger.crash(new LogIssuer(getClass(), CodePart.ENGINE), "Tried initializing " + getClass().getName() + " twice"); Logger.crash(new LogIssuer(getClass(), CodePart.ENGINE), "Tried initializing " + getClass().getName() + " twice");
// Load default configuration
loadDefaultConfiguration(); loadDefaultConfiguration();
} }
@ -260,6 +261,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
// Define variables // Define variables
PropertyParser parser = new PropertyParser(properties); PropertyParser parser = new PropertyParser(properties);
// Loop through all properties
for (String property : properties.stringPropertyNames()) { for (String property : properties.stringPropertyNames()) {
// Check if property name starts with group // Check if property name starts with group
if (!property.startsWith(group)) continue; if (!property.startsWith(group)) continue;
@ -267,7 +269,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
// Skip to important stuff // Skip to important stuff
property = property.substring(group.length()); property = property.substring(group.length());
// Match settings // Overwrite matching settings
try { try {
switch (property) { switch (property) {
case "debug" -> debug = parser.getBoolean(group + property); case "debug" -> debug = parser.getBoolean(group + property);
@ -294,7 +296,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
} catch (NullPointerException ignored) {} } catch (NullPointerException ignored) {}
} }
// Disable all debug options if 'debug' is disabled // Disable all debugging switches if 'debug' is disabled
if (!debug) { if (!debug) {
debugEvents = false; debugEvents = false;
debugShortcodeConverter = false; debugShortcodeConverter = false;

View file

@ -42,7 +42,7 @@ public interface Placeholder {
/** /**
* Replaces the placeholder with it's appropriate content. * Replaces the placeholder with it's appropriate content.
* *
* @param text the text to process * @param text text to process
* @return the processed text * @return the processed text
* @since 1-alpha0 * @since 1-alpha0
*/ */

View file

@ -49,7 +49,7 @@ public interface SubsystemConfiguration {
* Loads the subsystem configuration from the specified {@link Properties}.<br/> * Loads the subsystem configuration from the specified {@link Properties}.<br/>
* Unless you want to allow configuration overriding, resetting the configuration using {@code loadDefaultConfiguration()} is advised. * Unless you want to allow configuration overriding, resetting the configuration using {@code loadDefaultConfiguration()} is advised.
* *
* @param properties the {@link Properties} object * @param properties {@link Properties} object
* @see SubsystemConfiguration#loadDefaultConfiguration() * @see SubsystemConfiguration#loadDefaultConfiguration()
* @since 1-alpha0 * @since 1-alpha0
*/ */
@ -76,8 +76,8 @@ public interface SubsystemConfiguration {
/** /**
* Returns a configuration setting. * Returns a configuration setting.
* *
* @param setting the setting name * @param setting setting name
* @return the setting's value or {@code null} if not found * @return setting's value or {@code null} if not found
*/ */
Object getSetting(@NotNull String setting); Object getSetting(@NotNull String setting);
} }

View file

@ -65,11 +65,12 @@ public class EventHelper {
* @since 1-alpha0 * @since 1-alpha0
*/ */
public static void logCall(@NotNull Class<? extends Event> clazz, @NotNull Object ... arguments) { public static void logCall(@NotNull Class<? extends Event> clazz, @NotNull Object ... arguments) {
// Print event call if event debugging is enabled
if (EngineConfiguration.getInstance().isDebugEvents()) if (EngineConfiguration.getInstance().isDebugEvents())
if (arguments.length == 0) if (arguments.length == 0)
Logger.diag(new LogIssuer(clazz), "Event " + clazz.getName() + " called"); Logger.diag(new LogIssuer(clazz), "Event " + clazz.getName() + " emitted");
else else
Logger.diag(new LogIssuer(clazz), "Event " + clazz.getName() + " called with arguments " + ListFormatter.formatArray(arguments)); Logger.diag(new LogIssuer(clazz), "Event " + clazz.getName() + " emitted, passing arguments " + ListFormatter.formatArray(arguments));
} }
/** /**
@ -86,6 +87,7 @@ public class EventHelper {
if (forceScanning || !cachedEventListeners.containsKey(clazz)) { if (forceScanning || !cachedEventListeners.containsKey(clazz)) {
// Scan entire classpath through Reflections library // Scan entire classpath through Reflections library
// (enforced or not cached)
Reflections reflections = new Reflections( Reflections reflections = new Reflections(
new ConfigurationBuilder() new ConfigurationBuilder()
.setUrls(ClasspathHelper.forJavaClassPath()) .setUrls(ClasspathHelper.forJavaClassPath())
@ -100,7 +102,7 @@ public class EventHelper {
if (method.getAnnotation(EventListener.class).event() == clazz) if (method.getAnnotation(EventListener.class).event() == clazz)
methods.add(method); methods.add(method);
// Sort 'methods' linked list // Sort 'methods' linked list after event priority
methods.sort(Comparator.comparing(method0 -> method0.getAnnotation(EventListener.class).priority())); methods.sort(Comparator.comparing(method0 -> method0.getAnnotation(EventListener.class).priority()));
} else } else
// 'forcedScanning' is false and matching event listeners are cached // 'forcedScanning' is false and matching event listeners are cached
@ -147,7 +149,7 @@ public class EventHelper {
} }
/** /**
* Precomputes all event listeners listening on some event. * Caches all event listeners listening on some event.
* Will recompute all event listeners if the specified event is already cached. * Will recompute all event listeners if the specified event is already cached.
* *
* @param clazz event listeners to (p)recompute, set to {@code null} to recompute all cached events * @param clazz event listeners to (p)recompute, set to {@code null} to recompute all cached events
@ -170,7 +172,7 @@ public class EventHelper {
/** /**
* Removes events from the event listener cache. * Removes events from the event listener cache.
* *
* @param clazz event class to remove cached event listeners for, set to {@code null} to remove all cached event listeners * @param clazz event class to remove cached event listeners for or {@code null} to remove all cached event listeners
* @since 1-alpha0 * @since 1-alpha0
*/ */
public static void removePrecomputedEventListeners(@Nullable Class<? extends Event> clazz) { public static void removePrecomputedEventListeners(@Nullable Class<? extends Event> clazz) {

View file

@ -75,7 +75,7 @@ public class LogIssuer {
/** /**
* Constructor. * Constructor.
* *
* @param clazz the issuing class * @param clazz issuing class
* @param additionalInformation additional information about the issuer * @param additionalInformation additional information about the issuer
* @param codePart identifies to which part of the program the class belongs to * @param codePart identifies to which part of the program the class belongs to
* @since 1-alpha0 * @since 1-alpha0
@ -90,7 +90,7 @@ public class LogIssuer {
/** /**
* Constructor. * Constructor.
* *
* @param clazz the issuing class * @param clazz issuing class
* @param additionalInformation additional information about the issuer * @param additionalInformation additional information about the issuer
* @since 1-alpha0 * @since 1-alpha0
*/ */
@ -104,7 +104,7 @@ public class LogIssuer {
/** /**
* Constructor. * Constructor.
* *
* @param clazz the issuing class * @param clazz issuing class
* @param codePart identifies to which part of the program the class belongs to * @param codePart identifies to which part of the program the class belongs to
* @since 1-alpha0 * @since 1-alpha0
*/ */
@ -117,7 +117,7 @@ public class LogIssuer {
/** /**
* Constructor. * Constructor.
* *
* @param clazz the issuing class * @param clazz issuing class
* @since 1-alpha0 * @since 1-alpha0
*/ */
public LogIssuer(@NotNull Class<?> clazz) { public LogIssuer(@NotNull Class<?> clazz) {

View file

@ -225,12 +225,12 @@ public final class EngineInformation {
return; return;
} }
// Load properties from gradle.properties // Load properties from bundled gradle.properties
Properties properties = new Properties(); Properties properties = new Properties();
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("gradle.properties"); InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("gradle.properties");
if (inputStream == null) { if (inputStream == null) {
logger.crash("Unable to load build information: InputStream is null"); logger.crash("Unable to load build information: The bundled gradle.properties file could not be found. Do symlinks work on the system that built this JAR?");
return; return;
} }

View file

@ -48,10 +48,10 @@ public final class JvmInformation {
public static int getJavaVersion() { public static int getJavaVersion() {
String version = System.getProperty("java.version"); String version = System.getProperty("java.version");
if (version.startsWith("1.")) if (version.startsWith("1.")) // Omit "1." (if present)
version = version.substring(2, 3); version = version.substring(2, 3);
else { else {
if (version.contains(".")) if (version.contains(".")) // Only get MAJOR version
version = version.substring(0, version.indexOf(".")); version = version.substring(0, version.indexOf("."));
} }

View file

@ -53,9 +53,9 @@ public final class LogEvent implements Event {
/** /**
* Calls the event and notifies all annotated methods. * Calls the event and notifies all annotated methods.
* *
* @param level the log level * @param level log level
* @param logIssuer the log issuer * @param logIssuer log issuer
* @param message the log message * @param message log message
* @since 1-alpha0 * @since 1-alpha0
*/ */
public void callEvent(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String message) { public void callEvent(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String message) {

View file

@ -44,13 +44,6 @@ import java.util.*;
*/ */
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" }) @SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
public final class CrashHandler { public final class CrashHandler {
/**
* Hopefully {@code false} :)<br/>
* Note: Switching this to true might cause issues. Just don't do it ^^
*
* @since 1-alpha0
*/
public static boolean crashed = false;
/** /**
* Contains the template used to print a crash report. * Contains the template used to print a crash report.
@ -115,13 +108,12 @@ public final class CrashHandler {
* @since 1-alpha0 * @since 1-alpha0
*/ */
public static void handleCrash(@NotNull LogIssuer logIssuer, @NotNull String message, @Nullable Throwable throwable) { public static void handleCrash(@NotNull LogIssuer logIssuer, @NotNull String message, @Nullable Throwable throwable) {
crashed = true;
String base = crashTemplate; String base = crashTemplate;
// Convert crashContent to String and replace %content% in crashTemplate with the result // Replace '%content%' with crash content
base = base.replace("%content%", processCrashContent()); // This is so simple we don't need the PlaceholderEngine to do it for us base = base.replace("%content%", processCrashContent()); // This is so simple we don't need the PlaceholderEngine to do it for us
// Execute LoggerImpl#prePlaceholder // Invoke LoggerImpl#prePlaceholder
base = Logger.getLoggerImplementation().prePlaceholder(LogLevel.CRASH, logIssuer, base); base = Logger.getLoggerImplementation().prePlaceholder(LogLevel.CRASH, logIssuer, base);
// Create list of temporary placeholders // Create list of temporary placeholders
@ -140,13 +132,13 @@ public final class CrashHandler {
// Replace placeholders // Replace placeholders
base = PlaceholderEngine.getInstance().process(base, temporaryPlaceholders); base = PlaceholderEngine.getInstance().process(base, temporaryPlaceholders);
// Execute LoggerImpl#postPlaceholder // Invoke LoggerImpl#postPlaceholder
base = Logger.getLoggerImplementation().postPlaceholder(LogLevel.CRASH, logIssuer, base); base = Logger.getLoggerImplementation().postPlaceholder(LogLevel.CRASH, logIssuer, base);
// Print log message // Print log message by invoking LoggerImpl#print
Logger.getLoggerImplementation().print(LogLevel.CRASH, logIssuer, base); Logger.getLoggerImplementation().print(LogLevel.CRASH, logIssuer, base);
// Send EngineCrash event // Emit EngineCrashEvent
new EngineCrashEvent().callEvent(); new EngineCrashEvent().callEvent();
// Shutdown (engine &) JVM // Shutdown (engine &) JVM
@ -159,8 +151,8 @@ public final class CrashHandler {
/** /**
* Internal method for generating the crash message content. Do not call. * Internal method for generating the crash message content. Do not call.
* *
* @param map the {@link LinkedHashMap} to process * @param map {@link LinkedHashMap} to process
* @param indentationSize the indentation level * @param indentationSize indentation level
* @return crash content string * @return crash content string
* @see CrashHandler#processCrashContent() * @see CrashHandler#processCrashContent()
* @since 1-alpha0 * @since 1-alpha0
@ -170,11 +162,10 @@ public final class CrashHandler {
* We can safely ignore this as this method * We can safely ignore this as this method
* 1. checks data types as best as it can, * 1. checks data types as best as it can,
* 2. only works on a String and not on a File or something which could cause damage, and * 2. only works on a String and not on a File or something which could cause damage, and
* 3. we can trust our own engine and the application not doing shit in here. * 3. we can trust our own engine and possibly subsystems not doing shit in here.
* as an application or subsystem developer you'll likely want useful crash information. * As a subsystem developer you'll likely want useful crash information.
* *
* But hey, if someone breaks this method (which may be possible idk didn't test it) then congrats! * But hey, if someone breaks this method (which may be possible idk didn't test it) then congrats!
* If someone opens a pull requests wanting to "fix" this method, I'll happily decline it :)
*/ */
@NotNull @NotNull
private static String processCrashContent(@NotNull LinkedHashMap<Object, Object> map, int indentationSize) { private static String processCrashContent(@NotNull LinkedHashMap<Object, Object> map, int indentationSize) {
@ -189,6 +180,11 @@ public final class CrashHandler {
// Invalid content value, skip // Invalid content value, skip
continue; continue;
/*
* I'm too lazy to describe what you are seeing down below,
* so uuhhh just try breaking it and see what happens.
*/
if (!content.isEmpty()) if (!content.isEmpty())
content.append("\n"); content.append("\n");
@ -205,11 +201,9 @@ public final class CrashHandler {
else content.append(" ".repeat(indentationSize)).append("-> "); else content.append(" ".repeat(indentationSize)).append("-> ");
content.append(key).append("\n"); content.append(key).append("\n");
// We are the types in this function already
//noinspection unchecked //noinspection unchecked
content.append(processCrashContent((LinkedHashMap<Object, Object>) map.get(key), indentationSize + 1)); content.append(processCrashContent((LinkedHashMap<Object, Object>) map.get(key), indentationSize + 1));
} }
} }
return content.toString(); return content.toString();

View file

@ -65,7 +65,7 @@ public final class Logger {
* -- SETTER -- * -- SETTER --
* Sets the active {@link LoggerImpl}. * Sets the active {@link LoggerImpl}.
* *
* @param loggerImplementation the new active {@link LoggerImpl} * @param loggerImplementation new active {@link LoggerImpl}
* @see LoggerImpl * @see LoggerImpl
* @since 1-alpha0 * @since 1-alpha0
*/ */

View file

@ -58,7 +58,7 @@ public final class LoggerInstance {
/** /**
* Prints a diagnostic message. * Prints a diagnostic message.
* *
* @param message the diagnostic message * @param message diagnostic message
* @since 1-alpha0 * @since 1-alpha0
*/ */
public void diag(@NotNull String message) { public void diag(@NotNull String message) {
@ -68,7 +68,7 @@ public final class LoggerInstance {
/** /**
* Prints a verbose message. * Prints a verbose message.
* *
* @param message the verbose message * @param message verbose message
* @since 1-alpha0 * @since 1-alpha0
*/ */
public void verb(@NotNull String message) { public void verb(@NotNull String message) {
@ -78,7 +78,7 @@ public final class LoggerInstance {
/** /**
* Prints a silent warning message. * Prints a silent warning message.
* *
* @param message the silent warning message * @param message silent warning message
* @since 1-alpha0 * @since 1-alpha0
*/ */
public void sarn(@NotNull String message) { public void sarn(@NotNull String message) {
@ -88,7 +88,7 @@ public final class LoggerInstance {
/** /**
* Prints an informational message. * Prints an informational message.
* *
* @param message the informational message * @param message informational message
* @since 1-alpha0 * @since 1-alpha0
*/ */
public void info(@NotNull String message) { public void info(@NotNull String message) {
@ -98,7 +98,7 @@ public final class LoggerInstance {
/** /**
* Prints a warning message. * Prints a warning message.
* *
* @param message the warning message * @param message warning message
* @since 1-alpha0 * @since 1-alpha0
*/ */
public void warn(@NotNull String message) { public void warn(@NotNull String message) {
@ -108,7 +108,7 @@ public final class LoggerInstance {
/** /**
* Prints an error message. * Prints an error message.
* *
* @param message the error message * @param message error message
* @since 1-alpha0 * @since 1-alpha0
*/ */
public void error(@NotNull String message) { public void error(@NotNull String message) {
@ -118,8 +118,8 @@ public final class LoggerInstance {
/** /**
* Crashes the entire engine. * Crashes the entire engine.
* *
* @param message the diagnostic message * @param message diagnostic message
* @param throwable the throwable that caused this crash * @param throwable throwable that caused this crash
* @see CrashHandler * @see CrashHandler
* @since 1-alpha0 * @since 1-alpha0
*/ */
@ -130,7 +130,7 @@ public final class LoggerInstance {
/** /**
* Crashes the entire engine. * Crashes the entire engine.
* *
* @param message the diagnostic message * @param message diagnostic message
* @see CrashHandler * @see CrashHandler
* @since 1-alpha0 * @since 1-alpha0
*/ */

View file

@ -42,7 +42,7 @@ public final class IssuerClass implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param logIssuer the {@link LogIssuer} to use * @param logIssuer {@link LogIssuer} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public IssuerClass(@NotNull LogIssuer logIssuer) { public IssuerClass(@NotNull LogIssuer logIssuer) {

View file

@ -42,7 +42,7 @@ public final class IssuerCodePart implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param logIssuer the {@link LogIssuer} to use * @param logIssuer {@link LogIssuer} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public IssuerCodePart(@NotNull LogIssuer logIssuer) { public IssuerCodePart(@NotNull LogIssuer logIssuer) {

View file

@ -42,7 +42,7 @@ public final class IssuerInfo implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param logIssuer the {@link LogIssuer} to use * @param logIssuer {@link LogIssuer} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public IssuerInfo(@NotNull LogIssuer logIssuer) { public IssuerInfo(@NotNull LogIssuer logIssuer) {

View file

@ -41,7 +41,7 @@ public final class IssuerMessage implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param message the message to use * @param message message to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public IssuerMessage(@NotNull String message) { public IssuerMessage(@NotNull String message) {

View file

@ -42,7 +42,7 @@ public final class IssuerPackage implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param logIssuer the {@link LogIssuer} to use * @param logIssuer {@link LogIssuer} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public IssuerPackage(@NotNull LogIssuer logIssuer) { public IssuerPackage(@NotNull LogIssuer logIssuer) {

View file

@ -42,7 +42,7 @@ public final class IssuerPath implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param logIssuer the {@link LogIssuer} to use * @param logIssuer {@link LogIssuer} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public IssuerPath(@NotNull LogIssuer logIssuer) { public IssuerPath(@NotNull LogIssuer logIssuer) {

View file

@ -43,7 +43,7 @@ public final class Stacktrace implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param throwable the {@link Throwable} to use * @param throwable {@link Throwable} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public Stacktrace(@Nullable Throwable throwable) { public Stacktrace(@Nullable Throwable throwable) {

View file

@ -42,7 +42,7 @@ public final class LogClass implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param logIssuer the {@link LogIssuer} to use * @param logIssuer {@link LogIssuer} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public LogClass(@NotNull LogIssuer logIssuer) { public LogClass(@NotNull LogIssuer logIssuer) {

View file

@ -42,7 +42,7 @@ public final class LogCodePart implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param logIssuer the {@link LogIssuer} to use * @param logIssuer {@link LogIssuer} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public LogCodePart(@NotNull LogIssuer logIssuer) { public LogCodePart(@NotNull LogIssuer logIssuer) {

View file

@ -42,7 +42,7 @@ public final class LogColorPrimary implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param level the {@link LogLevel} to use * @param level {@link LogLevel} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public LogColorPrimary(@NotNull LogLevel level) { public LogColorPrimary(@NotNull LogLevel level) {

View file

@ -42,7 +42,7 @@ public final class LogColorSecondary implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param level the {@link LogLevel} to use * @param level {@link LogLevel} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public LogColorSecondary(@NotNull LogLevel level) { public LogColorSecondary(@NotNull LogLevel level) {

View file

@ -42,7 +42,7 @@ public final class LogInfo implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param logIssuer the {@link LogIssuer} to use * @param logIssuer {@link LogIssuer} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public LogInfo(@NotNull LogIssuer logIssuer) { public LogInfo(@NotNull LogIssuer logIssuer) {

View file

@ -41,7 +41,7 @@ public final class LogLevel implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param level the {@link de.staropensource.sosengine.base.classes.logging.LogLevel} to use * @param level {@link de.staropensource.sosengine.base.classes.logging.LogLevel} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public LogLevel(@NotNull de.staropensource.sosengine.base.classes.logging.LogLevel level) { public LogLevel(@NotNull de.staropensource.sosengine.base.classes.logging.LogLevel level) {

View file

@ -41,7 +41,7 @@ public final class LogMessage implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param message the message to use * @param message message to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public LogMessage(@NotNull String message) { public LogMessage(@NotNull String message) {

View file

@ -42,7 +42,7 @@ public final class LogPackage implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param logIssuer the {@link LogIssuer} to use * @param logIssuer {@link LogIssuer} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public LogPackage(@NotNull LogIssuer logIssuer) { public LogPackage(@NotNull LogIssuer logIssuer) {

View file

@ -42,7 +42,7 @@ public final class LogPath implements Placeholder {
/** /**
* Constructor. * Constructor.
* *
* @param logIssuer the {@link LogIssuer} to use * @param logIssuer {@link LogIssuer} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public LogPath(@NotNull LogIssuer logIssuer) { public LogPath(@NotNull LogIssuer logIssuer) {

View file

@ -39,13 +39,13 @@ public class Vec2 {
* -- GETTER -- * -- GETTER --
* Returns the X axis value. * Returns the X axis value.
* *
* @return the X axis value * @return X axis value
* @since 1-alpha0 * @since 1-alpha0
* *
* -- SETTER -- * -- SETTER --
* Sets the X axis value. * Sets the X axis value.
* *
* @param x the X axis value * @param x X axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
private float x; private float x;
@ -58,13 +58,13 @@ public class Vec2 {
* -- GETTER -- * -- GETTER --
* Returns the Y axis value. * Returns the Y axis value.
* *
* @return the Y axis value * @return Y axis value
* @since 1-alpha0 * @since 1-alpha0
* *
* -- SETTER -- * -- SETTER --
* Sets the Y axis value. * Sets the Y axis value.
* *
* @param y the Y axis value * @param y Y axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
private float y; private float y;
@ -72,8 +72,8 @@ public class Vec2 {
/** /**
* Constructor. * Constructor.
* *
* @param x the X axis value * @param x X axis value
* @param y the Y axis value * @param y Y axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
public Vec2(float x, float y) { public Vec2(float x, float y) {

View file

@ -45,7 +45,7 @@ public class Vec2i {
* -- SETTER -- * -- SETTER --
* Sets the X axis value. * Sets the X axis value.
* *
* @param x the X axis value * @param x X axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
private int x; private int x;
@ -58,13 +58,13 @@ public class Vec2i {
* -- GETTER -- * -- GETTER --
* Returns the Y axis value. * Returns the Y axis value.
* *
* @return the Y axis value * @return Y axis value
* @since 1-alpha0 * @since 1-alpha0
* *
* -- SETTER -- * -- SETTER --
* Sets the Y axis value. * Sets the Y axis value.
* *
* @param y the Y axis value * @param y Y axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
private int y; private int y;
@ -72,8 +72,8 @@ public class Vec2i {
/** /**
* Constructor. * Constructor.
* *
* @param x the X axis value * @param x X axis value
* @param y the Y axis value * @param y Y axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
public Vec2i(int x, int y) { public Vec2i(int x, int y) {

View file

@ -39,13 +39,13 @@ public class Vec3 {
* -- GETTER -- * -- GETTER --
* Returns the X axis value. * Returns the X axis value.
* *
* @return the X axis value * @return X axis value
* @since 1-alpha0 * @since 1-alpha0
* *
* -- SETTER -- * -- SETTER --
* Sets the X axis value. * Sets the X axis value.
* *
* @param x the X axis value * @param x X axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
private float x; private float x;
@ -58,13 +58,13 @@ public class Vec3 {
* -- GETTER -- * -- GETTER --
* Returns the Y axis value. * Returns the Y axis value.
* *
* @return the Y axis value * @return Y axis value
* @since 1-alpha0 * @since 1-alpha0
* *
* -- SETTER -- * -- SETTER --
* Sets the Y axis value. * Sets the Y axis value.
* *
* @param y the Y axis value * @param y Y axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
private float y; private float y;
@ -77,13 +77,13 @@ public class Vec3 {
* -- GETTER -- * -- GETTER --
* Returns the Z axis value. * Returns the Z axis value.
* *
* @return the Z axis value * @return Z axis value
* @since 1-alpha0 * @since 1-alpha0
* *
* -- SETTER -- * -- SETTER --
* Sets the Z axis value. * Sets the Z axis value.
* *
* @param z the Z axis value * @param z Z axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
private float z; private float z;
@ -91,9 +91,9 @@ public class Vec3 {
/** /**
* Constructor. * Constructor.
* *
* @param x the X axis value * @param x X axis value
* @param y the Y axis value * @param y Y axis value
* @param z the Z axis value * @param z Z axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
public Vec3(float x, float y, float z) { public Vec3(float x, float y, float z) {

View file

@ -39,13 +39,13 @@ public class Vec3i {
* -- GETTER -- * -- GETTER --
* Returns the X axis value. * Returns the X axis value.
* *
* @return the X axis value * @return X axis value
* @since 1-alpha0 * @since 1-alpha0
* *
* -- SETTER -- * -- SETTER --
* Sets the X axis value. * Sets the X axis value.
* *
* @param x the X axis value * @param x X axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
private int x; private int x;
@ -58,13 +58,13 @@ public class Vec3i {
* -- GETTER -- * -- GETTER --
* Returns the Y axis value. * Returns the Y axis value.
* *
* @return the Y axis value * @return Y axis value
* @since 1-alpha0 * @since 1-alpha0
* *
* -- SETTER -- * -- SETTER --
* Sets the Y axis value. * Sets the Y axis value.
* *
* @param y the Y axis value * @param y Y axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
private int y; private int y;
@ -77,13 +77,13 @@ public class Vec3i {
* -- GETTER -- * -- GETTER --
* Returns the Z axis value. * Returns the Z axis value.
* *
* @return the Z axis value * @return Z axis value
* @since 1-alpha0 * @since 1-alpha0
* *
* -- SETTER -- * -- SETTER --
* Sets the Z axis value. * Sets the Z axis value.
* *
* @param z the Z axis value * @param z Z axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
private int z; private int z;
@ -91,9 +91,9 @@ public class Vec3i {
/** /**
* Constructor. * Constructor.
* *
* @param x the X axis value * @param x X axis value
* @param y the Y axis value * @param y Y axis value
* @param z the Z axis value * @param z Z axis value
* @since 1-alpha0 * @since 1-alpha0
*/ */
public Vec3i(int x, int y, int z) { public Vec3i(int x, int y, int z) {

View file

@ -28,6 +28,7 @@ import java.util.Set;
/** /**
* Converts various data types to {@link String}s. * Converts various data types to {@link String}s.
* This class is unfinished.
* *
* @since 1-alpha0 * @since 1-alpha0
*/ */

View file

@ -73,7 +73,7 @@ public final class Miscellaneous {
/** /**
* Measures the execution time of a {@link Runnable}. * Measures the execution time of a {@link Runnable}.
* *
* @param runnable the {@link Runnable} to execute * @param runnable {@link Runnable} to execute
* @return execution time in milliseconds * @return execution time in milliseconds
* @see Runnable * @see Runnable
* @since 1-alpha0 * @since 1-alpha0

View file

@ -122,7 +122,7 @@ public final class PlaceholderEngine {
/** /**
* Process all placeholders for a given {@code text}. * Process all placeholders for a given {@code text}.
* *
* @param text the text to process * @param text text to process
* @param temporaryPlaceholders placeholders to process only for this run * @param temporaryPlaceholders placeholders to process only for this run
* @return the processed text * @return the processed text
* @since 1-alpha0 * @since 1-alpha0
@ -145,7 +145,7 @@ public final class PlaceholderEngine {
/** /**
* Process all placeholders for a given {@code text}. * Process all placeholders for a given {@code text}.
* *
* @param text the text to process * @param text text to process
* @return the processed text * @return the processed text
* @since 1-alpha0 * @since 1-alpha0
*/ */

View file

@ -82,7 +82,7 @@ public class PropertyParser {
/** /**
* Constructor. * Constructor.
* *
* @param properties the {@link Properties} to use * @param properties {@link Properties} to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public PropertyParser(@NotNull Properties properties) { public PropertyParser(@NotNull Properties properties) {
@ -93,7 +93,7 @@ public class PropertyParser {
/** /**
* Just returns the property value. * Just returns the property value.
* *
* @param name the property name * @param name property name
* @return a {@link String} * @return a {@link String}
* @throws NullPointerException if the specified property does not exist * @throws NullPointerException if the specified property does not exist
* @see String * @see String
@ -111,7 +111,7 @@ public class PropertyParser {
/** /**
* Parses a property as a {@link Boolean}. * Parses a property as a {@link Boolean}.
* *
* @param name the property name * @param name property name
* @return a {@link Boolean} * @return a {@link Boolean}
* @throws NullPointerException if the specified property does not exist * @throws NullPointerException if the specified property does not exist
* @see Boolean * @see Boolean
@ -137,7 +137,7 @@ public class PropertyParser {
/** /**
* Parses a property as a {@link Tristate}. * Parses a property as a {@link Tristate}.
* *
* @param name the property name * @param name property name
* @return a {@link Tristate} * @return a {@link Tristate}
* @throws NullPointerException if the specified property does not exist * @throws NullPointerException if the specified property does not exist
* @see Tristate * @see Tristate
@ -166,7 +166,7 @@ public class PropertyParser {
/** /**
* Parses a property as a {@link Byte}. * Parses a property as a {@link Byte}.
* *
* @param name the property name * @param name property name
* @return a {@link Byte} * @return a {@link Byte}
* @throws NullPointerException if the specified property does not exist * @throws NullPointerException if the specified property does not exist
* @throws NumberFormatException if the specified property cannot be parsed as a {@link Byte} * @throws NumberFormatException if the specified property cannot be parsed as a {@link Byte}
@ -191,7 +191,7 @@ public class PropertyParser {
/** /**
* Parses a property as a {@link Short}. * Parses a property as a {@link Short}.
* *
* @param name the property name * @param name property name
* @return a {@link Short} * @return a {@link Short}
* @throws NullPointerException if the specified property does not exist * @throws NullPointerException if the specified property does not exist
* @throws NumberFormatException if the specified property cannot be parsed as a {@link Short} * @throws NumberFormatException if the specified property cannot be parsed as a {@link Short}
@ -216,7 +216,7 @@ public class PropertyParser {
/** /**
* Parses a property as an {@link Integer}. * Parses a property as an {@link Integer}.
* *
* @param name the property name * @param name property name
* @param unsigned determines if the {@link Integer} is unsigned * @param unsigned determines if the {@link Integer} is unsigned
* @return an {@link Integer} * @return an {@link Integer}
* @throws NullPointerException if the specified property does not exist * @throws NullPointerException if the specified property does not exist
@ -245,7 +245,7 @@ public class PropertyParser {
/** /**
* Parses a property as a {@link Long}. * Parses a property as a {@link Long}.
* *
* @param name the property name * @param name property name
* @param unsigned determines if the {@link Long} is unsigned * @param unsigned determines if the {@link Long} is unsigned
* @return a {@link Long} * @return a {@link Long}
* @throws NullPointerException if the specified property does not exist * @throws NullPointerException if the specified property does not exist
@ -274,7 +274,7 @@ public class PropertyParser {
/** /**
* Parses a property as a {@link Float}. * Parses a property as a {@link Float}.
* *
* @param name the property name * @param name property name
* @return a {@link Float} * @return a {@link Float}
* @throws NullPointerException if the specified property does not exist * @throws NullPointerException if the specified property does not exist
* @throws NumberFormatException if the specified property cannot be parsed as an {@link Float} * @throws NumberFormatException if the specified property cannot be parsed as an {@link Float}
@ -299,7 +299,7 @@ public class PropertyParser {
/** /**
* Parses a property as a {@link Double}. * Parses a property as a {@link Double}.
* *
* @param name the property name * @param name property name
* @return a {@link Double} * @return a {@link Double}
* @throws NullPointerException if the specified property does not exist * @throws NullPointerException if the specified property does not exist
* @throws NumberFormatException if the specified property cannot be parsed as an {@link Double} * @throws NumberFormatException if the specified property cannot be parsed as an {@link Double}

View file

@ -78,7 +78,7 @@ public class ShortcodeConverter {
/** /**
* Converts shortcodes into ANSI escape sequences. * Converts shortcodes into ANSI escape sequences.
* *
* @param text the text to process * @param text text to process
* @param noErrors prevents printing tag/shortcode errors, overrides the engine configuration setting * @param noErrors prevents printing tag/shortcode errors, overrides the engine configuration setting
* @return {@link Ansi} sequence * @return {@link Ansi} sequence
* @see EngineConfiguration#errorShortcodeConverter * @see EngineConfiguration#errorShortcodeConverter
@ -87,12 +87,15 @@ public class ShortcodeConverter {
@NotNull @NotNull
public Ansi process(@NotNull String text, boolean noErrors) { public Ansi process(@NotNull String text, boolean noErrors) {
Ansi ansi = Ansi.ansi(); Ansi ansi = Ansi.ansi();
boolean tagActive = false; boolean tagActive = false; // Indicates that a tag is being parsed
String part = ""; String part = ""; // Current part. May be a tag, may be regular text
// Iterate through every character
for (char character : text.toCharArray()) { for (char character : text.toCharArray()) {
if (tagActive) { if (tagActive) {
// A tag is being parsed
if (character == '>') { if (character == '>') {
// Tag is ending, disable tag parsing
tagActive = false; tagActive = false;
// fg:* // fg:*
@ -213,29 +216,28 @@ public class ShortcodeConverter {
ansi.a("<" + part + ">"); ansi.a("<" + part + ">");
} }
// Reset part // Empty 'part'
part = ""; part = "";
} else } else
// Add character to part // Tag has not ended yet, add character to 'part'
//noinspection StringConcatenationInLoop // It bloats the code to do it with StringBuilder //noinspection StringConcatenationInLoop // It bloats the code to do it with StringBuilder
part += character; part += character;
} else { } else {
// Detect if character is start of tag // Regular text is being parsed
if (character == '<') { if (character == '<') {
// Insert previous text // Tag is starting, insert previous text
ansi.a(part); ansi.a(part);
// Prepare variables part = ""; // Empty 'part'
part = ""; tagActive = true; // Enable tag processing
tagActive = true;
} else } else
// Add character to part // Regular text, add character to 'part'
//noinspection StringConcatenationInLoop // It bloats the code to do it with StringBuilder //noinspection StringConcatenationInLoop // It bloats the code to do it with StringBuilder
part += character; part += character;
} }
} }
// Insert remaining characters // Processing ended, insert leftover text
ansi.a(part); ansi.a(part);
return ansi; return ansi;
@ -244,7 +246,7 @@ public class ShortcodeConverter {
/** /**
* Converts shortcodes into ANSI escape sequences. * Converts shortcodes into ANSI escape sequences.
* *
* @param text the text to process * @param text text to process
* @return {@link Ansi} sequence * @return {@link Ansi} sequence
* @since 1-alpha0 * @since 1-alpha0
*/ */

View file

@ -49,7 +49,7 @@ public class StackTraceParser {
/** /**
* Constructor. * Constructor.
* *
* @param throwable the throwable to use * @param throwable throwable to use
* @since 1-alpha0 * @since 1-alpha0
*/ */
public StackTraceParser(@NotNull Throwable throwable) { public StackTraceParser(@NotNull Throwable throwable) {

View file

@ -38,7 +38,7 @@ public class UnitLogger {
/** /**
* Constructor. * Constructor.
* *
* @param clazz the parent class * @param clazz parent class
*/ */
public UnitLogger(Class<?> clazz) { public UnitLogger(Class<?> clazz) {
this.clazz = clazz; this.clazz = clazz;
@ -47,8 +47,8 @@ public class UnitLogger {
/** /**
* Prints a log message. * Prints a log message.
* *
* @param level the log level * @param level log level
* @param message the log message (and arguments if called with level {@code SILENT_WARNING}) * @param message log message (and arguments if called with level {@code SILENT_WARNING})
*/ */
private void log(@NotNull LogLevel level, @NotNull String message, List<@Nullable Object> additionalStuff) { private void log(@NotNull LogLevel level, @NotNull String message, List<@Nullable Object> additionalStuff) {
String messageSingle = message; String messageSingle = message;
@ -92,7 +92,7 @@ public class UnitLogger {
/** /**
* Prints a diagnostic message. * Prints a diagnostic message.
* *
* @param message the diagnostic log message * @param message diagnostic log message
*/ */
public void diag(@NotNull String message) { public void diag(@NotNull String message) {
log(LogLevel.DIAGNOSTIC, message, null); log(LogLevel.DIAGNOSTIC, message, null);
@ -101,7 +101,7 @@ public class UnitLogger {
/** /**
* Prints a verbose message. * Prints a verbose message.
* *
* @param message the verbose log message * @param message verbose log message
*/ */
public void verb(@NotNull String message) { public void verb(@NotNull String message) {
log(LogLevel.VERBOSE, message, null); log(LogLevel.VERBOSE, message, null);
@ -120,7 +120,7 @@ public class UnitLogger {
/** /**
* Prints a informational message. * Prints a informational message.
* *
* @param message the informational log message * @param message informational log message
*/ */
public void info(@NotNull String message) { public void info(@NotNull String message) {
log(LogLevel.INFORMATIONAL, message, null); log(LogLevel.INFORMATIONAL, message, null);
@ -129,7 +129,7 @@ public class UnitLogger {
/** /**
* Prints a warning message. * Prints a warning message.
* *
* @param message the warning log message * @param message warning log message
*/ */
public void warn(@NotNull String message) { public void warn(@NotNull String message) {
log(LogLevel.WARNING, message, null); log(LogLevel.WARNING, message, null);
@ -138,7 +138,7 @@ public class UnitLogger {
/** /**
* Prints a error message. * Prints a error message.
* *
* @param message the error log message * @param message error log message
*/ */
public void error(@NotNull String message) { public void error(@NotNull String message) {
log(LogLevel.ERROR, message, null); log(LogLevel.ERROR, message, null);

View file

@ -89,13 +89,15 @@ public final class VulkanSubsystem implements ApiMainClass {
return; return;
} }
long initTime = Miscellaneous.measureExecutionTime(() -> {
// Warn about instability // Warn about instability
logger.warn("The Vulkan Graphics API is in an unfinished state. Trying to initialize the Graphics API will cause an engine crash."); logger.warn("The Vulkan Graphics API is in an unfinished state. Trying to initialize the Graphics API will cause an engine crash.");
// Register Graphics API // Register Graphics API
GraphicsSubsystem.getInstance().registerGraphicsApi(this); GraphicsSubsystem.getInstance().registerGraphicsApi(this);
});
logger.info("Initialized subsystem"); logger.info("Initialized subsystem in " + initTime + "ms");
} }
/** {@inheritDoc} */ /** {@inheritDoc} */

View file

@ -157,11 +157,11 @@ public class CompatibilityLogger extends LegacyAbstractLogger {
/** /**
* Just redirects to {@code forwardLogCall}. * Just redirects to {@code forwardLogCall}.
* *
* @param level the SLF4J level for this event * @param level SLF4J level for this event
* @param marker The marker to be used for this event, may be null. * @param marker marker to be used for this event, may be null.
* @param messagePattern The message pattern which will be parsed and formatted * @param messagePattern message pattern which will be parsed and formatted
* @param arguments the array of arguments to be formatted, may be null * @param arguments array of arguments to be formatted, may be null
* @param throwable The exception whose stack trace should be logged, may be null * @param throwable exception whose stack trace should be logged, may be null
* @see CompatibilityLogger#forwardLogCall(Level, String, Object[], Throwable) * @see CompatibilityLogger#forwardLogCall(Level, String, Object[], Throwable)
*/ */
@Override @Override