forked from StarOpenSource/Engine
Initial rewrite commit (see #17)
This commit is contained in:
parent
1e978e3146
commit
ba412cec50
326 changed files with 2004 additions and 44873 deletions
18
.gitattributes
vendored
18
.gitattributes
vendored
|
@ -1,15 +1,19 @@
|
|||
# Documentation
|
||||
# Linguist metadata
|
||||
# -> Documentation
|
||||
*.md linguist-documentation
|
||||
docs/* linguist-documentation
|
||||
|
||||
# Licensing information
|
||||
# -> Licensing information
|
||||
COPYING linguist-documentation
|
||||
LICENSE linguist-documentation
|
||||
|
||||
# Javadoc
|
||||
# -> HTML, CSS, etc.
|
||||
*.html linguist-documentation
|
||||
*.css linguist-documentation
|
||||
|
||||
# Gradle configuration
|
||||
# -> Configuration
|
||||
*.properties linguist-configuration
|
||||
*.gradle linguist-configuration
|
||||
|
||||
# Line endings
|
||||
/gradlew text eol=lf
|
||||
*.bat text eol=crlf
|
||||
*.cmd text oel=crlf
|
||||
*.jar binary
|
||||
|
|
14
.gitignore
vendored
14
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
|||
### Gradle ###
|
||||
# Gradle
|
||||
.gradle
|
||||
build/
|
||||
run/
|
||||
|
@ -6,7 +6,7 @@ run/
|
|||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
# IntelliJ IDEA
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
|
@ -19,7 +19,7 @@ out/
|
|||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
# Eclipse
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
|
@ -31,17 +31,17 @@ bin/
|
|||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
# NetBeans
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
# Visual Studio Code
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
### Java ###
|
||||
# Java
|
||||
hs_err_pid*.log
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="allowReplaceRegexp" value="Copyright .* The StarOpenSource Engine Authors" />
|
||||
<option name="notice" value="STAROPENSOURCE ENGINE SOURCE FILE Copyright (c) &#36;today.year The StarOpenSource Engine 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/>." />
|
||||
<option name="notice" value="STAROPENSOURCE ENGINE SOURCE FILE Copyright (c) &#36;today.year The StarOpenSource Engine Authors Licensed under the GNU Affero General Public License v3 with an exception allowing classpath linking. 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/>." />
|
||||
<option name="myName" value="sos!engine" />
|
||||
</copyright>
|
||||
</component>
|
||||
</component>
|
|
@ -1,191 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunManager">
|
||||
<configuration name="Build test application (native)" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="testapp:nativeImage" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Build test application" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="shadowJar" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Clean" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="clean" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Generate JavaDoc (combined)" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="javadocAll" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Generate Javadoc (separate)" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="javadoc" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Run test application (native)" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="testapp:runNativeimage" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Run test application" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="testapp:runShadow" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Run tests" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="test" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<list>
|
||||
<item itemvalue="Gradle.Clean" />
|
||||
<item itemvalue="Gradle.Run tests" />
|
||||
<item itemvalue="Gradle.Build test application" />
|
||||
<item itemvalue="Gradle.Run test application" />
|
||||
<item itemvalue="Gradle.Build test application (native)" />
|
||||
<item itemvalue="Gradle.Run test application (native)" />
|
||||
<item itemvalue="Gradle.Generate Javadoc (separate)" />
|
||||
<item itemvalue="Gradle.Generate JavaDoc (combined)" />
|
||||
</list>
|
||||
</component>
|
||||
</project>
|
98
README.md
98
README.md
|
@ -1,91 +1,11 @@
|
|||
# StarOpenSource Engine
|
||||
The StarOpenSource Engine (or sos!engine for short) is a modular, extensible and easy to use Java game and application engine.
|
||||
<div align="center">
|
||||
<a href="https://git.staropensource.de/StarOpenSource/Engine">
|
||||
<img alt="StarOpenSource Engine" width="200px" height="auto" src="https://fs.staropensource.de/imgs/branding/engine/v2/extended-brand.png"/>
|
||||
</a>
|
||||
|
||||
## WARNING
|
||||
The StarOpenSource Engine is under heavy development and is extremely unstable. Code will break often, prepare for potential major refactors when trying the engine out.
|
||||
<p align="center"><a href="https://git.staropensource.de/StarOpenSource/Engine">Repository</a> | <a href="https://engine.staropensource.de">Documentation</a> | <a href="https://develop.engine.staropensource.de">Documentation (development)</a></p>
|
||||
</div>
|
||||
|
||||
## Index
|
||||
- [About](#about)
|
||||
- [... the engine](#-the-engine)
|
||||
- [... the repository](#-the-repository)
|
||||
- [Priorities](#priorities)
|
||||
- [Documentation](#documentation)
|
||||
- [Contributing](#contributing)
|
||||
- [Requirements](#requirements)
|
||||
- [What IDE to use?](#what-ide-to-use)
|
||||
- [Code style](#code-style)
|
||||
- [Pull request guidelines](#pull-request-guidelines)
|
||||
- [Making your first contribution](#making-your-first-contribution)
|
||||
- [Gradle properties](#gradle-properties)
|
||||
|
||||
## About
|
||||
### ... the engine
|
||||
The StarOpenSource Engine is a modular and extensible framework for building applications and games written in [one of the multiple JVM programming languages](https://en.wikipedia.org/wiki/List_of_JVM_languages).
|
||||
The engine consists of various subsystems, each separate and responsible for only a few closely-related tasks.
|
||||
\
|
||||
Not only that. The engine also features various useful classes, interfaces and methods making development fun and simpler, while being lightweight.
|
||||
### ... the repository
|
||||
The sos!engine repository is a monorepo, consisting of [the core engine](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/base), multiple official subsystems and [their documentation](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/docs).
|
||||
### Priorities
|
||||
These are in no particular order.
|
||||
|
||||
- configurable
|
||||
- [do one thing and do it well](https://en.wikipedia.org/wiki/Unix_philosophy) (subsystems concept)
|
||||
- fast
|
||||
- few runtime dependencies (note: we will cut down on some of them during development)
|
||||
- modular & extensible
|
||||
- small & lightweight
|
||||
|
||||
## Documentation
|
||||
You can view the engine documentation at [engine.staropensource.de](https://engine.staropensource.de). It provides information, guides and tutorials about the core engine and subsystems.
|
||||
If you want the API reference, you can [visit the Javadoc](https://jd.engine.staropensource.de) for the engine and it's subsystems.
|
||||
|
||||
## Contributing
|
||||
### Requirements
|
||||
You need the following things to be able to contribute code to the StarOpenSource Engine:
|
||||
- knowledge of Java
|
||||
- knowledge about the internals of engine
|
||||
### What IDE to use?
|
||||
We recommend and are using [IntelliJ IDEA Community Edition](https://github.com/JetBrains/intellij-community) for development because it is flexible, extendable, customizable, provides good completions and error detection. It's also open source.
|
||||
### Code style
|
||||
We recommend looking at existing classes and code for a good understanding on how we'd like code to be written.
|
||||
Here's a quick rundown on the most important things:
|
||||
- Document EVERYTHING. Every single class, field and method, even if private.
|
||||
- Make comments about your code, unless it's extremely simple and easy to understand.
|
||||
- Make sure to add and update `@since` in javadoc comments (update if the javadoc changes a good amount).
|
||||
- Keep stuff simple, no need to elaborate what a logger is. Though remember to not make it *too* simple.
|
||||
- Make sure every field and method has a newline to separate it.
|
||||
- Files must end with a newline or cats might get angry.
|
||||
- Use your brain.
|
||||
### Pull request guidelines
|
||||
Before creating a pull request, make sure you've:
|
||||
- created tests for the functionality you've added, changed or removed (if applicable),
|
||||
- tested your changes,
|
||||
- made sure that everything works,
|
||||
- is compatible with other code in the monorepo, and
|
||||
- is compatible with other applications. If not, tell us in your pull request description.
|
||||
### Making your first contribution
|
||||
TODO
|
||||
### Gradle properties
|
||||
Gradle's behaviour can be changed by changing gradle project properties.
|
||||
To change them, simply append `-P<property>` or `-P<property>=<value>`, like this: `./gradlew -Pjobs=4 test`.
|
||||
#### Parallelism
|
||||
Use the `jobs` property to control how many jobs will get executed simultaneously.
|
||||
On Linux, specify `-Pjobs=$(nproc)`. Defaults to `8`.
|
||||
#### Rendering
|
||||
You can use the `renderingPlatform` property to control which rendering platform to initialize for.
|
||||
#### JVM Home
|
||||
You can use the `graalHome` property to specify the `$JAVA_HOME` of your local GraalVM installation.
|
||||
Only used in the `nativeImage` task. Useful if you aren't using GraalVM as your primary JDK.
|
||||
#### Testing
|
||||
You can use the following properties to modify the behaviour of the `test`-task:
|
||||
- `test.control.mode` (default *empty*)
|
||||
- `force-enable`: Disables all test classes except the ones specified
|
||||
- `force-disable`: Enables all test classes except the ones specified
|
||||
- *everything else*: Enables all test classes
|
||||
- `test.control.classes` (default *empty*): A comma-separated, case-sensitive list of test classes
|
||||
which (depending on `test.control.mode`'s value) enable or disable the specified classes.
|
||||
Example: `-Ptest.control.mode=MiscellaneousTest,DependencyResolverTest,EngineConfigurationTest`
|
||||
- `test.control.warning` (default `false`): If `true`, will emit a warning before a restricted test method exits
|
||||
- `test.loggerLevel` (default `silent_warning`): Will set `UnitLogger`'s logger level.
|
||||
Works like `-Dsosengine.base.loggerLevel`. See `UnitLogger#loggerLevel` for more information
|
||||
# TODO
|
||||
We haven't yet been able to finish the README yet, sorry.
|
||||
You can however still look at [the old README](https://git.staropensource.de/StarOpenSource/Engine/src/commit/1e978e314687109fefa4a0966d772bb0facac338/README.md).
|
||||
|
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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/>.
|
||||
*/
|
||||
|
||||
// Plugins
|
||||
plugins {
|
||||
id("java")
|
||||
id("io.freefair.lombok") version("${pluginLombok}")
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
// Dependencies
|
||||
dependencies {
|
||||
// Lombok
|
||||
compileOnly("org.projectlombok:lombok:${dependencyLombok}")
|
||||
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
|
||||
|
||||
// JetBrains Annotations
|
||||
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
|
||||
|
||||
// Jansi
|
||||
implementation("org.fusesource.jansi:jansi:${dependencyJansi}")
|
||||
|
||||
// Project
|
||||
implementation(project(":base"))
|
||||
}
|
||||
|
||||
// Javadoc configuration
|
||||
javadoc {
|
||||
outputs.upToDateWhen { false } // Force task execution
|
||||
dependsOn(delombok) // Make sure the source is delomboked first
|
||||
|
||||
javadoc {
|
||||
setClasspath(files(project.sourceSets.main.compileClasspath)) // Include dependencies
|
||||
|
||||
options {
|
||||
if (new File(projectDir, "src/main/javadoc/theme.css").exists())
|
||||
stylesheetFile = new File(projectDir, "src/main/javadoc/theme.css") // Theming is cool :3
|
||||
setMemberLevel(JavadocMemberLevel.PUBLIC) // Only display public stuff
|
||||
setOverview("src/main/javadoc/overview.html") // We want a custom overview page to greet the visitor
|
||||
setLocale("en_US") // 你好
|
||||
addStringOption("Xwerror", "-quiet") // Fail build on warning
|
||||
|
||||
setJFlags([
|
||||
"-Duser.language=en_US" // See above
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Include javadoc and source jar during publishing
|
||||
java {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
// Build publishing configuration
|
||||
// Note: You can safely ignore any errors or warnings thrown by your IDE here
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "staropensource"
|
||||
url = uri("https://mvn.staropensource.de/engine")
|
||||
credentials(org.gradle.api.credentials.PasswordCredentials)
|
||||
authentication {
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
basic (BasicAuthentication)
|
||||
}
|
||||
}
|
||||
}
|
||||
publications {
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
maven (MavenPublication) {
|
||||
groupId = group
|
||||
artifactId = project.getName()
|
||||
version = version
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fix delombok task
|
||||
delombok.doFirst {
|
||||
File target = file("${project.projectDir}/src/main/module-info.java")
|
||||
File source = file("${project.projectDir}/src/main/java/module-info.java")
|
||||
|
||||
target.delete()
|
||||
source.renameTo(target)
|
||||
}
|
||||
delombok.doLast {
|
||||
File target = file("${project.projectDir}/src/main/java/module-info.java")
|
||||
File source = file("${project.projectDir}/src/main/module-info.java")
|
||||
|
||||
target.delete()
|
||||
source.renameTo(target)
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
../gradle
|
1
ansi/gradlew
vendored
1
ansi/gradlew
vendored
|
@ -1 +0,0 @@
|
|||
../gradlew
|
1
ansi/gradlew.bat
vendored
1
ansi/gradlew.bat
vendored
|
@ -1 +0,0 @@
|
|||
../gradlew.bat
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.ansi;
|
||||
|
||||
import de.staropensource.engine.base.EngineConfiguration;
|
||||
import de.staropensource.engine.base.implementable.LoggingAdapter;
|
||||
import de.staropensource.engine.base.logging.Logger;
|
||||
import de.staropensource.engine.base.type.logging.LogLevel;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
import org.fusesource.jansi.AnsiConsole;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Prints colored log output using the Jansi library.
|
||||
*
|
||||
* @see Logger
|
||||
* @see LoggingAdapter
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public class AnsiLoggingAdapter implements LoggingAdapter {
|
||||
/**
|
||||
* Creates and initializes an instance of this class.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public AnsiLoggingAdapter() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
@SuppressWarnings({ "resource" }) // Using try-with-resources will cause issues here
|
||||
public void print(@NotNull LogLevel level, @NotNull StackTraceElement issuer, @NotNull String message, @NotNull String format) {
|
||||
// Convert to Ansi
|
||||
Ansi output = new AnsiShortcodeParser(format, true).getAnsi();
|
||||
|
||||
// Print message
|
||||
if (level == LogLevel.ERROR || level == LogLevel.CRASH)
|
||||
if (EngineConfiguration.getInstance().isLogForceStandardOutput())
|
||||
AnsiConsole.out().println(output);
|
||||
else
|
||||
AnsiConsole.err().println(output);
|
||||
else
|
||||
AnsiConsole.out().println(output);
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.ansi;
|
||||
|
||||
import de.staropensource.engine.base.implementable.ShortcodeParser;
|
||||
import de.staropensource.engine.base.exception.ParserException;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Implementation of the {@link ShortcodeParser} class
|
||||
* with ANSI support using the Jansi library.
|
||||
*
|
||||
* @see ShortcodeParser
|
||||
* @since v1-alpha8
|
||||
*/
|
||||
public final class AnsiShortcodeParser extends ShortcodeParser {
|
||||
/**
|
||||
* Creates and initializes an instance of this class.
|
||||
*
|
||||
* @param string string to convert
|
||||
* @param ignoreInvalidEscapes will ignore invalid escapes and print treat them like regular text
|
||||
* @throws ParserException when parsing failed
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public AnsiShortcodeParser(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
|
||||
super(string, ignoreInvalidEscapes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parsed string as an {@link Ansi} sequence.
|
||||
*
|
||||
* @return {@link Ansi} sequence
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public @NotNull Ansi getAnsi() {
|
||||
Ansi ansi = Ansi.ansi();
|
||||
Set<@NotNull String> status = new HashSet<>();
|
||||
|
||||
for (String component : components)
|
||||
if (component.equals("RESET")) {
|
||||
ansi.a(Ansi.Attribute.RESET);
|
||||
status.clear();
|
||||
} else if (component.startsWith("TEXT:"))
|
||||
ansi.a(component.substring(5));
|
||||
else if (component.startsWith("COLOR:")) {
|
||||
if (component.startsWith("COLOR:FOREGROUND:"))
|
||||
ansi.fg(Ansi.Color.valueOf(component.substring(17)));
|
||||
else if (component.startsWith("COLOR:BACKGROUND:"))
|
||||
ansi.bg(Ansi.Color.valueOf(component.substring(17)));
|
||||
} else if (component.startsWith("ATTRIBUTE:"))
|
||||
if (component.startsWith("ATTRIBUTE:BLINK")) {
|
||||
if (status.contains("ATTRIBUTE:BLINK"))
|
||||
continue;
|
||||
|
||||
ansi.a(Ansi.Attribute.BLINK_SLOW);
|
||||
status.add("ATTRIBUTE:BLINK");
|
||||
} else if (component.startsWith("ATTRIBUTE:BOLD")) {
|
||||
if (status.contains("ATTRIBUTE:BOLD"))
|
||||
continue;
|
||||
|
||||
ansi.a(Ansi.Attribute.INTENSITY_BOLD);
|
||||
status.add("ATTRIBUTE:BOLD");
|
||||
} else if (component.startsWith("ATTRIBUTE:ITALIC")) {
|
||||
if (status.contains("ATTRIBUTE:ITALIC"))
|
||||
continue;
|
||||
|
||||
ansi.a(Ansi.Attribute.ITALIC);
|
||||
status.add("ATTRIBUTE:ITALIC");
|
||||
} else if (component.startsWith("ATTRIBUTE:STRIKETHROUGH")) {
|
||||
if (status.contains("ATTRIBUTE:STRIKETHROUGH"))
|
||||
continue;
|
||||
|
||||
ansi.a(Ansi.Attribute.STRIKETHROUGH_ON);
|
||||
status.add("ATTRIBUTE:STRIKETHROUGH");
|
||||
} else if (component.startsWith("ATTRIBUTE:UNDERLINE")) {
|
||||
if (status.contains("ATTRIBUTE:UNDERLINE"))
|
||||
continue;
|
||||
|
||||
ansi.a(Ansi.Attribute.UNDERLINE);
|
||||
status.add("ATTRIBUTE:UNDERLINE");
|
||||
}
|
||||
|
||||
|
||||
return ansi;
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.ansi;
|
||||
|
||||
import de.staropensource.engine.base.annotation.EngineSubsystem;
|
||||
import de.staropensource.engine.base.implementable.SubsystemClass;
|
||||
import de.staropensource.engine.base.implementation.logging.PlainLoggingAdapter;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import de.staropensource.engine.base.implementation.versioning.StarOpenSourceVersioningSystem;
|
||||
import de.staropensource.engine.base.logging.Logger;
|
||||
import de.staropensource.engine.base.type.DependencyVector;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Main class of the ANSI Compatibility subsystem.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@EngineSubsystem
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class AnsiSubsystem extends SubsystemClass {
|
||||
/**
|
||||
* Contains the class instance.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
* -- GETTER --
|
||||
* Returns the class instance.
|
||||
*
|
||||
* @return class instance unless the subsystem is uninitialized
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@Getter
|
||||
private static AnsiSubsystem instance = null;
|
||||
|
||||
/**
|
||||
* Initializes this subsystem.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public AnsiSubsystem() {
|
||||
// Check if subsystem has already initialized
|
||||
if (instance == null)
|
||||
instance = this;
|
||||
else
|
||||
Logger.crash("Only one instance of this class is allowed, use getInstance() instead of creating a new instance");
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return "ansi";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void initializeSubsystem() {
|
||||
if (Logger.getLoggingAdapter().getClass().getName().equals(PlainLoggingAdapter.class.getName()))
|
||||
Logger.setLoggingAdapter(new AnsiLoggingAdapter());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull DependencyVector getDependencyVector() {
|
||||
return new DependencyVector.Builder()
|
||||
.setIdentifier("ansi")
|
||||
.setVersioningSystem(StarOpenSourceVersioningSystem.class)
|
||||
.setVersion(EngineInformation.getVersioningString())
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
/**
|
||||
* The ANSI subsystem, allowing the engine to
|
||||
* use ANSI escape codes using the Jansi library.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
module sosengine.ansi {
|
||||
// Dependencies
|
||||
// -> Java
|
||||
requires transitive java.management;
|
||||
// -> Engine
|
||||
requires transitive sosengine.base;
|
||||
// -> Libraries
|
||||
requires transitive static lombok;
|
||||
requires transitive org.jetbrains.annotations;
|
||||
requires org.fusesource.jansi;
|
||||
|
||||
// API access
|
||||
exports de.staropensource.engine.ansi;
|
||||
|
||||
// Reflection access
|
||||
opens de.staropensource.engine.ansi;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
<!--
|
||||
~ STAROPENSOURCE ENGINE SOURCE FILE
|
||||
~ Copyright (c) 2024 The StarOpenSource Engine 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/>.
|
||||
-->
|
||||
|
||||
<body>
|
||||
<p>Welcome to the sos!engine API documentation!<br/>
|
||||
You are currently in the documentation for the <b>ansi</b> subsystem, allowing ANSI escape sequences to be used using Jansi.</p>
|
||||
</body>
|
|
@ -1 +0,0 @@
|
|||
../../../../src/main/javadoc/theme.css
|
1
base/.gitignore
vendored
1
base/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
src/main/resources/git.properties
|
|
@ -1,2 +0,0 @@
|
|||
# The `base` subsystem
|
||||
This is not just a subsystem, this is the core engine. It contains data types, logging infrastructure, an event system, a crash reporter and much more stuff required for basic applications.
|
|
@ -1,183 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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/>.
|
||||
*/
|
||||
|
||||
import java.nio.file.Files
|
||||
// Plugins
|
||||
plugins {
|
||||
id("java")
|
||||
id("io.freefair.lombok") version("${pluginLombok}")
|
||||
id("com.gorylenko.gradle-git-properties") version("${pluginGitProperties}")
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
// Dependencies
|
||||
dependencies {
|
||||
// -> Runtime
|
||||
// Lombok
|
||||
compileOnly("org.projectlombok:lombok:${dependencyLombok}")
|
||||
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
|
||||
|
||||
// JetBrains Annotations
|
||||
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
|
||||
|
||||
// Reflections
|
||||
implementation("org.reflections:reflections:${dependencyReflections}")
|
||||
|
||||
// -> Testing
|
||||
// Jetbrains Annotations
|
||||
testCompileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
|
||||
|
||||
// JUnit
|
||||
testImplementation(platform("org.junit:junit-bom:${dependencyJunit}"))
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
|
||||
// Project
|
||||
testImplementation(project(":testing"))
|
||||
}
|
||||
|
||||
// Javadoc configuration
|
||||
javadoc {
|
||||
outputs.upToDateWhen { false } // Force task execution
|
||||
dependsOn(delombok) // Make sure the source is delomboked first
|
||||
|
||||
javadoc {
|
||||
setClasspath(files(project.sourceSets.main.compileClasspath)) // Include dependencies
|
||||
|
||||
options {
|
||||
if (new File(projectDir, "src/main/javadoc/theme.css").exists())
|
||||
stylesheetFile = new File(projectDir, "src/main/javadoc/theme.css") // Theming is cool :3
|
||||
setMemberLevel(JavadocMemberLevel.PUBLIC) // Only display public stuff
|
||||
setOverview("src/main/javadoc/overview.html") // We want a custom overview page to greet the visitor
|
||||
setLocale("en_US") // 你好
|
||||
addStringOption("Xwerror", "-quiet") // Fail build on warning
|
||||
|
||||
setJFlags([
|
||||
"-Duser.language=en_US" // See above
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Unit testing configuration
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
|
||||
// Pass test configuration to test VMs
|
||||
Map<String, String> testConfiguration = new HashMap<>();
|
||||
for (String property : project.properties.keySet())
|
||||
if (property.startsWith("test."))
|
||||
testConfiguration.put(property, project.properties.get(property).toString())
|
||||
systemProperties(testConfiguration)
|
||||
|
||||
setMaxParallelForks(project.hasProperty("jobs") ? Integer.parseInt((String) project.property("jobs")) : 8)
|
||||
setForkEvery(1)
|
||||
setFailFast(true)
|
||||
|
||||
testLogging {
|
||||
events("passed", "skipped", "failed")
|
||||
}
|
||||
}
|
||||
|
||||
// Include javadoc and source jar during publishing
|
||||
java {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
// Build publishing configuration
|
||||
// Note: You can safely ignore any errors or warnings thrown by your IDE here
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "staropensource"
|
||||
url = uri("https://mvn.staropensource.de/engine")
|
||||
credentials(org.gradle.api.credentials.PasswordCredentials)
|
||||
authentication {
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
basic (BasicAuthentication)
|
||||
}
|
||||
}
|
||||
}
|
||||
publications {
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
maven (MavenPublication) {
|
||||
groupId = group
|
||||
artifactId = project.getName()
|
||||
version = version
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy gradle.properties file
|
||||
// for inclusion in final build
|
||||
tasks.register("copyGradleProperties") {
|
||||
doFirst {
|
||||
File target = file("${project.projectDir}/src/main/resources/sosengine-gradle.properties")
|
||||
File source = file(project(":").projectDir.getPath() + "/gradle.properties")
|
||||
target.delete()
|
||||
Files.copy(source.toPath(), target.toPath())
|
||||
}
|
||||
|
||||
outputs.upToDateWhen({ false }) // Force task execution
|
||||
}
|
||||
processResources.dependsOn(copyGradleProperties)
|
||||
|
||||
// Git properties configuration
|
||||
// Allows us to embed git commit information in the engine build
|
||||
gitProperties {
|
||||
dotGitDirectory = file("${rootProject.rootDir}/.git")
|
||||
failOnNoGitDirectory = false // Allow continuing if .git directory is missing for the few who use tarballs
|
||||
extProperty = "gitProps"
|
||||
|
||||
dateFormat = "yyyy-MM-dd'T'HH:mmZ"
|
||||
dateFormatTimeZone = "UTC"
|
||||
}
|
||||
|
||||
tasks.register("writeGitProperties") { // This task's only purpose is to copy the git.properties from our git properties plugin to the resources directory so it's included in the final build
|
||||
doLast {
|
||||
File target = file("${project.projectDir}/src/main/resources/sosengine-git.properties")
|
||||
File source = file("${project.projectDir}/build/resources/main/git.properties")
|
||||
|
||||
target.delete()
|
||||
source.renameTo(target)
|
||||
}
|
||||
|
||||
outputs.upToDateWhen({ false }) // Force task execution
|
||||
}
|
||||
generateGitProperties.outputs.upToDateWhen({ false }) // Force task execution
|
||||
processResources.dependsOn(writeGitProperties) // Ensure git.properties file is present
|
||||
|
||||
// Fix delombok task
|
||||
delombok.doFirst {
|
||||
File target = file("${project.projectDir}/src/main/module-info.java")
|
||||
File source = file("${project.projectDir}/src/main/java/module-info.java")
|
||||
|
||||
target.delete()
|
||||
source.renameTo(target)
|
||||
}
|
||||
delombok.doLast {
|
||||
File target = file("${project.projectDir}/src/main/java/module-info.java")
|
||||
File source = file("${project.projectDir}/src/main/module-info.java")
|
||||
|
||||
target.delete()
|
||||
source.renameTo(target)
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine Authors
|
||||
* Licensed under the GNU Affero General Public License v3
|
||||
* with an exception allowing classpath linking.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -17,10 +18,11 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Built-in versioning systems which
|
||||
* can be used to represent versions of some work.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
package de.staropensource.engine.base.implementation.versioning;
|
||||
// Dependencies
|
||||
dependencies {
|
||||
// Kotlin support
|
||||
kotlin(property("dependencyKotlinStdIdentifier") as String)
|
||||
|
||||
// sos!engine
|
||||
implementation(project(":logging"))
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
../gradle
|
1
base/gradlew
vendored
1
base/gradlew
vendored
|
@ -1 +0,0 @@
|
|||
../gradlew
|
1
base/gradlew.bat
vendored
1
base/gradlew.bat
vendored
|
@ -1 +0,0 @@
|
|||
../gradlew.bat
|
|
@ -1,614 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base;
|
||||
|
||||
import de.staropensource.engine.base.annotation.EngineSubsystem;
|
||||
import de.staropensource.engine.base.event.*;
|
||||
import de.staropensource.engine.base.exception.IllegalAccessException;
|
||||
import de.staropensource.engine.base.exception.dependency.UnmetDependenciesException;
|
||||
import de.staropensource.engine.base.implementable.ShutdownHandler;
|
||||
import de.staropensource.engine.base.implementable.SubsystemClass;
|
||||
import de.staropensource.engine.base.implementable.helper.EventHelper;
|
||||
import de.staropensource.engine.base.implementation.versioning.StarOpenSourceVersioningSystem;
|
||||
import de.staropensource.engine.base.event.InternalEngineShutdownEvent;
|
||||
import de.staropensource.engine.base.internal.type.DependencySubsystemVector;
|
||||
import de.staropensource.engine.base.logging.PrintStreamService;
|
||||
import de.staropensource.engine.base.logging.*;
|
||||
import de.staropensource.engine.base.logging.backend.async.LoggingQueue;
|
||||
import de.staropensource.engine.base.logging.backend.async.LoggingThread;
|
||||
import de.staropensource.engine.base.type.DependencyVector;
|
||||
import de.staropensource.engine.base.type.EngineState;
|
||||
import de.staropensource.engine.base.utility.DependencyResolver;
|
||||
import de.staropensource.engine.base.utility.FileAccess;
|
||||
import de.staropensource.engine.base.utility.misc.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 lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.Scanners;
|
||||
import org.reflections.util.ClasspathHelper;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Main class of the sos!engine.
|
||||
*
|
||||
* @see EngineConfiguration
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class Engine extends SubsystemClass {
|
||||
/**
|
||||
* Contains the class instance.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* -- GETTER --
|
||||
* Returns the class instance.
|
||||
*
|
||||
* @return class instance unless {@link Engine} is uninitialized
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@Getter
|
||||
private static Engine instance = null;
|
||||
|
||||
/**
|
||||
* Contains the thread group of the engine.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
* -- GETTER --
|
||||
* Returns the thread group of the engine.
|
||||
*
|
||||
* @return engine thread group
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@Getter
|
||||
private static final ThreadGroup threadGroup = new ThreadGroup("sos!engine");
|
||||
|
||||
/**
|
||||
* Contains the engine state.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
* -- GETTER --
|
||||
* Returns the engine state.
|
||||
*
|
||||
* @return shutdown state
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@Getter
|
||||
private @NotNull EngineState state;
|
||||
|
||||
/**
|
||||
* Contains a list of all registered subsystems.
|
||||
* The list is sorted after initialization order.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns a list of all registered subsystems.
|
||||
* The list is sorted after initialization order.
|
||||
*
|
||||
* @return subsystem list
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
private @NotNull List<@NotNull DependencySubsystemVector> subsystems = Collections.emptyList();
|
||||
|
||||
/**
|
||||
* Contains the engine's shutdown handler.
|
||||
* The shutdown handler is responsible for
|
||||
* shutting down the JVM safely.
|
||||
*
|
||||
* @see ShutdownHandler
|
||||
* @since v1-alpha2
|
||||
* -- GETTER --
|
||||
* Returns the engine's shutdown handler.
|
||||
* The shutdown handler is responsible for
|
||||
* shutting down the JVM safely.
|
||||
*
|
||||
* @return shutdown handler
|
||||
* @see ShutdownHandler
|
||||
* @since v1-alpha2
|
||||
* -- SETTER --
|
||||
* Sets the engine's shutdown handler.
|
||||
* The shutdown handler is responsible for
|
||||
* shutting down the JVM safely.
|
||||
*
|
||||
* @param shutdownHandler new shutdown handler
|
||||
* @see ShutdownHandler
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@Getter(value = AccessLevel.MODULE)
|
||||
@Setter(value = AccessLevel.MODULE)
|
||||
private @NotNull ShutdownHandler shutdownHandler = new Engine.JvmShutdownHandler();
|
||||
|
||||
/**
|
||||
* Contains the JVM shutdown hook thread,
|
||||
* which ensures that the engine is fully shut
|
||||
* down before the JVM exits.
|
||||
*
|
||||
* @see EngineInternals#installSafetyShutdownHook(boolean)
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
@Getter(AccessLevel.MODULE)
|
||||
private final @NotNull Thread safetyShutdownHook = Thread.ofPlatform()
|
||||
.name("Engine shutdown thread")
|
||||
.group(getThreadGroup())
|
||||
.unstarted(() -> {
|
||||
// Check if already shutting down
|
||||
switch (state) {
|
||||
case UNKNOWN, SHUTDOWN, CRASHED -> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Print warning about shutdown
|
||||
Logger.warn("Trying to shut down engine using shutdown hook.\nThis approach to shutting down the engine and JVM is NOT RECOMMENDED, please use Engine#shutdown() instead.");
|
||||
|
||||
// Shutdown
|
||||
Engine.getInstance().shutdown();
|
||||
|
||||
// Print last message
|
||||
Logger.warn("Engine successfully shut down using shutdown hook. PLEASE USE Engine#shutdown() INSTEAD OF System#exit() or Runtime#exit()!");
|
||||
});
|
||||
|
||||
/**
|
||||
* Initializes the StarOpenSource Engine.
|
||||
*
|
||||
* @throws RuntimeException for all exceptions thrown by this constructor
|
||||
* @since v1-alpha8
|
||||
*/
|
||||
private Engine() throws RuntimeException {
|
||||
try {
|
||||
instance = this;
|
||||
state = EngineState.EARLY_STARTUP;
|
||||
|
||||
// For measuring the initialization time
|
||||
long initTimeEarly = System.currentTimeMillis();
|
||||
long initTimeLate = initTimeEarly;
|
||||
|
||||
// Check for incompatible JVM implementations
|
||||
checkJvmIncompatibilities();
|
||||
|
||||
// Display that the engine is initializing
|
||||
Logger.verb("Initializing engine");
|
||||
|
||||
// Start the logging thread
|
||||
Logger.diag("Starting logging infrastructure");
|
||||
LoggingThread.startThread(false);
|
||||
PrintStreamService.initializeStreams();
|
||||
|
||||
// Initialize EngineInternals
|
||||
Logger.diag("Initializing EngineInternals class");
|
||||
new EngineInternals();
|
||||
|
||||
// Load engine configuration
|
||||
Logger.diag("Loading engine configuration");
|
||||
new EngineConfiguration();
|
||||
EngineConfiguration.getInstance().loadConfiguration();
|
||||
|
||||
// Load engine build information
|
||||
Logger.diag("Loading engine build information");
|
||||
EngineInformation.update();
|
||||
|
||||
// Check for reflective classpath scanning compatibility
|
||||
checkReflectiveClasspathScanningCompatibility();
|
||||
|
||||
// Check for Java version incompatibilities
|
||||
checkJavaVersion();
|
||||
|
||||
// Initialize PlaceholderEngine
|
||||
Logger.diag("Initializing PlaceholderEngine");
|
||||
PlaceholderEngine.initialize();
|
||||
|
||||
// Initialize static FileAccess instances
|
||||
Logger.diag("Initializing static FileAccess instances");
|
||||
FileAccess.initializeInstances();
|
||||
|
||||
// Install the safety shutdown hook
|
||||
Logger.diag("Installing safety shutdown hook");
|
||||
EngineInternals.getInstance().installSafetyShutdownHook(true);
|
||||
|
||||
// Cache events
|
||||
Logger.diag("Caching event listeners");
|
||||
cacheEvents();
|
||||
|
||||
// Complete early initialization stage
|
||||
Logger.verb("Completing early initialization stage");
|
||||
state = EngineState.STARTUP;
|
||||
initTimeEarly = System.currentTimeMillis() - initTimeEarly;
|
||||
|
||||
// Perform automatic subsystem initialization
|
||||
if (EngineConfiguration.getInstance().isInitialPerformSubsystemInitialization()) {
|
||||
// Collect all subsystems
|
||||
Logger.diag("Collecting subsystems");
|
||||
collectSubsystems();
|
||||
|
||||
// Initialize subsystems
|
||||
try {
|
||||
initializeSubsystems();
|
||||
} catch (Exception exception) {
|
||||
Logger.error("Subsystem dependency resolution failed");
|
||||
}
|
||||
}
|
||||
|
||||
// Complete late initialization stage
|
||||
Logger.verb("Completing late initialization stage");
|
||||
state = EngineState.RUNNING;
|
||||
initTimeLate = System.currentTimeMillis() - initTimeLate;
|
||||
|
||||
// Print welcome message
|
||||
Logger.info(
|
||||
"""
|
||||
Welcome to the StarOpenSource Engine "%engine_version_codename%" %engine_version%!
|
||||
Running commit %engine_git_commit_id_long% (dirty %engine_git_dirty%).
|
||||
Initialization took %init_time_total%ms (early %init_time_early%ms, late %init_time_late%ms).
|
||||
|
||||
Copyright (c) 2024 The StarOpenSource Engine Authors
|
||||
Licensed under the GNU Affero General Public License v3"""
|
||||
.replace("%init_time_total%", String.valueOf(initTimeEarly + initTimeLate))
|
||||
.replace("%init_time_early%", String.valueOf(initTimeEarly))
|
||||
.replace("%init_time_late%", String.valueOf(initTimeLate))
|
||||
);
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the StarOpenSource
|
||||
* Engine, if it isn't already.
|
||||
*
|
||||
* @throws IllegalStateException when running in an incompatible environment
|
||||
* @throws RuntimeException on engine initialization failure
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
public static void initialize() throws RuntimeException {
|
||||
try {
|
||||
if (instance == null)
|
||||
new Engine();
|
||||
} catch (RuntimeException exception) {
|
||||
Logger.error("Engine initialization failed\n" + Miscellaneous.stacktraceAsStringRecursive(exception.getCause(), true, true));
|
||||
Logger.flush();
|
||||
|
||||
throw new RuntimeException("Engine initialization failed", exception.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the running JVM implementation is not supported by the engine.
|
||||
*
|
||||
* @since v1-alpha8
|
||||
*/
|
||||
private void checkJvmIncompatibilities() {
|
||||
if (System.getProperties().getProperty("sosengine.base.allowUnsupportedJVMInitialization", "false").equals("true")) {
|
||||
Logger.warn("Skipping JVM implementation incompatibilities check");
|
||||
return;
|
||||
}
|
||||
|
||||
// Substrate VM (GraalVM Community)
|
||||
if (JvmInformation.getImplementationName().equals("Substrate VM") && JvmInformation.getImplementationVendor().equals("GraalVM Community")) {
|
||||
Logger.error("##############################################################################################");
|
||||
Logger.error("## Running in Substrate VM, which is the name of the JVM used by GraalVM native-image. ##");
|
||||
Logger.error("## The StarOpenSource Engine does not support native-image as using reflection in a certain ##");
|
||||
Logger.error("## way seems to cause the Substrate JVM to crash. Workarounds have failed. ##");
|
||||
Logger.error("## This has already been noted in issue #3, which you can view here: ##");
|
||||
Logger.error("## https://git.staropensource.de/StarOpenSource/Engine/issues/3 ##");
|
||||
Logger.error("## ##");
|
||||
Logger.error("## While this is sad, we unfortunately can't do anything against it unless we introduce ##");
|
||||
Logger.error("## annoying and stupid changes into the engine, which we don't want to do. ##");
|
||||
Logger.error("## ##");
|
||||
Logger.error("## We're truly sorry for this inconvenience. The sos!engine will now terminate. ##");
|
||||
Logger.error("##############################################################################################");
|
||||
Runtime.getRuntime().exit(255);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if reflective classpath scanning is supported.
|
||||
*
|
||||
* @since v1-alpha8
|
||||
*/
|
||||
private void checkReflectiveClasspathScanningCompatibility() {
|
||||
// Check if reflective classpath scanning is supported
|
||||
if (System.getProperties().getProperty("sosengine.base.considerEnvironmentUnfriendlyToClasspathScanning", "false").equals("true")) {
|
||||
Logger.warn("Running in an classpath scanning-unfriendly environment, disabling classpath scanning support.");
|
||||
Logger.warn("If shit doesn't work and is expected to be discovered by annotations, you'll need to");
|
||||
Logger.warn("either register it first or have to update some engine configuration setting.");
|
||||
Logger.warn("Please consult sos!engine's documentation for more information about this issue.");
|
||||
EngineInternals.getInstance().overrideReflectiveClasspathScanning(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks and warns if the Java version of the
|
||||
* running JVM is higher than the engine supports.
|
||||
*
|
||||
* @since v1-alpha8
|
||||
*/
|
||||
private void checkJavaVersion() {
|
||||
if (JvmInformation.getJavaVersion() > EngineInformation.getJavaSource())
|
||||
Logger.warn("The StarOpenSource Engine is running on an untested Java version.\nThings may not work as expected or features which can improve performance, stability, compatibility or ease of use may be missing.\nIf you encounter issues, try running a JVM implementing Java " + EngineInformation.getJavaSource());
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches all base engine events.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private void cacheEvents() {
|
||||
EventHelper.cacheEvent(EngineCrashEvent.class);
|
||||
EventHelper.cacheEvent(EngineShutdownEvent.class);
|
||||
EventHelper.cacheEvent(EngineSoftCrashEvent.class);
|
||||
EventHelper.cacheEvent(InternalEngineShutdownEvent.class);
|
||||
EventHelper.cacheEvent(LogEvent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects all subsystems by their {@link EngineSubsystem} annotation.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private void collectSubsystems() {
|
||||
ArrayList<@NotNull DependencySubsystemVector> subsystemsMutable = new ArrayList<>();
|
||||
Object initializedClassRaw;
|
||||
SubsystemClass initializedClass;
|
||||
|
||||
// Check and initialize all classes, get dependency vector and check version, then add to 'subsystemsMutable'
|
||||
for (Class<?> clazz : getRawSubsystemClasses())
|
||||
try {
|
||||
// Create new instance
|
||||
initializedClassRaw = clazz.getDeclaredConstructor().newInstance();
|
||||
initializedClass = null;
|
||||
|
||||
// Check if class implements SubsystemMainClass
|
||||
if (initializedClassRaw instanceof SubsystemClass)
|
||||
initializedClass = (SubsystemClass) initializedClassRaw;
|
||||
else
|
||||
Logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Does not implement " + SubsystemClass.class.getName());
|
||||
|
||||
//noinspection DataFlowIssue // the crash call will prevent a NullPointerException
|
||||
subsystemsMutable.add(new DependencySubsystemVector(initializedClass.getDependencyVector(), initializedClass));
|
||||
} catch (Exception exception) {
|
||||
if (exception.getClass() == IllegalStateException.class && exception.getMessage().startsWith("The version string is invalid: "))
|
||||
Logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Invalid version string: " + exception.getMessage().replace("The version string is invalid: ", ""));
|
||||
Logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Method invocation error", exception);
|
||||
}
|
||||
|
||||
// Update 'subsystems'
|
||||
subsystems = Collections.unmodifiableList(subsystemsMutable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of classes which are potentially
|
||||
* eligible for subsystem initialization.
|
||||
*
|
||||
* @return potential subsystem classes
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
private Set<@NotNull Class<?>> getRawSubsystemClasses() {
|
||||
Set<@NotNull Class<?>> classes = new HashSet<>();
|
||||
|
||||
if (EngineInternals.getInstance().getReflectiveClasspathScanning()) {
|
||||
// Scan entire classpath using the Reflections library
|
||||
Reflections reflections = new Reflections(
|
||||
new ConfigurationBuilder()
|
||||
.setUrls(ClasspathHelper.forJavaClassPath())
|
||||
.setScanners(Scanners.TypesAnnotated)
|
||||
);
|
||||
|
||||
// Get annotated methods
|
||||
classes = reflections.getTypesAnnotatedWith(EngineSubsystem.class);
|
||||
} else
|
||||
for (String path : EngineConfiguration.getInstance().getInitialIncludeSubsystemClasses())
|
||||
try {
|
||||
Logger.diag("Resolving class " + path);
|
||||
classes.add(Class.forName(path));
|
||||
} catch (ClassNotFoundException exception) {
|
||||
Logger.error("Failed loading subsystem class " + path + ": Class not found");
|
||||
}
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes all subsystems.
|
||||
*
|
||||
* @throws Exception exceptions thrown by the {@link DependencyResolver}
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private void initializeSubsystems() throws Exception {
|
||||
DependencyResolver resolver = new DependencyResolver();
|
||||
LinkedList<DependencySubsystemVector> order = new LinkedList<>();
|
||||
|
||||
// Add vectors
|
||||
resolver.addVector(getDependencyVector());
|
||||
resolver.addVectors(subsystems);
|
||||
|
||||
// Resolve dependencies and get order
|
||||
Logger.diag("Resolving subsystem dependencies");
|
||||
try {
|
||||
for (DependencyVector vector : resolver.resolve().getOrder()) // smol workaround
|
||||
order.add((DependencySubsystemVector) vector);
|
||||
} catch (Throwable throwable) {
|
||||
if (throwable instanceof UnmetDependenciesException exception) {
|
||||
List<@NotNull String> unmetDependencies = exception.getUnmetDependencies();
|
||||
StringBuilder list = new StringBuilder();
|
||||
|
||||
for (String error : unmetDependencies)
|
||||
list
|
||||
.append("\n")
|
||||
.append("- ")
|
||||
.append(error);
|
||||
|
||||
Logger.crash("Found unresolved dependencies:" + list, throwable);
|
||||
return;
|
||||
}
|
||||
Logger.crash("An error occurred trying to resolve subsystem dependencies: " + throwable.getClass().getName() + (throwable.getMessage() == null ? "" : ": " + throwable.getMessage()));
|
||||
throw throwable;
|
||||
}
|
||||
|
||||
// Initialize subsystems
|
||||
Logger.diag("Initializing engine subsystems");
|
||||
long initTime;
|
||||
for (DependencySubsystemVector vector : subsystems) {
|
||||
Logger.diag("Initializing subsystem '" + vector.getSubsystemClass().getName() + "' (" + vector.getSubsystemClass().getClass().getName() + ")");
|
||||
try {
|
||||
initTime = Miscellaneous.measureExecutionTime(() -> vector.getSubsystemClass().initializeSubsystem());
|
||||
} catch (Throwable throwable) {
|
||||
Logger.crash("An error occurred trying to initialize subsystem " + vector.getSubsystemClass().getName() + " (" + vector.getSubsystemClass().getClass().getName() + "): " + throwable.getClass().getName() + (throwable.getMessage() == null ? "" : ": " + throwable.getMessage()));
|
||||
throw throwable;
|
||||
}
|
||||
Logger.diag("Initialized subsystem '" + vector.getSubsystemClass().getName() + "' (" + vector.getSubsystemClass().getClass().getName() + ") in " + initTime + "ms");
|
||||
}
|
||||
|
||||
// Update 'subsystems'
|
||||
subsystems = Collections.unmodifiableList(order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts the engine down.
|
||||
*
|
||||
* @param exitCode code to exit with, from 0-255
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public synchronized void shutdown(@Range(from = 0, to = 255) int exitCode) {
|
||||
if (state == EngineState.UNKNOWN || state == EngineState.SHUTDOWN)
|
||||
return;
|
||||
|
||||
Logger.info("Shutting engine down");
|
||||
if (state != EngineState.CRASHED)
|
||||
state = EngineState.SHUTDOWN;
|
||||
|
||||
// Make engine single-threaded
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("sosengine.base.optimizeLogging", "false");
|
||||
properties.setProperty("sosengine.base.optimizeEvents", "false");
|
||||
EngineConfiguration.getInstance().loadConfiguration(properties);
|
||||
|
||||
// Flush log messages
|
||||
LoggingQueue.flush();
|
||||
|
||||
// Disable safety shutdown hook
|
||||
try {
|
||||
Runtime.getRuntime().removeShutdownHook(safetyShutdownHook);
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
// Send events
|
||||
Logger.verb("Notifying classes about shutdown");
|
||||
new EngineShutdownEvent().callEvent();
|
||||
|
||||
Logger.verb("Notifying subsystems about shutdown");
|
||||
new InternalEngineShutdownEvent().callEvent();
|
||||
|
||||
// Delete scheduled files
|
||||
FileAccess.deleteScheduled();
|
||||
|
||||
// Invoke shutdown handler
|
||||
Logger.verb("Invoking shutdown handler (code " + exitCode + ")");
|
||||
shutdownHandler.shutdown((short) exitCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts the engine down.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public void shutdown() {
|
||||
if (instance != null)
|
||||
instance.shutdown(0);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return "base";
|
||||
}
|
||||
|
||||
/**
|
||||
* This method does nothing.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Override
|
||||
public void initializeSubsystem() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull DependencyVector getDependencyVector() {
|
||||
return new DependencyVector.Builder()
|
||||
.setIdentifier("engine")
|
||||
.setVersioningSystem(StarOpenSourceVersioningSystem.class)
|
||||
.setVersion(EngineInformation.getVersioningString())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the engine state.
|
||||
*
|
||||
* @param state new state
|
||||
* @throws IllegalAccessException if the caller class is unauthorized
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public void setState(@NotNull EngineState state) throws IllegalAccessException {
|
||||
if (!Thread.currentThread().getStackTrace()[2].getClassName().startsWith("de.staropensource.engine.base."))
|
||||
throw new IllegalAccessException("Only classes inside the \"de.staropensource.engine.base\" package are allowed to call this method.");
|
||||
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default shutdown handler, which causes the JVM to exit.
|
||||
*
|
||||
* @see ShutdownHandler
|
||||
* @see System#exit(int)
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public static final class JvmShutdownHandler implements ShutdownHandler {
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public JvmShutdownHandler() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void shutdown(short exitCode) {
|
||||
// Check if already shutting down
|
||||
try {
|
||||
Thread thread = Thread.ofVirtual().unstarted(() -> {});
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(thread);
|
||||
Runtime.getRuntime().removeShutdownHook(thread);
|
||||
} catch (IllegalStateException exception) {
|
||||
Logger.warn("Terminating JVM: Already shutting down, skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.warn("Terminating JVM");
|
||||
Runtime.getRuntime().exit(exitCode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,526 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base;
|
||||
|
||||
import de.staropensource.engine.base.annotation.EngineSubsystem;
|
||||
import de.staropensource.engine.base.event.LogEvent;
|
||||
import de.staropensource.engine.base.implementable.Configuration;
|
||||
import de.staropensource.engine.base.implementable.ShortcodeParser;
|
||||
import de.staropensource.engine.base.implementable.SubsystemClass;
|
||||
import de.staropensource.engine.base.logging.Logger;
|
||||
import de.staropensource.engine.base.logging.backend.async.LoggingThread;
|
||||
import de.staropensource.engine.base.type.EngineState;
|
||||
import de.staropensource.engine.base.type.logging.LogLevel;
|
||||
import de.staropensource.engine.base.type.vector.Vec2f;
|
||||
import de.staropensource.engine.base.type.vector.Vec2i;
|
||||
import de.staropensource.engine.base.utility.PropertiesReader;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Provides the base engine configuration.
|
||||
* <p>
|
||||
* This class does not only provide engine settings but is also
|
||||
* responsible for loading them into memory from {@link Properties} objects.
|
||||
* <p>
|
||||
* Now you might ask why we didn't go with the string-based approach.
|
||||
* The answer is simple: It's a maintenance burden.
|
||||
* Having various settings strings scattered across many classes will cause
|
||||
* trouble at some point, which will cause some strings to be undocumented
|
||||
* or have an inconsistent naming scheme. Containing settings as variables in
|
||||
* one centralized place mitigates this.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class EngineConfiguration extends Configuration {
|
||||
/**
|
||||
* Contains the class instance.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* -- GETTER --
|
||||
* Returns the class instance.
|
||||
*
|
||||
* @return class instance unless {@link Engine} is uninitialized
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@Getter
|
||||
private static EngineConfiguration instance;
|
||||
|
||||
/**
|
||||
* Contains the configuration prefix.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* -- GETTER --
|
||||
* Returns the configuration prefix.
|
||||
*
|
||||
* @return property group
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private final @NotNull String group = "sosengine.base.";
|
||||
|
||||
|
||||
/**
|
||||
* Contains if debugging options should be allowed.
|
||||
* All debugging options will be forcefully set to
|
||||
* {@code false} if this option is set to {@code false}.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* -- GETTER --
|
||||
* Returns if debugging options should be allowed.
|
||||
* All debugging options will be forcefully set to
|
||||
* {@code false} if this option is set to {@code false}.
|
||||
*
|
||||
* @return debugging enabled?
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private boolean debug;
|
||||
|
||||
/**
|
||||
* Contains whether or not to log
|
||||
* events being emitted.
|
||||
* <p>
|
||||
* This will cause all events to
|
||||
* be logged, with the exception
|
||||
* of the {@link LogEvent}.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* -- GETTER --
|
||||
* Returns whether or not to log
|
||||
* events being emitted.
|
||||
* <p>
|
||||
* This will cause all events to
|
||||
* be logged, with the exception
|
||||
* of the {@link LogEvent}.
|
||||
*
|
||||
* @return detailed event logging enabled?
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private boolean debugEvents;
|
||||
|
||||
|
||||
/**
|
||||
* Contains whether or not to automatically discover
|
||||
* and initialize any class extending {@link SubsystemClass}
|
||||
* whilst being annotated with {@link EngineSubsystem}.
|
||||
* <p>
|
||||
* This mechanism may fail in certain situations, where
|
||||
* manual subsystem initialization may be desired. Make
|
||||
* sure to disable this setting before engine startup
|
||||
* and then initialize all subsystems manually.
|
||||
*
|
||||
* @see Engine
|
||||
* @since v1-alpha5
|
||||
* -- GETTER --
|
||||
* Returns whether or not to automatically discover
|
||||
* and initialize any class extending {@link SubsystemClass}
|
||||
* whilst being annotated with {@link EngineSubsystem}.
|
||||
* <p>
|
||||
* This mechanism may fail in certain situations, where
|
||||
* manual subsystem initialization may be desired. Make
|
||||
* sure to disable this setting before engine startup
|
||||
* and then initialize all subsystems manually.
|
||||
*
|
||||
* @return automatically discover and initialize subsystems?
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
private boolean initialPerformSubsystemInitialization;
|
||||
|
||||
/**
|
||||
* Contains a set of class names to try to load
|
||||
* and initialize as subsystems. Will only take effect
|
||||
* if {@link #initialPerformSubsystemInitialization} is
|
||||
* turned off.
|
||||
*
|
||||
* @since v1-alpha5
|
||||
* -- GETTER --
|
||||
* Returns a set of class names to try to load
|
||||
* and initialize as subsystems. Will only take effect
|
||||
* if {@link #getInitialIncludeSubsystemClasses()} is
|
||||
* turned off.
|
||||
*
|
||||
* @return set of class names to try and initialize as subsystems
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
private Set<@NotNull String> initialIncludeSubsystemClasses;
|
||||
|
||||
|
||||
/**
|
||||
* Contains whether or not to complain about invalid
|
||||
* shortcodes.
|
||||
* <p>
|
||||
* Requires the active log level to be set at least
|
||||
* to {@link LogLevel#SILENT_WARNING} to have effect.
|
||||
*
|
||||
* @see #logLevel
|
||||
* @since v1-alpha0
|
||||
* -- GETTER --
|
||||
* Returns whether or not to complain about invalid
|
||||
* shortcodes.
|
||||
* <p>
|
||||
* Requires the active log level to be set at least
|
||||
* to {@link LogLevel#SILENT_WARNING} to have effect.
|
||||
*
|
||||
* @return complain about invalid shortcodes?
|
||||
* @see #getLogLevel()
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private boolean errorShortcodeParser;
|
||||
|
||||
|
||||
/**
|
||||
* Contains if to log asynchronously.
|
||||
* <p>
|
||||
* If enabled, will cause a logging thread
|
||||
* to spawn. All log messages will be queued
|
||||
* and printed after a set delay
|
||||
* ({@link #logPollingSpeed}).
|
||||
* Highly recommended to keep enabled, or
|
||||
* the performance of your application will
|
||||
* very likely suffer.
|
||||
*
|
||||
* @see #logPollingSpeed
|
||||
* @since v1-alpha0
|
||||
* -- GETTER --
|
||||
* Returns if to log asynchronously.
|
||||
* <p>
|
||||
* If enabled, will cause a logging thread
|
||||
* to spawn. All log messages will be queued
|
||||
* and printed after a set delay
|
||||
* ({@link #getLogPollingSpeed()}).
|
||||
* Highly recommended to keep enabled, or
|
||||
* the performance of your application will
|
||||
* very likely suffer.
|
||||
*
|
||||
* @return log asynchronously?
|
||||
* @see #getLogPollingSpeed()
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private boolean optimizeLogging;
|
||||
|
||||
/**
|
||||
* Contains whether or not to emit events
|
||||
* asynchronously.
|
||||
* <p>
|
||||
* This will cause a
|
||||
* <a href="https://openjdk.org/jeps/444">VirtualThread</a>
|
||||
* to spawn every time an event is emitted.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* -- GETTER --
|
||||
* Contains whether or not to emit events
|
||||
* asynchronously.
|
||||
* <p>
|
||||
* This will cause a
|
||||
* <a href="https://openjdk.org/jeps/444">VirtualThread</a>
|
||||
* to spawn every time an event is emitted.
|
||||
*
|
||||
* @return emit events asynchronously?
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private boolean optimizeEvents;
|
||||
|
||||
|
||||
/**
|
||||
* Contains the minimum allowed log level.
|
||||
* <p>
|
||||
* The priority list is as follows (from high to low priority):
|
||||
* <ul>
|
||||
* <li>{@link LogLevel#CRASH}</li>
|
||||
* <li>{@link LogLevel#ERROR}</li>
|
||||
* <li>{@link LogLevel#WARNING}</li>
|
||||
* <li>{@link LogLevel#INFORMATIONAL}</li>
|
||||
* <li>{@link LogLevel#SILENT_WARNING}</li>
|
||||
* <li>{@link LogLevel#VERBOSE}</li>
|
||||
* <li>{@link LogLevel#DIAGNOSTIC}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* -- GETTER --
|
||||
* Returns the minimum allowed log level.
|
||||
* <p>
|
||||
* The priority list is as follows (from high to low priority):
|
||||
* <ul>
|
||||
* <li>{@link LogLevel#CRASH}</li>
|
||||
* <li>{@link LogLevel#ERROR}</li>
|
||||
* <li>{@link LogLevel#WARNING}</li>
|
||||
* <li>{@link LogLevel#INFORMATIONAL}</li>
|
||||
* <li>{@link LogLevel#SILENT_WARNING}</li>
|
||||
* <li>{@link LogLevel#VERBOSE}</li>
|
||||
* <li>{@link LogLevel#DIAGNOSTIC}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return minimum allowed log level
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private LogLevel logLevel;
|
||||
|
||||
/**
|
||||
* Contains a comma-separated list of optional
|
||||
* features to add to the final log output.
|
||||
* <p>
|
||||
* Available features (in order of appearance):
|
||||
* <ul>
|
||||
* <li><code>formatting</code></li>
|
||||
* <li><code>runtime</code></li>
|
||||
* <li><code>date</code></li>
|
||||
* <li><code>time</code></li>
|
||||
* <li><code>shortIssuerClass</code></li>
|
||||
* <li><code>moduleName</code></li>
|
||||
* <li><code>moduleVersion</code> (requires <code>moduleName</code>)</li>
|
||||
* <li><code>methodName</code></li>
|
||||
* <li><code>lineNumber</code></li>
|
||||
* </ul>
|
||||
*
|
||||
* @since v1-alpha8
|
||||
* -- GETTER --
|
||||
* Returns a comma-separated list of optional
|
||||
* features to add to the final log output.
|
||||
* <p>
|
||||
* Available features (in order of appearance):
|
||||
* <ul>
|
||||
* <li><code>formatting</code></li>
|
||||
* <li><code>runtime</code></li>
|
||||
* <li><code>date</code></li>
|
||||
* <li><code>time</code></li>
|
||||
* <li><code>shortIssuerClass</code></li>
|
||||
* <li><code>moduleName</code></li>
|
||||
* <li><code>moduleVersion</code> (requires <code>moduleName</code>)</li>
|
||||
* <li><code>methodName</code></li>
|
||||
* <li><code>lineNumber</code></li>
|
||||
* <li><code>level</code></li>
|
||||
* <li><code>origin</code></li>
|
||||
* </ul>
|
||||
*
|
||||
* @return optional features to enable
|
||||
* @since v1-alpha8
|
||||
*/
|
||||
private Set<@NotNull String> logFeatures;
|
||||
|
||||
/**
|
||||
* Contains how fast the logging thread will
|
||||
* poll for queued messages in milliseconds.
|
||||
* This also causes messages to be buffered.
|
||||
* <p>
|
||||
* Only applies if {@code optimizeLogging} is turned on.
|
||||
* Values below {@code 1} will poll for queued messages
|
||||
* as fast as it can. This however has pretty much no
|
||||
* benefit. Leave it at {@code 5}, it works quite well.
|
||||
*
|
||||
* @see #optimizeLogging
|
||||
* @since v1-alpha4
|
||||
* -- GETTER --
|
||||
* Contains how fast the logging thread will
|
||||
* poll for queued messages, in milliseconds.
|
||||
* This also causes messages to be buffered.
|
||||
* <p>
|
||||
* Only applies if {@code optimizeLogging} is turned on.
|
||||
* Values below {@code 1} will poll for queued messages
|
||||
* as fast as it can. This however has pretty much no
|
||||
* benefit. Leave it at {@code 5}, it works quite well.
|
||||
*
|
||||
* @return logging thread polling speed in milliseconds
|
||||
* @see #isOptimizeLogging()
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
private int logPollingSpeed;
|
||||
|
||||
/**
|
||||
* Contains whether or not to forcefully write
|
||||
* to the standard output instead of the
|
||||
* standard error stream.
|
||||
* <p>
|
||||
* This only applies to the {@link LogLevel#ERROR} and
|
||||
* {@link LogLevel#CRASH} log levels, as these use
|
||||
* the standard error stream by default.
|
||||
*
|
||||
* @see <a href="https://man7.org/linux/man-pages/man3/stderr.3.html">man page about standard streams</a>
|
||||
* @since v1-alpha0
|
||||
* -- GETTER --
|
||||
* Contains whether or not to forcefully write
|
||||
* to the standard output instead of the
|
||||
* standard error stream.
|
||||
* <p>
|
||||
* This only applies to the {@link LogLevel#ERROR} and
|
||||
* {@link LogLevel#CRASH} log levels, as these use
|
||||
* the standard error stream by default.
|
||||
*
|
||||
* @return force use stdout?
|
||||
* @see <a href="https://man7.org/linux/man-pages/man3/stderr.3.html">man page about standard streams</a>
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private boolean logForceStandardOutput;
|
||||
|
||||
|
||||
/**
|
||||
* Contains if to truncate the full path
|
||||
* of a class when invoking using their
|
||||
* {@link #toString()} method.
|
||||
* <p>
|
||||
* Here's an example: Lets say that you have a
|
||||
* {@link Vec2f} instance and want to convert
|
||||
* it to a String. You can do that by using
|
||||
* {@link Vec2f}'s {@link Vec2f#toString()}
|
||||
* method. With this flag disabled it will
|
||||
* return
|
||||
* {@code de.staropensource.engine.base.types.vectors.}{@link Vec2i}{@code (x=64 y=64)}.
|
||||
* With this flag enabled however the method will return
|
||||
* {@link Vec2i}{@code (x=64 y=64)},
|
||||
* which is much smaller.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
* -- GETTER --
|
||||
* Returns if to truncate the full path
|
||||
* of a class when invoking using their
|
||||
* {@link #toString()} method.
|
||||
* <p>
|
||||
* Here's an example: Lets say that you have a
|
||||
* {@link Vec2f} instance and want to convert
|
||||
* it to a String. You can do that by using
|
||||
* {@link Vec2f}'s {@link Vec2f#toString()}
|
||||
* method. With this flag disabled it will
|
||||
* return
|
||||
* {@code de.staropensource.engine.base.types.vectors.}{@link Vec2i}{@code (x=64 y=64)}.
|
||||
* With this flag enabled however the method will return
|
||||
* {@link Vec2i}{@code (x=64 y=64)},
|
||||
* which is much smaller.
|
||||
*
|
||||
* @return truncate class paths?
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
private boolean hideFullTypePath;
|
||||
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
* @see Engine
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
EngineConfiguration() {
|
||||
super();
|
||||
|
||||
instance = this;
|
||||
|
||||
// Load default configuration
|
||||
loadDefaultConfiguration();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void matchProperty(@NotNull PropertiesReader parser, @NotNull String property) {
|
||||
try {
|
||||
switch (property) {
|
||||
case "debug" -> debug = parser.getBoolean(group + property);
|
||||
case "debugEvents" -> debugEvents = parser.getBoolean(group + property);
|
||||
|
||||
case "initialPerformSubsystemInitialization" -> initialPerformSubsystemInitialization = parser.getBoolean(group + property);
|
||||
case "initialIncludeSubsystemClasses" -> {
|
||||
initialIncludeSubsystemClasses = new HashSet<>();
|
||||
initialIncludeSubsystemClasses.addAll(Arrays.stream(parser.getString(group + property).split(",")).toList());
|
||||
}
|
||||
|
||||
case "errorShortcodeParser" -> errorShortcodeParser = parser.getBoolean(group + property);
|
||||
|
||||
case "optimizeLogging" -> {
|
||||
optimizeLogging = parser.getBoolean(group + property);
|
||||
|
||||
// Start logging thread automatically
|
||||
if (optimizeLogging && Engine.getInstance().getState() == EngineState.RUNNING) {
|
||||
LoggingThread.startThread(false);
|
||||
}
|
||||
}
|
||||
case "optimizeEvents" -> optimizeEvents = parser.getBoolean(group + property);
|
||||
|
||||
case "logLevel" -> {
|
||||
try {
|
||||
logLevel = LogLevel.valueOf(parser.getString(group + property).toUpperCase());
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
Logger.error("The log level '" + parser.getString(group + property) + "' is not valid");
|
||||
}
|
||||
}
|
||||
case "logFeatures" -> logFeatures = Set.copyOf(Arrays.stream(parser.getString(group + property).split(",")).toList());
|
||||
case "logPollingSpeed" -> logPollingSpeed = parser.getInteger(group + property, true);
|
||||
case "logForceStandardOutput" -> logForceStandardOutput = parser.getBoolean(group + property);
|
||||
|
||||
case "hideFullTypePath" -> hideFullTypePath = parser.getBoolean(group + property);
|
||||
}
|
||||
} catch (NullPointerException ignored) {}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void processSettings(@NotNull PropertiesReader parser) {
|
||||
// Disable all debugging switches if 'debug' is disabled
|
||||
if (!debug) {
|
||||
debugEvents = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void loadDefaultConfiguration() {
|
||||
debug = false;
|
||||
debugEvents = false;
|
||||
|
||||
initialPerformSubsystemInitialization = true;
|
||||
initialIncludeSubsystemClasses = new HashSet<>();
|
||||
|
||||
errorShortcodeParser = true;
|
||||
|
||||
optimizeLogging = true;
|
||||
optimizeEvents = true;
|
||||
|
||||
logLevel = LogLevel.INFORMATIONAL;
|
||||
logFeatures = Set.of("formatting", "time", "methodName", "lineNumber", "level", "origin");
|
||||
logPollingSpeed = 5;
|
||||
logForceStandardOutput = false;
|
||||
|
||||
hideFullTypePath = false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @Nullable Object getSetting(@NotNull String setting) {
|
||||
return switch (setting) {
|
||||
case "debug" -> debug;
|
||||
case "debugEvents" -> debugEvents;
|
||||
|
||||
case "initialPerformSubsystemInitialization" -> initialPerformSubsystemInitialization;
|
||||
case "initialIncludeSubsystemClasses" -> initialIncludeSubsystemClasses;
|
||||
|
||||
case "errorShortcodeParser" -> errorShortcodeParser;
|
||||
|
||||
case "optimizeLogging" -> optimizeLogging;
|
||||
case "optimizeEvents" -> optimizeEvents;
|
||||
|
||||
case "logLevel" -> logLevel;
|
||||
case "logFeatures" -> logFeatures;
|
||||
case "logPollingSpeed" -> logPollingSpeed;
|
||||
case "logForceStandardOutput" -> logForceStandardOutput;
|
||||
|
||||
case "hideFullTypePath" -> hideFullTypePath;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,226 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base;
|
||||
|
||||
import de.staropensource.engine.base.exception.IllegalAccessException;
|
||||
import de.staropensource.engine.base.implementable.Event;
|
||||
import de.staropensource.engine.base.implementable.EventListenerCode;
|
||||
import de.staropensource.engine.base.implementable.ShutdownHandler;
|
||||
import de.staropensource.engine.base.implementable.helper.EventHelper;
|
||||
import de.staropensource.engine.base.logging.Logger;
|
||||
import de.staropensource.engine.base.type.InternalAccessArea;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class which allows access to the internals
|
||||
* and changing the behaviour of the engine.
|
||||
*
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class EngineInternals {
|
||||
/**
|
||||
* Contains the class instance.
|
||||
*
|
||||
* @since v1-alpha4
|
||||
* -- GETTER --
|
||||
* Returns the class instance.
|
||||
*
|
||||
* @return class instance unless the engine is uninitialized
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
@Getter
|
||||
private static EngineInternals instance;
|
||||
|
||||
/**
|
||||
* Contains all disabled internal access areas.
|
||||
*
|
||||
* @since v1-alpha4
|
||||
* -- GETTER --
|
||||
* Returns all disabled internal access areas.
|
||||
*
|
||||
* @return restricted areas
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
@Getter
|
||||
private final @NotNull List<@NotNull InternalAccessArea> restrictedAreas = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Contains whether the engine should reflectively
|
||||
* search the classpath for events or other annotations.
|
||||
* <p>
|
||||
* If disabled, code will either have to manually call
|
||||
* registration methods or certain classes have to
|
||||
* be created in a certain package, depending on the
|
||||
* use case and application.
|
||||
*
|
||||
* @see EventHelper#registerEvent(Class, EventListenerCode)
|
||||
* @see EventHelper#registerEvent(Class, EventListenerCode, Event.Priority)
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
private boolean reflectiveClasspathScanning = true;
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this class.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
EngineInternals() {
|
||||
// Only allow one instance
|
||||
if (instance == null && Engine.getInstance() != null)
|
||||
instance = this;
|
||||
else
|
||||
Logger.crash("Only one instance of this class is allowed, use getInstance() instead of creating a new instance");
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether access to the specified area is allowed.
|
||||
*
|
||||
* @param area internal access area to check
|
||||
* @throws IllegalAccessException when restricted
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
private void isRestricted(@NotNull InternalAccessArea area) throws IllegalAccessException {
|
||||
if (restrictedAreas.contains(area))
|
||||
throw new IllegalAccessException("The internal access area " + area.name() + " has been restricted");
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts access to certain areas of this class.
|
||||
*
|
||||
* @param area area to restrict
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
public void restrictAccess(@NotNull InternalAccessArea area) {
|
||||
switch (area) {
|
||||
case ALL -> {
|
||||
List<@NotNull InternalAccessArea> areas = new ArrayList<>(List.of(InternalAccessArea.values()));
|
||||
areas.remove(InternalAccessArea.ALL);
|
||||
areas.remove(InternalAccessArea.ALL_READ);
|
||||
areas.remove(InternalAccessArea.ALL_WRITE);
|
||||
areas.remove(InternalAccessArea.ALL_READ_ESSENTIAL);
|
||||
restrictedAreas.addAll(areas);
|
||||
}
|
||||
case ALL_WRITE -> restrictedAreas.addAll(Arrays.stream(InternalAccessArea.valuesWriteOnly()).toList());
|
||||
case ALL_READ -> restrictedAreas.addAll(Arrays.stream(InternalAccessArea.valuesReadOnly()).toList());
|
||||
case ALL_READ_ESSENTIAL -> restrictedAreas.addAll(Arrays.stream(InternalAccessArea.valuesEssentialReadOnly()).toList());
|
||||
default -> restrictedAreas.add(area);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs or uninstalls the JVM shutdown
|
||||
* hook, which prevents the JVM from exiting
|
||||
* before the engine has fully shut down.
|
||||
* Highly recommended to keep enabled.
|
||||
*
|
||||
* @param status {@code true} to install, {@code false} otherwise
|
||||
* @throws IllegalAccessException when restricted ({@link InternalAccessArea#SAFETY_SHUTDOWN_HOOK_UPDATE})
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
public void installSafetyShutdownHook(boolean status) throws IllegalAccessException {
|
||||
isRestricted(InternalAccessArea.SAFETY_SHUTDOWN_HOOK_UPDATE);
|
||||
|
||||
try {
|
||||
if (status)
|
||||
Runtime.getRuntime().addShutdownHook(Engine.getInstance().getSafetyShutdownHook());
|
||||
else
|
||||
Runtime.getRuntime().removeShutdownHook(Engine.getInstance().getSafetyShutdownHook());
|
||||
} catch (IllegalArgumentException | IllegalStateException ignored) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the engine's shutdown handler.
|
||||
* The shutdown handler is responsible for
|
||||
* shutting down the JVM safely.
|
||||
*
|
||||
* @return shutdown handler
|
||||
* @throws IllegalAccessException when restricted ({@link InternalAccessArea#SHUTDOWN_HANDLER_GET})
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
public @NotNull ShutdownHandler getShutdownHandler() throws IllegalAccessException {
|
||||
isRestricted(InternalAccessArea.SHUTDOWN_HANDLER_GET);
|
||||
return Engine.getInstance().getShutdownHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the engine's shutdown handler.
|
||||
* The shutdown handler is responsible for
|
||||
* shutting down the JVM safely.
|
||||
*
|
||||
* @param shutdownHandler new shutdown handler
|
||||
* @throws IllegalAccessException when restricted ({@link InternalAccessArea#SHUTDOWN_HANDLER_UPDATE})
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
public void setShutdownHandler(@NotNull ShutdownHandler shutdownHandler) throws IllegalAccessException {
|
||||
isRestricted(InternalAccessArea.SHUTDOWN_HANDLER_UPDATE);
|
||||
Engine.getInstance().setShutdownHandler(shutdownHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the engine should reflectively
|
||||
* search the classpath for events or other annotations.
|
||||
* <p>
|
||||
* If disabled, code will either have to manually call
|
||||
* registration methods or certain classes have to
|
||||
* be created in a certain package, depending on the
|
||||
* use case and application.
|
||||
*
|
||||
* @return reflective classpath scanning flag state
|
||||
* @throws IllegalAccessException when restricted ({@link InternalAccessArea#REFLECTIVE_CLASSPATH_SCANNING_GET})
|
||||
* @see EventHelper#registerEvent(Class, EventListenerCode)
|
||||
* @see EventHelper#registerEvent(Class, EventListenerCode, Event.Priority)
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public boolean getReflectiveClasspathScanning() throws IllegalAccessException {
|
||||
isRestricted(InternalAccessArea.REFLECTIVE_CLASSPATH_SCANNING_GET);
|
||||
return reflectiveClasspathScanning;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides whether the engine should reflectively
|
||||
* search the classpath for events or other annotations.
|
||||
* <p>
|
||||
* If disabled, code will either have to manually call
|
||||
* registration methods or certain classes have to
|
||||
* be created in a certain package, depending on the
|
||||
* use case and application.
|
||||
* <p>
|
||||
* Enabling reflective classpath scanning in an unsupported
|
||||
* environment may cause minor to extreme side effects,
|
||||
* including but not limited to <b>bugs, exceptions, engine
|
||||
* or even whole JVM crashes</b>. <i>You have been warned!</i>
|
||||
*
|
||||
* @param reflectiveClasspathScanning new reflective classpath scanning
|
||||
* @throws IllegalAccessException when restricted ({@link InternalAccessArea#REFLECTIVE_CLASSPATH_SCANNING_OVERRIDE})
|
||||
* @see EventHelper#registerEvent(Class, EventListenerCode)
|
||||
* @see EventHelper#registerEvent(Class, EventListenerCode, Event.Priority)
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public void overrideReflectiveClasspathScanning(boolean reflectiveClasspathScanning) throws IllegalAccessException {
|
||||
isRestricted(InternalAccessArea.REFLECTIVE_CLASSPATH_SCANNING_OVERRIDE);
|
||||
this.reflectiveClasspathScanning = reflectiveClasspathScanning;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.annotation;
|
||||
|
||||
import de.staropensource.engine.base.implementable.SubsystemClass;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Marks a class as a subsystem main class.
|
||||
* Make sure your subsystem implements {@link SubsystemClass}.
|
||||
*
|
||||
* @see SubsystemClass
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Documented
|
||||
public @interface EngineSubsystem {}
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.annotation;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Marks a method as an event listener, allowing it
|
||||
* to respond to an events when it is emitted.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Documented
|
||||
public @interface EventListener {
|
||||
/**
|
||||
* Specifies the event to listen for.
|
||||
*
|
||||
* @return event to listen on
|
||||
* @see Event
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull Class<? extends Event> event();
|
||||
|
||||
/**
|
||||
* Specifies the priority of the event.
|
||||
*
|
||||
* @return event priority
|
||||
* @see Event.Priority
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull Event.Priority priority() default Event.Priority.DEFAULT;
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.event;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Event;
|
||||
import de.staropensource.engine.base.implementable.helper.EventHelper;
|
||||
|
||||
/**
|
||||
* Called in the event of an engine crash.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public final class EngineCrashEvent implements Event {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineCrashEvent() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void callEvent() {
|
||||
EventHelper.invokeAnnotatedMethods(getClass());
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.event;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Event;
|
||||
import de.staropensource.engine.base.implementable.helper.EventHelper;
|
||||
|
||||
/**
|
||||
* Called when the engine is about to shutdown.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public final class EngineShutdownEvent implements Event {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineShutdownEvent() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void callEvent() {
|
||||
EventHelper.invokeAnnotatedMethods(getClass());
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.event;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Event;
|
||||
import de.staropensource.engine.base.implementable.helper.EventHelper;
|
||||
import de.staropensource.engine.base.logging.Logger;
|
||||
|
||||
/**
|
||||
* Called in the event of a soft engine crash
|
||||
* ie. when a crash report is thrown but marked
|
||||
* as handled.
|
||||
*
|
||||
* @see Logger#crash(Class, String, String, String, Throwable, boolean)
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public final class EngineSoftCrashEvent implements Event {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineSoftCrashEvent() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void callEvent() {
|
||||
EventHelper.invokeAnnotatedMethods(getClass());
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.event;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Event;
|
||||
import de.staropensource.engine.base.implementable.helper.EventHelper;
|
||||
|
||||
/**
|
||||
* Called when the engine is about to shutdown, after {@link de.staropensource.engine.base.event.EngineShutdownEvent}.
|
||||
* <p>
|
||||
* Meant for subsystems to perform cleanup and shutdown routines, not for applications.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public final class InternalEngineShutdownEvent implements Event {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public InternalEngineShutdownEvent() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void callEvent() {
|
||||
EventHelper.invokeAnnotatedMethods(getClass());
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.event;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Event;
|
||||
import de.staropensource.engine.base.implementable.helper.EventHelper;
|
||||
import de.staropensource.engine.base.type.logging.LogLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Called before a new log message is printed.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public final class LogEvent implements Event {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public LogEvent() {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @deprecated use the {@code callEvent} method with arguments
|
||||
* @see #callEvent(LogLevel, Class, String, String, String)
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void callEvent() {}
|
||||
|
||||
/**
|
||||
* Emits the event and calls all event listeners.
|
||||
*
|
||||
* @param level level
|
||||
* @param issuerClass issuer class
|
||||
* @param issuerOrigin issuer origin
|
||||
* @param issuerMetadata issuer metadata
|
||||
* @param message message
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public void callEvent(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message) {
|
||||
EventHelper.invokeAnnotatedMethods(getClass(), level, issuerClass, issuerOrigin, issuerMetadata, message);
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when something fails to parse.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public class ParserException extends RuntimeException {
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param message parsing error
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public ParserException(@NotNull String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception;
|
||||
|
||||
import de.staropensource.engine.base.type.Tristate;
|
||||
|
||||
/**
|
||||
* Thrown when converting a {@link Tristate} into a {@link Boolean} fails.
|
||||
* <p>
|
||||
* This exception inherits {@link RuntimeException} on purpose,
|
||||
* as sometimes you may sure/have already validated that the
|
||||
* {@link Tristate} is not {@link Tristate#UNSET}.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public class TristateConversionException extends RuntimeException {
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public TristateConversionException() {
|
||||
super("Tristate.UNSET cannot be converted into a boolean");
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when a sequence of if checks or switch cases fail unexpectedly.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public class UnexpectedCheckEndException extends RuntimeException {
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param checkOccurrence the sequence of checks that failed
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public UnexpectedCheckEndException(@NotNull String checkOccurrence) {
|
||||
super("A sequence of if checks or switch cases failed unexpectedly while " + checkOccurrence);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public UnexpectedCheckEndException() {
|
||||
super("A sequence of if checks or switch cases failed unexpectedly");
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception.dependency;
|
||||
|
||||
import de.staropensource.engine.base.utility.DependencyResolver;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when the {@link DependencyResolver} detects a dependency cycle.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public class DependencyCycleException extends RuntimeException {
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param path cycle path
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public DependencyCycleException(@NotNull String path) {
|
||||
super("Dependency cycle detected: " + path);
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception.dependency;
|
||||
|
||||
import de.staropensource.engine.base.type.DependencyVector;
|
||||
import de.staropensource.engine.base.utility.DependencyResolver;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Thrown when the {@link DependencyResolver} cannot resolve one
|
||||
* or more {@link DependencyVector}s due to unmet dependencies.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public class UnmetDependenciesException extends Exception {
|
||||
/**
|
||||
* Contains the unmet dependencies list supplied to the constructor.
|
||||
*
|
||||
* @since v1-alpha4
|
||||
* -- GETTER --
|
||||
* Returns the unmet dependencies list supplied to the constructor.
|
||||
*
|
||||
* @return unmet dependencies list
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
private final @NotNull List<@NotNull String> unmetDependencies;
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @param unmetDependencies map of all unmet dependencies
|
||||
* @see #unmetDependencies
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
public UnmetDependenciesException(@NotNull List<@NotNull String> unmetDependencies) {
|
||||
this.unmetDependencies = unmetDependencies;
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception.reflection;
|
||||
|
||||
import de.staropensource.engine.base.type.reflection.ClassType;
|
||||
import de.staropensource.engine.base.utility.misc.ListFormatter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when the invoked method does not apply to the type of the class.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public class IncompatibleTypeException extends RuntimeException {
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param methodName name of the method that failed
|
||||
* @param requiredClassType class type received by the method
|
||||
* @param compatibleTypes class types the method is compatible with
|
||||
*/
|
||||
public IncompatibleTypeException(@NotNull String methodName, @NotNull ClassType requiredClassType, @NotNull ClassType @NotNull [] compatibleTypes) {
|
||||
super("The method ReflectionClass#" + methodName + " only applies to type(s) " + ListFormatter.formatArray(compatibleTypes) + ", not " + requiredClassType.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param methodName name of the method that failed
|
||||
* @param requiredClassType class type received by the method
|
||||
* @param compatibleType class type the method is compatible with
|
||||
*/
|
||||
public IncompatibleTypeException(@NotNull String methodName, @NotNull ClassType requiredClassType, @NotNull ClassType compatibleType) {
|
||||
super("The method ReflectionClass#" + methodName + " only applies to type(s) " + ListFormatter.formatArray(new ClassType[]{ compatibleType }) + ", not " + requiredClassType.name());
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception.reflection;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when trying to call an instance (non-static) method from a static context.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public class InstanceMethodFromStaticContextException extends Exception {
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param methodName name of the method
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public InstanceMethodFromStaticContextException(@NotNull String methodName) {
|
||||
super("Method " + methodName + " could not be called as the method is non-static and was called from a static context");
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception.reflection;
|
||||
|
||||
import de.staropensource.engine.base.reflection.ReflectionClass;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when a field could not be found.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public class InvalidFieldException extends Exception {
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param clazz caller {@link ReflectionClass}
|
||||
* @param fieldName name of the invalid field
|
||||
*/
|
||||
public InvalidFieldException(@NotNull ReflectionClass clazz, @NotNull String fieldName) {
|
||||
super("Invalid field name \"" + fieldName + "\" in class " + clazz.getPath());
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception.reflection;
|
||||
|
||||
import de.staropensource.engine.base.reflection.ReflectionClass;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when a method could not be found.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public class InvalidMethodException extends Exception {
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param clazz caller {@link ReflectionClass}
|
||||
* @param fieldName name of the invalid method
|
||||
*/
|
||||
public InvalidMethodException(@NotNull ReflectionClass clazz, @NotNull String fieldName) {
|
||||
super("Invalid method name \"" + fieldName + "\" in class " + clazz.getPath());
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception.reflection;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when a method could not be found due to an invalid method signature.
|
||||
*
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public class InvalidMethodSignatureException extends Exception {
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param methodName method name
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public InvalidMethodSignatureException(@NotNull String methodName) {
|
||||
super("Method " + methodName + " has a different method signature");
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception.reflection;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown if access to some class, method or field has been denied.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public class NoAccessException extends Exception {
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param type {@code class}, {@code method} or {@code field}
|
||||
* @param name class, method or field name
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public NoAccessException(@NotNull String type, @NotNull String name) {
|
||||
super("Access to " + type + " " + name + " has been denied");
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception.reflection;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when an exception is thrown by a static initializer.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public class StaticInitializerException extends Exception {
|
||||
/**
|
||||
* Contains the throwable thrown by the static initializer.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
* -- GETTER --
|
||||
* Returns the throwable thrown by the static initializer.
|
||||
*
|
||||
* @return throwable thrown by the static initializer
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
private final @NotNull Throwable throwable;
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param throwable throwable thrown by the static initializer
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public StaticInitializerException(@NotNull Throwable throwable) {
|
||||
this.throwable = throwable;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exceptions related to reflection.
|
||||
*
|
||||
* @see de.staropensource.engine.base.reflection
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
package de.staropensource.engine.base.exception.reflection;
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception.versioning;
|
||||
|
||||
import de.staropensource.engine.base.implementable.VersioningSystem;
|
||||
|
||||
/**
|
||||
* Thrown when trying to compare a {@link VersioningSystem} against another
|
||||
* {@link VersioningSystem}, which it does not support.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public class IncompatibleVersioningSystemException extends RuntimeException {
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param required required versioning system ie. the versioning system throwing this error
|
||||
* @param found found versioning system ie. the incompatible one
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public IncompatibleVersioningSystemException(VersioningSystem required, VersioningSystem found) {
|
||||
super("The versioning system " + required + " is incompatible with " + found);
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.exception.versioning;
|
||||
|
||||
import de.staropensource.engine.base.implementable.VersioningSystem;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* Thrown when an invalid version string is supplied
|
||||
* to an implementation of {@link VersioningSystem}.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public class InvalidVersionStringException extends Exception {
|
||||
/**
|
||||
* Contains the throwable supplied to the constructor.
|
||||
*
|
||||
* @see #InvalidVersionStringException(VersioningSystem, String, Throwable)
|
||||
* @see #InvalidVersionStringException(VersioningSystem, String, String, Throwable)
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the throwable supplied by the constructor.
|
||||
*
|
||||
* @return throwable
|
||||
* @see #InvalidVersionStringException(VersioningSystem, String, Throwable)
|
||||
* @see #InvalidVersionStringException(VersioningSystem, String, String, Throwable)
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final @Nullable Throwable throwable;
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param versioningSystem versioning system that is unable to parse version strings
|
||||
* @param versionString version string {@code a}
|
||||
* @param message some error message
|
||||
* @param throwable throwable that caused the parsing error
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public InvalidVersionStringException(@NotNull VersioningSystem versioningSystem, @NotNull String versionString, @NotNull String message, @NotNull Throwable throwable) {
|
||||
super("Versioning system " + versioningSystem.getName() + " can't parse version string \"" + versionString + "\": " + message);
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param versioningSystem versioning system that is unable to parse version strings
|
||||
* @param versionString version string {@code a}
|
||||
* @param message some error message
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public InvalidVersionStringException(@NotNull VersioningSystem versioningSystem, @NotNull String versionString, @NotNull String message) {
|
||||
super("Versioning system " + versioningSystem.getName() + " can't parse version string \"" + versionString + "\": " + message);
|
||||
throwable = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param versioningSystem versioning system that is unable to parse version strings
|
||||
* @param versionString version string {@code a}
|
||||
* @param throwable throwable that caused the parsing error
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public InvalidVersionStringException(@NotNull VersioningSystem versioningSystem, @NotNull String versionString, @NotNull Throwable throwable) {
|
||||
super("Versioning system " + versioningSystem.getName() + " can't parse version string \"" + versionString + "\"");
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this exception.
|
||||
*
|
||||
* @param versioningSystem versioning system that is unable to parse version strings
|
||||
* @param versionString version string {@code a}
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public InvalidVersionStringException(@NotNull VersioningSystem versioningSystem, @NotNull String versionString) {
|
||||
super("Versioning system " + versioningSystem.getName() + " can't parse version string \"" + versionString + "\"");
|
||||
this.throwable = null;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exceptions thrown by implementations of {@link de.staropensource.engine.base.implementable.VersioningSystem}s.
|
||||
*
|
||||
* @see de.staropensource.engine.base.implementable.VersioningSystem
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
package de.staropensource.engine.base.exception.versioning;
|
|
@ -1,132 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementable;
|
||||
|
||||
import de.staropensource.engine.base.utility.PropertiesReader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Interface for implementing configuration classes.
|
||||
* <p>
|
||||
* Configuration classes use {@link Properties} objects to modify
|
||||
* their settings as they can be supplied to the JVM's arguments
|
||||
* and can be written to and read from during runtime.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public abstract class Configuration {
|
||||
/**
|
||||
* Creates and initializes an instance of this abstract class.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
protected Configuration() {
|
||||
// Load default configuration
|
||||
loadDefaultConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all settings from the specified {@link Properties} object.
|
||||
* Unless you want to override settings, consider invoking {@link #loadDefaultConfiguration()} first.
|
||||
*
|
||||
* @param properties {@link Properties} to read from
|
||||
* @see #loadDefaultConfiguration()
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public void loadConfiguration(@NotNull Properties properties) {
|
||||
PropertiesReader parser = new PropertiesReader(properties);
|
||||
|
||||
// Loop through all properties
|
||||
for (String property : properties.stringPropertyNames()) {
|
||||
// Check if property name starts with group
|
||||
if (!property.startsWith(getGroup()))
|
||||
continue;
|
||||
|
||||
// Remove group
|
||||
property = property.substring(getGroup().length());
|
||||
|
||||
// Overwrite matching settings
|
||||
try {
|
||||
matchProperty(parser, property);
|
||||
} catch (NullPointerException ignored) {}
|
||||
}
|
||||
|
||||
processSettings(parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all settings from the system properties.
|
||||
* Useful if you want to allow the user to modify settings at startup.
|
||||
*
|
||||
* @see #loadConfiguration(Properties)
|
||||
* @see System#getProperties()
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public void loadConfiguration() {
|
||||
loadConfiguration(System.getProperties());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns prefix properties must begin with.
|
||||
*
|
||||
* @return property group
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public abstract @NotNull String getGroup();
|
||||
|
||||
/**
|
||||
* Loads the default subsystem configuration.
|
||||
*
|
||||
* @see #loadConfiguration()
|
||||
* @see #loadConfiguration(Properties)
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public abstract void loadDefaultConfiguration();
|
||||
|
||||
/**
|
||||
* Matches the given {@code property} against all settings.
|
||||
* If a match has been found, the setting will be overwritten with the property's value.
|
||||
*
|
||||
* @param parser matching {@link PropertiesReader}
|
||||
* @param property property to match
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
protected abstract void matchProperty(@NotNull PropertiesReader parser, @NotNull String property);
|
||||
|
||||
/**
|
||||
* Allows the implementor to process all settings and potentially
|
||||
* modify them before {@link #loadConfiguration(Properties)} returns.
|
||||
*
|
||||
* @param parser matching {@link PropertiesReader}
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
protected abstract void processSettings(@NotNull PropertiesReader parser);
|
||||
|
||||
/**
|
||||
* Returns a configuration setting.
|
||||
*
|
||||
* @param setting setting name
|
||||
* @return setting's value or {@code null} if not found
|
||||
*/
|
||||
public abstract @Nullable Object getSetting(@NotNull String setting);
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementable;
|
||||
|
||||
import de.staropensource.engine.base.annotation.EventListener;
|
||||
import de.staropensource.engine.base.implementable.helper.EventHelper;
|
||||
|
||||
/**
|
||||
* Represents an event.
|
||||
*
|
||||
* @see EventHelper
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public interface Event {
|
||||
/**
|
||||
* Emits the event and calls all event listeners.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
void callEvent();
|
||||
|
||||
/**
|
||||
* Specifies in which order {@link EventListener}s shall be called.
|
||||
*
|
||||
* @since v1-alpha9
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
enum Priority {
|
||||
/**
|
||||
* {@link EventListener}s with this
|
||||
* priority are called before all others.
|
||||
* <p>
|
||||
* This priority is exclusive to the
|
||||
* engine and subsystems and should
|
||||
* not be used by applications.
|
||||
*
|
||||
* @since v1-alpha9
|
||||
*/
|
||||
EXCLUSIVELY_IMPORTANT,
|
||||
|
||||
/**
|
||||
* {@link EventListener}s with
|
||||
* this priority are called 2nd.
|
||||
*
|
||||
* @since v1-alpha9
|
||||
*/
|
||||
VERY_IMPORTANT,
|
||||
|
||||
/**
|
||||
* {@link EventListener}s with
|
||||
* this priority are called 3rd.
|
||||
*
|
||||
* @since v1-alpha9
|
||||
*/
|
||||
IMPORTANT,
|
||||
|
||||
/**
|
||||
* {@link EventListener}s with
|
||||
* this priority are called 4th.
|
||||
*
|
||||
* @since v1-alpha9
|
||||
*/
|
||||
DEFAULT,
|
||||
|
||||
/**
|
||||
* {@link EventListener}s with
|
||||
* this priority are called 5th.
|
||||
*
|
||||
* @since v1-alpha9
|
||||
*/
|
||||
UNIMPORTANT,
|
||||
|
||||
/**
|
||||
* {@link EventListener}s with
|
||||
* this priority are called 6th.
|
||||
*
|
||||
* @since v1-alpha9
|
||||
*/
|
||||
VERY_UNIMPORTANT,
|
||||
|
||||
/**
|
||||
* {@link EventListener}s with this
|
||||
* priority are called after all others.
|
||||
* <p>
|
||||
* This priority is exclusive to the
|
||||
* engine and subsystems and should
|
||||
* not be used by applications.
|
||||
*
|
||||
* @since v1-alpha9
|
||||
*/
|
||||
EXCLUSIVELY_UNIMPORTANT
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementable;
|
||||
|
||||
import de.staropensource.engine.base.implementable.helper.EventHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Used by {@link EventHelper} to execute event listeners.
|
||||
*
|
||||
* @see Runnable
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public abstract class EventListenerCode {
|
||||
/**
|
||||
* Contains the priority of this
|
||||
* event listener.
|
||||
* <p>
|
||||
* Set automatically by {@link EventHelper},
|
||||
* do not change this manually.
|
||||
*
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public @NotNull Event.Priority priority = Event.Priority.DEFAULT;
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this abstract class.
|
||||
*
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
protected EventListenerCode() {}
|
||||
|
||||
/**
|
||||
* Invokes the event listener.
|
||||
*
|
||||
* @param arguments arguments passed along by the event
|
||||
* @throws Exception exceptions thrown
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public abstract void run(Object... arguments) throws Exception;
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementable;
|
||||
|
||||
import de.staropensource.engine.base.logging.Logger;
|
||||
import de.staropensource.engine.base.type.logging.LogLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Interface for implementing custom logger implementations.
|
||||
*
|
||||
* @see Logger#setLoggingAdapter(LoggingAdapter)
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public interface LoggingAdapter {
|
||||
/**
|
||||
* Prints a log message.
|
||||
*
|
||||
* @param level level of the log call
|
||||
* @param issuer {@link StackTraceElement} of the issuer
|
||||
* @param message raw message
|
||||
* @param format processed log call output (print this!)
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
void print(@NotNull LogLevel level, @NotNull StackTraceElement issuer, @NotNull String message, @NotNull String format);
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementable;
|
||||
|
||||
import de.staropensource.engine.base.utility.PlaceholderEngine;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Interface for implementing placeholders.
|
||||
*
|
||||
* @see PlaceholderEngine
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public interface Placeholder {
|
||||
/**
|
||||
* Replaces the placeholder with content.
|
||||
*
|
||||
* @param text text to process
|
||||
* @return processed text
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@NotNull String replace(@NotNull String text);
|
||||
}
|
|
@ -1,218 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementable;
|
||||
|
||||
import de.staropensource.engine.base.EngineConfiguration;
|
||||
import de.staropensource.engine.base.exception.ParserException;
|
||||
import de.staropensource.engine.base.logging.Logger;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Base class for implementing a shortcode parser.
|
||||
* <p>
|
||||
* This class parses a string and converts it into a list of
|
||||
* components, which can then be in turn be converted to something
|
||||
* else, for example, ANSI escape codes.
|
||||
* <p>
|
||||
* The following shortcodes are available and can be used:
|
||||
* <ul>
|
||||
* <li>reset</li>
|
||||
* <li>fg:[black,red,green,yellow,blue,magenta,cyan,white]</li>
|
||||
* <li>bg:[black,red,green,yellow,blue,magenta,cyan,white]</li>
|
||||
* <li>bold</li>
|
||||
* <li>italic</li>
|
||||
* <li>strikethrough</li>
|
||||
* <li>underline</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public abstract class ShortcodeParser {
|
||||
/**
|
||||
* Contains a list of components the parsed text is made out of.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns a list of components the parsed text is made out of.
|
||||
*
|
||||
* @return component list
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
protected final @NotNull LinkedList<String> components;
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this abstract class.
|
||||
*
|
||||
* @param string string to parse
|
||||
* @param ignoreInvalidEscapes if {@code true}, will ignore and treat invalid escapes as text
|
||||
* @throws ParserException on error
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
protected ShortcodeParser(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
|
||||
components = parse(string, ignoreInvalidEscapes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the input string and returns a list
|
||||
* of components the text is made out of.
|
||||
*
|
||||
* @param string string to parse
|
||||
* @param ignoreInvalidEscapes if {@code true}, will ignore and treat invalid escapes as text
|
||||
* @return list of components
|
||||
* @throws ParserException on error
|
||||
* @see EngineConfiguration#errorShortcodeParser
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
protected @NotNull LinkedList<@NotNull String> parse(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
|
||||
LinkedList<String> components = new LinkedList<>(); // List of components
|
||||
boolean tagActive = false; // Indicates that a tag is being parsed
|
||||
boolean escape = false; // Indicates whether the last character was a \ character
|
||||
StringBuilder part = new StringBuilder(); // Temporary string. May be a tag, may be regular text
|
||||
|
||||
// Iterate through every character
|
||||
for (char character : string.toCharArray()) {
|
||||
// Escaping
|
||||
if (escape) {
|
||||
if (character == '\\' || character == '<')
|
||||
part.append(character);
|
||||
else if (!(character == 'r' || character == 'n'))
|
||||
if (ignoreInvalidEscapes)
|
||||
part.append("\\").append(character);
|
||||
else
|
||||
throw new ParserException("Invalid escape \\" + character);
|
||||
|
||||
escape = false;
|
||||
continue;
|
||||
}
|
||||
if (character == '\\') {
|
||||
escape = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tagActive) {
|
||||
// A tag is being parsed
|
||||
if (character == '>') {
|
||||
// Tag is ending, disable tag parsing
|
||||
tagActive = false;
|
||||
|
||||
// fg:*
|
||||
if (part.toString().startsWith("fg:"))
|
||||
if (isValidColor(part.substring(3).toUpperCase()))
|
||||
components.add("COLOR:FOREGROUND:" + part.substring(3).toUpperCase());
|
||||
else {
|
||||
// Complain about invalid shortcode
|
||||
if (EngineConfiguration.getInstance() != null && EngineConfiguration.getInstance().isErrorShortcodeParser())
|
||||
Logger.sarn("Invalid shortcode: " + part);
|
||||
|
||||
// Convert tag regular text
|
||||
components.add("TEXT:" + "<" + part + ">");
|
||||
}
|
||||
// bg:*
|
||||
else if (part.toString().startsWith("bg:"))
|
||||
if (isValidColor(part.substring(3).toUpperCase()))
|
||||
components.add("COLOR:BACKGROUND:" + part.substring(3).toUpperCase());
|
||||
else {
|
||||
// Complain about invalid shortcode
|
||||
if (EngineConfiguration.getInstance() != null && EngineConfiguration.getInstance().isErrorShortcodeParser())
|
||||
Logger.sarn("Invalid shortcode: " + part);
|
||||
|
||||
// Convert tag regular text
|
||||
components.add("TEXT:" + "<" + part + ">");
|
||||
}
|
||||
// bold
|
||||
else if (part.toString().equals("bold"))
|
||||
components.add("ATTRIBUTE:BOLD");
|
||||
// italic
|
||||
else if (part.toString().equals("italic"))
|
||||
components.add("ATTRIBUTE:ITALIC");
|
||||
// strikethrough
|
||||
else if (part.toString().equals("strikethrough"))
|
||||
components.add("ATTRIBUTE:STRIKETHROUGH");
|
||||
// underline
|
||||
else if (part.toString().equals("underline"))
|
||||
components.add("ATTRIBUTE:UNDERLINE");
|
||||
// blink
|
||||
else if (part.toString().equals("blink"))
|
||||
components.add("ATTRIBUTE:BLINK");
|
||||
// reset
|
||||
else if (part.toString().equals("reset"))
|
||||
components.add("RESET");
|
||||
|
||||
// error case
|
||||
else {
|
||||
// Complain about invalid shortcode
|
||||
if (EngineConfiguration.getInstance() != null && EngineConfiguration.getInstance().isErrorShortcodeParser())
|
||||
Logger.sarn("Invalid shortcode: " + part);
|
||||
|
||||
// Convert tag regular text
|
||||
components.add("TEXT:" + "<" + part + ">");
|
||||
}
|
||||
|
||||
// Empty 'part'
|
||||
part = new StringBuilder();
|
||||
} else
|
||||
// Tag has not ended yet, add character to 'part'
|
||||
// It bloats the code to do it with StringBuilder
|
||||
part.append(character);
|
||||
} else {
|
||||
// Regular text is being parsed
|
||||
if (character == '<') {
|
||||
if (!part.isEmpty()) {
|
||||
// Tag is starting, insert previous text
|
||||
components.add("TEXT:" + part);
|
||||
part = new StringBuilder();
|
||||
}
|
||||
|
||||
tagActive = true; // Enable tag processing
|
||||
} else
|
||||
// Regular text, add character to 'part'
|
||||
// It bloats the code to do it with StringBuilder
|
||||
part.append(character);
|
||||
}
|
||||
}
|
||||
|
||||
// Processing ended, insert leftover text
|
||||
if (!part.isEmpty())
|
||||
components.add("TEXT:" + part);
|
||||
|
||||
return components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the specified color is valid
|
||||
*
|
||||
* @return {@code true} if valid, {@code false} otherwise
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
private boolean isValidColor(@NotNull String color) {
|
||||
return switch (color.toLowerCase(Locale.ROOT)) {
|
||||
case "black", "white", "red",
|
||||
"green", "blue", "yellow",
|
||||
"magenta", "cyan" -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementable;
|
||||
|
||||
import de.staropensource.engine.base.Engine;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
/**
|
||||
* Interface for custom shutdown handlers.
|
||||
* <p>
|
||||
* Shutdown handlers are responsible for shutting down
|
||||
* the platform safely after the engine has shut down.
|
||||
*
|
||||
* @see Engine#setShutdownHandler(ShutdownHandler)
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public interface ShutdownHandler {
|
||||
/**
|
||||
* Executes the shutdown handler.
|
||||
*
|
||||
* @param exitCode exit code
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
void shutdown(@Range(from = 0, to = 255) short exitCode);
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementable;
|
||||
|
||||
import de.staropensource.engine.base.Engine;
|
||||
import de.staropensource.engine.base.annotation.EngineSubsystem;
|
||||
import de.staropensource.engine.base.annotation.EventListener;
|
||||
import de.staropensource.engine.base.event.InternalEngineShutdownEvent;
|
||||
import de.staropensource.engine.base.type.DependencyVector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Abstract class for building subsystem main classes.
|
||||
*
|
||||
* @see EngineSubsystem
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public abstract class SubsystemClass {
|
||||
/**
|
||||
* Creates and initializes an instance of this abstract class.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
protected SubsystemClass() {}
|
||||
|
||||
/**
|
||||
* Returns the name of the subsystem.
|
||||
*
|
||||
* @return subsystem name
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public abstract @NotNull String getName();
|
||||
|
||||
/**
|
||||
* Initializes the subsystem.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public abstract void initializeSubsystem();
|
||||
|
||||
/**
|
||||
* Returns a matching {@link DependencyVector}.
|
||||
* Used for dependency resolution during startup.
|
||||
*
|
||||
* @return matching {@link DependencyVector} for the subsystem
|
||||
* @throws IllegalStateException when building the DependencyVector fails, see {@link DependencyVector.Builder#build()}
|
||||
* @see DependencyVector
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
public abstract @NotNull DependencyVector getDependencyVector() throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Called on engine shutdown.
|
||||
*
|
||||
* @see Engine#shutdown()
|
||||
* @see Engine#shutdown(int)
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@EventListener(event = InternalEngineShutdownEvent.class)
|
||||
@SuppressWarnings({ "unused" })
|
||||
protected static void shutdownSubsystem() {}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementable;
|
||||
|
||||
import de.staropensource.engine.base.exception.versioning.IncompatibleVersioningSystemException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
/**
|
||||
* Interface for building a versioning system (parser).
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public interface VersioningSystem {
|
||||
/**
|
||||
* Returns the name of the versioning system.
|
||||
*
|
||||
* @return versioning system name
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@NotNull String getName();
|
||||
|
||||
/**
|
||||
* Compares a {@link VersioningSystem} with another.
|
||||
*
|
||||
* @param version {@link VersioningSystem} to compare against
|
||||
* @return {@code 0} if the supplied version is bigger, {@code 1} if equal and {@code 2} if smaller
|
||||
* @throws IncompatibleVersioningSystemException incompatible with the supplied versioning system
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Range(from = 0, to = 2)
|
||||
int compare(@NotNull VersioningSystem version) throws IncompatibleVersioningSystemException;
|
||||
|
||||
/**
|
||||
* Returns the version string.
|
||||
*
|
||||
* @return version string
|
||||
* @since v1-alpha9
|
||||
*/
|
||||
@Override
|
||||
@NotNull String toString();
|
||||
}
|
|
@ -1,256 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementable.helper;
|
||||
|
||||
import de.staropensource.engine.base.EngineConfiguration;
|
||||
import de.staropensource.engine.base.EngineInternals;
|
||||
import de.staropensource.engine.base.annotation.EventListener;
|
||||
import de.staropensource.engine.base.event.LogEvent;
|
||||
import de.staropensource.engine.base.exception.reflection.InstanceMethodFromStaticContextException;
|
||||
import de.staropensource.engine.base.exception.reflection.InvalidMethodSignatureException;
|
||||
import de.staropensource.engine.base.exception.reflection.NoAccessException;
|
||||
import de.staropensource.engine.base.exception.reflection.StaticInitializerException;
|
||||
import de.staropensource.engine.base.implementable.Event;
|
||||
import de.staropensource.engine.base.implementable.EventListenerCode;
|
||||
import de.staropensource.engine.base.internal.implementation.EventListenerMethod;
|
||||
|
||||
import de.staropensource.engine.base.logging.Logger;
|
||||
import de.staropensource.engine.base.utility.misc.ListFormatter;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.Scanners;
|
||||
import org.reflections.util.ClasspathHelper;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Simplifies event logging and calling.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@Getter
|
||||
public final class EventHelper {
|
||||
/**
|
||||
* Holds all cached events.
|
||||
*
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
private static final @NotNull Map<@NotNull Class<? extends Event>, LinkedList<@NotNull EventListenerCode>> cachedEventListeners = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this class.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private EventHelper() {}
|
||||
|
||||
/**
|
||||
* Registers a new {@link Event}.
|
||||
* <p>
|
||||
* This method does nothing if classpath searching is disabled.
|
||||
*
|
||||
* @param event {@link Event} to register for
|
||||
* @param eventListener {@link EventListenerCode} to register
|
||||
* @param priority priority of the listener
|
||||
* @see EngineInternals#getReflectiveClasspathScanning()
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public static synchronized void registerEvent(@NotNull Class<? extends Event> event, @NotNull EventListenerCode eventListener, @NotNull Event.Priority priority) {
|
||||
if (EngineInternals.getInstance().getReflectiveClasspathScanning())
|
||||
return;
|
||||
|
||||
// Update 'eventListener' priority
|
||||
eventListener.priority = priority;
|
||||
|
||||
// Check if event already exists in map
|
||||
// If not, create entry with a LinkedList
|
||||
if (cachedEventListeners.containsKey(event))
|
||||
if (cachedEventListeners.get(event).contains(eventListener))
|
||||
return;
|
||||
else
|
||||
cachedEventListeners.get(event).add(eventListener);
|
||||
else {
|
||||
LinkedList<@NotNull EventListenerCode> list = new LinkedList<>();
|
||||
list.add(eventListener);
|
||||
cachedEventListeners.put(event, list);
|
||||
}
|
||||
|
||||
Logger.diag("Registered event listener " + eventListener + " for event " + event + " with priority " + priority.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new {@link Event}.
|
||||
* <p>
|
||||
* This method does nothing if classpath searching is disabled.
|
||||
*
|
||||
* @param event {@link Event} to register for
|
||||
* @param eventListener {@link EventListenerCode} to register
|
||||
* @see EngineInternals#getReflectiveClasspathScanning()
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public static void registerEvent(@NotNull Class<? extends Event> event, @NotNull EventListenerCode eventListener) {
|
||||
registerEvent(event, eventListener, Event.Priority.DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* (Re-)Caches all event listeners for some {@link Event}.
|
||||
* <p>
|
||||
* This method does nothing if classpath searching is enabled.
|
||||
*
|
||||
* @param event event to (re-)cache. Set to {@code null} to recompute all cached events
|
||||
* @see EngineInternals#getReflectiveClasspathScanning()
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public static synchronized void cacheEvent(@Nullable Class<? extends Event> event) {
|
||||
if (!EngineInternals.getInstance().getReflectiveClasspathScanning())
|
||||
return;
|
||||
|
||||
if (event == null)
|
||||
for (Class<? extends Event> cachedEvent : cachedEventListeners.keySet())
|
||||
cacheEvent(cachedEvent);
|
||||
else {
|
||||
LinkedList<@NotNull EventListenerCode> annotatedMethods = getAnnotatedMethods(event);
|
||||
|
||||
if (cachedEventListeners.containsKey(event))
|
||||
cachedEventListeners.replace(event, annotatedMethods);
|
||||
else
|
||||
cachedEventListeners.put(event, annotatedMethods);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an event from the event listener cache.
|
||||
* <p>
|
||||
* This method does nothing if classpath searching is enabled.
|
||||
*
|
||||
* @param event event to uncache. Set to {@code null} to clear the entire cache
|
||||
* @see EngineInternals#getReflectiveClasspathScanning()
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public static synchronized void uncacheEvent(@Nullable Class<? extends Event> event) {
|
||||
if (!EngineInternals.getInstance().getReflectiveClasspathScanning())
|
||||
return;
|
||||
|
||||
if (event == null)
|
||||
cachedEventListeners.clear();
|
||||
else
|
||||
cachedEventListeners.remove(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes all event listeners.
|
||||
*
|
||||
* @param event event class
|
||||
* @param arguments arguments to pass to event listeners
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public static void invokeAnnotatedMethods(@NotNull Class<? extends Event> event, Object... arguments) {
|
||||
if (event != LogEvent.class && EngineConfiguration.getInstance().isDebugEvents())
|
||||
if (arguments.length == 0)
|
||||
Logger.diag("Event " + event.getName() + " was emitted");
|
||||
else
|
||||
Logger.diag("Event " + event.getName() + " was emitted, passing arguments " + ListFormatter.formatArray(arguments));
|
||||
|
||||
Runnable eventCode = () -> {
|
||||
for (EventListenerCode eventListener : getAnnotatedMethods(event)) {
|
||||
try {
|
||||
eventListener.run(arguments);
|
||||
} catch (NoAccessException exception) {
|
||||
Logger.warn("Event listener " + eventListener + " could not be called as the method could not be accessed");
|
||||
} catch (InvalidMethodSignatureException exception) {
|
||||
Logger.warn("Event listener " + eventListener + " has an invalid method signature");
|
||||
} catch (InvocationTargetException exception) {
|
||||
Logger.crash("Event listener " + eventListener + " threw a throwable", exception.getTargetException(), true);
|
||||
} catch (InstanceMethodFromStaticContextException exception) {
|
||||
Logger.warn("Event listener " + eventListener + " is not static. Event listener methods must be static for them to be called.");
|
||||
} catch (StaticInitializerException exception) {
|
||||
Logger.crash("Event listener " + eventListener + " could not be called as the static initializer failed", exception.getThrowable(), true);
|
||||
} catch (Exception exception) {
|
||||
Logger.crash("Event listener " + eventListener + " could not be called as an error occurred during reflection", exception, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (EngineConfiguration.getInstance().isOptimizeEvents())
|
||||
Thread
|
||||
.ofVirtual()
|
||||
.name("Event " + event.getName())
|
||||
.start(eventCode);
|
||||
else
|
||||
eventCode.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all {@link EventListener}s listening on some event.
|
||||
* The classpath will be scanned for listeners, unless cached results exist and {@code !forceScanning}.
|
||||
*
|
||||
* @param event event class
|
||||
* @param forceScanning forces scanning the classpath for listeners. not recommended due to a huge performance penalty
|
||||
* @return list of event listeners
|
||||
* @see #cacheEvent(Class)
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public static @NotNull LinkedList<EventListenerCode> getAnnotatedMethods(@NotNull Class<? extends Event> event, boolean forceScanning) {
|
||||
LinkedList<EventListenerCode> eventListeners = new LinkedList<>();
|
||||
|
||||
if (!EngineInternals.getInstance().getReflectiveClasspathScanning())
|
||||
return Objects.requireNonNullElse(cachedEventListeners.get(event), eventListeners);
|
||||
|
||||
if (forceScanning || !cachedEventListeners.containsKey(event)) {
|
||||
Reflections reflections = new Reflections(
|
||||
new ConfigurationBuilder()
|
||||
.setUrls(ClasspathHelper.forJavaClassPath())
|
||||
.setScanners(Scanners.MethodsAnnotated)
|
||||
);
|
||||
|
||||
// Get annotated methods
|
||||
Set<@NotNull Method> annotatedMethods = reflections.getMethodsAnnotatedWith(EventListener.class);
|
||||
|
||||
// Sort event listeners not listening for the specified event out
|
||||
for (Method method : annotatedMethods)
|
||||
if (method.getAnnotation(EventListener.class).event() == event)
|
||||
eventListeners.add(new EventListenerMethod(method));
|
||||
|
||||
// Sort list after event priority
|
||||
eventListeners.sort(Comparator.comparing(method -> Objects.requireNonNull(((EventListenerMethod) method).getAnnotation(EventListener.class)).priority()));
|
||||
} else
|
||||
// Event listeners are cached and !forceScanning, return cached results
|
||||
eventListeners = cachedEventListeners.get(event);
|
||||
|
||||
return eventListeners;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all {@link EventListener}s listening on some event.
|
||||
* The classpath will be scanned for listeners, unless cached results exist.
|
||||
*
|
||||
* @param event event class
|
||||
* @return list of event listeners
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public static @NotNull LinkedList<EventListenerCode> getAnnotatedMethods(@NotNull Class<? extends Event> event) {
|
||||
return getAnnotatedMethods(event, false);
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Not necessarily interfaces or extendable classes. Rather, they
|
||||
* support implementing classes by providing useful or complex code.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
package de.staropensource.engine.base.implementable.helper;
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interfaces and abstract classes which can be used for implementing classes.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
package de.staropensource.engine.base.implementable;
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementation.logging;
|
||||
|
||||
import de.staropensource.engine.base.EngineConfiguration;
|
||||
import de.staropensource.engine.base.implementable.LoggingAdapter;
|
||||
import de.staropensource.engine.base.logging.Logger;
|
||||
import de.staropensource.engine.base.type.logging.LogLevel;
|
||||
import de.staropensource.engine.base.implementation.shortcode.EmptyShortcodeParser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Prints log messages to the console, without any fancy colors or formatting.
|
||||
*
|
||||
* @see Logger
|
||||
* @see LoggingAdapter
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public class PlainLoggingAdapter implements LoggingAdapter {
|
||||
/**
|
||||
* Creates and initializes an instance of this class.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public PlainLoggingAdapter() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void print(@NotNull LogLevel level, @NotNull StackTraceElement issuer, @NotNull String message, @NotNull String format) {
|
||||
format = new EmptyShortcodeParser(format, true).getClean();
|
||||
if (level == LogLevel.ERROR || level == LogLevel.CRASH)
|
||||
if (EngineConfiguration.getInstance() != null && EngineConfiguration.getInstance().isLogForceStandardOutput())
|
||||
System.out.println(format);
|
||||
else
|
||||
System.err.println(format);
|
||||
else
|
||||
System.out.println(format);
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementation.logging;
|
||||
|
||||
import de.staropensource.engine.base.implementable.LoggingAdapter;
|
||||
import de.staropensource.engine.base.type.logging.LogLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An implementation of {@link LoggingAdapter}, which does nothing.
|
||||
* Useful if you want to silence engine startup messages.
|
||||
*
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
public class QuietLoggingAdapter implements LoggingAdapter {
|
||||
/**
|
||||
* Creates and initializes an instance of this class.
|
||||
*
|
||||
* @since v1-alpha4
|
||||
*/
|
||||
public QuietLoggingAdapter() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void print(@NotNull LogLevel level, @NotNull StackTraceElement issuer, @NotNull String message, @NotNull String format) {}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementation.logging;
|
||||
|
||||
import de.staropensource.engine.base.EngineConfiguration;
|
||||
import de.staropensource.engine.base.implementable.LoggingAdapter;
|
||||
import de.staropensource.engine.base.logging.Logger;
|
||||
import de.staropensource.engine.base.type.logging.LogLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Prints log messages to the console, without performing any message changes.
|
||||
* Will reveal shortcodes as they will not be replaced.
|
||||
*
|
||||
* @see Logger
|
||||
* @see LoggingAdapter
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public class RawLoggingAdapter implements LoggingAdapter {
|
||||
/**
|
||||
* Creates and initializes an instance of this class.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public RawLoggingAdapter() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void print(@NotNull LogLevel level, @NotNull StackTraceElement issuer, @NotNull String message, @NotNull String format) {
|
||||
if (level == LogLevel.ERROR || level == LogLevel.CRASH)
|
||||
if (EngineConfiguration.getInstance().isLogForceStandardOutput())
|
||||
System.out.println(format);
|
||||
else
|
||||
System.err.println(format);
|
||||
else
|
||||
System.out.println(format);
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A set of built-in {@link de.staropensource.engine.base.implementable.LoggingAdapter}s.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
package de.staropensource.engine.base.implementation.logging;
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementation.shortcode;
|
||||
|
||||
import de.staropensource.engine.base.implementable.ShortcodeParser;
|
||||
import de.staropensource.engine.base.exception.ParserException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Cleans the string of any tags.
|
||||
*
|
||||
* @see ShortcodeParser
|
||||
* @since v1-alpha8
|
||||
*/
|
||||
public final class EmptyShortcodeParser extends ShortcodeParser {
|
||||
/**
|
||||
* Creates and initializes an instance of this class.
|
||||
*
|
||||
* @param string string to parse
|
||||
* @param ignoreInvalidEscapes if {@code true}, will ignore and treat invalid escapes as text
|
||||
* @throws ParserException on error
|
||||
* @since v1-alpha8
|
||||
*/
|
||||
public EmptyShortcodeParser(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
|
||||
super(string, ignoreInvalidEscapes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parsed string without any tags.
|
||||
*
|
||||
* @return cleaned input string
|
||||
* @since v1-alpha8
|
||||
*/
|
||||
public @NotNull String getClean() {
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
for (String component : components)
|
||||
if (component.startsWith("TEXT:"))
|
||||
output.append(component.substring(5));
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Classes which convert data.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
package de.staropensource.engine.base.implementation.shortcode;
|
|
@ -1,160 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementation.versioning;
|
||||
|
||||
import de.staropensource.engine.base.implementable.VersioningSystem;
|
||||
import de.staropensource.engine.base.exception.versioning.IncompatibleVersioningSystemException;
|
||||
import de.staropensource.engine.base.exception.versioning.InvalidVersionStringException;
|
||||
import de.staropensource.engine.base.utility.misc.StringUtil;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
/**
|
||||
* Represents a four-numbered versioning system, where an application or work is versioning by four arbitrary numbers.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class FourNumberVersioningSystem implements VersioningSystem {
|
||||
/**
|
||||
* Contains the first number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the first number vector.
|
||||
*
|
||||
* @return first number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number1;
|
||||
|
||||
/**
|
||||
* Contains the second number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the second number vector.
|
||||
*
|
||||
* @return second number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number2;
|
||||
|
||||
/**
|
||||
* Contains the third number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the third number vector.
|
||||
*
|
||||
* @return third number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number3;
|
||||
|
||||
/**
|
||||
* Contains the fourth number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the fourth number vector.
|
||||
*
|
||||
* @return fourth number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number4;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return "n4";
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to parse the specified version string
|
||||
* and if successful, return a new instance.
|
||||
*
|
||||
* @param versionString version string to parse
|
||||
* @throws InvalidVersionStringException if the version string is invalid
|
||||
*/
|
||||
public FourNumberVersioningSystem(@NotNull String versionString) throws InvalidVersionStringException {
|
||||
String[] separatorList = new String[]{ ".", "-" };
|
||||
String separator = StringUtil.getSeparatorRequired(versionString, separatorList, 3);
|
||||
|
||||
// Escape separator or throw error if invalid
|
||||
switch (separator) {
|
||||
case "." -> separator = "\\.";
|
||||
case null -> throw new InvalidVersionStringException(this, versionString, "No matching separator could be found. Required are either three dots ('.') or hyphens ('-')");
|
||||
default -> {}
|
||||
}
|
||||
|
||||
// Split the version string at every separator
|
||||
String[] versionStringSplit = versionString.split(separator);
|
||||
|
||||
// Convert to integers
|
||||
try {
|
||||
this.number1 = Integer.parseUnsignedInt(versionStringSplit[0]);
|
||||
this.number2 = Integer.parseUnsignedInt(versionStringSplit[1]);
|
||||
this.number3 = Integer.parseUnsignedInt(versionStringSplit[2]);
|
||||
this.number4 = Integer.parseUnsignedInt(versionStringSplit[3]);
|
||||
} catch (NumberFormatException exception) {
|
||||
throw new InvalidVersionStringException(this, versionString, "Failed converting one of the vectors to an integer", exception);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Range(from = 0, to = 2)
|
||||
@Override
|
||||
public int compare(@NotNull VersioningSystem versionInterface) throws IncompatibleVersioningSystemException {
|
||||
if (versionInterface instanceof FourNumberVersioningSystem version) {
|
||||
if (version.getNumber1() < number1)
|
||||
return 0;
|
||||
if (version.getNumber1() > number1)
|
||||
return 2;
|
||||
|
||||
if (version.getNumber2() < number2)
|
||||
return 0;
|
||||
if (version.getNumber2() > number2)
|
||||
return 2;
|
||||
|
||||
if (version.getNumber3() < number3)
|
||||
return 0;
|
||||
if (version.getNumber3() > number3)
|
||||
return 2;
|
||||
|
||||
if (version.getNumber4() < number4)
|
||||
return 0;
|
||||
if (version.getNumber4() > number4)
|
||||
return 2;
|
||||
|
||||
return 1;
|
||||
|
||||
} else
|
||||
throw new IncompatibleVersioningSystemException(this, versionInterface);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return number1 + "." + number2 + "." + number3 + "." + number4;
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementation.versioning;
|
||||
|
||||
import de.staropensource.engine.base.implementable.VersioningSystem;
|
||||
import de.staropensource.engine.base.exception.versioning.IncompatibleVersioningSystemException;
|
||||
import de.staropensource.engine.base.exception.versioning.InvalidVersionStringException;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
/**
|
||||
* Represents a one-numbered versioning system, where an application or work is versioned by one arbitrary number.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class OneNumberVersioningSystem implements VersioningSystem {
|
||||
/**
|
||||
* Contains the number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the number vector.
|
||||
*
|
||||
* @return number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return "n1";
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to parse the specified version string
|
||||
* and if successful, return a new instance.
|
||||
*
|
||||
* @param versionString version string to parse
|
||||
* @throws InvalidVersionStringException if the version string is invalid
|
||||
*/
|
||||
public OneNumberVersioningSystem(@NotNull String versionString) throws InvalidVersionStringException {
|
||||
// Convert to integers
|
||||
try {
|
||||
this.number = Integer.parseUnsignedInt(versionString);
|
||||
} catch (NumberFormatException exception) {
|
||||
throw new InvalidVersionStringException(this, versionString, "Failed converting the version string into an integer", exception);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Range(from = 0, to = 2)
|
||||
@Override
|
||||
public int compare(@NotNull VersioningSystem versionInterface) throws IncompatibleVersioningSystemException {
|
||||
if (versionInterface instanceof OneNumberVersioningSystem version) {
|
||||
if (version.getNumber() < number)
|
||||
return 0;
|
||||
if (version.getNumber() > number)
|
||||
return 2;
|
||||
|
||||
return 1;
|
||||
} else
|
||||
throw new IncompatibleVersioningSystemException(this, versionInterface);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return String.valueOf(number);
|
||||
}
|
||||
}
|
|
@ -1,229 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementation.versioning;
|
||||
|
||||
import de.staropensource.engine.base.implementable.VersioningSystem;
|
||||
import de.staropensource.engine.base.exception.versioning.IncompatibleVersioningSystemException;
|
||||
import de.staropensource.engine.base.exception.versioning.InvalidVersionStringException;
|
||||
import de.staropensource.engine.base.utility.misc.StringUtil;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents the semantic versioning system (version 2.0.0), where an application
|
||||
* or work is versioning by a {@code MAJOR} version, {@code MINOR} version,
|
||||
* {@code PATCH} version and optionally, a pre-release vector and a build number.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class SemanticVersioningSystem implements VersioningSystem {
|
||||
/**
|
||||
* Contains the {@code MAJOR} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the {@code MAJOR} vector.
|
||||
*
|
||||
* @return {@code MAJOR} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int major;
|
||||
|
||||
/**
|
||||
* Contains the {@code MINOR} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the {@code MINOR} vector.
|
||||
*
|
||||
* @return {@code MINOR} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int minor;
|
||||
|
||||
/**
|
||||
* Contains the {@code PATCH} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the {@code PATCH} vector.
|
||||
*
|
||||
* @return {@code PATCH} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int patch;
|
||||
|
||||
/**
|
||||
* Contains the {@code PRERELEASE} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the {@code PRERELEASE} vector.
|
||||
*
|
||||
* @return {@code PRERELEASE} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final @Nullable String prerelease;
|
||||
|
||||
/**
|
||||
* Contains the {@code BUILD} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the {@code BUILD} vector.
|
||||
*
|
||||
* @return {@code BUILD} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int build;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return "Semantic";
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to parse the specified version string
|
||||
* and if successful, return a new instance.
|
||||
*
|
||||
* @param versionString version string to parse
|
||||
* @throws InvalidVersionStringException if the version string is invalid
|
||||
*/
|
||||
public SemanticVersioningSystem(@NotNull String versionString) throws InvalidVersionStringException {
|
||||
String[] separatorList = new String[]{ "." };
|
||||
String separator = StringUtil.getSeparatorRequired(versionString, separatorList, 2);
|
||||
|
||||
// Escape separator or throw error if invalid
|
||||
switch (separator) {
|
||||
case "." -> separator = "\\.";
|
||||
case null -> throw new InvalidVersionStringException(this, versionString, "No matching separator could be found. Required are two dots ('.')");
|
||||
default -> {}
|
||||
}
|
||||
|
||||
// Split the version string at every separator
|
||||
List<String> versionStringSplit = new ArrayList<>(Arrays.stream(versionString.split(separator)).toList());
|
||||
|
||||
// Get pre-release and build vectors
|
||||
String build = null;
|
||||
String prerelease = null;
|
||||
if (versionStringSplit.get(2).contains("+")) { // Build vector
|
||||
int position = versionStringSplit.get(2).indexOf("+");
|
||||
build = versionStringSplit.get(2).substring(position + 1);
|
||||
versionStringSplit.set(2, versionStringSplit.get(2).substring(0, position));
|
||||
}
|
||||
if (versionStringSplit.get(2).contains("-")) {
|
||||
int position = versionStringSplit.get(2).indexOf("-");
|
||||
prerelease = versionStringSplit.get(2).substring(position + 1);
|
||||
versionStringSplit.set(2, versionStringSplit.get(2).substring(0, position));
|
||||
}
|
||||
|
||||
// Convert to integers
|
||||
try {
|
||||
this.major = Integer.parseUnsignedInt(versionStringSplit.get(0));
|
||||
this.minor = Integer.parseUnsignedInt(versionStringSplit.get(1));
|
||||
this.patch = Integer.parseUnsignedInt(versionStringSplit.get(2));
|
||||
this.prerelease = prerelease;
|
||||
if (build == null)
|
||||
this.build = 0;
|
||||
else
|
||||
this.build = Integer.parseUnsignedInt(build);
|
||||
} catch (NumberFormatException exception) {
|
||||
throw new InvalidVersionStringException(this, versionString, "Failed converting one of the vectors to an integer", exception);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Range(from = 0, to = 2)
|
||||
@Override
|
||||
public int compare(@NotNull VersioningSystem versionInterface) throws IncompatibleVersioningSystemException {
|
||||
if (versionInterface instanceof SemanticVersioningSystem version) {
|
||||
if (version.getMajor() < major)
|
||||
return 0;
|
||||
if (version.getMajor() > major)
|
||||
return 2;
|
||||
|
||||
if (version.getMinor() < minor)
|
||||
return 0;
|
||||
if (version.getMinor() > minor)
|
||||
return 2;
|
||||
|
||||
if (version.getPatch() < patch)
|
||||
return 0;
|
||||
if (version.getPatch() > patch)
|
||||
return 2;
|
||||
|
||||
if (version.getPrerelease() == null && prerelease != null)
|
||||
return 2;
|
||||
else if (version.getPrerelease() != null && prerelease == null)
|
||||
return 0;
|
||||
else if (version.getPrerelease() != null)
|
||||
switch (prerelease) {
|
||||
case "alpha" -> {
|
||||
switch (version.getPrerelease()) {
|
||||
case "beta", "releasecandidate", "release-candidate", "rc" -> {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
case "beta" -> {
|
||||
switch (version.getPrerelease()) {
|
||||
case "alpha" -> {
|
||||
return 0;
|
||||
}
|
||||
case "releasecandidate", "release-candidate", "rc" -> {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
case "releasecandidate", "release-candidate", "rc" -> {
|
||||
switch (version.getPrerelease()) {
|
||||
case "alpha", "beta" -> {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version.getBuild() < build)
|
||||
return 0;
|
||||
if (version.getBuild() > build)
|
||||
return 2;
|
||||
|
||||
return 1;
|
||||
|
||||
} else
|
||||
throw new IncompatibleVersioningSystemException(this, versionInterface);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return major + "." + minor + "." + patch + (prerelease == null ? "" : "-" + prerelease) + (build == 0 ? "" : "+" + build);
|
||||
}
|
||||
}
|
|
@ -1,272 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementation.versioning;
|
||||
|
||||
import de.staropensource.engine.base.implementable.VersioningSystem;
|
||||
import de.staropensource.engine.base.exception.versioning.IncompatibleVersioningSystemException;
|
||||
import de.staropensource.engine.base.exception.versioning.InvalidVersionStringException;
|
||||
import de.staropensource.engine.base.type.VersionType;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Represents the StarOpenSource versioning
|
||||
* system version two, where an application
|
||||
* or work is versioning by the {@code RELEASE},
|
||||
* {@code TYPE}, {@code TYPERELEASE} and
|
||||
* optionally, the {@code FORK} and
|
||||
* {@code COMPANION} vectors.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class StarOpenSourceVersioningSystem implements VersioningSystem {
|
||||
/**
|
||||
* Contains the {@code RELEASE} vector.
|
||||
*
|
||||
* @since v1-alpha9
|
||||
* -- GETTER --
|
||||
* Returns the {@code RELEASE} vector.
|
||||
*
|
||||
* @return {@code RELEASE} vector
|
||||
* @since v1-alpha9
|
||||
*/
|
||||
private final int release;
|
||||
|
||||
/**
|
||||
* Contains the {@code TYPE} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the {@code TYPE} vector.
|
||||
*
|
||||
* @return {@code TYPE} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final VersionType type;
|
||||
|
||||
/**
|
||||
* Contains the {@code TYPERELEASE} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the {@code TYPERELEASE}- vector.
|
||||
*
|
||||
* @return {@code TYPERELEASE} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int typerelease;
|
||||
|
||||
/**
|
||||
* Contains the {@code COMPANION} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the {@code COMPANION} vector.
|
||||
*
|
||||
* @return {@code COMPANION} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final @Nullable String companion;
|
||||
|
||||
/**
|
||||
* Contains the FORK vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the FORK vector.
|
||||
*
|
||||
* @return FORK vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final String fork;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return "StarOpenSource";
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to parse the specified version string
|
||||
* and if successful, return a new instance.
|
||||
*
|
||||
* @param versionString version string to parse
|
||||
* @throws InvalidVersionStringException if the version string is invalid
|
||||
*/
|
||||
public StarOpenSourceVersioningSystem(@NotNull String versionString) throws InvalidVersionStringException {
|
||||
// Split the version string at every separator
|
||||
StringBuilder charSequence = new StringBuilder();
|
||||
/*
|
||||
* 0 = 'v'
|
||||
* 1 = release vector
|
||||
* 3 = type vector
|
||||
* 4 = typerelease vector
|
||||
* 5 = companion vector
|
||||
* 6 = fork vector
|
||||
*/
|
||||
int parsingId = 0;
|
||||
List<String> versionStringSplit = new ArrayList<>();
|
||||
String companion = null;
|
||||
String fork = null;
|
||||
|
||||
// Iterate through all characters
|
||||
for (Character character : versionString.toCharArray()) {
|
||||
switch (parsingId) {
|
||||
case 0 -> { // 'v' character
|
||||
if (character != 'v')
|
||||
throw new InvalidVersionStringException(this, versionString, "Does not start with the character 'v'");
|
||||
parsingId++;
|
||||
}
|
||||
case 1 -> { // Version vector
|
||||
if (character == '-') {
|
||||
versionStringSplit.add(charSequence.toString());
|
||||
charSequence = new StringBuilder();
|
||||
parsingId++;
|
||||
} else
|
||||
charSequence.append(character);
|
||||
}
|
||||
case 2 -> { // Type vector
|
||||
charSequence.append(character);
|
||||
|
||||
if (charSequence.toString().equals("alpha") || charSequence.toString().equals("beta") || charSequence.toString().equals("release")) {
|
||||
versionStringSplit.add(charSequence.toString());
|
||||
charSequence = new StringBuilder();
|
||||
parsingId++;
|
||||
} else if (versionStringSplit.size() == 2 && versionStringSplit.get(1).contains("releasec") && charSequence.toString().equals("andidate")) {
|
||||
versionStringSplit.set(1, versionStringSplit.get(1) + charSequence);
|
||||
charSequence = new StringBuilder();
|
||||
parsingId++;
|
||||
}
|
||||
}
|
||||
case 3 -> { // Typerelease vector
|
||||
if (character == '-' || character == '+') {
|
||||
versionStringSplit.add(charSequence.toString());
|
||||
charSequence = new StringBuilder();
|
||||
parsingId++;
|
||||
if (character == '+')
|
||||
parsingId++;
|
||||
} else
|
||||
if (character == 'c' && versionStringSplit.get(1).equals("release")) {
|
||||
versionStringSplit.set(1, versionStringSplit.get(1) + character);
|
||||
parsingId--;
|
||||
} else
|
||||
charSequence.append(character);
|
||||
}
|
||||
case 4 -> { // Fork vector
|
||||
if (character == '+') {
|
||||
fork = charSequence.toString();
|
||||
charSequence = new StringBuilder();
|
||||
parsingId++;
|
||||
} else
|
||||
charSequence.append(character);
|
||||
}
|
||||
case 5 -> // Companion vector
|
||||
charSequence.append(character);
|
||||
}
|
||||
}
|
||||
|
||||
switch (parsingId) {
|
||||
case 0, 1, 2 -> throw new InvalidVersionStringException(this, versionString, "Required vectors not found");
|
||||
case 3 -> {
|
||||
if (charSequence.isEmpty())
|
||||
throw new InvalidVersionStringException(this, versionString, "Required vectors not found");
|
||||
else {
|
||||
if (versionStringSplit.size() == 2 && versionStringSplit.get(1).contains("releasec") && charSequence.toString().equals("andidate")) {
|
||||
versionStringSplit.set(1, versionStringSplit.get(1) + charSequence);
|
||||
} else
|
||||
versionStringSplit.add(charSequence.toString());
|
||||
}
|
||||
}
|
||||
case 5 -> {
|
||||
if (charSequence.isEmpty())
|
||||
throw new InvalidVersionStringException(this, versionString, "Fork vector not found");
|
||||
else
|
||||
fork = charSequence.toString();
|
||||
}
|
||||
case 6 -> {
|
||||
if (charSequence.isEmpty())
|
||||
throw new InvalidVersionStringException(this, versionString, "Companion vector not found");
|
||||
else
|
||||
companion = charSequence.toString();
|
||||
}
|
||||
}
|
||||
|
||||
// Rewrite type
|
||||
if (versionStringSplit.get(1).equals("releasecandidate"))
|
||||
versionStringSplit.set(1, "RELEASE_CANDIDATE");
|
||||
else
|
||||
versionStringSplit.set(1, versionStringSplit.get(1).toUpperCase(Locale.ROOT));
|
||||
|
||||
|
||||
// Update variables
|
||||
try {
|
||||
this.release = Integer.parseUnsignedInt(versionStringSplit.get(0));
|
||||
this.type = VersionType.valueOf(versionStringSplit.get(1));
|
||||
this.typerelease = Integer.parseUnsignedInt(versionStringSplit.get(2));
|
||||
this.companion = companion;
|
||||
this.fork = fork;
|
||||
} catch (NumberFormatException exception) {
|
||||
throw new InvalidVersionStringException(this, versionString, "Failed converting one of the vectors to an integer", exception);
|
||||
}
|
||||
|
||||
if (this.release == 0)
|
||||
throw new InvalidVersionStringException(this, versionString, "The version vector must start at 1");
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Range(from = 0, to = 2)
|
||||
@Override
|
||||
public int compare(@NotNull VersioningSystem versionInterface) throws IncompatibleVersioningSystemException {
|
||||
if (versionInterface instanceof StarOpenSourceVersioningSystem versionCompare) {
|
||||
if (versionCompare.getRelease() < this.release)
|
||||
return 0;
|
||||
if (versionCompare.getRelease() > this.release)
|
||||
return 2;
|
||||
|
||||
if (type.compareTo(versionCompare.getType()) > 0)
|
||||
return 0;
|
||||
if (type.compareTo(versionCompare.getType()) < 0)
|
||||
return 2;
|
||||
|
||||
if (versionCompare.getTyperelease() < typerelease)
|
||||
return 0;
|
||||
if (versionCompare.getTyperelease() > typerelease)
|
||||
return 2;
|
||||
|
||||
return 1;
|
||||
|
||||
} else
|
||||
throw new IncompatibleVersioningSystemException(this, versionInterface);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return "v" + release + "-" + type.name().toLowerCase(Locale.ROOT) + typerelease + (fork == null ? "" : "-" + fork) + (companion == null ? "" : "+" + companion);
|
||||
}
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementation.versioning;
|
||||
|
||||
import de.staropensource.engine.base.implementable.VersioningSystem;
|
||||
import de.staropensource.engine.base.exception.versioning.IncompatibleVersioningSystemException;
|
||||
import de.staropensource.engine.base.exception.versioning.InvalidVersionStringException;
|
||||
import de.staropensource.engine.base.utility.misc.StringUtil;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
/**
|
||||
* Represents a three-numbered versioning system, where an application or work is versioning by three arbitrary numbers.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class ThreeNumberVersioningSystem implements VersioningSystem {
|
||||
/**
|
||||
* Contains the first number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the first number vector.
|
||||
*
|
||||
* @return first number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number1;
|
||||
|
||||
/**
|
||||
* Contains the second number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the second number vector.
|
||||
*
|
||||
* @return second number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number2;
|
||||
|
||||
/**
|
||||
* Contains the third number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the third number vector.
|
||||
*
|
||||
* @return third number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number3;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return "n3";
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to parse the specified version string
|
||||
* and if successful, return a new instance.
|
||||
*
|
||||
* @param versionString version string to parse
|
||||
* @throws InvalidVersionStringException if the version string is invalid
|
||||
*/
|
||||
public ThreeNumberVersioningSystem(@NotNull String versionString) throws InvalidVersionStringException {
|
||||
String[] separatorList = new String[]{ ".", "-" };
|
||||
String separator = StringUtil.getSeparatorRequired(versionString, separatorList, 2);
|
||||
|
||||
// Escape separator or throw error if invalid
|
||||
switch (separator) {
|
||||
case "." -> separator = "\\.";
|
||||
case null -> throw new InvalidVersionStringException(this, versionString, "No matching separator could be found. Required are either two dots ('.') or hyphens ('-')");
|
||||
default -> {}
|
||||
}
|
||||
|
||||
// Split the version string at every separator
|
||||
String[] versionStringSplit = versionString.split(separator);
|
||||
|
||||
// Convert to integers
|
||||
try {
|
||||
this.number1 = Integer.parseUnsignedInt(versionStringSplit[0]);
|
||||
this.number2 = Integer.parseUnsignedInt(versionStringSplit[1]);
|
||||
this.number3 = Integer.parseUnsignedInt(versionStringSplit[2]);
|
||||
} catch (NumberFormatException exception) {
|
||||
throw new InvalidVersionStringException(this, versionString, "Failed converting one of the vectors to an integer", exception);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Range(from = 0, to = 2)
|
||||
@Override
|
||||
public int compare(@NotNull VersioningSystem versionInterface) throws IncompatibleVersioningSystemException {
|
||||
if (versionInterface instanceof ThreeNumberVersioningSystem version) {
|
||||
if (version.getNumber1() < number1)
|
||||
return 0;
|
||||
if (version.getNumber1() > number1)
|
||||
return 2;
|
||||
|
||||
if (version.getNumber2() < number2)
|
||||
return 0;
|
||||
if (version.getNumber2() > number2)
|
||||
return 2;
|
||||
|
||||
if (version.getNumber3() < number3)
|
||||
return 0;
|
||||
if (version.getNumber3() > number3)
|
||||
return 2;
|
||||
|
||||
return 1;
|
||||
|
||||
} else
|
||||
throw new IncompatibleVersioningSystemException(this, versionInterface);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return number1 + "." + number2 + "." + number3;
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.implementation.versioning;
|
||||
|
||||
import de.staropensource.engine.base.implementable.VersioningSystem;
|
||||
import de.staropensource.engine.base.exception.versioning.IncompatibleVersioningSystemException;
|
||||
import de.staropensource.engine.base.exception.versioning.InvalidVersionStringException;
|
||||
import de.staropensource.engine.base.utility.misc.StringUtil;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
/**
|
||||
* Represents a two-numbered versioning system, where an application or work is versioning by two arbitrary numbers.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class TwoNumberVersioningSystem implements VersioningSystem {
|
||||
/**
|
||||
* Contains the first number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the first number vector.
|
||||
*
|
||||
* @return first number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number1;
|
||||
|
||||
/**
|
||||
* Contains the second number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
* -- GETTER --
|
||||
* Returns the second number vector.
|
||||
*
|
||||
* @return second number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number2;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return "n2";
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to parse the specified version string
|
||||
* and if successful, return a new instance.
|
||||
*
|
||||
* @param versionString version string to parse
|
||||
* @throws InvalidVersionStringException if the version string is invalid
|
||||
*/
|
||||
public TwoNumberVersioningSystem(@NotNull String versionString) throws InvalidVersionStringException {
|
||||
String[] separatorList = new String[]{ ".", "-" };
|
||||
String separator = StringUtil.getSeparatorRequired(versionString, separatorList, 1);
|
||||
|
||||
// Escape separator or throw error if invalid
|
||||
switch (separator) {
|
||||
case "." -> separator = "\\.";
|
||||
case null -> throw new InvalidVersionStringException(this, versionString, "No matching separator could be found. Required are either one dot ('.') or hyphen ('-')");
|
||||
default -> {}
|
||||
}
|
||||
|
||||
// Split the version string at every separator
|
||||
String[] versionStringSplit = versionString.split(separator);
|
||||
|
||||
// Convert to integers
|
||||
try {
|
||||
this.number1 = Integer.parseUnsignedInt(versionStringSplit[0]);
|
||||
this.number2 = Integer.parseUnsignedInt(versionStringSplit[1]);
|
||||
} catch (NumberFormatException exception) {
|
||||
throw new InvalidVersionStringException(this, versionString, "Failed converting one of the vectors to an integer", exception);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Range(from = 0, to = 2)
|
||||
@Override
|
||||
public int compare(@NotNull VersioningSystem versionInterface) throws IncompatibleVersioningSystemException {
|
||||
if (versionInterface instanceof TwoNumberVersioningSystem version) {
|
||||
if (version.getNumber1() < number1)
|
||||
return 0;
|
||||
if (version.getNumber1() > number1)
|
||||
return 2;
|
||||
|
||||
if (version.getNumber2() < number2)
|
||||
return 0;
|
||||
if (version.getNumber2() > number2)
|
||||
return 2;
|
||||
|
||||
return 1;
|
||||
|
||||
} else
|
||||
throw new IncompatibleVersioningSystemException(this, versionInterface);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return number1 + "." + number2;
|
||||
}
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation;
|
||||
|
||||
import de.staropensource.engine.base.implementable.EventListenerCode;
|
||||
import de.staropensource.engine.base.reflection.Reflect;
|
||||
import de.staropensource.engine.base.reflection.ReflectionMethod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Interface specifically for executing event listener methods.
|
||||
*
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public final class EventListenerMethod extends EventListenerCode {
|
||||
/**
|
||||
* Contains the method to call and get.
|
||||
*
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
private final @NotNull ReflectionMethod method;
|
||||
|
||||
/**
|
||||
* Creates and initializes an instance of this class.
|
||||
*
|
||||
* @param method method to execute
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public EventListenerMethod(@NotNull Method method) {
|
||||
this.method = Reflect.reflectOn(method);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void run(@Nullable Object @NotNull [] arguments) throws Exception {
|
||||
method.invoke(arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forwards {@link ReflectionMethod#getAnnotation(Class)}
|
||||
* to the internal {@link ReflectionMethod} instance.
|
||||
*
|
||||
* @param <T> annotation
|
||||
* @param annotation annotation to get
|
||||
* @return annotation or {@code null} on error
|
||||
* @see ReflectionMethod#getAnnotation(Class)
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
public <T extends Annotation> @Nullable T getAnnotation(@NotNull Class<T> annotation) {
|
||||
try {
|
||||
return method.getAnnotation(annotation);
|
||||
} catch (NullPointerException exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String toString() {
|
||||
return "method " + method.getMethod().getDeclaringClass().getName() + "#" + method.getName();
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interfaces and abstract classes which can be used for implementing classes.
|
||||
*
|
||||
* @since v1-alpha5
|
||||
*/
|
||||
package de.staropensource.engine.base.internal.implementation;
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.misc.NumberUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Implements the {@code date_day} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class DateDay implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public DateDay() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%date_day%", NumberUtil.padNumbers(Calendar.getInstance().get(Calendar.DAY_OF_MONTH), 2));
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.misc.NumberUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Implements the {@code date_month} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class DateMonth implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public DateMonth() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%date_month%", NumberUtil.padNumbers(Calendar.getInstance().get(Calendar.MONTH), 2));
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.misc.NumberUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Implements the {@code date_year} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class DateYear implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public DateYear() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%date_year%", NumberUtil.padNumbers(Calendar.getInstance().get(Calendar.YEAR), 4));
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_dependency_jansi} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineDependencyJansi implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineDependencyJansi() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_dependency_jansi%", EngineInformation.getDependencyJansi());
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_dependency_lwjgl} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineDependencyLwjgl implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineDependencyLwjgl() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_dependency_lwjgl%", EngineInformation.getDependencyLwjgl());
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_dependency_reflections} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineDependencyReflections implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineDependencyReflections() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_dependency_reflections%", EngineInformation.getDependencyReflections());
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_dependency_slf4j} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineDependencySlf4j implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineDependencySlf4j() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_dependency_slf4j%", EngineInformation.getDependencySlf4j());
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_branch} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitBranch implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitBranch() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_branch%", EngineInformation.getGitBranch());
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_commit_header} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitCommitHeader implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitCommitHeader() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_header%", EngineInformation.getGitCommitHeader());
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_commit_id_long} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitCommitIdLong implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitCommitIdLong() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_id_long%", EngineInformation.getGitCommitIdentifierLong());
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_commit_id_short} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitCommitIdShort implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitCommitIdShort() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_id_short%", EngineInformation.getGitCommitIdentifierShort());
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_commit_time_day} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitCommitTimeDay implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitCommitTimeDay() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_time_day%", String.valueOf(EngineInformation.getGitCommitTime().getDayOfMonth()));
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_commit_time_hour} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitCommitTimeHour implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitCommitTimeHour() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_time_hour%", String.valueOf(EngineInformation.getGitCommitTime().getHour()));
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_commit_time_minute} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitCommitTimeMinute implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitCommitTimeMinute() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_time_minute%", String.valueOf(EngineInformation.getGitCommitTime().getMinute()));
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_commit_time_month} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitCommitTimeMonth implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitCommitTimeMonth() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_time_month%", String.valueOf(EngineInformation.getGitCommitTime().getMonth()));
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_commit_time_second} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitCommitTimeSecond implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitCommitTimeSecond() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_time_second%", String.valueOf(EngineInformation.getGitCommitTime().getSecond()));
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_commit_time_year} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitCommitTimeYear implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitCommitTimeYear() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_time_year%", String.valueOf(EngineInformation.getGitCommitTime().getYear()));
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_commits} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitCommits implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitCommits() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commits%", String.valueOf(EngineInformation.getGitCommitCount()));
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_committer_email} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitCommitterEmail implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitCommitterEmail() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_committer_email%", EngineInformation.getGitCommitterEmail());
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_committer_name} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitCommitterName implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitCommitterName() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_committer_name%", EngineInformation.getGitCommitterName());
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_git_dirty} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineGitDirty implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineGitDirty() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_dirty%", String.valueOf(EngineInformation.isGitDirty()));
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_version} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineVersion implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineVersion() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_version%", "v%engine_version_version%-%engine_version_type%%engine_version_typerelease%%engine_version_fork%");
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_version_codename} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha8
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineVersionCodename implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha8
|
||||
*/
|
||||
public EngineVersionCodename() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_version_codename%", EngineInformation.getVersioningCodename());
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_version_type} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineVersionType implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineVersionType() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_version_type%", EngineInformation.getVersioningType().name().toLowerCase());
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_version_typerelease} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineVersionTyperelease implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineVersionTyperelease() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_version_typerelease%", String.valueOf(EngineInformation.getVersioningTyperelease()));
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine 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.base.internal.implementation.placeholder;
|
||||
|
||||
import de.staropensource.engine.base.implementable.Placeholder;
|
||||
import de.staropensource.engine.base.utility.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code engine_version_version} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineVersionVersion implements Placeholder {
|
||||
/**
|
||||
* Creates and initializes an instance of this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineVersionVersion() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_version_version%", String.valueOf(EngineInformation.getVersioningVersion()));
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue