Compare commits
No commits in common. "develop" and "v1-alpha3" have entirely different histories.
495 changed files with 43469 additions and 15564 deletions
|
@ -1,117 +0,0 @@
|
||||||
name: "⚠️ Bug report"
|
|
||||||
about: "Report a bug in the engine."
|
|
||||||
title: "bug: "
|
|
||||||
labels:
|
|
||||||
- "Bug/New"
|
|
||||||
body:
|
|
||||||
- type: "markdown"
|
|
||||||
id: "text-introduction"
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Hey there! Thank you for taking the time to report a bug to us. \
|
|
||||||
This means a lot to us, as that's the only way to get better... and many people don't file bug reports. \
|
|
||||||
Anyway, please answer the following questions accurately, otherwise we may not be able to diagnose the issue. \
|
|
||||||
\
|
|
||||||
**Please check if the same bug report already exists. If so, participate in that one instead. If another issue is similar, make sure to mention the related issues.** \
|
|
||||||
**Please don't censor anything *except* sensitive information. You don't need to be embarrased about your username. You censor your bug report, we censor our answers.**
|
|
||||||
- type: "textarea"
|
|
||||||
id: "bug-description"
|
|
||||||
attributes:
|
|
||||||
label: "Bug description"
|
|
||||||
description: "Explain what the bug is about. Include as many details as possible."
|
|
||||||
placeholder: "My cat spontaneously explodes when I try to download from `https://yourdick.zip`."
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: "textarea"
|
|
||||||
id: "bug-log"
|
|
||||||
attributes:
|
|
||||||
label: "Bug log"
|
|
||||||
description: |
|
|
||||||
Please insert the ENTIRE log output here, so we can understand the problem at hand. \
|
|
||||||
You must give us `DIAGNOSTIC` level logs (pass `-Dsosengine.base.loggerLevel=diagnostic` to the JVM) with the default log template.
|
|
||||||
|
|
||||||
**This field can be left empty if the bug does not involve/require log output.**
|
|
||||||
placeholder: "Your log file here..."
|
|
||||||
value: |
|
|
||||||
```plain
|
|
||||||
Your log file here...
|
|
||||||
```
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: "textarea"
|
|
||||||
id: "bug-snippet"
|
|
||||||
attributes:
|
|
||||||
label: "Bug snippet"
|
|
||||||
description: |
|
|
||||||
Please insert a snippet of the (application and/or engine) code which you think is causing the issue.
|
|
||||||
|
|
||||||
**This field can be left empty if you intend on supplying a reproduction project.**
|
|
||||||
value: |
|
|
||||||
```java
|
|
||||||
Your code snippet here...
|
|
||||||
```
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: "textarea"
|
|
||||||
id: "bug-reproduce"
|
|
||||||
attributes:
|
|
||||||
label: "Bug reproduction guide"
|
|
||||||
description: |
|
|
||||||
Explain how we can reproduce this bug as easy as possible, step by step.
|
|
||||||
|
|
||||||
**This field can be left empty if the bug does not involve/require a reproduction guide.**
|
|
||||||
placeholder: |
|
|
||||||
1. Pass "-Dsosengine.base.optimizeLogging=false" to the JVM
|
|
||||||
2. Override logging implementation
|
|
||||||
2. Initialize engine
|
|
||||||
4. The nearest cat should explode in the next few seconds
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: "input"
|
|
||||||
id: "bug-reproduce-project"
|
|
||||||
attributes:
|
|
||||||
label: "Bug reproduction project"
|
|
||||||
description: |
|
|
||||||
Drop a link to some repository or zip file of an example project showcasing the bug.
|
|
||||||
|
|
||||||
**Only supply a repro project if the bug is a bit more advanced, needs specific timing, etc..** \
|
|
||||||
**Also please make sure that the bug actually occurs in the example project!**"
|
|
||||||
placeholder: "https://your.reproduction.project/download/url/here"
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: "input"
|
|
||||||
id: "engine-version"
|
|
||||||
attributes:
|
|
||||||
label: "Full engine version"
|
|
||||||
description: |
|
|
||||||
Input the full engine version here.
|
|
||||||
Simply copy the `Initialized sos!engine v<version> (commit <commit>-<branch>, dirty <dirty>) in <inittime>ms` message here.
|
|
||||||
placeholder: "Example: sos!engine v1-alpha4 (commit 05b9644eba5263809b6655dabb92669523a95805-develop, dirty true)"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: "dropdown"
|
|
||||||
id: "jvm-java"
|
|
||||||
attributes:
|
|
||||||
label: "Java version"
|
|
||||||
description: "Which Java version is your application compiled against?"
|
|
||||||
options:
|
|
||||||
- "20 and lower"
|
|
||||||
- "21"
|
|
||||||
- "22"
|
|
||||||
- "23"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: "input"
|
|
||||||
id: "os"
|
|
||||||
attributes:
|
|
||||||
label: "Operating system"
|
|
||||||
description: "Name the operating system, version (if applicable) and CPU architecture the error occurs on. This may be some Linux distribution, Android or Windoze on `amd64`/`aarch64`/`ppc64`/etc.."
|
|
||||||
placeholder: "Example: Debian trixie (amd64)"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: "markdown"
|
|
||||||
id: "text-tysm"
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Thank you for filling out this bug report.
|
|
||||||
Please check your answers for *mistaeks* or sensitive information before sending this report.
|
|
|
@ -1,5 +0,0 @@
|
||||||
blank_issues_enabled: false
|
|
||||||
contact_links:
|
|
||||||
- name: "📚 Documentation"
|
|
||||||
about: "Visit the documentation. Maybe you just skipped something important or just haven't found the page you're looking for yet."
|
|
||||||
url: "https://engine.staropensource.de"
|
|
|
@ -1,20 +0,0 @@
|
||||||
name: "👾 Empty"
|
|
||||||
about: "A clean slate. Only use this one for specific, special cases."
|
|
||||||
title: "empty: "
|
|
||||||
labels:
|
|
||||||
- "Empty"
|
|
||||||
body:
|
|
||||||
- type: "markdown"
|
|
||||||
id: "introduction"
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
This issue template is meant for specific, special cases, where an empty issue template may be wanted.
|
|
||||||
You should *NOT* use this template to write bug reports, feature or help requests.
|
|
||||||
This issue template should ideally only be used by the repository maintainer.
|
|
||||||
- type: "textarea"
|
|
||||||
id: "content"
|
|
||||||
attributes:
|
|
||||||
label: "Issue content"
|
|
||||||
description: "Write your issue content here."
|
|
||||||
validations:
|
|
||||||
required: true
|
|
|
@ -1,61 +0,0 @@
|
||||||
name: "✨ Feature Request"
|
|
||||||
about: "Request a feature to be implemented in the engine."
|
|
||||||
title: "feat: "
|
|
||||||
labels:
|
|
||||||
- "FeatureRequest/New"
|
|
||||||
body:
|
|
||||||
- type: "markdown"
|
|
||||||
id: "text-introduction"
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Hey there! Thank you for taking the time to request a feature to us. \
|
|
||||||
Before filling any of this out, please think for one minute if the feature is really important and necessary enough to implement in the engine. If you're unsure, continue. \
|
|
||||||
Please answer the following questions accurately, or we may not be able to implement the feature as you requested it. \
|
|
||||||
\
|
|
||||||
**Please check if the same feature request already exists. If so, participate in that one instead. If another issue is similar, make sure to mention the related issues.** \
|
|
||||||
**Please don't censor anything *except* sensitive information. You don't need to be embarrased about your username. You censor your bug report, we censor our answers.** \
|
|
||||||
**Submitting a feature request will *not* gurantee it's inclusion into the engine. By submitting a feature request, you are at the grace of the community to pick up your suggestion.**
|
|
||||||
- type: "textarea"
|
|
||||||
id: "feature-description"
|
|
||||||
attributes:
|
|
||||||
label: "Feature description"
|
|
||||||
description: "Explain *what* you want added. Include as many details as possible."
|
|
||||||
placeholder: |
|
|
||||||
Example:
|
|
||||||
I want to do X in my project, which would simplify doing Y.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: "textarea"
|
|
||||||
id: "feature-implementation"
|
|
||||||
attributes:
|
|
||||||
label: "Feature implementation"
|
|
||||||
description: |
|
|
||||||
Explain *how* you want it added. Include as many details as possible.
|
|
||||||
Also explore alternative ways of implementing the feature in the engine (if possible).
|
|
||||||
placeholder: |
|
|
||||||
Example:
|
|
||||||
I would propose to <some description on how to implement your feature>.
|
|
||||||
I've also thought on simply <some other description on how to implement your feature>.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: "textarea"
|
|
||||||
id: "feature-alternatives"
|
|
||||||
attributes:
|
|
||||||
label: "Feature alternatives"
|
|
||||||
description: |
|
|
||||||
Explain how to implement the feature without building it into the engine directly. Include as many details as possible.
|
|
||||||
|
|
||||||
**Leave empty if it can't simply be solved by creating a subsystem.**
|
|
||||||
placeholder: |
|
|
||||||
Example:
|
|
||||||
I've considered writing a subsystem for this feature.
|
|
||||||
Otherwise it would be possible to use <link to some project> with some configuration.
|
|
||||||
I've also considered using the normal way of doing it by <how to do it using the normal way>.
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: "markdown"
|
|
||||||
id: "text-tysm"
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Thank you for filling out this feature request form.
|
|
||||||
Please check your answers for *mistaeks* before sending this report.
|
|
|
@ -1,89 +0,0 @@
|
||||||
name: "💬 Help"
|
|
||||||
about: "Request help."
|
|
||||||
title: "help: "
|
|
||||||
labels:
|
|
||||||
- "Help/Wanted"
|
|
||||||
body:
|
|
||||||
- type: "markdown"
|
|
||||||
id: "text-introduction"
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Hey there! Seems like you have some kind of issue with the StarOpenSource Engine. \
|
|
||||||
Please answer the following questions accurately, otherwise we may not be able to help you. \
|
|
||||||
\
|
|
||||||
**Please check if the same help request already exists. If so, participate in that one instead. If another issue is similar, make sure to mention the related issues.** \
|
|
||||||
**Please don't censor anything *except* sensitive information. You don't need to be embarrased about your username. You censor your stuff, we censor our answers.**
|
|
||||||
- type: "textarea"
|
|
||||||
id: "help-description"
|
|
||||||
attributes:
|
|
||||||
label: "Problem description"
|
|
||||||
description: "Explain what your problem is as detailed as possible."
|
|
||||||
placeholder: "How can I create a custom LoggerImplementation implementation?"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: "textarea"
|
|
||||||
id: "help-log"
|
|
||||||
attributes:
|
|
||||||
label: "Log"
|
|
||||||
description: |
|
|
||||||
Please insert the ENTIRE log output here, so we can understand the problem at hand. \
|
|
||||||
You must give us `DIAGNOSTIC` level logs (pass `-Dsosengine.base.loggerLevel=diagnostic` to the JVM) with the default log template.
|
|
||||||
|
|
||||||
*This field can be left empty if the problem you are faciing does not involve/require log output.**
|
|
||||||
placeholder: "Your log file here..."
|
|
||||||
value: |
|
|
||||||
```plain
|
|
||||||
Your log file here...
|
|
||||||
```
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: "textarea"
|
|
||||||
id: "help-snippet"
|
|
||||||
attributes:
|
|
||||||
label: "Code snippet"
|
|
||||||
description: |
|
|
||||||
Please insert a snippet of the application code which you think is causing the issue.
|
|
||||||
|
|
||||||
**This field can be left empty if the problem you are faciing does not involve/require code.**
|
|
||||||
value: |
|
|
||||||
```java
|
|
||||||
Your code snippet here...
|
|
||||||
```
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: "input"
|
|
||||||
id: "engine-version"
|
|
||||||
attributes:
|
|
||||||
label: "Full engine version"
|
|
||||||
description: |
|
|
||||||
Input the full engine version here.
|
|
||||||
Simply copy the `Initialized sos!engine v<version> (commit <commit>-<branch>, dirty <dirty>) in <inittime>ms` message here.
|
|
||||||
placeholder: "Example: sos!engine v1-alpha4 (commit 05b9644eba5263809b6655dabb92669523a95805-develop, dirty true)"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: "dropdown"
|
|
||||||
id: "jvm-java"
|
|
||||||
attributes:
|
|
||||||
label: "Java version"
|
|
||||||
description: "Which Java version is your application compiled against?"
|
|
||||||
options:
|
|
||||||
- "20 and lower"
|
|
||||||
- "21"
|
|
||||||
- "22"
|
|
||||||
- "23"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: "input"
|
|
||||||
id: "os"
|
|
||||||
attributes:
|
|
||||||
label: "Operating system"
|
|
||||||
description: "Name the operating system, version (if applicable) and CPU architecture the error occurs on. This may be some Linux distribution, Android or Windoze on `amd64`/`aarch64`/`ppc64`/etc.."
|
|
||||||
placeholder: "Example: Debian trixie (amd64)"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: "markdown"
|
|
||||||
id: "text-tysm"
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Thank you for filling out this help form.
|
|
||||||
Please check your answers for *mistaeks* or sensitive information before sending this help request.
|
|
|
@ -1,12 +0,0 @@
|
||||||
---
|
|
||||||
name: 'Pull Request'
|
|
||||||
about: 'Submit a pull request.'
|
|
||||||
title: 'new: '
|
|
||||||
ref: 'develop'
|
|
||||||
labels:
|
|
||||||
- 'PRStatus/Open'
|
|
||||||
- 'PR/New'
|
|
||||||
---
|
|
||||||
<!--
|
|
||||||
Please list your changes here.
|
|
||||||
-->
|
|
|
@ -1,104 +0,0 @@
|
||||||
name: "PRs & Pushes"
|
|
||||||
|
|
||||||
on:
|
|
||||||
- push
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: git.staropensource.de/infrastructure/actions-docker:java
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: https://code.forgejo.org/actions/checkout@v4
|
|
||||||
- name: Restore Gradle cache
|
|
||||||
uses: actions/cache/restore@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.gradle/caches
|
|
||||||
~/.gradle/wrapper
|
|
||||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
||||||
restore-keys: |
|
|
||||||
gradle-${{ runner.os }}-
|
|
||||||
- name: Run tests
|
|
||||||
run: ./gradlew --no-daemon -Pjava.skipToolchainSpecification=true test
|
|
||||||
- name: Save Gradle cache
|
|
||||||
uses: actions/cache/save@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.gradle/caches
|
|
||||||
~/.gradle/wrapper
|
|
||||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
||||||
restore-keys: |
|
|
||||||
gradle-${{ runner.os }}-
|
|
||||||
build-jars:
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: git.staropensource.de/infrastructure/actions-docker:java
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: https://code.forgejo.org/actions/checkout@v4
|
|
||||||
- name: Restore Gradle cache
|
|
||||||
uses: actions/cache/restore@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.gradle/caches
|
|
||||||
~/.gradle/wrapper
|
|
||||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
||||||
restore-keys: |
|
|
||||||
gradle-${{ runner.os }}-
|
|
||||||
- name: Compile
|
|
||||||
run: ./gradlew --no-daemon -Pjava.skipToolchainSpecification=true jar javadocJar sourcesJar
|
|
||||||
- name: Save Gradle cache
|
|
||||||
uses: actions/cache/save@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.gradle/caches
|
|
||||||
~/.gradle/wrapper
|
|
||||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
||||||
restore-keys: |
|
|
||||||
gradle-${{ runner.os }}-
|
|
||||||
- name: Upload JARs
|
|
||||||
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: jars
|
|
||||||
path: |
|
|
||||||
**/build/libs/*.jar
|
|
||||||
if-no-files-found: error
|
|
||||||
build-apidoc:
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: git.staropensource.de/infrastructure/actions-docker:java
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: https://code.forgejo.org/actions/checkout@v4
|
|
||||||
- name: Restore Gradle cache
|
|
||||||
uses: actions/cache/restore@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.gradle/caches
|
|
||||||
~/.gradle/wrapper
|
|
||||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
||||||
restore-keys: |
|
|
||||||
gradle-${{ runner.os }}-
|
|
||||||
- name: Compile
|
|
||||||
run: ./gradlew --no-daemon -Pjava.skipToolchainSpecification=true dokkaHtml dokkaHtmlMultiModule
|
|
||||||
- name: Save Gradle cache
|
|
||||||
uses: actions/cache/save@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.gradle/caches
|
|
||||||
~/.gradle/wrapper
|
|
||||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
||||||
restore-keys: |
|
|
||||||
gradle-${{ runner.os }}-
|
|
||||||
- name: Upload JARs
|
|
||||||
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: apidoc
|
|
||||||
path: |
|
|
||||||
build/dokka/htmlMultiModule
|
|
||||||
**/build/dokka/html
|
|
||||||
**/build/libs/*.jar
|
|
||||||
if-no-files-found: error
|
|
19
.gitattributes
vendored
19
.gitattributes
vendored
|
@ -1,19 +0,0 @@
|
||||||
# Linguist metadata
|
|
||||||
# -> Documentation
|
|
||||||
*.md linguist-documentation
|
|
||||||
docs/* linguist-documentation
|
|
||||||
# -> Licensing information
|
|
||||||
COPYING linguist-documentation
|
|
||||||
LICENSE linguist-documentation
|
|
||||||
# -> HTML, CSS, etc.
|
|
||||||
*.html linguist-documentation
|
|
||||||
*.css linguist-documentation
|
|
||||||
# -> Configuration
|
|
||||||
*.properties linguist-configuration
|
|
||||||
*.gradle linguist-configuration
|
|
||||||
|
|
||||||
# Line endings
|
|
||||||
/gradlew text eol=lf
|
|
||||||
*.bat text eol=crlf
|
|
||||||
*.cmd text oel=crlf
|
|
||||||
*.jar binary
|
|
16
.gitignore
vendored
16
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
||||||
# Gradle
|
### Gradle ###
|
||||||
.gradle
|
.gradle
|
||||||
build/
|
build/
|
||||||
run/
|
run/
|
||||||
|
@ -6,7 +6,7 @@ run/
|
||||||
!**/src/main/**/build/
|
!**/src/main/**/build/
|
||||||
!**/src/test/**/build/
|
!**/src/test/**/build/
|
||||||
|
|
||||||
# IntelliJ IDEA
|
### IntelliJ IDEA ###
|
||||||
.idea/modules.xml
|
.idea/modules.xml
|
||||||
.idea/jarRepositories.xml
|
.idea/jarRepositories.xml
|
||||||
.idea/compiler.xml
|
.idea/compiler.xml
|
||||||
|
@ -19,7 +19,7 @@ out/
|
||||||
!**/src/main/**/out/
|
!**/src/main/**/out/
|
||||||
!**/src/test/**/out/
|
!**/src/test/**/out/
|
||||||
|
|
||||||
# Eclipse
|
### Eclipse ###
|
||||||
.apt_generated
|
.apt_generated
|
||||||
.classpath
|
.classpath
|
||||||
.factorypath
|
.factorypath
|
||||||
|
@ -31,18 +31,14 @@ bin/
|
||||||
!**/src/main/**/bin/
|
!**/src/main/**/bin/
|
||||||
!**/src/test/**/bin/
|
!**/src/test/**/bin/
|
||||||
|
|
||||||
# NetBeans
|
### NetBeans ###
|
||||||
/nbproject/private/
|
/nbproject/private/
|
||||||
/nbbuild/
|
/nbbuild/
|
||||||
/nbdist/
|
/nbdist/
|
||||||
/.nb-gradle/
|
/.nb-gradle/
|
||||||
|
|
||||||
# Visual Studio Code
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
# macOS
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# Java & Kotlin
|
|
||||||
hs_err_pid*.log
|
|
||||||
.kotlin
|
|
||||||
|
|
4
.idea/copyright/sos_engine.xml
generated
4
.idea/copyright/sos_engine.xml
generated
|
@ -1,7 +1,7 @@
|
||||||
<component name="CopyrightManager">
|
<component name="CopyrightManager">
|
||||||
<copyright>
|
<copyright>
|
||||||
<option name="allowReplaceRegexp" value="Copyright .* The StarOpenSource Engine Authors" />
|
<option name="allowReplaceRegexp" value="Copyright .* The StarOpenSource Engine Contributors" />
|
||||||
<option name="notice" value="STAROPENSOURCE ENGINE SOURCE FILE Copyright (c) &#36;today.year The StarOpenSource Engine Authors Licensed under the GNU General Public License v3. This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU 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 Contributors 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="myName" value="sos!engine" />
|
<option name="myName" value="sos!engine" />
|
||||||
</copyright>
|
</copyright>
|
||||||
</component>
|
</component>
|
191
.idea/workspace.xml
generated
Normal file
191
.idea/workspace.xml
generated
Normal file
|
@ -0,0 +1,191 @@
|
||||||
|
<?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>
|
661
COPYING
Normal file
661
COPYING
Normal file
|
@ -0,0 +1,661 @@
|
||||||
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights
|
||||||
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified source code becomes available
|
||||||
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and
|
||||||
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
|
this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
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/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer
|
||||||
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for the
|
||||||
|
specific requirements.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
698
LICENSE
698
LICENSE
|
@ -1,674 +1,24 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
The software in this package is distributed under the GNU Affero
|
||||||
Version 3, 29 June 2007
|
General Public License (with a special exception described below).
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
A copy of the GNU Affero General Public License (AGPL) is included in this distribution,
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
in the file COPYING. If you do not have the source code, it is available at:
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
https://git.staropensource.de/StarOpenSource/Engine
|
||||||
Preamble
|
|
||||||
|
Linking this library statically or dynamically with other modules is
|
||||||
The GNU General Public License is a free, copyleft license for
|
making a combined work based on this library. Thus, the terms and
|
||||||
software and other kinds of works.
|
conditions of the GNU Affero General Public License cover the whole
|
||||||
|
combination.
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
As a special exception, the copyright holders of this library give you
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
permission to link this library with independent modules to produce an
|
||||||
share and change all versions of a program--to make sure it remains free
|
executable, regardless of the license terms of these independent
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
modules, and to copy and distribute the resulting executable under
|
||||||
GNU General Public License for most of our software; it applies also to
|
terms of your choice, provided that you also meet, for each linked
|
||||||
any other work released this way by its authors. You can apply it to
|
independent module, the terms and conditions of the license of that
|
||||||
your programs, too.
|
module. An independent module is a module which is not derived from
|
||||||
|
or based on this library. If you modify this library, you may extend
|
||||||
When we speak of free software, we are referring to freedom, not
|
this exception to your version of the library, but you are not
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
obligated to do so. If you do not wish to do so, delete this
|
||||||
have the freedom to distribute copies of free software (and charge for
|
exception statement from your version.
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
||||||
|
|
123
README.md
123
README.md
|
@ -1,72 +1,67 @@
|
||||||
<div align="center">
|
# StarOpenSource Engine
|
||||||
<a href="https://git.staropensource.de/StarOpenSource/Engine">
|
The StarOpenSource Engine (or sos!engine for short) is a modular, extensible and easy to use Java game and application engine.
|
||||||
<img alt="StarOpenSource Engine" width="856px" height="auto" src="https://fs.staropensource.de/imgs/branding/engine/v2/extended-brand.png"/>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<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>
|
## WARNING
|
||||||
</div>
|
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.
|
||||||
|
|
||||||
# Index
|
## Index
|
||||||
- [About](#about)
|
- [About](#about)
|
||||||
|
- [... the engine](#-the-engine)
|
||||||
|
- [... the repository](#-the-repository)
|
||||||
|
- [Priorities](#priorities)
|
||||||
|
- [Documentation](#documentation)
|
||||||
- [Contributing](#contributing)
|
- [Contributing](#contributing)
|
||||||
- [Gradle properties](#gradle-properties)
|
- [Requirements](#requirements)
|
||||||
- [Skipping the Java toolchain specification](#skipping-the-java-toolchain-specification)
|
- [What IDE to use?](#what-ide-to-use)
|
||||||
- [JVM arguments](#jvm-arguments)
|
- [Code style](#code-style)
|
||||||
- [`jvm.logGC`](#jvm-loggc)
|
- [Pull request guidelines](#pull-request-guidelines)
|
||||||
- [`jvm.logJITandAOT`](#jvm-logjitandaot)
|
- [Making your first contribution](#making-your-first-contribution)
|
||||||
- [`jvm.garbageCollector`](#jvm-garbagecollector)
|
|
||||||
|
|
||||||
# About
|
## About
|
||||||
The StarOpenSource Engine is a game and application
|
### ... the engine
|
||||||
framework written in Kotlin, primarily targeting the JVM.
|
The StarOpenSource Engine is a modular and extensible framework for building applications and games written in the Java programming language.
|
||||||
The engine is designed to be modular, configurable
|
The engine consists of various subsystems, each separate and responsible for only a few closely-related things.
|
||||||
and extensible while being lightweight and fast.
|
\
|
||||||
|
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.
|
||||||
|
|
||||||
In this repository you can find the
|
- configurable
|
||||||
[core engine](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/base), official
|
- [do one thing and do it well](https://en.wikipedia.org/wiki/Unix_philosophy) (subsystems concept)
|
||||||
subsystems, [their documentation (TODO)](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/docs)
|
- fast
|
||||||
and [some miscellaneous files](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/dist).
|
- few runtime dependencies (note: we will cut down on some of them during development)
|
||||||
|
- modular & extensible
|
||||||
|
- small & lightweight
|
||||||
|
|
||||||
# Documentation
|
## Documentation
|
||||||
The documentation is not yet available. We will create one soon.
|
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
|
## Contributing
|
||||||
TODO, waiting for [Infrastructure/website-docs#1](https://git.staropensource.de/Infrastructure/website-docs/issues/1). Sorry :c
|
### Requirements
|
||||||
|
You need the following things to be able to contribute code to the StarOpenSource Engine:
|
||||||
# Gradle properties
|
- knowledge of Java
|
||||||
You can modify Gradle's behaviour by passing one or multiple *project properties*.
|
- knowledge about the internals of engine
|
||||||
These are read by our `build.gradle.kts` files and actively change the build behaviour.
|
### What IDE to use?
|
||||||
You can pass one by adding `-P<property>=<value>` to your Gradle command line.
|
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
|
||||||
## Skipping the Java toolchain specification
|
We recommend looking at existing classes and code for a good understanding on how we'd like code to be written.
|
||||||
Setting `java.skipToolchainSpecification` to `true` disables the
|
Here's a quick rundown on the most important things:
|
||||||
JDK version check & download step performed by Gradle. Useful when
|
- Document EVERYTHING. Every single class, field and method, even if private.
|
||||||
automating things or if you're facing the `No locally installed
|
- Make comments about your code, unless it's extremly simple and easy to understand.
|
||||||
toolchains match and toolchain download repositories have not
|
- Make sure to add and update `@since` in javadoc comments (update if the javadoc changes a good amount).
|
||||||
been defined` error.
|
- 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 seperate it.
|
||||||
Please note however that you should only pass this option if your
|
- Files must end with a newline or cats might get angry.
|
||||||
default, installed JDK is matching Java 21 or you will experience
|
- Use your brain.
|
||||||
issues.
|
### Pull request guidelines
|
||||||
|
Before creating a pull request, make sure you've:
|
||||||
## JVM arguments
|
- created tests for the functionality you've added, changed or removed (if applicable),
|
||||||
You can pass the following arguments to modify the
|
- tested your changes,
|
||||||
behaviour of JVMs used for executing projects.
|
- made sure that everything works,
|
||||||
### `jvm.logGC`
|
- is compatible with other code in the monorepo, and
|
||||||
Enables garbage collection logging.
|
- is compatible with other applications. If not, tell us in your pull request description.
|
||||||
|
### Making your first contribution
|
||||||
Takes effect if set to `true`.
|
TODO
|
||||||
### `jvm.logJITandAOT`
|
|
||||||
Enables logging about [JIT](https://en.wikipedia.org/wiki/Just-in-time_compilation)
|
|
||||||
and [AOT](https://en.wikipedia.org/wiki/Ahead-of-time_compilation) code compilation.
|
|
||||||
|
|
||||||
Takes effect if set to `true`.
|
|
||||||
### `jvm.garbageCollector`
|
|
||||||
Sets the garbage collector to use.
|
|
||||||
Requires the specified garbage collector to
|
|
||||||
be built into the JVM (some aren't compiled
|
|
||||||
by default).
|
|
||||||
|
|
||||||
Accepts [`epsilon`](https://openjdk.org/jeps/318),
|
|
||||||
[`serial`](https://docs.oracle.com/en/java/javase/21/gctuning/available-collectors.html#GUID-45794DA6-AB96-4856-A96D-FDE5F7DEE498)
|
|
||||||
and [`g1`](https://en.wikipedia.org/wiki/Garbage-first_collector).
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
# `/ansi`
|
|
||||||
The subsystem which provides a nice formatter.
|
|
133
ansi/build.gradle
Normal file
133
ansi/build.gradle
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Project dependencies
|
||||||
|
dependencies {
|
||||||
|
// -> Runtime <-
|
||||||
|
// Lombok
|
||||||
|
compileOnly("org.projectlombok:lombok:${dependencyLombok}")
|
||||||
|
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
|
||||||
|
|
||||||
|
// JetBrains Annotations
|
||||||
|
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
|
||||||
|
|
||||||
|
// ANSI support
|
||||||
|
implementation("org.fusesource.jansi:jansi:${dependencyJansi}")
|
||||||
|
|
||||||
|
// Project
|
||||||
|
implementation(project(":base"))
|
||||||
|
|
||||||
|
// -> 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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") // 你好
|
||||||
|
|
||||||
|
setJFlags([
|
||||||
|
"-Duser.language=en_US" // See above
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unit testing configuration
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
|
||||||
|
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/sosengine")
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
|
||||||
* Copyright (c) 2025 The StarOpenSource Engine Authors
|
|
||||||
* Licensed under the GNU General Public License v3.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Plugins
|
|
||||||
plugins {
|
|
||||||
id("engine.generic")
|
|
||||||
id("engine.generic.properties")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dependencies
|
|
||||||
dependencies {
|
|
||||||
// sos!engine
|
|
||||||
implementation(project(":base"))
|
|
||||||
}
|
|
1
ansi/gradle
Symbolic link
1
ansi/gradle
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../gradle
|
1
ansi/gradlew
vendored
Symbolic link
1
ansi/gradlew
vendored
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../gradlew
|
1
ansi/gradlew.bat
vendored
Symbolic link
1
ansi/gradlew.bat
vendored
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../gradlew.bat
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.ansi;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.EngineConfiguration;
|
||||||
|
import de.staropensource.sosengine.base.classes.LoggerImplementation;
|
||||||
|
import de.staropensource.sosengine.base.logging.Logger;
|
||||||
|
import de.staropensource.sosengine.base.types.logging.LogLevel;
|
||||||
|
import org.fusesource.jansi.Ansi;
|
||||||
|
import org.fusesource.jansi.AnsiConsole;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints colored log output using the Jansi library.
|
||||||
|
*
|
||||||
|
* @see Logger
|
||||||
|
* @see LoggerImplementation
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public class AnsiLoggerImplementation implements LoggerImplementation {
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
public AnsiLoggerImplementation() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public @NotNull String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
||||||
|
return format; // No modifications necessary
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public @NotNull String postPlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
||||||
|
return format; // No modifications necessary
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings({ "resource" }) // Using try-with-resources will cause issues here
|
||||||
|
public void print(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
||||||
|
// Convert to Ansi
|
||||||
|
Ansi output = new AnsiShortcodeConverter(format, true).getAnsi();
|
||||||
|
|
||||||
|
// Print message
|
||||||
|
if (level == LogLevel.ERROR || level == LogLevel.CRASH)
|
||||||
|
if (EngineConfiguration.getInstance().isLoggerForceStandardOutput())
|
||||||
|
AnsiConsole.out().println(output);
|
||||||
|
else
|
||||||
|
AnsiConsole.err().println(output);
|
||||||
|
else
|
||||||
|
AnsiConsole.out().println(output);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.ansi;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.ShortcodeParserSkeleton;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.ParserException;
|
||||||
|
import org.fusesource.jansi.Ansi;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts shortcodes such as {@code <bold>} or {@code <blink>} into a usable {@link Ansi} escape sequence.
|
||||||
|
*
|
||||||
|
* @see ShortcodeParserSkeleton
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public final class AnsiShortcodeConverter extends ShortcodeParserSkeleton {
|
||||||
|
/**
|
||||||
|
* Constructs 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 AnsiShortcodeConverter(@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();
|
||||||
|
|
||||||
|
for (String component : components)
|
||||||
|
if (component.equals("RESET"))
|
||||||
|
ansi.a(Ansi.Attribute.RESET);
|
||||||
|
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"))
|
||||||
|
ansi.a(Ansi.Attribute.BLINK_SLOW);
|
||||||
|
else if (component.startsWith("ATTRIBUTE:BOLD"))
|
||||||
|
ansi.a(Ansi.Attribute.INTENSITY_BOLD);
|
||||||
|
else if (component.startsWith("ATTRIBUTE:ITALIC"))
|
||||||
|
ansi.a(Ansi.Attribute.ITALIC);
|
||||||
|
else if (component.startsWith("ATTRIBUTE:STRIKETHROUGH"))
|
||||||
|
ansi.a(Ansi.Attribute.STRIKETHROUGH_ON);
|
||||||
|
else if (component.startsWith("ATTRIBUTE:UNDERLINE"))
|
||||||
|
ansi.a(Ansi.Attribute.UNDERLINE);
|
||||||
|
else if (component.startsWith("ATTRIBUTE:NEGATIVE"))
|
||||||
|
ansi.a(Ansi.Attribute.NEGATIVE_ON);
|
||||||
|
|
||||||
|
return ansi;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.ansi;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.annotations.EngineSubsystem;
|
||||||
|
import de.staropensource.sosengine.base.classes.SubsystemClass;
|
||||||
|
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||||
|
import de.staropensource.sosengine.base.data.versioning.StarOpenSourceVersioningSystem;
|
||||||
|
import de.staropensource.sosengine.base.logging.Logger;
|
||||||
|
import de.staropensource.sosengine.base.types.DependencyVector;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main object for the ANSI Compatibility subsystem.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@EngineSubsystem
|
||||||
|
@SuppressWarnings({ "unused", "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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs 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() {
|
||||||
|
Logger.setLoggerImplementation(new AnsiLoggerImplementation());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public @NotNull DependencyVector getDependencyVector() {
|
||||||
|
return new DependencyVector("ansi", StarOpenSourceVersioningSystem.class, EngineInformation.getVersioningString());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
* Copyright (c) 2024 The StarOpenSource Engine Authors
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
* Licensed under the GNU Affero General Public License v3
|
* 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
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -18,8 +17,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Dependencies
|
/**
|
||||||
dependencies {
|
* Contains the ANSI subsystem code.
|
||||||
// sos!engine
|
*/
|
||||||
implementation(project(":base"))
|
package de.staropensource.sosengine.ansi;
|
||||||
}
|
|
27
ansi/src/main/java/module-info.java
Normal file
27
ansi/src/main/java/module-info.java
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
// -> Common stuff <-
|
||||||
|
requires transitive static lombok;
|
||||||
|
requires transitive org.jetbrains.annotations;
|
||||||
|
|
||||||
|
// -> Subystem-specific dependencies <-
|
||||||
|
requires org.fusesource.jansi;
|
||||||
|
|
||||||
|
// API access
|
||||||
|
exports de.staropensource.sosengine.ansi;
|
||||||
|
|
||||||
|
// Reflection access
|
||||||
|
opens de.staropensource.sosengine.ansi;
|
||||||
|
}
|
23
ansi/src/main/javadoc/overview.html
Normal file
23
ansi/src/main/javadoc/overview.html
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<!--
|
||||||
|
~ STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
~ Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
~ 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
ansi/src/main/javadoc/theme.css
Symbolic link
1
ansi/src/main/javadoc/theme.css
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../../../src/main/javadoc/theme.css
|
|
@ -1,146 +0,0 @@
|
||||||
/*
|
|
||||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
|
||||||
* Copyright (c) 2025 The StarOpenSource Engine Authors
|
|
||||||
* Licensed under the GNU General Public License v3.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.staropensource.engine.ansi
|
|
||||||
|
|
||||||
import de.staropensource.engine.ansi.AnsiSubsystem.Companion.logger
|
|
||||||
import de.staropensource.engine.base.implementable.formatter.TwoCycleFormatterImpl
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Formats a string using ANSI
|
|
||||||
* escape sequences.
|
|
||||||
*
|
|
||||||
* @constructor Initializes this formatter
|
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
|
||||||
class AnsiFormatter : TwoCycleFormatterImpl() {
|
|
||||||
/**
|
|
||||||
* Companion object of [AnsiFormatter].
|
|
||||||
*
|
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
|
||||||
companion object {
|
|
||||||
/**
|
|
||||||
* The `ESC` character.
|
|
||||||
*
|
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
|
||||||
const val ESCAPE: Char = '\u001b'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Global instance of [AnsiFormatter].
|
|
||||||
*
|
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
|
||||||
@JvmStatic
|
|
||||||
val instance: AnsiFormatter = AnsiFormatter()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("CyclomaticComplexMethod")
|
|
||||||
override fun format(messageComponents: Array<String>): String = buildString {
|
|
||||||
val enabledTags: MutableSet<String> = mutableSetOf()
|
|
||||||
var lastColor: String? = null
|
|
||||||
var modifiers: String = ""
|
|
||||||
|
|
||||||
for (component: String in messageComponents)
|
|
||||||
// Reset
|
|
||||||
if (component == "RESET") {
|
|
||||||
append("${ESCAPE}[0;39;49m")
|
|
||||||
modifiers = ""
|
|
||||||
lastColor = null
|
|
||||||
enabledTags.clear()
|
|
||||||
|
|
||||||
// Text
|
|
||||||
} else if (component.startsWith("TEXT:")) {
|
|
||||||
append(component.substring(5))
|
|
||||||
|
|
||||||
// Attributes
|
|
||||||
} else if (component.startsWith("ATTRIBUTE:")) {
|
|
||||||
try {
|
|
||||||
if (!enabledTags.contains(component)) {
|
|
||||||
modifiers = attribute(component.substring(10), modifiers)!!
|
|
||||||
enabledTags.add(component)
|
|
||||||
if (lastColor != null)
|
|
||||||
append(color(lastColor, modifiers))
|
|
||||||
}
|
|
||||||
} catch (_: NullPointerException) {
|
|
||||||
logger.crash("Internal inconsistency: Unknown attribute '${component.substring(10)}' (component '${component}')")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Colors
|
|
||||||
} else if (component.startsWith("COLOR:")) {
|
|
||||||
try {
|
|
||||||
lastColor = component.substring(6)
|
|
||||||
append(color(lastColor, modifiers)!!)
|
|
||||||
} catch (_: NullPointerException) {
|
|
||||||
logger.crash("Internal inconsistency: Unknown color '${component.substring(6)}' (component '${component}')")
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
logger.crash("Internal inconsistency: Unknown component '${component}'")
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the matching ANSI color code.
|
|
||||||
*
|
|
||||||
* @param color color to return
|
|
||||||
* @return ANSI color code
|
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
|
||||||
@Suppress("CyclomaticComplexMethod")
|
|
||||||
private fun color(color: String, modifiers: String): String? {
|
|
||||||
var colorCode: String = "${ESCAPE}[${modifiers}38;2;"
|
|
||||||
|
|
||||||
when (color) {
|
|
||||||
"WHITE" -> colorCode += "255;255;255"
|
|
||||||
"BLACK" -> colorCode += "0;0;0"
|
|
||||||
"GRAY" -> colorCode += "150;150;150"
|
|
||||||
"YELLOW" -> colorCode += "204;232;69"
|
|
||||||
"GREEN" -> colorCode += "53;224;63"
|
|
||||||
"CYAN" -> colorCode += "36;227;233"
|
|
||||||
"LIGHT_BLUE" -> colorCode += "7;161;247"
|
|
||||||
"BLUE" -> colorCode += "7;100;247"
|
|
||||||
"PURPLE" -> colorCode += "86;4;219"
|
|
||||||
"MAGENTA" -> colorCode += "164;37;237"
|
|
||||||
"PINK" -> colorCode += "215;88;214"
|
|
||||||
"RED" -> colorCode += "214;5;50"
|
|
||||||
"ORANGE" -> colorCode += "228;148;55"
|
|
||||||
else -> return null
|
|
||||||
}
|
|
||||||
|
|
||||||
colorCode += "m"
|
|
||||||
|
|
||||||
return colorCode
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolves the attribute and
|
|
||||||
* returns the matching modifiers.
|
|
||||||
*
|
|
||||||
* @param attribute attribute to resolve
|
|
||||||
* @return modifiers
|
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
|
||||||
private fun attribute(attribute: String, modifiers: String): String? = when (attribute) {
|
|
||||||
"BOLD" -> modifiers.plus("1;")
|
|
||||||
"ITALIC" -> modifiers.plus("3;")
|
|
||||||
"UNDERLINE" -> modifiers.plus("4;")
|
|
||||||
"STRIKETHROUGH" -> modifiers.plus("9;")
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,114 +0,0 @@
|
||||||
/*
|
|
||||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
|
||||||
* Copyright (c) 2025 The StarOpenSource Engine Authors
|
|
||||||
* Licensed under the GNU General Public License v3.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU 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.Engine
|
|
||||||
import de.staropensource.engine.base.implementable.Subsystem
|
|
||||||
import de.staropensource.engine.base.logging.Logger
|
|
||||||
import de.staropensource.engine.base.type.logging.ChannelSettings
|
|
||||||
import de.staropensource.engine.base.utility.dnihbd.BuildInformation
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The ANSI subsystem.
|
|
||||||
*
|
|
||||||
* @constructor Initializes this subsystem
|
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
|
||||||
class AnsiSubsystem : Subsystem() {
|
|
||||||
/**
|
|
||||||
* Companion object of [AnsiSubsystem].
|
|
||||||
*
|
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
|
||||||
companion object {
|
|
||||||
/**
|
|
||||||
* Contains the [Logger] instance of the ANSI subsystem.
|
|
||||||
*
|
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
|
||||||
@JvmStatic
|
|
||||||
internal val logger: Logger = Logger(channel = "engine-ansi")
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains a [BuildInformation] instance
|
|
||||||
* providing information about the running
|
|
||||||
* ANSI subsystem build.
|
|
||||||
*
|
|
||||||
* @see BuildInformation
|
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
|
||||||
@JvmStatic
|
|
||||||
var info: BuildInformation? = null
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers this subsystem.
|
|
||||||
*
|
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
|
||||||
@JvmStatic
|
|
||||||
fun register() {
|
|
||||||
if (!Engine.getSubsystems().map { item -> item::class }.contains(AnsiSubsystem::class))
|
|
||||||
Engine.registerSubsystem(AnsiSubsystem())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -----> Metadata
|
|
||||||
override fun getName(): String = "ANSI"
|
|
||||||
override fun getVersion(): String = info?.versionString(semver = false) ?: "unknown"
|
|
||||||
|
|
||||||
|
|
||||||
// -----> Lifecycle
|
|
||||||
override fun initialize() {
|
|
||||||
info = BuildInformation("sosengine-ansi")
|
|
||||||
|
|
||||||
if (Engine.info!!.versionString(semver = false) != info!!.versionString(semver = false))
|
|
||||||
logger.crash("""
|
|
||||||
The version of the core engine and the ANSI subsystem differs.
|
|
||||||
Engine: ${Engine.info!!.versionString(semver = false)}
|
|
||||||
ANSI subsystem: ${info!!.versionString(semver = false)}
|
|
||||||
""".trimIndent().trimEnd())
|
|
||||||
|
|
||||||
if (Engine.info!!.gitCommitIdentifierLong != info!!.gitCommitIdentifierLong)
|
|
||||||
logger.crash("""
|
|
||||||
The commit id of the core engine and the ANSI subsystem differs.
|
|
||||||
Engine: ${Engine.info!!.gitCommitIdentifierLong}
|
|
||||||
ANSI subsystem: ${info!!.gitCommitIdentifierLong}
|
|
||||||
""".trimIndent().trimEnd())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun shutdown(final: Boolean, fatalCrash: Boolean) {
|
|
||||||
info = null
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -----> Miscellaneous
|
|
||||||
/**
|
|
||||||
* Makes the [AnsiFormatter]
|
|
||||||
* the default log formatter.
|
|
||||||
*
|
|
||||||
* @return this instance
|
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
|
||||||
fun makeFormatterDefault(): AnsiSubsystem {
|
|
||||||
ChannelSettings.global = ChannelSettings.global.copy(formatter = AnsiFormatter.instance)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
}
|
|
2
ansi/src/main/resources/.gitignore
vendored
2
ansi/src/main/resources/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
sosengine-*-git.properties
|
|
||||||
sosengine-*-gradle.properties
|
|
1
base/.gitignore
vendored
Normal file
1
base/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
src/main/resources/git.properties
|
|
@ -1,2 +1,2 @@
|
||||||
# `/base`
|
# The `base` subsystem
|
||||||
The core engine. The grand piece of code which makes everything work.
|
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.
|
||||||
|
|
172
base/build.gradle
Normal file
172
base/build.gradle
Normal file
|
@ -0,0 +1,172 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Project 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// 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") // 你好
|
||||||
|
|
||||||
|
setJFlags([
|
||||||
|
"-Duser.language=en_US" // See above
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unit testing configuration
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
|
||||||
|
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/sosengine")
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
|
||||||
* Copyright (c) 2025 The StarOpenSource Engine Authors
|
|
||||||
* Licensed under the GNU General Public License v3.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Plugins
|
|
||||||
plugins {
|
|
||||||
id("engine.generic")
|
|
||||||
id("engine.generic.properties")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dependencies
|
|
||||||
dependencies {
|
|
||||||
// OSHI
|
|
||||||
implementation("${property("dependencyOshiIdentifier") as String}:${property("dependencyOshiVersion") as String}")
|
|
||||||
}
|
|
1
base/gradle
Symbolic link
1
base/gradle
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../gradle
|
1
base/gradlew
vendored
Symbolic link
1
base/gradlew
vendored
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../gradlew
|
1
base/gradlew.bat
vendored
Symbolic link
1
base/gradlew.bat
vendored
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../gradlew.bat
|
472
base/src/main/java/de/staropensource/sosengine/base/Engine.java
Normal file
472
base/src/main/java/de/staropensource/sosengine/base/Engine.java
Normal file
|
@ -0,0 +1,472 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.annotations.EngineSubsystem;
|
||||||
|
import de.staropensource.sosengine.base.classes.ShutdownHandler;
|
||||||
|
import de.staropensource.sosengine.base.classes.SubsystemClass;
|
||||||
|
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||||
|
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||||
|
import de.staropensource.sosengine.base.data.information.JvmInformation;
|
||||||
|
import de.staropensource.sosengine.base.data.versioning.StarOpenSourceVersioningSystem;
|
||||||
|
import de.staropensource.sosengine.base.events.*;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.NoAccessException;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.dependency.UnmetDependenciesException;
|
||||||
|
import de.staropensource.sosengine.base.internal.events.InternalEngineShutdownEvent;
|
||||||
|
import de.staropensource.sosengine.base.internal.types.DependencySubsystemVector;
|
||||||
|
import de.staropensource.sosengine.base.logging.CrashHandler;
|
||||||
|
import de.staropensource.sosengine.base.logging.Logger;
|
||||||
|
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||||
|
import de.staropensource.sosengine.base.types.DependencyVector;
|
||||||
|
import de.staropensource.sosengine.base.types.EngineState;
|
||||||
|
import de.staropensource.sosengine.base.types.immutable.ImmutableLinkedList;
|
||||||
|
import de.staropensource.sosengine.base.utility.DependencyResolver;
|
||||||
|
import de.staropensource.sosengine.base.utility.Miscellaneous;
|
||||||
|
import de.staropensource.sosengine.base.utility.PlaceholderEngine;
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
@EngineSubsystem
|
||||||
|
@SuppressWarnings({ "unused", "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 {@link LoggerInstance} for this instance.
|
||||||
|
*
|
||||||
|
* @see LoggerInstance
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private static LoggerInstance logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the engine state.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the engine state.
|
||||||
|
*
|
||||||
|
* @return shutdown state
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private @NotNull EngineState state = EngineState.UNKNOWN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
@Setter
|
||||||
|
private @NotNull ShutdownHandler shutdownHandler = new Engine.JvmShutdownHandler();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 ImmutableLinkedList<@NotNull DependencySubsystemVector> subsystems = new ImmutableLinkedList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the StarOpenSource Engine.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public Engine() {
|
||||||
|
if (instance == null)
|
||||||
|
instance = this;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
long initTime = Miscellaneous.measureExecutionTime(() -> {
|
||||||
|
state = EngineState.STARTUP;
|
||||||
|
|
||||||
|
// Initialize engine configuration
|
||||||
|
new EngineConfiguration();
|
||||||
|
EngineConfiguration.getInstance().loadConfiguration();
|
||||||
|
|
||||||
|
initializeClasses(); // Initialize classes
|
||||||
|
populateCrashContent(); // Populate crash content
|
||||||
|
cacheEvents(); // Cache event listeners
|
||||||
|
startThreads(); // Start threads
|
||||||
|
|
||||||
|
// Set the logger instance
|
||||||
|
logger = new LoggerInstance.Builder().setClazz(getClass()).setOrigin("ENGINE").setMetadata(EngineInformation.getVersioningCodename()).build();
|
||||||
|
|
||||||
|
// Perform automatic subsystem initialization
|
||||||
|
if (EngineConfiguration.getInstance().isOptimizeSubsystemInitialization()) {
|
||||||
|
collectSubsystems(); // Collect subsystems
|
||||||
|
|
||||||
|
// Initialize subsystems
|
||||||
|
try {
|
||||||
|
initializeSubsystems();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
logger.crash("Subsystem dependency resolution failed", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
state = EngineState.RUNNING;
|
||||||
|
logger.info("Initialized sos!engine %engine_version% (commit %engine_git_commit_id_long%-%engine_git_branch%, dirty %engine_git_dirty%) in " + initTime + "ms");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all classes.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private void initializeClasses() {
|
||||||
|
new PlaceholderEngine();
|
||||||
|
|
||||||
|
EngineInformation.updateVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method populates {@link CrashHandler#crashContent} with content.
|
||||||
|
*
|
||||||
|
* @see CrashHandler#getCrashContent()
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "ExtractMethodRecommender" })
|
||||||
|
private void populateCrashContent() {
|
||||||
|
// Issuer
|
||||||
|
Map<@NotNull String, @NotNull String> crashContentIssuer = new LinkedHashMap<>();
|
||||||
|
crashContentIssuer.put("Code part", "%issuer_origin%");
|
||||||
|
crashContentIssuer.put("Classpath", "%issuer_path%");
|
||||||
|
crashContentIssuer.put("Additional information", "%issuer_metadata%");
|
||||||
|
crashContentIssuer.put("Message", "%crash_message%");
|
||||||
|
|
||||||
|
// Engine -> Dependencies
|
||||||
|
LinkedList<@NotNull String> crashContentEngineDependencies = new LinkedList<>();
|
||||||
|
crashContentEngineDependencies.add("Subsystem 'base': Reflections: %engine_dependency_reflections%");
|
||||||
|
crashContentEngineDependencies.add("Subsystem 'ansi': Jansi: %engine_dependency_jansi%");
|
||||||
|
crashContentEngineDependencies.add("Subsystem 'slf4j-compat': SLF4J: %engine_dependency_slf4j%");
|
||||||
|
crashContentEngineDependencies.add("Subsystems 'glfw', 'opengl' & 'vulkan': LWJGL: %engine_dependency_lwjgl%");
|
||||||
|
// Engine -> *
|
||||||
|
Map<@NotNull String, @NotNull Object> crashContentEngine = new LinkedHashMap<>();
|
||||||
|
crashContentEngine.put("Version", "%engine_version%");
|
||||||
|
crashContentEngine.put("Dependencies", crashContentEngineDependencies);
|
||||||
|
|
||||||
|
// JVM -> Implementation
|
||||||
|
Map<@NotNull String, @NotNull String> crashContentJvmImplementation = new LinkedHashMap<>();
|
||||||
|
crashContentJvmImplementation.put("Name", "%jvm_implementation_name%");
|
||||||
|
crashContentJvmImplementation.put("Version", "%jvm_implementation_version%");
|
||||||
|
crashContentJvmImplementation.put("Vendor", "%jvm_implementation_vendor%");
|
||||||
|
// JVM -> *
|
||||||
|
Map<@NotNull String, @NotNull Object> crashContentJvm = new LinkedHashMap<>();
|
||||||
|
crashContentJvm.put("Java Version", "%jvm_java%");
|
||||||
|
crashContentJvm.put("Implementation", crashContentJvmImplementation);
|
||||||
|
crashContentJvm.put("Arguments", JvmInformation.getArguments());
|
||||||
|
|
||||||
|
// Operating system
|
||||||
|
Map<@NotNull String, @NotNull String> crashContentOS = new LinkedHashMap<>();
|
||||||
|
crashContentOS.put("Time", "%time_hour%:%time_minute%:%time_second% (%time_zone%, UNIX Epoch: %time_epoch%)");
|
||||||
|
crashContentOS.put("Date", "%date_day%.%date_month%.%date_year%");
|
||||||
|
|
||||||
|
// Add to crash handler
|
||||||
|
CrashHandler.getCrashContent().put("Issuer", crashContentIssuer);
|
||||||
|
CrashHandler.getCrashContent().put("Engine", crashContentEngine);
|
||||||
|
CrashHandler.getCrashContent().put("Java Virtual Machine", crashContentJvm);
|
||||||
|
CrashHandler.getCrashContent().put("Operating system", crashContentOS);
|
||||||
|
CrashHandler.getCrashContent().put("Stacktrace", "\n%stacktrace%");
|
||||||
|
CrashHandler.getCrashContent().put("Stacktrace for all threads", "\n%stacktrace_all%");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caches all base engine events.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private void cacheEvents() {
|
||||||
|
// Internal events
|
||||||
|
EventHelper.cacheEvent(InternalEngineShutdownEvent.class);
|
||||||
|
|
||||||
|
// General events
|
||||||
|
EventHelper.cacheEvent(EngineCrashEvent.class);
|
||||||
|
EventHelper.cacheEvent(EngineShutdownEvent.class);
|
||||||
|
EventHelper.cacheEvent(EngineSoftCrashEvent.class);
|
||||||
|
EventHelper.cacheEvent(LogEvent.class);
|
||||||
|
EventHelper.cacheEvent(ThrowableCatchEvent.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts engine threads.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
public void startThreads() {
|
||||||
|
Logger.startLoggingThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects all subsystems by their {@link EngineSubsystem} annotation.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
private void collectSubsystems() {
|
||||||
|
ArrayList<@NotNull DependencySubsystemVector> subsystemsMutable = new ArrayList<>();
|
||||||
|
|
||||||
|
// Scan entire classpath using the Reflections library
|
||||||
|
Reflections reflections = new Reflections(
|
||||||
|
new ConfigurationBuilder()
|
||||||
|
.setUrls(ClasspathHelper.forJavaClassPath())
|
||||||
|
.setScanners(Scanners.TypesAnnotated)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Get annotated methods
|
||||||
|
Set<@NotNull Class<?>> annotatedClasses = reflections.getTypesAnnotatedWith(EngineSubsystem.class);
|
||||||
|
|
||||||
|
// Initialize classes, get dependency vector and add to 'subsystemsMutable'
|
||||||
|
for (Class<?> clazz : annotatedClasses) {
|
||||||
|
try {
|
||||||
|
// Create new instance
|
||||||
|
Object initializedClassRaw = clazz.getDeclaredConstructor().newInstance();
|
||||||
|
SubsystemClass initializedClass = null;
|
||||||
|
|
||||||
|
// Check if class implements SubsystemMainClass
|
||||||
|
if (initializedClassRaw instanceof SubsystemClass subsystemInstance)
|
||||||
|
initializedClass = subsystemInstance;
|
||||||
|
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) {
|
||||||
|
logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Method invocation error", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update 'subsystems'
|
||||||
|
subsystems = new ImmutableLinkedList<>(subsystemsMutable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.addVectors(subsystems);
|
||||||
|
|
||||||
|
// Resolve dependencies and get order
|
||||||
|
logger.verb("Resolving subsystem dependencies");
|
||||||
|
try {
|
||||||
|
for (DependencyVector vector : resolver.resolve().getOrder()) // smol workaround
|
||||||
|
order.add((DependencySubsystemVector) vector);
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
if (throwable instanceof UnmetDependenciesException exception) {
|
||||||
|
Map<@NotNull DependencyVector, @NotNull String> unmetDependencies = exception.getUnmetDependencies();
|
||||||
|
StringBuilder list = new StringBuilder();
|
||||||
|
|
||||||
|
for (DependencyVector vector : unmetDependencies.keySet())
|
||||||
|
list.append("- ")
|
||||||
|
.append(vector.getIdentifier())
|
||||||
|
.append(": ")
|
||||||
|
.append(unmetDependencies.get(vector));
|
||||||
|
|
||||||
|
logger.crash("Found unresolved dependencies:" + list, throwable);
|
||||||
|
}
|
||||||
|
logger.crash("An error occurred trying to resolve subsystem dependencies: " + throwable.getClass().getName() + (throwable.getMessage() == null ? "" : ": " + throwable.getMessage()));
|
||||||
|
throw throwable;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize subsystems
|
||||||
|
logger.info("Initializing engine subsystems");
|
||||||
|
long initTime;
|
||||||
|
for (DependencySubsystemVector vector : subsystems) {
|
||||||
|
logger.diag("Initializing subsystem " + vector.getMainClass().getName() + " (" + vector.getMainClass().getClass().getName() + ")");
|
||||||
|
try {
|
||||||
|
initTime = Miscellaneous.measureExecutionTime(() -> vector.getMainClass().initializeSubsystem());
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
logger.crash("An error occurred trying to initialize subsystem " + vector.getMainClass().getName() + " (" + vector.getMainClass().getClass().getName() + "): " + throwable.getClass().getName() + (throwable.getMessage() == null ? "" : ": " + throwable.getMessage()));
|
||||||
|
throw throwable;
|
||||||
|
}
|
||||||
|
logger.diag("Initialized subsystem " + vector.getMainClass().getName() + " (" + vector.getMainClass().getClass().getName() + ") in " + initTime + "ms");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update 'subsystems'
|
||||||
|
subsystems = new ImmutableLinkedList<>(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) {
|
||||||
|
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
|
||||||
|
Logger.flushLogMessages();
|
||||||
|
|
||||||
|
logger.verb("Notifiying classes about shutdown");
|
||||||
|
new EngineShutdownEvent().callEvent();
|
||||||
|
|
||||||
|
logger.verb("Notifying subsystems about shutdown");
|
||||||
|
new InternalEngineShutdownEvent().callEvent();
|
||||||
|
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public void initializeSubsystem() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public @NotNull DependencyVector getDependencyVector() {
|
||||||
|
return new DependencyVector("engine", StarOpenSourceVersioningSystem.class, EngineInformation.getVersioningString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the engine state.
|
||||||
|
*
|
||||||
|
* @param state new state
|
||||||
|
* @throws NoAccessException if the caller class is unauthorized
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
public void setState(@NotNull EngineState state) throws NoAccessException {
|
||||||
|
if (!Thread.currentThread().getStackTrace()[2].getClassName().startsWith("de.staropensource.sosengine.base."))
|
||||||
|
throw new NoAccessException("Only classes inside the \"de.staropensource.sosengine.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) {
|
||||||
|
logger.warn("Terminating JVM");
|
||||||
|
|
||||||
|
System.exit(exitCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,393 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.ShortcodeParserSkeleton;
|
||||||
|
import de.staropensource.sosengine.base.classes.Configuration;
|
||||||
|
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||||
|
import de.staropensource.sosengine.base.logging.CrashHandler;
|
||||||
|
import de.staropensource.sosengine.base.logging.Logger;
|
||||||
|
import de.staropensource.sosengine.base.types.EngineState;
|
||||||
|
import de.staropensource.sosengine.base.types.logging.LogLevel;
|
||||||
|
import de.staropensource.sosengine.base.types.vectors.Vec2f;
|
||||||
|
import de.staropensource.sosengine.base.utility.PropertiesReader;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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({ "unused", "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 group in which setting overrides must begin with..
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the group in which setting overrides must begin with.
|
||||||
|
*
|
||||||
|
* @return property group
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final @NotNull String group = "sosengine.base.";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, allows for unintentional behaviour and excess logging.
|
||||||
|
* Unless you want to debug or work on a sensitive part of the engine, don't enable this!
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #debug}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #debug
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private boolean debug;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, all called events will be logged.
|
||||||
|
*
|
||||||
|
* @see EventHelper#logCall(Class, Object...)
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #debugEvents}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #debugEvents
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private boolean debugEvents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, very verbose messages about the {@link ShortcodeParserSkeleton}'s internals will be printed.
|
||||||
|
* Don't enable unless you want to work on it.
|
||||||
|
*
|
||||||
|
* @see ShortcodeParserSkeleton
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #debugShortcodeConverter}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #debugShortcodeConverter
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private boolean debugShortcodeConverter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, invalid shortcodes will be logged by the {@link ShortcodeParserSkeleton}.
|
||||||
|
* The message will be printed as a {@link LogLevel#SILENT_WARNING}.
|
||||||
|
*
|
||||||
|
* @see ShortcodeParserSkeleton
|
||||||
|
* @see #loggerLevel
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #errorShortcodeConverter}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #errorShortcodeConverter
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private boolean errorShortcodeConverter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, will makes the {@link Logger} work asynchronous, in a separate platform thread.
|
||||||
|
* Don't disable unless you want your application to run <b>extremely</b> slowly.
|
||||||
|
*
|
||||||
|
* @see #loggerPollingSpeed
|
||||||
|
* @see Thread
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #optimizeLogging}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #optimizeLogging
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private boolean optimizeLogging;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, will make all events asynchronous, in separate virtual threads.
|
||||||
|
* Don't disable unless you want your application to run slower.
|
||||||
|
*
|
||||||
|
* @see VirtualThread
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #optimizeEvents}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #optimizeEvents
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private boolean optimizeEvents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, will try to automatically initialize every subsystem found though reflection.
|
||||||
|
* <p>
|
||||||
|
* This however may fail in certain situation, where manual subsystem initialization may be required.
|
||||||
|
* For this reason, this can be turned off before the engine initializes.
|
||||||
|
* Please note though that dependency resolution between subsystems will not be done, be careful when
|
||||||
|
* initializing subsystems manually.
|
||||||
|
*
|
||||||
|
* @see Engine
|
||||||
|
* @since v1-alpha2
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #optimizeSubsystemInitialization}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #optimizeSubsystemInitialization
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
private boolean optimizeSubsystemInitialization;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains which logger levels are allowed by setting the minimum logger level.
|
||||||
|
*
|
||||||
|
* @see Logger
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #loggerLevel}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #loggerLevel
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private LogLevel loggerLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the logging template used for creating log messages.
|
||||||
|
*
|
||||||
|
* @see Logger
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #loggerTemplate}
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #loggerTemplate
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private String loggerTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, the JVM will immediately shutdown on an engine crash. This will prevent shutdown hooks from executing.
|
||||||
|
* Note: This will also prevent Jansi and potentially other libraries from removing temporary native libraries at shutdown.
|
||||||
|
*
|
||||||
|
* @see CrashHandler
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #loggerImmediateShutdown}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #loggerImmediateShutdown
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private boolean loggerImmediateShutdown;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, will force the {@link Logger} and {@link CrashHandler} to use <a href="https://www.man7.org/linux/man-pages/man3/stderr.3.html">the standard output</a>
|
||||||
|
* instead of <a href="https://www.man7.org/linux/man-pages/man3/stderr.3.html">the standard error</a> for logging {@code ERROR} and {@code CRASH}.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #loggerForceStandardOutput}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #loggerForceStandardOutput
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private boolean loggerForceStandardOutput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains how fast the logging thread will poll for queued messages.
|
||||||
|
* Only applies if {@code optimizeLogging} is turned on.
|
||||||
|
*
|
||||||
|
* @see #optimizeLogging
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #loggerForceStandardOutput}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #loggerForceStandardOutput
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
private int loggerPollingSpeed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will truncate the path of types when using their {@code toString} method.
|
||||||
|
* <p>
|
||||||
|
* Here's an example: Lets say that you have a {@link Vec2f} and to convert it
|
||||||
|
* to a String, which you can do with {@link Vec2f#toString()}. With this flag disabled
|
||||||
|
* it would return {@code de.staropensource.sosengine.base.types.vectors.Vec2(x=64 y=64)},
|
||||||
|
* with it however it would be {@code Vec2(x=64 y=64)}, which is much smaller.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #hideFullTypePath}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see #hideFullTypePath
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
private boolean hideFullTypePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @see Engine
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public EngineConfiguration() {
|
||||||
|
super("ENGINE"); // TODO Wait for flexible constructor bodies (JEP 482) to be implemented into the JVM as a stable feature. We don't want to use preview features in production code.
|
||||||
|
|
||||||
|
// Only allow one instance
|
||||||
|
if (instance == null)
|
||||||
|
instance = this;
|
||||||
|
else
|
||||||
|
logger.crash("Only one instance of this class is allowed, use getInstance() instead of creating a new instance");
|
||||||
|
|
||||||
|
// 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 "debugShortcodeConverter" -> debugShortcodeConverter = parser.getBoolean(group + property);
|
||||||
|
|
||||||
|
case "errorShortcodeConverter" -> errorShortcodeConverter = parser.getBoolean(group + property);
|
||||||
|
|
||||||
|
case "optimizeLogging" -> {
|
||||||
|
optimizeLogging = parser.getBoolean(group + property);
|
||||||
|
|
||||||
|
// Start logging thread automatically
|
||||||
|
if (optimizeLogging && Engine.getInstance().getState() == EngineState.RUNNING)
|
||||||
|
Logger.startLoggingThread();
|
||||||
|
}
|
||||||
|
case "optimizeEvents" -> optimizeEvents = parser.getBoolean(group + property);
|
||||||
|
case "optimizeSubsystemInitialization" -> optimizeSubsystemInitialization = parser.getBoolean(group + property);
|
||||||
|
|
||||||
|
case "loggerLevel" -> {
|
||||||
|
try {
|
||||||
|
loggerLevel = LogLevel.valueOf(parser.getString(group + property).toUpperCase());
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
System.out.println("Logger level " + parser.getString(group + property) + " is not valid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "loggerTemplate" -> loggerTemplate = parser.getString(group + property);
|
||||||
|
case "loggerImmediateShutdown" -> loggerImmediateShutdown = parser.getBoolean(group + property);
|
||||||
|
case "loggerForceStandardOutput" -> loggerForceStandardOutput = parser.getBoolean(group + property);
|
||||||
|
case "loggerPollingSpeed" -> loggerPollingSpeed = parser.getInteger(group + property, true);
|
||||||
|
|
||||||
|
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;
|
||||||
|
debugShortcodeConverter = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public void loadDefaultConfiguration() {
|
||||||
|
debug = false;
|
||||||
|
debugEvents = false;
|
||||||
|
debugShortcodeConverter = false;
|
||||||
|
|
||||||
|
errorShortcodeConverter = true;
|
||||||
|
|
||||||
|
optimizeLogging = true;
|
||||||
|
optimizeEvents = true;
|
||||||
|
optimizeSubsystemInitialization = true;
|
||||||
|
|
||||||
|
loggerLevel = LogLevel.INFORMATIONAL;
|
||||||
|
loggerTemplate = "%log_color_primary%[%time_hour%:%time_minute%:%time_second%] [%log_level% %log_path%%log_metadata%] %log_color_secondary%%log_message%<reset>";
|
||||||
|
loggerImmediateShutdown = false;
|
||||||
|
loggerForceStandardOutput = false;
|
||||||
|
loggerPollingSpeed = 5;
|
||||||
|
|
||||||
|
hideFullTypePath = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public @Nullable Object getSetting(@NotNull String setting) {
|
||||||
|
switch (setting) {
|
||||||
|
case "debug" -> { return debug; }
|
||||||
|
case "debugEvents" -> { return debugEvents; }
|
||||||
|
case "debugShortcodeConverter" -> { return debugShortcodeConverter; }
|
||||||
|
|
||||||
|
case "errorShortcodeConverter" -> { return errorShortcodeConverter; }
|
||||||
|
|
||||||
|
case "optimizeLogging" -> { return optimizeLogging; }
|
||||||
|
case "optimizeEvents" -> { return optimizeEvents; }
|
||||||
|
case "optimizeSubsystemInitialization" -> { return optimizeSubsystemInitialization; }
|
||||||
|
|
||||||
|
case "loggerLevel" -> { return loggerLevel; }
|
||||||
|
case "loggerTemplate" -> { return loggerTemplate; }
|
||||||
|
case "loggerImmediateShutdown" -> { return loggerImmediateShutdown; }
|
||||||
|
case "loggerForceStandardOutput" -> { return loggerForceStandardOutput; }
|
||||||
|
case "loggerPollingSpeed" -> { return loggerPollingSpeed; }
|
||||||
|
|
||||||
|
case "hideFullTypePath" -> { return hideFullTypePath; }
|
||||||
|
default -> { return null; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.annotations;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.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
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public @interface EngineSubsystem {}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.annotations;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Event;
|
||||||
|
import de.staropensource.sosengine.base.types.EventPriority;
|
||||||
|
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
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
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 EventPriority
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@NotNull EventPriority priority() default EventPriority.DEFAULT;
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotations used by the sos!engine to access
|
||||||
|
* classes and methods using reflection.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
package de.staropensource.sosengine.base.annotations;
|
|
@ -0,0 +1,146 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.classes;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||||
|
import de.staropensource.sosengine.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
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public abstract class Configuration {
|
||||||
|
/**
|
||||||
|
* Contains the {@link LoggerInstance} for this instance.
|
||||||
|
*
|
||||||
|
* @see LoggerInstance
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
protected final @NotNull LoggerInstance logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @param origin see {@link LoggerInstance.Builder#setOrigin(String)}
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
public Configuration(@NotNull String origin) {
|
||||||
|
// Set logger instance
|
||||||
|
logger = new LoggerInstance.Builder().setClazz(getClass()).setOrigin(origin).build();
|
||||||
|
|
||||||
|
// 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 the group in which setting overrides 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);
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.classes;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an event.
|
||||||
|
*
|
||||||
|
* @see EventHelper
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public interface Event {
|
||||||
|
/**
|
||||||
|
* Emits the event and calls all event listeners.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
void callEvent();
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.classes;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.logging.Logger;
|
||||||
|
import de.staropensource.sosengine.base.types.logging.LogLevel;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for implementing custom logger implementations.
|
||||||
|
*
|
||||||
|
* @see Logger#setLoggerImplementation(LoggerImplementation)
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public interface LoggerImplementation {
|
||||||
|
/**
|
||||||
|
* Invoked before anything is done with the log message.
|
||||||
|
*
|
||||||
|
* @param level level
|
||||||
|
* @param issuerClass issuer class
|
||||||
|
* @param issuerOrigin issuer origin
|
||||||
|
* @param issuerMetadata issuer metadata
|
||||||
|
* @param message raw message
|
||||||
|
* @param format unmodified log format
|
||||||
|
* @return new log message, return {@code null} for no change
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@Nullable String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked after placeholders have been processed and replaced.
|
||||||
|
*
|
||||||
|
* @param level level
|
||||||
|
* @param issuerClass issuer class
|
||||||
|
* @param issuerOrigin issuer origin
|
||||||
|
* @param issuerMetadata issuer metadata
|
||||||
|
* @param message raw message
|
||||||
|
* @param format unmodified log format
|
||||||
|
* @return new log format
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@NotNull String postPlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints the log message.
|
||||||
|
*
|
||||||
|
* @param level level
|
||||||
|
* @param issuerClass issuer class
|
||||||
|
* @param issuerOrigin issuer origin
|
||||||
|
* @param issuerMetadata issuer metadata
|
||||||
|
* @param message raw message
|
||||||
|
* @param format unmodified log format
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
void print(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format);
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.classes;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.utility.PlaceholderEngine;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for implementing placeholders.
|
||||||
|
*
|
||||||
|
* @see PlaceholderEngine
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
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);
|
||||||
|
}
|
|
@ -0,0 +1,291 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.classes;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.EngineConfiguration;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.ParserException;
|
||||||
|
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for implementing a shortcode converter.
|
||||||
|
* <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
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||||
|
public abstract class ShortcodeParserSkeleton {
|
||||||
|
/**
|
||||||
|
* Contains the {@link LoggerInstance} for this instance.
|
||||||
|
*
|
||||||
|
* @see LoggerInstance
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
protected final @NotNull LoggerInstance logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
protected final @NotNull LinkedList<String> components;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs 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-alpha2
|
||||||
|
*/
|
||||||
|
public ShortcodeParserSkeleton(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
|
||||||
|
logger = new LoggerInstance.Builder().setClazz(getClass()).setOrigin("ENGINE").build();
|
||||||
|
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#errorShortcodeConverter
|
||||||
|
* @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:")) {
|
||||||
|
// Print debug message
|
||||||
|
if (EngineConfiguration.getInstance().isDebugShortcodeConverter())
|
||||||
|
System.out.println(getClass().getName() + "#" + string.hashCode() + " tag=fg data=" + part.substring(3).toUpperCase());
|
||||||
|
|
||||||
|
if (isValidColor(part.substring(3).toUpperCase()))
|
||||||
|
components.add("COLOR:FOREGROUND:" + part.substring(3).toUpperCase());
|
||||||
|
else {
|
||||||
|
// Complain about invalid shortcode
|
||||||
|
if (EngineConfiguration.getInstance().isErrorShortcodeConverter())
|
||||||
|
logger.sarn("Invalid shortcode: " + part);
|
||||||
|
|
||||||
|
// Convert tag regular text
|
||||||
|
components.add("TEXT:" + "<" + part + ">");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bg:*
|
||||||
|
else if (part.toString().startsWith("bg:")) {
|
||||||
|
// Print debug message
|
||||||
|
if (EngineConfiguration.getInstance().isDebugShortcodeConverter())
|
||||||
|
System.out.println(getClass().getName() + "#" + string.hashCode() + " tag=bg data=" + part.substring(3).toUpperCase());
|
||||||
|
|
||||||
|
if (isValidColor(part.substring(3).toUpperCase()))
|
||||||
|
components.add("COLOR:BACKGROUND:" + part.substring(3).toUpperCase());
|
||||||
|
else {
|
||||||
|
// Complain about invalid shortcode
|
||||||
|
if (EngineConfiguration.getInstance().isErrorShortcodeConverter())
|
||||||
|
logger.sarn("Invalid shortcode: " + part);
|
||||||
|
|
||||||
|
// Convert tag regular text
|
||||||
|
components.add("TEXT:" + "<" + part + ">");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bold
|
||||||
|
else if (part.toString().equals("bold")) {
|
||||||
|
// Print debug message
|
||||||
|
if (EngineConfiguration.getInstance().isDebugShortcodeConverter())
|
||||||
|
System.out.println(getClass().getName() + "#" + string.hashCode() + " tag=bold");
|
||||||
|
|
||||||
|
// Insert attribute
|
||||||
|
components.add("ATTRIBUTE:BOLD");
|
||||||
|
}
|
||||||
|
|
||||||
|
// italic
|
||||||
|
else if (part.toString().equals("italic")) {
|
||||||
|
// Print debug message
|
||||||
|
if (EngineConfiguration.getInstance().isDebugShortcodeConverter())
|
||||||
|
System.out.println(getClass().getName() + "#" + string.hashCode() + " tag=italic");
|
||||||
|
|
||||||
|
// Insert attribute
|
||||||
|
components.add("ATTRIBUTE:ITALIC");
|
||||||
|
}
|
||||||
|
|
||||||
|
// strikethrough
|
||||||
|
else if (part.toString().equals("strikethrough")) {
|
||||||
|
// Print debug message
|
||||||
|
if (EngineConfiguration.getInstance().isDebugShortcodeConverter())
|
||||||
|
System.out.println(getClass().getName() + "#" + string.hashCode() + " tag=strikethrough");
|
||||||
|
|
||||||
|
// Insert attribute
|
||||||
|
components.add("ATTRIBUTE:STRIKETHROUGH");
|
||||||
|
}
|
||||||
|
|
||||||
|
// underline
|
||||||
|
else if (part.toString().equals("underline")) {
|
||||||
|
// Print debug message
|
||||||
|
if (EngineConfiguration.getInstance().isDebugShortcodeConverter())
|
||||||
|
System.out.println(getClass().getName() + "#" + string.hashCode() + " tag=underline");
|
||||||
|
|
||||||
|
// Insert attribute
|
||||||
|
components.add("ATTRIBUTE:UNDERLINE");
|
||||||
|
}
|
||||||
|
|
||||||
|
// underline
|
||||||
|
else if (part.toString().equals("blink")) {
|
||||||
|
// Print debug message
|
||||||
|
if (EngineConfiguration.getInstance().isDebugShortcodeConverter())
|
||||||
|
System.out.println(getClass().getName() + "#" + string.hashCode() + " tag=blink");
|
||||||
|
|
||||||
|
// Insert attribute
|
||||||
|
components.add("ATTRIBUTE:BLINK");
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset
|
||||||
|
else if (part.toString().equals("reset")) {
|
||||||
|
// Print debug message
|
||||||
|
if (EngineConfiguration.getInstance().isDebugShortcodeConverter())
|
||||||
|
System.out.println(getClass().getName() + "#" + string.hashCode() + " tag=reset");
|
||||||
|
|
||||||
|
// Insert reset
|
||||||
|
components.add("RESET");
|
||||||
|
}
|
||||||
|
|
||||||
|
// error case
|
||||||
|
else {
|
||||||
|
// Print debug message
|
||||||
|
if (EngineConfiguration.getInstance().isDebugShortcodeConverter())
|
||||||
|
System.out.println(getClass().getName() + "#" + string.hashCode() + " invalidtag=" + part);
|
||||||
|
|
||||||
|
// Complain about invalid shortcode
|
||||||
|
if (EngineConfiguration.getInstance().isErrorShortcodeConverter())
|
||||||
|
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
|
||||||
|
if (EngineConfiguration.getInstance().isDebugShortcodeConverter())
|
||||||
|
System.out.println(getClass().getName() + "#" + string.hashCode() + " text=" + part);
|
||||||
|
|
||||||
|
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()) {
|
||||||
|
if (EngineConfiguration.getInstance().isDebugShortcodeConverter())
|
||||||
|
System.out.println(getClass().getName() + "#" + string.hashCode() + " endtext=" + part);
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.classes;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.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);
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.classes;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.Engine;
|
||||||
|
import de.staropensource.sosengine.base.annotations.EngineSubsystem;
|
||||||
|
import de.staropensource.sosengine.base.annotations.EventListener;
|
||||||
|
import de.staropensource.sosengine.base.internal.events.InternalEngineShutdownEvent;
|
||||||
|
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||||
|
import de.staropensource.sosengine.base.types.DependencyVector;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for building subsystem main classes.
|
||||||
|
*
|
||||||
|
* @see EngineSubsystem
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public abstract class SubsystemClass {
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
public SubsystemClass() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the {@link LoggerInstance} for this instance.
|
||||||
|
*
|
||||||
|
* @see LoggerInstance
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public final LoggerInstance logger = new LoggerInstance.Builder().setClazz(getClass()).setOrigin("ENGINE").build();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* @see DependencyVector
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
public abstract @NotNull DependencyVector getDependencyVector();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called on engine shutdown.
|
||||||
|
*
|
||||||
|
* @see Engine#shutdown()
|
||||||
|
* @see Engine#shutdown(int)
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@EventListener(event = InternalEngineShutdownEvent.class)
|
||||||
|
protected static void shutdownSubsystem() {}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.classes;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.exceptions.versioning.IncompatibleVersioningSystemException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Range;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for building a versioning system (parser).
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
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 smaller = {@code 0}, equal = {@code 1}, bigger = {@code 2}
|
||||||
|
* @throws IncompatibleVersioningSystemException incompatible with the supplied versioning system
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Range(from = 0, to = 2)
|
||||||
|
int compare(@NotNull VersioningSystem version) throws IncompatibleVersioningSystemException;
|
||||||
|
}
|
|
@ -0,0 +1,218 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.classes.helpers;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.EngineConfiguration;
|
||||||
|
import de.staropensource.sosengine.base.annotations.EventListener;
|
||||||
|
import de.staropensource.sosengine.base.classes.Event;
|
||||||
|
import de.staropensource.sosengine.base.events.LogEvent;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.UnexpectedThrowableException;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.reflection.InstanceMethodFromStaticContextException;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.reflection.InvalidMethodSignature;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.reflection.NoAccessException;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.reflection.StaticInitializerException;
|
||||||
|
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||||
|
import de.staropensource.sosengine.base.reflection.Reflect;
|
||||||
|
import de.staropensource.sosengine.base.reflection.ReflectionMethod;
|
||||||
|
import de.staropensource.sosengine.base.utility.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.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simplifies event logging and calling.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public final class EventHelper {
|
||||||
|
/**
|
||||||
|
* Holds all cached events.
|
||||||
|
* Should not be modified manually.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
private static final @NotNull HashMap<@NotNull Class<? extends Event>, LinkedList<@NotNull ReflectionMethod>> cachedEventListeners = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the {@link LoggerInstance} for this instance.
|
||||||
|
*
|
||||||
|
* @see LoggerInstance
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
private static final @NotNull LoggerInstance logger = new LoggerInstance.Builder().setClazz(EventHelper.class).setOrigin("ENGINE").build();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public EventHelper() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs an event call.
|
||||||
|
*
|
||||||
|
* @param event event class
|
||||||
|
* @param arguments arguments passed to event listeners
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public static void logCall(@NotNull Class<? extends Event> event, @NotNull Object ... arguments) {
|
||||||
|
// Print event call if event debugging is enabled
|
||||||
|
if (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));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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-alpha0
|
||||||
|
*/
|
||||||
|
public static @NotNull LinkedList<ReflectionMethod> getAnnotatedMethods(@NotNull Class<? extends Event> event, boolean forceScanning) {
|
||||||
|
LinkedList<ReflectionMethod> methods = new LinkedList<>();
|
||||||
|
|
||||||
|
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 this event out
|
||||||
|
for (Method method : annotatedMethods)
|
||||||
|
if (method.getAnnotation(EventListener.class).event() == event)
|
||||||
|
methods.add(Reflect.reflectOn(method));
|
||||||
|
|
||||||
|
// Sort 'methods' linked list after event priority
|
||||||
|
methods.sort(Comparator.comparing(method -> method.getAnnotation(EventListener.class).priority()));
|
||||||
|
} else
|
||||||
|
// Event listeners are cached and !forceScanning, return cached results
|
||||||
|
methods = cachedEventListeners.get(event);
|
||||||
|
|
||||||
|
return methods;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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-alpha0
|
||||||
|
*/
|
||||||
|
public static @NotNull LinkedList<ReflectionMethod> getAnnotatedMethods(@NotNull Class<? extends Event> event) {
|
||||||
|
return getAnnotatedMethods(event, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invokes all event listeners.
|
||||||
|
*
|
||||||
|
* @param event event class
|
||||||
|
* @param arguments arguments to pass to event listeners
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public static void invokeAnnotatedMethods(@NotNull Class<? extends Event> event, Object... arguments) {
|
||||||
|
if (event != LogEvent.class)
|
||||||
|
logCall(event);
|
||||||
|
|
||||||
|
Runnable eventCode = () -> {
|
||||||
|
for (ReflectionMethod method : getAnnotatedMethods(event)) {
|
||||||
|
try {
|
||||||
|
method.invoke(arguments);
|
||||||
|
} catch (UnexpectedThrowableException exception) {
|
||||||
|
logger.crash("Event listener method " + method.getName() + " could not be called as an error occurred during reflection", exception, true);
|
||||||
|
} catch (NoAccessException exception) {
|
||||||
|
logger.warn("Event listener method " + method.getName() + " could not be called as the method could not be accessed");
|
||||||
|
} catch (InvalidMethodSignature exception) {
|
||||||
|
logger.warn("Event listener method " + method.getName() + " has an invalid method signature");
|
||||||
|
} catch (InvocationTargetException exception) {
|
||||||
|
logger.crash("Event listener method " + method.getName() + " threw a throwable", exception.getTargetException(), true);
|
||||||
|
} catch (InstanceMethodFromStaticContextException exception) {
|
||||||
|
logger.warn("Event listener method " + method.getName() + " is not static. Event listener methods must be static for them to be called.");
|
||||||
|
} catch (StaticInitializerException exception) {
|
||||||
|
logger.crash("Event listener method " + method.getName() + " could not be called as the static initializer failed", exception.getThrowable(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (EngineConfiguration.getInstance().isOptimizeEvents())
|
||||||
|
Thread
|
||||||
|
.ofVirtual()
|
||||||
|
.name("Event " + event.getName())
|
||||||
|
.start(eventCode);
|
||||||
|
else
|
||||||
|
eventCode.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Re-)Caches all event listeners for some {@link Event}.
|
||||||
|
*
|
||||||
|
* @param event event to (re-)cache. Set to {@code null} to recompute all cached events
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public static synchronized void cacheEvent(@Nullable Class<? extends Event> event) {
|
||||||
|
if (event == null)
|
||||||
|
for (Class<? extends Event> cachedEvent : cachedEventListeners.keySet())
|
||||||
|
cacheEvent(cachedEvent);
|
||||||
|
else {
|
||||||
|
LinkedList<@NotNull ReflectionMethod> annotatedMethods = getAnnotatedMethods(event);
|
||||||
|
|
||||||
|
if (cachedEventListeners.containsKey(event))
|
||||||
|
cachedEventListeners.replace(event, annotatedMethods);
|
||||||
|
else
|
||||||
|
cachedEventListeners.put(event, annotatedMethods);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an event from the event listener cache.
|
||||||
|
*
|
||||||
|
* @param event event to uncache. Set to {@code null} to clear the entire cache
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public static synchronized void uncacheEvent(@Nullable Class<? extends Event> event) {
|
||||||
|
if (event == null)
|
||||||
|
cachedEventListeners.clear();
|
||||||
|
else
|
||||||
|
cachedEventListeners.remove(event);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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.sosengine.base.classes.helpers;
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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.
|
||||||
|
* <p>
|
||||||
|
* These are not to be confused with data types. See {@link de.staropensource.sosengine.base.types}.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
package de.staropensource.sosengine.base.classes;
|
|
@ -0,0 +1,413 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.data.information;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.Engine;
|
||||||
|
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||||
|
import de.staropensource.sosengine.base.types.VersionType;
|
||||||
|
import de.staropensource.sosengine.base.utility.PropertiesReader;
|
||||||
|
import de.staropensource.sosengine.base.utility.parser.StackTraceParser;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides build information about the engine.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||||
|
public final class EngineInformation {
|
||||||
|
/**
|
||||||
|
* Contains the {@link LoggerInstance} for this instance.
|
||||||
|
*
|
||||||
|
* @see LoggerInstance
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
private static final @NotNull LoggerInstance logger = new LoggerInstance.Builder().setClazz(EngineInformation.class).setOrigin("ENGINE").build();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the engine's version codename.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the engine's version codename.
|
||||||
|
*
|
||||||
|
* @return engine version codename
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String versioningCodename;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the engine's version.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the engine's version.
|
||||||
|
*
|
||||||
|
* @return engine version
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static int versioningVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the engine's version type.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the engine's version type.
|
||||||
|
*
|
||||||
|
* @return engine version type
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static VersionType versioningType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the engine's typerelease.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the engine's typerelease.
|
||||||
|
*
|
||||||
|
* @return engine typerelease
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static int versioningTyperelease;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the engine's fork identifier.
|
||||||
|
* <p>
|
||||||
|
* Likely empty. If not, prefixed with a dash.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the engine's fork identifier.
|
||||||
|
* <p>
|
||||||
|
* Likely empty. If not, prefixed with a dash.
|
||||||
|
*
|
||||||
|
* @return engine fork identifier
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String versioningFork;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the engine's full version string.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the engine's full version string.
|
||||||
|
*
|
||||||
|
* @return engine version string
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String versioningString;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the {@code dirty} value (i.e. if the source tree has been modified).
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the {@code dirty} value (i.e. if the source tree has been modified).
|
||||||
|
*
|
||||||
|
* @return git dirty value
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static boolean gitDirty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the branch the engine was built on.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the branch the engine was built on.
|
||||||
|
*
|
||||||
|
* @return git branch
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String gitBranch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the commit count.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the commit count.
|
||||||
|
*
|
||||||
|
* @return git commit count
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static int gitCommitCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the commit identifier (short form).
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the commit identifier (short form).
|
||||||
|
*
|
||||||
|
* @return git long commit id
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String gitCommitIdentifierShort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the commit identifier (long form).
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the commit identifier (long form).
|
||||||
|
*
|
||||||
|
* @return git long commit id
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String gitCommitIdentifierLong;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the commit header.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the commit header.
|
||||||
|
*
|
||||||
|
* @return git commit header
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String gitCommitHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the commit time.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the commit time.
|
||||||
|
*
|
||||||
|
* @return git commit time
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static ZonedDateTime gitCommitTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the commiter's name.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the commiter's name.
|
||||||
|
*
|
||||||
|
* @return git committer name
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String gitCommitterName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the commiter's email.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the commiter's email.
|
||||||
|
*
|
||||||
|
* @return git committer email
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String gitCommitterEmail;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the version of the dependency {@code Jansi}.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the version of the dependency {@code Jansi}.
|
||||||
|
*
|
||||||
|
* @return Jansi dependency version
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String dependencyJansi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the version of the dependency {@code Reflections}.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the version of the dependency {@code Reflections}.
|
||||||
|
*
|
||||||
|
* @return Reflections dependency version
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String dependencyReflections;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the version of the dependency {@code SLF4J}.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the version of the dependency {@code SLF4J}.
|
||||||
|
*
|
||||||
|
* @return SLF4J dependency version
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String dependencySlf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the version of the dependency {@code LWJGL}.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the version of the dependency {@code LWJGL}.
|
||||||
|
*
|
||||||
|
* @return LWJGL dependency version
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static String dependencyLwjgl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public EngineInformation() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates all variables.
|
||||||
|
* <p>
|
||||||
|
* This method does not need to be invoked, as the information provided by this
|
||||||
|
* class is static (does not change) and is already populated at engine startup.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
public static synchronized void updateVariables() {
|
||||||
|
// Load properties from bundled gradle.properties
|
||||||
|
Properties gradleProperties = new Properties();
|
||||||
|
InputStream gradleStream = EngineInformation.class.getClassLoader().getResourceAsStream("sosengine-gradle.properties");
|
||||||
|
|
||||||
|
if (gradleStream == null) {
|
||||||
|
System.out.println("Unable to load build information: The bundled gradle.properties file could not be found.");
|
||||||
|
Engine.getInstance().shutdown(69);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
gradleProperties.load(gradleStream);
|
||||||
|
gradleStream.close();
|
||||||
|
} catch (IOException exception) {
|
||||||
|
StackTraceParser parser = new StackTraceParser(exception);
|
||||||
|
System.out.println("Unable to load build information: InputStream 'gradleStream' failed");
|
||||||
|
System.out.println(parser.getHeader() + "\n" + parser.getStackTrace());
|
||||||
|
Engine.getInstance().shutdown(69);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load properties from bundled git.properties
|
||||||
|
// or fill in blank information if file missing
|
||||||
|
Properties gitProperties = new Properties();
|
||||||
|
InputStream gitStream = EngineInformation.class.getClassLoader().getResourceAsStream("sosengine-git.properties");
|
||||||
|
if (gitStream == null) {
|
||||||
|
logger.error("Unable to load build information: The bundled git.properties file could not be found. Did you download a tarball?");
|
||||||
|
|
||||||
|
// Fake information
|
||||||
|
gitProperties.setProperty("git.total.commit.count", "0");
|
||||||
|
gitProperties.setProperty("git.dirty", "true");
|
||||||
|
gitProperties.setProperty("git.branch", "/git.properties is missing/");
|
||||||
|
gitProperties.setProperty("git.commit.id", "########################################");
|
||||||
|
gitProperties.setProperty("git.commit.id.abbrev", "#######");
|
||||||
|
gitProperties.setProperty("git.commit.message.short", "git.properties file is missing :/");
|
||||||
|
gitProperties.setProperty("git.commit.time", "1970-01-01T00:00+0000");
|
||||||
|
gitProperties.setProperty("git.commit.user.name", "git.properties file is missing :/");
|
||||||
|
gitProperties.setProperty("git.commit.user.email", "git.properties-is-missing@example.com");
|
||||||
|
} else {
|
||||||
|
// Load real information from git.properties file
|
||||||
|
try {
|
||||||
|
gitProperties.load(gitStream);
|
||||||
|
gitStream.close();
|
||||||
|
} catch (IOException exception) {
|
||||||
|
StackTraceParser parser = new StackTraceParser(exception);
|
||||||
|
System.out.println("Unable to load build information: InputStream 'gitStream' failed");
|
||||||
|
System.out.println(parser.getHeader() + "\n" + parser.getStackTrace());
|
||||||
|
Engine.getInstance().shutdown(69);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new PropertyParsers
|
||||||
|
PropertiesReader gradleParser = new PropertiesReader(gradleProperties);
|
||||||
|
PropertiesReader gitParser = new PropertiesReader(gitProperties);
|
||||||
|
|
||||||
|
// Apply properties to fields
|
||||||
|
versioningCodename = gradleParser.getString("versioningCodename");
|
||||||
|
versioningVersion = gradleParser.getInteger("versioningVersion", true);
|
||||||
|
versioningType = VersionType.valueOf(gradleParser.getString("versioningType").toUpperCase());
|
||||||
|
versioningTyperelease = gradleParser.getInteger("versioningTyperelease", true);
|
||||||
|
versioningFork = gradleParser.getString("versioningFork");
|
||||||
|
versioningString = "v" + versioningVersion + "-" + (versioningType == VersionType.RELEASE_CANDIDATE ? "releasecandidate" : versioningType.name()) + versioningTyperelease + versioningFork;
|
||||||
|
|
||||||
|
dependencyJansi = gradleParser.getString("dependencyJansi");
|
||||||
|
dependencyReflections = gradleParser.getString("dependencyReflections");
|
||||||
|
dependencySlf4j = gradleParser.getString("dependencySlf4j");
|
||||||
|
dependencyLwjgl = gradleParser.getString("dependencyLwjgl");
|
||||||
|
|
||||||
|
gitDirty = gitParser.getBoolean("git.dirty");
|
||||||
|
gitBranch = gitParser.getString("git.branch");
|
||||||
|
gitCommitCount = gitParser.getInteger("git.total.commit.count", true);
|
||||||
|
gitCommitIdentifierShort = gitParser.getString("git.commit.id.abbrev");
|
||||||
|
gitCommitIdentifierLong = gitParser.getString("git.commit.id");
|
||||||
|
gitCommitHeader = gitParser.getString("git.commit.message.short");
|
||||||
|
try {
|
||||||
|
Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ").parse(gitParser.getString("git.commit.time"));
|
||||||
|
GregorianCalendar calendar = new GregorianCalendar();
|
||||||
|
calendar.setTime(date);
|
||||||
|
gitCommitTime = calendar.toZonedDateTime();
|
||||||
|
} catch (ParseException exception) {
|
||||||
|
StackTraceParser parser = new StackTraceParser(exception);
|
||||||
|
System.out.println("Unable to load build information: Can't parse \"" + gitParser.getString("git.commit.time") + "\" using format \"yyyy-MM-dd'T'HH:mmZ\"");
|
||||||
|
System.out.println(parser.getHeader() + "\n" + parser.getStackTrace());
|
||||||
|
Engine.getInstance().shutdown(69);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gitCommitterName = gitParser.getString("git.commit.user.name");
|
||||||
|
gitCommitterEmail = gitParser.getString("git.commit.user.email");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,201 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.data.information;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
import java.lang.management.MemoryUsage;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides information about the running Java Virtual Machine.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public final class JvmInformation {
|
||||||
|
/**
|
||||||
|
* Contains the {@link LoggerInstance} for this instance.
|
||||||
|
*
|
||||||
|
* @see LoggerInstance
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
private static final @NotNull LoggerInstance logger = new LoggerInstance.Builder().setClazz(JvmInformation.class).setOrigin("ENGINE").build();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public JvmInformation() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Java version this JVM implements.
|
||||||
|
*
|
||||||
|
* @return Java version
|
||||||
|
* @throws NumberFormatException on integer conversion failure
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public static int getJavaVersion() throws NumberFormatException {
|
||||||
|
String version = System.getProperty("java.version");
|
||||||
|
|
||||||
|
if (version.startsWith("1.")) // Omit "1." (if present)
|
||||||
|
version = version.substring(2, 3);
|
||||||
|
else {
|
||||||
|
if (version.contains(".")) // Only get MAJOR version
|
||||||
|
version = version.substring(0, version.indexOf("."));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(version);
|
||||||
|
} catch (NumberFormatException exception) {
|
||||||
|
logger.crash("Could not parse Java version: Integer conversion failed for string \"" + version + "\"", exception, true);
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the JVM implementation name.
|
||||||
|
*
|
||||||
|
* @return implementation name
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public static @NotNull String getImplementationName() {
|
||||||
|
return ManagementFactory.getRuntimeMXBean().getVmName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the JVM implementation version.
|
||||||
|
*
|
||||||
|
* @return implementation version
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public static @NotNull String getImplementationVersion() {
|
||||||
|
return ManagementFactory.getRuntimeMXBean().getVmVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the JVM implementation vendor.
|
||||||
|
*
|
||||||
|
* @return implementation vendor
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public static @NotNull String getImplementationVendor() {
|
||||||
|
return ManagementFactory.getRuntimeMXBean().getVmVendor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the uptime of the JVM.
|
||||||
|
*
|
||||||
|
* @return uptime in milliseconds
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public static long getUptime() {
|
||||||
|
return ManagementFactory.getRuntimeMXBean().getUptime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all arguments passed to the JVM.
|
||||||
|
* This excludes all arguments passed to the application.
|
||||||
|
*
|
||||||
|
* @return JVM arguments
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public static @NotNull List<@NotNull String> getArguments() {
|
||||||
|
return ManagementFactory.getRuntimeMXBean().getInputArguments();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the <b>estimated</b> total amount of memory used the running application and JVM.
|
||||||
|
*
|
||||||
|
* @return estimated total amount of used memory
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
public static long getMemoryTotal() {
|
||||||
|
return Runtime.getRuntime().totalMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the maximum amount of memory which can be used by the running application.
|
||||||
|
*
|
||||||
|
* @return maximum amount of memory usable in bytes
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
public static long getMemoryLimit() {
|
||||||
|
return Runtime.getRuntime().maxMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the amount of free memory available to the running application.
|
||||||
|
*
|
||||||
|
* @return amount of free memory in bytes
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
public static long getMemoryFree() {
|
||||||
|
return Runtime.getRuntime().freeMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the amount of memory used by the running application.
|
||||||
|
*
|
||||||
|
* @return amount of used memory in bytes
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
public static long getMemoryUsed() {
|
||||||
|
return getMemoryLimit() - getMemoryFree();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of <a href="https://en.wikipedia.org/wiki/Heap_(programming)">heap memory</a>.
|
||||||
|
*
|
||||||
|
* @return heap memory size
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
public static @NotNull MemoryUsage getMemoryHeap() {
|
||||||
|
return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns size of <a href="https://en.wikipedia.org/wiki/Stack-based_memory_allocation">stack memory</a>.
|
||||||
|
*
|
||||||
|
* @return stack memory size
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
public static @NotNull MemoryUsage getMemoryStack() {
|
||||||
|
return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the amount of processors available to the JVM.
|
||||||
|
* <p>
|
||||||
|
* Note: The amount of available processors may change rapidly.
|
||||||
|
* If your application scales resources based on the output of
|
||||||
|
* this method, consider checking it's output often and scaling
|
||||||
|
* resources accordingly.
|
||||||
|
*
|
||||||
|
* @return amount of available processors
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
public static int getAvailableProcessors() {
|
||||||
|
return Runtime.getRuntime().availableProcessors();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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 can be used to retrieve information about the execution environment.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
package de.staropensource.sosengine.base.data.information;
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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 provide or process information.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
package de.staropensource.sosengine.base.data;
|
|
@ -0,0 +1,153 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.data.versioning;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.VersioningSystem;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.versioning.IncompatibleVersioningSystemException;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.versioning.InvalidVersionStringException;
|
||||||
|
import de.staropensource.sosengine.base.utility.Miscellaneous;
|
||||||
|
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({ "unused", "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";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a four number-based version string.
|
||||||
|
*
|
||||||
|
* @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 = Miscellaneous.getSeparator(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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.data.versioning;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.VersioningSystem;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.versioning.IncompatibleVersioningSystemException;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.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({ "unused", "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";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a one number-based version string.
|
||||||
|
*
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,222 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.data.versioning;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.VersioningSystem;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.versioning.IncompatibleVersioningSystemException;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.versioning.InvalidVersionStringException;
|
||||||
|
import de.staropensource.sosengine.base.utility.Miscellaneous;
|
||||||
|
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({ "unused", "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";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a semantic versioning string.
|
||||||
|
*
|
||||||
|
* @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 = Miscellaneous.getSeparator(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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,263 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.data.versioning;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.VersioningSystem;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.versioning.IncompatibleVersioningSystemException;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.versioning.InvalidVersionStringException;
|
||||||
|
import de.staropensource.sosengine.base.types.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 2), where an application
|
||||||
|
* or work is versioning by a {@code VERSION} vector, {@code TYPE} version type,
|
||||||
|
* {@code TYPERELEASE} vector and optionally, a {@code FORK} vector and
|
||||||
|
* {@code COMPANION} vector.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||||
|
public final class StarOpenSourceVersioningSystem implements VersioningSystem {
|
||||||
|
/**
|
||||||
|
* Contains the {@code VERSION} vector.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the {@code VERSION} vector.
|
||||||
|
*
|
||||||
|
* @return {@code VERSION} vector
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
private final int version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a StarOpenSource versioning string.
|
||||||
|
*
|
||||||
|
* @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 = version 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 chraracters
|
||||||
|
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.version = 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.version == 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.getVersion() < this.version)
|
||||||
|
return 0;
|
||||||
|
if (versionCompare.getVersion() > this.version)
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.data.versioning;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.VersioningSystem;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.versioning.IncompatibleVersioningSystemException;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.versioning.InvalidVersionStringException;
|
||||||
|
import de.staropensource.sosengine.base.utility.Miscellaneous;
|
||||||
|
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({ "unused", "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";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a three number-based version string.
|
||||||
|
*
|
||||||
|
* @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 = Miscellaneous.getSeparator(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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.data.versioning;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.VersioningSystem;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.versioning.IncompatibleVersioningSystemException;
|
||||||
|
import de.staropensource.sosengine.base.exceptions.versioning.InvalidVersionStringException;
|
||||||
|
import de.staropensource.sosengine.base.utility.Miscellaneous;
|
||||||
|
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({ "unused", "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";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a two number-based version string.
|
||||||
|
*
|
||||||
|
* @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 = Miscellaneous.getSeparator(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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built-in versioning systems which
|
||||||
|
* can be used to represent versions of some work.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
package de.staropensource.sosengine.base.data.versioning;
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.events;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Event;
|
||||||
|
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called in the event of an engine crash.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public final class EngineCrashEvent implements Event {
|
||||||
|
/**
|
||||||
|
* Constructs this event.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public EngineCrashEvent() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public void callEvent() {
|
||||||
|
EventHelper.invokeAnnotatedMethods(getClass());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.events;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Event;
|
||||||
|
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the engine is about to shutdown.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public final class EngineShutdownEvent implements Event {
|
||||||
|
/**
|
||||||
|
* Constructs this event.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public EngineShutdownEvent() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public void callEvent() {
|
||||||
|
EventHelper.invokeAnnotatedMethods(getClass());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.events;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Event;
|
||||||
|
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||||
|
import de.staropensource.sosengine.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
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public final class EngineSoftCrashEvent implements Event {
|
||||||
|
/**
|
||||||
|
* Constructs this event.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public EngineSoftCrashEvent() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public void callEvent() {
|
||||||
|
EventHelper.invokeAnnotatedMethods(getClass());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.events;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Event;
|
||||||
|
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||||
|
import de.staropensource.sosengine.base.types.logging.LogLevel;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called before a new log message is printed.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public final class LogEvent implements Event {
|
||||||
|
/**
|
||||||
|
* Constructs 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.events;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Event;
|
||||||
|
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||||
|
import de.staropensource.sosengine.base.utility.Miscellaneous;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an exception is caught by {@link Miscellaneous#executeSafely(Runnable, String)}.
|
||||||
|
*
|
||||||
|
* @see Miscellaneous#executeSafely(Runnable, String)
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public final class ThrowableCatchEvent implements Event {
|
||||||
|
/**
|
||||||
|
* Constructs this event.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public ThrowableCatchEvent() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @deprecated use the {@code callEvent} method with arguments
|
||||||
|
* @see ThrowableCatchEvent#callEvent(Throwable, String)
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public void callEvent() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits the event and calls all event listeners.
|
||||||
|
*
|
||||||
|
* @param throwable caught throwable
|
||||||
|
* @param identifier an identifier given to the runnable
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public void callEvent(@NotNull Throwable throwable, @NotNull String identifier) {
|
||||||
|
EventHelper.invokeAnnotatedMethods(getClass(), throwable, identifier);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events. There's nothing more to say.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
package de.staropensource.sosengine.base.events;
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when the caller class is not allowed to call the throwing method.
|
||||||
|
* <p>
|
||||||
|
* Not to be confused with {@link de.staropensource.sosengine.base.exceptions.reflection.NoAccessException},
|
||||||
|
* which handles access violations of reflection objects.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public class NoAccessException extends RuntimeException {
|
||||||
|
/**
|
||||||
|
* Constructs this exception.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
public NoAccessException() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs this exception.
|
||||||
|
*
|
||||||
|
* @param message message
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
public NoAccessException(@NotNull String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when something fails to parse.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
public class ParserException extends RuntimeException {
|
||||||
|
/**
|
||||||
|
* Constructs this exception.
|
||||||
|
*
|
||||||
|
* @param message parsing error
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
public ParserException(@NotNull String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.types.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 {
|
||||||
|
/**
|
||||||
|
* Constructs this exception.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
public TristateConversionException() {
|
||||||
|
super("Tristate.UNSET cannot be converted into a boolean");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions;
|
||||||
|
|
||||||
|
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 {
|
||||||
|
/**
|
||||||
|
* Constructs 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs this exception.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
public UnexpectedCheckEndException() {
|
||||||
|
super("A sequence of if checks or switch cases failed unexpectedly");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when a method invokes another method and it throws an unhandled {@link Throwable}.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||||
|
public class UnexpectedThrowableException extends Exception {
|
||||||
|
/**
|
||||||
|
* Contains the throwable supplied to the constructor.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the throwable supplied by the constructor.
|
||||||
|
*
|
||||||
|
* @return throwable
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
private final @NotNull Throwable throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs this exception.
|
||||||
|
*
|
||||||
|
* @param throwable throwable
|
||||||
|
* @param message message
|
||||||
|
*/
|
||||||
|
public UnexpectedThrowableException(@NotNull Throwable throwable, @NotNull String message) {
|
||||||
|
super(message);
|
||||||
|
this.throwable = throwable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs this exception.
|
||||||
|
*
|
||||||
|
* @param throwable throwable
|
||||||
|
*/
|
||||||
|
public UnexpectedThrowableException(@NotNull Throwable throwable) {
|
||||||
|
this.throwable = throwable;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions.dependency;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.utility.DependencyResolver;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when the {@link DependencyResolver} detects a dependency cycle.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public class DependencyCycleException extends RuntimeException {
|
||||||
|
/**
|
||||||
|
* Constructs this exception.
|
||||||
|
*
|
||||||
|
* @param path cycle path
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
public DependencyCycleException(@NotNull String path) {
|
||||||
|
super("Dependency cycle detected: " + path);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions.dependency;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.types.DependencyVector;
|
||||||
|
import de.staropensource.sosengine.base.utility.DependencyResolver;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when the {@link DependencyResolver} cannot resolve one
|
||||||
|
* or more {@link DependencyVector}s due to unmet dependencies.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||||
|
public class UnmetDependenciesException extends Exception {
|
||||||
|
/**
|
||||||
|
* Contains the unmet dependencies list supplied to the constructor.
|
||||||
|
* <p>
|
||||||
|
* The key contains the {@link DependencyVector} that
|
||||||
|
* has unmet dependencies, while the value contains the error.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the unmet dependencies list supplied to the constructor.
|
||||||
|
* <p>
|
||||||
|
* The key contains the {@link DependencyVector} that
|
||||||
|
* has unmet dependencies, while the value contains the error.
|
||||||
|
*
|
||||||
|
* @return unmet dependencies list
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
private final @NotNull Map<@NotNull DependencyVector, @NotNull String> unmetDependencies;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs this exception.
|
||||||
|
*
|
||||||
|
* @param unmetDependencies map of all unmet dependencies
|
||||||
|
* @see #unmetDependencies
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
public UnmetDependenciesException(@NotNull Map<@NotNull DependencyVector, @NotNull String> unmetDependencies) {
|
||||||
|
this.unmetDependencies = unmetDependencies;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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 dependency resolving.
|
||||||
|
*
|
||||||
|
* @see de.staropensource.sosengine.base.utility.DependencyResolver
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
package de.staropensource.sosengine.base.exceptions.dependency;
|
|
@ -1,8 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
* Copyright (c) 2024 The StarOpenSource Engine Authors
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
* Licensed under the GNU Affero General Public License v3
|
* 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
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -18,13 +17,9 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.staropensource.engine.newsubprj
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An example class.
|
* Exceptions thrown by the engine, subsystems and applications.
|
||||||
*
|
*
|
||||||
* @constructor Initializes this class
|
* @since v1-alpha1
|
||||||
* @since v1-alpha10
|
|
||||||
*/
|
*/
|
||||||
class Example private constructor() {
|
package de.staropensource.sosengine.base.exceptions;
|
||||||
}
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions.reflection;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.types.reflection.ClassType;
|
||||||
|
import de.staropensource.sosengine.base.utility.ListFormatter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when the invoked method does not apply to the type of the class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public class IncompatibleTypeException extends RuntimeException {
|
||||||
|
/**
|
||||||
|
* Constructs 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[] compatibleTypes) {
|
||||||
|
super("The method ReflectionClass#" + methodName + " only applies to type(s) " + ListFormatter.formatArray(compatibleTypes) + ", not " + requiredClassType.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs 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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions.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 {
|
||||||
|
/**
|
||||||
|
* Constructs 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");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions.reflection;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.reflection.ReflectionClass;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when a field could not be found.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public class InvalidFieldException extends Exception {
|
||||||
|
/**
|
||||||
|
* Constructs 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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions.reflection;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.reflection.ReflectionClass;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when a method could not be found.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public class InvalidMethodException extends Exception {
|
||||||
|
/**
|
||||||
|
* Constructs 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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions.reflection;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when a method could not be found due to an invalid method signature.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public class InvalidMethodSignature extends Exception {
|
||||||
|
/**
|
||||||
|
* Constructs this exception.
|
||||||
|
*
|
||||||
|
* @param methodName method name
|
||||||
|
*/
|
||||||
|
public InvalidMethodSignature(@NotNull String methodName) {
|
||||||
|
super("Method " + methodName + " has a different method signature");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions.reflection;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown if access to some class, method or field has been denied.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public class NoAccessException extends Exception {
|
||||||
|
/**
|
||||||
|
* Constructs 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");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions.reflection;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when an exception is thrown by a static initializer.
|
||||||
|
*
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@SuppressWarnings({ "unused", "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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs this exception.
|
||||||
|
*
|
||||||
|
* @param throwable throwable thrown by the static initializer
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
public StaticInitializerException(@NotNull Throwable throwable) {
|
||||||
|
this.throwable = throwable;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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.sosengine.base.reflection
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
package de.staropensource.sosengine.base.exceptions.reflection;
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions.versioning;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.VersioningSystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when trying to compare a {@link VersioningSystem} against another
|
||||||
|
* {@link VersioningSystem}, which it does not support.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public class IncompatibleVersioningSystemException extends RuntimeException {
|
||||||
|
/**
|
||||||
|
* Constructs 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.exceptions.versioning;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.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({ "unused", "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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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.sosengine.base.classes.VersioningSystem}s.
|
||||||
|
*
|
||||||
|
* @see de.staropensource.sosengine.base.classes.VersioningSystem
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
package de.staropensource.sosengine.base.exceptions.versioning;
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.internal.events;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Event;
|
||||||
|
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the engine is about to shutdown, after {@link de.staropensource.sosengine.base.events.EngineShutdownEvent}.
|
||||||
|
* <p>
|
||||||
|
* Meant for subsystems to perform cleanup and shutdown routines, not for applications.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public final class InternalEngineShutdownEvent implements Event {
|
||||||
|
/**
|
||||||
|
* Constructs this event.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public InternalEngineShutdownEvent() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public void callEvent() {
|
||||||
|
EventHelper.invokeAnnotatedMethods(getClass());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events used for engine-internal communication.
|
||||||
|
* These events are meant to be listened on by the base engine and it's subsystems.
|
||||||
|
*/
|
||||||
|
package de.staropensource.sosengine.base.internal.events;
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Engine-internal stuff, not part of the API.
|
||||||
|
*
|
||||||
|
* @since v1-alpha1
|
||||||
|
*/
|
||||||
|
package de.staropensource.sosengine.base.internal;
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.internal.placeholders;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||||
|
import de.staropensource.sosengine.base.utility.Math;
|
||||||
|
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 {
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public DateDay() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public @NotNull String replace(@NotNull String text) {
|
||||||
|
return text.replace("%date_day%", Math.padNumbers(Calendar.getInstance().get(Calendar.DAY_OF_MONTH), 2));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.internal.placeholders;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||||
|
import de.staropensource.sosengine.base.utility.Math;
|
||||||
|
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 {
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public DateMonth() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public @NotNull String replace(@NotNull String text) {
|
||||||
|
return text.replace("%date_month%", Math.padNumbers(Calendar.getInstance().get(Calendar.MONTH), 2));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.internal.placeholders;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||||
|
import de.staropensource.sosengine.base.utility.Math;
|
||||||
|
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 {
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public DateYear() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public @NotNull String replace(@NotNull String text) {
|
||||||
|
return text.replace("%date_year%", Math.padNumbers(Calendar.getInstance().get(Calendar.YEAR), 4));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.internal.placeholders;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||||
|
import de.staropensource.sosengine.base.data.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 {
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public EngineDependencyJansi() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public @NotNull String replace(@NotNull String text) {
|
||||||
|
return text.replace("%engine_dependency_jansi%", EngineInformation.getDependencyJansi());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.internal.placeholders;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||||
|
import de.staropensource.sosengine.base.data.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 {
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public EngineDependencyLwjgl() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public @NotNull String replace(@NotNull String text) {
|
||||||
|
return text.replace("%engine_dependency_lwjgl%", EngineInformation.getDependencyLwjgl());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.internal.placeholders;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||||
|
import de.staropensource.sosengine.base.data.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 {
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public EngineDependencyReflections() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public @NotNull String replace(@NotNull String text) {
|
||||||
|
return text.replace("%engine_dependency_reflections%", EngineInformation.getDependencyReflections());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||||
|
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||||
|
* Licensed under the GNU Affero General Public License v3
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.internal.placeholders;
|
||||||
|
|
||||||
|
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||||
|
import de.staropensource.sosengine.base.data.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 {
|
||||||
|
/**
|
||||||
|
* Constructs this class.
|
||||||
|
*
|
||||||
|
* @since v1-alpha0
|
||||||
|
*/
|
||||||
|
public EngineDependencySlf4j() {}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public @NotNull String replace(@NotNull String text) {
|
||||||
|
return text.replace("%engine_dependency_slf4j%", EngineInformation.getDependencySlf4j());
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue