Compare commits

..

222 commits

Author SHA1 Message Date
bbfb7802f1
Fix smol formatting issue 2024-12-21 13:40:01 +01:00
c640176dd7
Fix ANSI formatting issues 2024-12-21 13:38:41 +01:00
687631661d
Add AnsiSubsystem import
All checks were successful
PRs & Pushes / test (push) Successful in 2m45s
PRs & Pushes / build (push) Successful in 2m50s
PRs & Pushes / build-apidoc (push) Successful in 2m56s
2024-12-20 23:43:25 +01:00
edc1c4c1eb
Add charset check
Some checks failed
PRs & Pushes / build (push) Failing after 2m3s
PRs & Pushes / test (push) Failing after 2m3s
PRs & Pushes / build-apidoc (push) Failing after 16m22s
2024-12-20 23:42:59 +01:00
cd81e60808
Add register method and version checks to the ANSI subsystem
Some checks failed
PRs & Pushes / test (push) Failing after 2m17s
PRs & Pushes / build (push) Failing after 16m20s
PRs & Pushes / build-apidoc (push) Failing after 22m23s
2024-12-20 21:59:19 +01:00
3421fe55bf
Fix startup crashes not shutting down the engine
All checks were successful
PRs & Pushes / build (push) Successful in 3m36s
PRs & Pushes / test (push) Successful in 3m10s
PRs & Pushes / build-apidoc (push) Successful in 3m37s
2024-12-20 21:58:53 +01:00
0ffd137891
Add ansi subsystem (only formatter for now)
All checks were successful
PRs & Pushes / build (push) Successful in 4m47s
PRs & Pushes / test (push) Successful in 4m41s
PRs & Pushes / build-apidoc (push) Successful in 2m52s
2024-12-20 21:49:18 +01:00
76b2105e53
Remove Jansi dependency
All checks were successful
PRs & Pushes / test (push) Successful in 3m5s
PRs & Pushes / build (push) Successful in 3m8s
PRs & Pushes / build-apidoc (push) Successful in 3m17s
2024-12-20 21:47:30 +01:00
e483e5c3f1
Add formatting to SOSLSv2FormatBuilder 2024-12-20 21:47:15 +01:00
01c91244aa
Fix TwoCycleFormatterImpl parsing
All checks were successful
PRs & Pushes / test (push) Successful in 3m29s
PRs & Pushes / build (push) Successful in 2m48s
PRs & Pushes / build-apidoc (push) Successful in 3m21s
2024-12-20 21:46:46 +01:00
048ae6b074
Add subsystem version to log messages
All checks were successful
PRs & Pushes / build (push) Successful in 2m51s
PRs & Pushes / test (push) Successful in 3m22s
PRs & Pushes / build-apidoc (push) Successful in 3m38s
2024-12-20 21:46:20 +01:00
91128541f9
Remove unnecessary dependency inclusions
All checks were successful
PRs & Pushes / build (push) Successful in 2m45s
PRs & Pushes / test (push) Successful in 2m45s
PRs & Pushes / build-apidoc (push) Successful in 3m8s
2024-12-20 19:36:47 +01:00
e15ca5435c
Add more Tristate.of methods
All checks were successful
PRs & Pushes / build (push) Successful in 3m3s
PRs & Pushes / test (push) Successful in 4m25s
PRs & Pushes / build-apidoc (push) Successful in 4m22s
2024-12-20 19:36:18 +01:00
35099737a4
MOve OSHI dependency to 'base'
All checks were successful
PRs & Pushes / build (push) Successful in 2m31s
PRs & Pushes / test (push) Successful in 2m42s
PRs & Pushes / build-apidoc (push) Successful in 2m17s
2024-12-20 18:38:20 +01:00
9866b9b0dd
Use buildString method for some StringBuilders
All checks were successful
PRs & Pushes / build (push) Successful in 2m35s
PRs & Pushes / test (push) Successful in 2m38s
PRs & Pushes / build-apidoc (push) Successful in 2m28s
2024-12-20 18:31:19 +01:00
6eca780ebf
Move formatter stuff out of logging package
Some checks failed
PRs & Pushes / build (push) Failing after 1m57s
PRs & Pushes / test (push) Failing after 2m6s
PRs & Pushes / build-apidoc (push) Successful in 2m27s
2024-12-20 17:45:10 +01:00
f2576af0b3
Add dead documentation warning
Some checks failed
PRs & Pushes / test (push) Failing after 1m38s
PRs & Pushes / build (push) Failing after 1m40s
PRs & Pushes / build-apidoc (push) Successful in 2m32s
2024-12-20 02:52:24 +01:00
a49e437a4a
Add "Environment" crash category
Some checks failed
PRs & Pushes / build (push) Failing after 1m56s
PRs & Pushes / test (push) Failing after 2m2s
PRs & Pushes / build-apidoc (push) Has been cancelled
2024-12-20 02:50:50 +01:00
01b2955c39
Add tests for StackTraceUtils 2024-12-20 02:50:30 +01:00
3b532a2dda
Rename methods, update default value for methodCaller(depth) 2024-12-20 02:50:06 +01:00
9d001032c2
Add '@DisplayName's to tests, fix FileAccess scheduled deletion 2024-12-20 02:48:40 +01:00
d0dbdbeef8
Add 'fullTypePath' setting, give data types some love 2024-12-20 02:47:55 +01:00
60ce99305b
Add subsystem support
Some checks failed
PRs & Pushes / build (push) Failing after 1m57s
PRs & Pushes / test (push) Failing after 2m3s
PRs & Pushes / build-apidoc (push) Successful in 2m25s
2024-12-20 01:38:41 +01:00
8913f5a678
Add initialization & final shutdown message 2024-12-20 01:38:22 +01:00
e4f4ab6f8c
Add EngineConfiguration.toDefault method 2024-12-20 01:37:39 +01:00
04f8aa360a
Add Engine.reload method and SHUT_DOWN_FINAL state 2024-12-20 01:37:03 +01:00
c1a14d343c
Move testapp's logger to internal property 2024-12-20 01:32:40 +01:00
803e18239d
Change license from GNU AGPL v3 to GNU GPL v3
All checks were successful
PRs & Pushes / build (push) Successful in 2m37s
PRs & Pushes / test (push) Successful in 2m36s
PRs & Pushes / build-apidoc (push) Successful in 2m15s
2024-12-20 01:23:25 +01:00
50e438a16b
Add Tristate
All checks were successful
PRs & Pushes / build (push) Successful in 2m56s
PRs & Pushes / test (push) Successful in 2m54s
PRs & Pushes / build-apidoc (push) Successful in 2m21s
2024-12-20 00:35:43 +01:00
611d7a93ff
Prevent copying in root project
All checks were successful
PRs & Pushes / build (push) Successful in 2m38s
PRs & Pushes / test (push) Successful in 3m17s
PRs & Pushes / build-apidoc (push) Successful in 2m31s
2024-12-19 02:52:37 +01:00
e035b5ab80
Quote channel in crash report
Some checks failed
PRs & Pushes / build (push) Failing after 2m12s
PRs & Pushes / test (push) Failing after 2m10s
PRs & Pushes / build-apidoc (push) Has been cancelled
2024-12-19 02:51:05 +01:00
47bb0f6cab
Add BuildInformation & a matching CrashCategory 2024-12-19 02:50:00 +01:00
8b15e8a84e
Update gradle.properties naming scheme 2024-12-19 02:49:32 +01:00
b602897ff4
Update files 2024-12-19 02:49:15 +01:00
aa9200a372
Update Call data class, squash all TODOs 2024-12-19 02:48:55 +01:00
a7c33284dd
Add Miscellaneous and StackTraceUtils classes 2024-12-19 02:47:18 +01:00
70e81a7a2c
Add VersionType class for SOSVS 2024-12-19 02:46:51 +01:00
9b264ca6cc
Allow for null in CrashCategory return values 2024-12-19 02:46:09 +01:00
2629e940e7
Add git and gradle build information
Some checks failed
PRs & Pushes / build (push) Failing after 1m50s
PRs & Pushes / test (push) Failing after 1m55s
PRs & Pushes / build-apidoc (push) Successful in 2m6s
2024-12-18 17:41:53 +01:00
574c9586a1
Rename method argument
All checks were successful
PRs & Pushes / build (push) Successful in 2m36s
PRs & Pushes / test (push) Successful in 2m35s
PRs & Pushes / build-apidoc (push) Successful in 2m33s
2024-12-18 17:22:08 +01:00
9ee4ff933f
Fix unwanted state change during non-fatal crash 2024-12-18 17:21:50 +01:00
933971c82f
Fix Kdoc class comment in SOSLSv2FormatBuilder
All checks were successful
PRs & Pushes / build (push) Successful in 4m0s
PRs & Pushes / test (push) Successful in 4m19s
PRs & Pushes / build-apidoc (push) Successful in 4m3s
2024-12-17 19:59:44 +01:00
b0c3473c83
Add newline indent for multiline log messages
All checks were successful
PRs & Pushes / test (push) Successful in 3m48s
PRs & Pushes / build (push) Successful in 3m51s
PRs & Pushes / build-apidoc (push) Successful in 3m44s
2024-12-17 19:58:36 +01:00
b7772f5fb8
Add much more getters to the Environment class
All checks were successful
PRs & Pushes / build (push) Successful in 2m32s
PRs & Pushes / test (push) Successful in 3m14s
PRs & Pushes / build-apidoc (push) Successful in 3m15s
2024-12-17 19:42:04 +01:00
dd920dffaa
Fix FileAccess test issues, now works everywhere
All checks were successful
PRs & Pushes / build (push) Successful in 2m40s
PRs & Pushes / build-apidoc (push) Successful in 2m37s
PRs & Pushes / test (push) Successful in 3m11s
2024-12-17 16:16:04 +01:00
bec621e410
Hopefully fix paths on Windoze?
All checks were successful
PRs & Pushes / test (push) Successful in 3m8s
PRs & Pushes / build (push) Successful in 3m12s
PRs & Pushes / build-apidoc (push) Successful in 3m37s
2024-12-17 15:57:11 +01:00
5e1dd3fc35
Add more properties to Environment class
All checks were successful
PRs & Pushes / test (push) Successful in 3m3s
PRs & Pushes / build (push) Successful in 3m5s
PRs & Pushes / build-apidoc (push) Successful in 3m3s
Will probably add more tomorrow
2024-12-17 04:29:20 +01:00
d5a03c885b
Add support for macOS
Just had to install macOS in a VM using QuickEmu (many thanks to them!) to add support for this. After installing it, creating an Apple account just to download Xcode, install OpenJDK using Homebrew and then using JShell and some searching I can confidently say that I find it hilarious that this piece of garbage exists. No keyboard shortcuts work (likely because of that Command key thingy), everything is clunky as hell and nothing really makes sense. How can anybody use this piece of overpriced shit? Anyway, for these four rich kiddies which want to run their favourite game on their parent's Macbook can do that now.

In case you need to install shitOS too: https://github.com/quickemu-project/quickemu/wiki/03-Create-macOS-virtual-machines
They make it incredibly easy to do, so big shoutouts to them!
2024-12-17 03:55:07 +01:00
bf449971e9
Finalize FileAccess tests
All checks were successful
PRs & Pushes / build (push) Successful in 2m28s
PRs & Pushes / test (push) Successful in 2m25s
PRs & Pushes / build-apidoc (push) Successful in 2m23s
2024-12-17 03:26:52 +01:00
c13eaead94
Fix FileAccess for good, add new 2 verify methods 2024-12-17 03:26:39 +01:00
32816ecce1
Split TestBase's methods & add more functionality 2024-12-17 03:24:50 +01:00
ce535fdca6
Add test job to commit workflow
All checks were successful
PRs & Pushes / build (push) Successful in 2m54s
PRs & Pushes / build-apidoc (push) Successful in 3m50s
PRs & Pushes / test (push) Successful in 3m52s
2024-12-16 02:45:36 +01:00
560c01100f
Update FileAccess tests
All checks were successful
PRs & Pushes / build (push) Successful in 2m10s
PRs & Pushes / build-apidoc (push) Successful in 2m31s
2024-12-16 02:37:16 +01:00
ce7bd233b6
Make FileAccess.createLink accept FileAccess' only 2024-12-16 02:37:09 +01:00
f0c43d7b53
Add 'noFollowSymbolicLink' argument to 'exists' 2024-12-16 02:36:55 +01:00
f7855afc3e
Add symbolic link and void file handling 2024-12-16 02:36:20 +01:00
6389aaa5d0
Remove never working hard link detection 2024-12-16 02:34:53 +01:00
0f49fff498
Remove FileAccess.isHidden method 2024-12-16 02:33:51 +01:00
f43f9b6e2e
Delete scheduled directories on shutdown 2024-12-16 02:33:14 +01:00
4d7474ae22
Add .kotlin directory to .gitignore 2024-12-16 02:33:02 +01:00
479c965c1a
Move LoggerThreadingHandler, support start & stop 2024-12-16 02:32:50 +01:00
31c015dc65
Add default engine-core channel 2024-12-15 22:34:05 +01:00
a655dec583
Add unit testing 2024-12-15 22:33:31 +01:00
6b201fd0e0
do many fun things (see commit desc)
All checks were successful
PRs & Pushes / build-apidoc (push) Successful in 2m29s
PRs & Pushes / build (push) Successful in 2m32s
This commit adds a few shutdown methods, the EngineConfiguration class (pretty much the LoggingConfiguration class with properties renamed and one added), a new adapter, support for multiple adapters per channel and better communication between the logging system and the engine.
2024-12-15 20:11:26 +01:00
353e9527c2
Remove standalone logging system comment
All checks were successful
PRs & Pushes / build (push) Successful in 2m31s
PRs & Pushes / build-apidoc (push) Successful in 2m30s
2024-12-15 19:22:47 +01:00
86dd1e4520
Integrate logging subproject into base subproject
All checks were successful
PRs & Pushes / build (push) Successful in 3m25s
PRs & Pushes / build-apidoc (push) Successful in 3m24s
2024-12-15 19:22:25 +01:00
c540060bcd
Remove traces of StackTraceElement class
All checks were successful
PRs & Pushes / build (push) Successful in 2m8s
PRs & Pushes / build-apidoc (push) Successful in 2m34s
2024-12-15 19:20:24 +01:00
2b8cf723f6
Add crash handler and add various optimizations 2024-12-15 19:16:43 +01:00
2cfc8cad9d
Add verification pass to updateDefaultPaths method
Some checks failed
PRs & Pushes / build (push) Failing after 1m39s
PRs & Pushes / build-apidoc (push) Failing after 1m49s
2024-12-15 13:50:53 +01:00
1fc337d9b8
Make engine more resilient against init crashes 2024-12-15 13:50:36 +01:00
6f998f4e33
Update NonKotlinContact targets 2024-12-15 13:50:09 +01:00
ae5ba252a5
Move logger interfaces and classes to correct pkg 2024-12-15 13:49:38 +01:00
e6b5ead361
[noci] Add toolchain skip note 2024-12-15 01:17:52 +01:00
8393818043
Add FileAccess class with many exceptions
All checks were successful
PRs & Pushes / build (push) Successful in 2m7s
PRs & Pushes / build-apidoc (push) Successful in 2m22s
The FileAccess class is an almost 1:1 rewrite of the old FileAccess class from v1-alpha9, just with some method names changed, a set of "verify" methods, no setPosixPermissions method anymore and wrapper exceptions around Java exceptions to avoid direct contact with Java stuff for public API. See the NonKotlinContact annotation for more information.
The old FileAccess class (for reference): 1e978e3146/base/src/main/java/de/staropensource/engine/base/utility/FileAccess.java
2024-12-15 01:15:50 +01:00
56152536f9
Add Environment class 2024-12-15 01:12:07 +01:00
eea7f5f4af
Add Engine.State, Engine.bootstrap & Engine.shutdown 2024-12-15 01:11:22 +01:00
1e40c8b121
Add NonKotlinContact annotation 2024-12-15 01:09:58 +01:00
e76b0e72ff
Fix padding of dates and times in log format 2024-12-15 01:06:05 +01:00
ef692a31d5
No kotlin multiplatform
All checks were successful
PRs & Pushes / build-apidoc (push) Successful in 2m11s
PRs & Pushes / build (push) Successful in 2m18s
While running the engine on multiple of Kotlin's supported platforms would
be cool, the standard library is just way too limited for our usecase. The
JVM simply has the best support and is the most suited option.
This would reap additional benefits:
- Java, Scala and Groovy interoperability
- existing Java libraries and tooling can be (re)used
- compilation using native-image may be possible under the new rewrite (which would replace the need for Kotlin/Native)
2024-12-13 21:52:08 +01:00
92b36f30e2
Rename TwoCycleFormatterBase -> TwoCycleFormatterImpl
All checks were successful
PRs & Pushes / build (push) Successful in 3m20s
PRs & Pushes / build-apidoc (push) Successful in 3m49s
2024-12-13 18:36:27 +01:00
da0040fb02
Add & update package-info files 2024-12-13 18:36:27 +01:00
9b5d12203f
Make private secondary constructors the primaries 2024-12-13 18:36:27 +01:00
fe2edbf3c1
Fix link
For anywone wondering: The last commit (f8ec8e282d) was authored by me. I authored it on the go on Forgejo's web interface, that's why it is unsigned.
2024-12-13 18:36:27 +01:00
f8ec8e282d Fix icon size on mobile devices
All checks were successful
PRs & Pushes / build-apidoc (push) Successful in 2m16s
PRs & Pushes / build (push) Successful in 2m18s
2024-12-13 09:24:09 +01:00
aef292f55c
Add project properties how-to-use explanation
All checks were successful
PRs & Pushes / build (push) Successful in 3m41s
PRs & Pushes / build-apidoc (push) Successful in 3m39s
2024-12-13 03:45:59 +01:00
b243a22e53
Fix index references
All checks were successful
PRs & Pushes / build (push) Successful in 2m28s
PRs & Pushes / build-apidoc (push) Successful in 2m27s
2024-12-13 03:41:54 +01:00
7fd83872de
Update README.md
Some checks failed
PRs & Pushes / build-apidoc (push) Has been cancelled
PRs & Pushes / build (push) Has been cancelled
2024-12-13 03:40:58 +01:00
3b1d60f41c
Shorten JVM options 2024-12-13 03:35:55 +01:00
0a30180d00
Fix artifact names
All checks were successful
PRs & Pushes / build (push) Successful in 2m7s
PRs & Pushes / build-apidoc (push) Successful in 2m6s
2024-12-13 03:16:50 +01:00
b56164f545
Add 'java.skipToolchainSpecification' option
All checks were successful
PRs & Pushes / build (push) Successful in 2m6s
PRs & Pushes / build-apidoc (push) Successful in 2m36s
2024-12-13 03:13:38 +01:00
f6238067fd
Update workflows
Some checks failed
PRs & Pushes / build (push) Failing after 1m43s
PRs & Pushes / build-apidoc (push) Failing after 1m43s
2024-12-13 03:10:28 +01:00
377c71dfba
Extend testapp build.gradle.kts
Some checks failed
build-and-test / generate-javadoc (push) Has been cancelled
build-and-test / build (push) Has been cancelled
build-and-test / test (push) Has been cancelled
2024-12-13 03:10:15 +01:00
c78cb4eb75
Use string templates 2024-12-13 02:59:35 +01:00
083bd022bc
Add Kotlin compiler configuration 2024-12-13 02:59:25 +01:00
5fb6046e5f
[noci] Update README icon size 2024-12-12 23:11:25 +01:00
ba412cec50
Initial rewrite commit (see #17)
Some checks failed
build-and-test / build (push) Failing after 1m54s
build-and-test / generate-javadoc (push) Failing after 1m54s
build-and-test / test (push) Failing after 1m54s
2024-12-12 23:10:29 +01:00
1e978e3146
Add toString() method to VersioningSystem
Some checks failed
build-and-test / build (push) Failing after 2m21s
build-and-test / test (push) Failing after 17m14s
build-and-test / generate-javadoc (push) Failing after 17m30s
2024-12-08 00:10:15 +01:00
499d704695
Add <reset_correct> tag to logging system
Some checks failed
build-and-test / build (push) Failing after 1m6s
build-and-test / test (push) Failing after 1m11s
build-and-test / generate-javadoc (push) Failing after 1m14s
2024-12-05 15:37:37 +01:00
0c26660f27
Fix AnsiShortcodeParser parsing
Some checks failed
build-and-test / generate-javadoc (push) Failing after 1m10s
build-and-test / build (push) Failing after 1m13s
build-and-test / test (push) Failing after 1m11s
2024-12-05 15:27:23 +01:00
f76878f067
Add ability to disable log message sanitization
Some checks failed
build-and-test / test (push) Failing after 1m19s
build-and-test / generate-javadoc (push) Failing after 1m21s
build-and-test / build (push) Failing after 1m23s
2024-12-04 22:22:40 +01:00
a392e8eb48
Fix directory handling, add more content listing methods
Some checks failed
build-and-test / build (push) Failing after 1m34s
build-and-test / generate-javadoc (push) Failing after 1m36s
build-and-test / test (push) Failing after 1m34s
2024-12-04 01:01:17 +01:00
a7c02cc9c2
Update logging calls in FileAccess 2024-12-04 01:00:06 +01:00
f7c130d66e
Fix FileAccess#move and FileAccess#copy
Some checks failed
build-and-test / test (push) Failing after 1m31s
build-and-test / build (push) Failing after 1m35s
build-and-test / generate-javadoc (push) Failing after 1m33s
2024-12-03 21:46:46 +01:00
8126b3ab83
Fix MiscellaneousTest failing tests
Some checks failed
build-and-test / build (push) Failing after 1m37s
build-and-test / generate-javadoc (push) Failing after 1m39s
build-and-test / test (push) Failing after 1m46s
2024-12-02 21:41:38 +01:00
a7dabfb923
Add FileAccess#move and FileAccess#copy methods
Some checks failed
build-and-test / build (push) Failing after 1m27s
build-and-test / test (push) Failing after 1m35s
build-and-test / generate-javadoc (push) Failing after 1m40s
2024-12-02 21:39:28 +01:00
de6b5f76f2
Add getPathRaw() and toString() methods 2024-12-02 21:34:59 +01:00
19f6838300
Fix engine initialization exception handling 2024-12-02 21:34:35 +01:00
8d5cb0ce23
Add more default directories 2024-12-02 21:34:24 +01:00
ed1c1d3b1a
Add 'level' and 'origin' log features
Some checks failed
build-and-test / generate-javadoc (push) Failing after 1m36s
build-and-test / test (push) Failing after 1m34s
build-and-test / build (push) Failing after 1m38s
2024-12-02 20:59:47 +01:00
571d600b09
Fix NPE in stacktraceAsStringRecursive method
Some checks failed
build-and-test / build (push) Failing after 1m23s
build-and-test / generate-javadoc (push) Failing after 1m26s
build-and-test / test (push) Failing after 1m29s
2024-12-02 02:31:04 +01:00
92aa012738
Attempt at fixing window and bgfx reinit
Some checks failed
build-and-test / build (push) Failing after 1m32s
build-and-test / test (push) Failing after 1m48s
build-and-test / generate-javadoc (push) Failing after 4m47s
2024-12-01 21:11:46 +01:00
ec1dcb734a
Remove subpackages from rendering.type package
Some checks failed
build-and-test / test (push) Failing after 2m9s
build-and-test / build (push) Failing after 15m9s
build-and-test / generate-javadoc (push) Failing after 15m51s
2024-12-01 20:10:37 +01:00
3450ba3fb0
Add renderer and render info settings
Some checks failed
build-and-test / build (push) Has been cancelled
build-and-test / test (push) Has been cancelled
build-and-test / generate-javadoc (push) Has been cancelled
2024-12-01 20:09:36 +01:00
91b2ab7a22
Add check if logging adapter has changed
Some checks failed
build-and-test / build (push) Failing after 4m30s
build-and-test / test (push) Failing after 5m16s
build-and-test / generate-javadoc (push) Failing after 43m0s
2024-12-01 16:40:06 +01:00
a2a19c03aa
Fix Javadoc issues 2024-12-01 16:39:52 +01:00
2e69d37ec7
[noci] Update actions-docker pull url 2024-11-30 12:56:17 +01:00
d71ff5db0d
Relocate + split rendering code -> separate class
Some checks failed
build-and-test / build (push) Failing after 1m57s
build-and-test / generate-javadoc (push) Failing after 2m2s
build-and-test / test (push) Failing after 2m2s
This should allow for more JIT optimizations
2024-11-25 02:52:55 +01:00
485b813853
Fix FPS calculation
Some checks failed
build-and-test / build (push) Failing after 1m51s
build-and-test / test (push) Failing after 1m57s
build-and-test / generate-javadoc (push) Failing after 2m5s
2024-11-25 02:29:00 +01:00
d6d890b259
Fix delta time and FPS count calculation
Some checks failed
build-and-test / build (push) Failing after 2m0s
build-and-test / generate-javadoc (push) Failing after 2m3s
build-and-test / test (push) Failing after 2m5s
2024-11-25 02:26:32 +01:00
2db14012f8
Remove all remaining traces of ImmutableHashMap
Some checks failed
build-and-test / build (push) Failing after 1m58s
build-and-test / test (push) Failing after 2m4s
build-and-test / generate-javadoc (push) Failing after 2m7s
2024-11-25 01:59:16 +01:00
7d15c5c73d
Cleanup rendering subsystem
Some checks failed
build-and-test / build (push) Failing after 2m4s
build-and-test / generate-javadoc (push) Failing after 2m5s
build-and-test / test (push) Failing after 2m6s
2024-11-25 01:47:00 +01:00
c89e65882c
Very experimental rendering subsystem changes
Some checks failed
build-and-test / build (push) Failing after 2m4s
build-and-test / test (push) Failing after 2m4s
build-and-test / generate-javadoc (push) Failing after 2m8s
2024-11-24 16:39:11 +01:00
45ec057457
Rename some Miscellaneous methods, add stacktraceAsStringRecursive
Some checks failed
build-and-test / build (push) Failing after 1m57s
build-and-test / generate-javadoc (push) Failing after 2m1s
build-and-test / test (push) Failing after 2m1s
2024-11-24 15:39:48 +01:00
c975c5adff
Update icon
Some checks failed
build-and-test / test (push) Failing after 1m56s
build-and-test / generate-javadoc (push) Failing after 2m11s
build-and-test / build (push) Failing after 2m13s
2024-11-24 13:28:28 +01:00
64f48a472f
Perform code maintenance
Please note that this commit may not fully compile as I'm currently working on a rendering subsystem rewrite.
2024-11-24 13:28:15 +01:00
8bd0896415
Ignore JVM segfault log files
Some checks failed
build-and-test / build (push) Failing after 59s
build-and-test / generate-javadoc (push) Failing after 1m31s
build-and-test / test (push) Successful in 1m37s
2024-11-10 20:56:52 +01:00
20580fb80b
Update documentation to reflect last commit 2024-11-10 20:56:35 +01:00
a45f010196
Merge and rename windowing subsystem 2024-11-10 20:55:01 +01:00
69cf668c4d
Heavily improve API doc of EngineConfiguration class
All checks were successful
build-and-test / test (push) Successful in 1m40s
build-and-test / generate-javadoc (push) Successful in 1m46s
build-and-test / build (push) Successful in 1m49s
2024-11-10 17:59:21 +01:00
7560e150af
Bump version
All checks were successful
build-and-test / test (push) Successful in 1m50s
build-and-test / build (push) Successful in 1m55s
build-and-test / generate-javadoc (push) Successful in 1m55s
2024-11-10 17:17:10 +01:00
b643735d0b
Update Docusaurus once again
All checks were successful
build-and-test / test (push) Successful in 1m18s
build-and-test / generate-javadoc (push) Successful in 1m22s
build-and-test / build (push) Successful in 1m24s
2024-11-09 16:16:34 +01:00
d12206b925
Update dependencies, set source version to Java 21
All checks were successful
build-and-test / test (push) Successful in 1m26s
build-and-test / generate-javadoc (push) Successful in 1m32s
build-and-test / build (push) Successful in 1m34s
2024-11-09 15:51:39 +01:00
dde8972feb
Remove unused logTemplate config setting
All checks were successful
build-and-test / test (push) Successful in 1m4s
build-and-test / build (push) Successful in 1m15s
build-and-test / generate-javadoc (push) Successful in 1m21s
2024-11-09 14:37:32 +01:00
6425442c25
Update documentation
All checks were successful
build-and-test / test (push) Successful in 1m2s
build-and-test / build (push) Successful in 1m21s
build-and-test / generate-javadoc (push) Successful in 1m20s
2024-11-08 22:15:25 +01:00
d1d8e305ed
Fix build.gradle log call
All checks were successful
build-and-test / build (push) Successful in 1m17s
build-and-test / test (push) Successful in 1m27s
build-and-test / generate-javadoc (push) Successful in 1m34s
2024-11-06 14:29:31 +01:00
a6a41f5cec
Update docusaurus
Some checks failed
build-and-test / generate-javadoc (push) Failing after 59s
build-and-test / test (push) Successful in 1m48s
build-and-test / build (push) Successful in 1m52s
2024-11-06 02:31:45 +01:00
7cf9a4f418
Remove all old shortcode converter references
Some checks failed
build-and-test / test (push) Successful in 1m17s
build-and-test / build (push) Successful in 1m47s
build-and-test / generate-javadoc (push) Failing after 1m45s
2024-11-05 21:16:42 +01:00
ea93d12151
Move the very internal shutdown event to the non-internal events package
Some checks failed
build-and-test / build (push) Has been cancelled
build-and-test / generate-javadoc (push) Has been cancelled
build-and-test / test (push) Has been cancelled
2024-11-05 21:15:30 +01:00
c533a06148
Overhaul engine init procedure + add new placeholder
Some checks failed
build-and-test / build (push) Successful in 1m17s
build-and-test / generate-javadoc (push) Failing after 1m21s
build-and-test / test (push) Successful in 1m30s
2024-11-05 21:13:30 +01:00
4281f946be
Fix Javadoc generation issues
Some checks failed
build-and-test / generate-javadoc (push) Failing after 1m4s
build-and-test / build (push) Successful in 1m16s
build-and-test / test (push) Successful in 1m15s
2024-11-05 03:07:34 +01:00
5021f2cc35
Remove testing Logger#crash call
Some checks failed
build-and-test / build (push) Failing after 46s
build-and-test / test (push) Failing after 53s
build-and-test / generate-javadoc (push) Failing after 1m4s
2024-11-05 02:57:52 +01:00
edd28bef2f
Make getArguments return an immutable list
Some checks failed
build-and-test / test (push) Failing after 58s
build-and-test / generate-javadoc (push) Failing after 1m0s
build-and-test / build (push) Failing after 1m3s
2024-11-05 02:55:28 +01:00
7c0b7e1e90
Rewrite logging infrastructure
This commit changes the following things inside the logging infrastructure:
- passing issuerClass, issuerOrigin and issuerMetadata is no longer required, relevant information is now being pulled from the stack
- split huge classes into multiple smaller ones
- separated "normal" and asynchronous logging classes
- simplified logging
- improved performance
- more detailed crash reporting
- regex-based filtering
- internal placeholders have been replaced with more lightweight method calls
- much more changes
2024-11-05 02:54:50 +01:00
0966a43d5e
Fix Javadoc generation issues
All checks were successful
build-and-test / build (push) Successful in 1m4s
build-and-test / test (push) Successful in 1m16s
build-and-test / generate-javadoc (push) Successful in 1m22s
2024-11-03 18:54:27 +01:00
2730aa0f61
Add forced early engine init stage check
Some checks failed
build-and-test / build (push) Failing after 1m22s
build-and-test / test (push) Successful in 1m18s
build-and-test / generate-javadoc (push) Failing after 1m21s
2024-11-03 18:42:42 +01:00
ed1c8b9d3e
Add FileAccess class for filesystem access
Some checks failed
build-and-test / generate-javadoc (push) Failing after 1m18s
build-and-test / build (push) Failing after 1m22s
build-and-test / test (push) Successful in 1m30s
2024-11-03 18:40:48 +01:00
d3a01c2c66
Allow throwing all exceptions during engine init
Due to some Java limitation we are required to throw a RuntimeException with our original exception contained within and afterwards unwrap it so we can throw any exception we like. That is dumb.
2024-11-03 18:40:19 +01:00
a21ef1bc5f
Fix variable name convention 2024-11-03 18:32:40 +01:00
a619746e8d
Update abstract class constructor API doc 2024-10-30 22:32:03 +01:00
e42ac8a08e
Remove unecessary Window#render() call
All checks were successful
build-and-test / build (push) Successful in 1m7s
build-and-test / test (push) Successful in 1m27s
build-and-test / generate-javadoc (push) Successful in 1m30s
2024-10-18 17:58:03 +02:00
ffcf4604a4
Add setter docs for GlfwWindow#renderCode
All checks were successful
build-and-test / test (push) Successful in 1m8s
build-and-test / generate-javadoc (push) Successful in 1m40s
build-and-test / build (push) Successful in 1m43s
2024-10-18 17:51:00 +02:00
6f8d190d6f
Add ability to inject custom rendering code, open GLFW subsystem
Some checks failed
build-and-test / build (push) Failing after 1m18s
build-and-test / generate-javadoc (push) Failing after 1m18s
build-and-test / test (push) Successful in 1m24s
2024-10-18 16:24:10 +02:00
c2028cfa33
Add window hint to instruct GLFW to use no API
All checks were successful
build-and-test / build (push) Successful in 1m16s
build-and-test / test (push) Successful in 1m30s
build-and-test / generate-javadoc (push) Successful in 1m34s
2024-10-18 15:08:06 +02:00
40894bedba
Bump version 2024-10-16 13:43:46 +02:00
6d7701a7c3
Update GlfwWindow#setIcons logging
All checks were successful
build-and-test / generate-javadoc (push) Successful in 1m34s
build-and-test / test (push) Successful in 1m33s
build-and-test / build (push) Successful in 1m37s
2024-10-16 13:21:54 +02:00
665ea05041
Fix Window#setIcons issue 2024-10-16 13:21:32 +02:00
37ac235662
Update versions and links in documentation
Some checks are pending
build-and-test / generate-javadoc (push) Waiting to run
build-and-test / test (push) Waiting to run
build-and-test / build (push) Successful in 1m12s
2024-10-16 13:09:53 +02:00
01ea995177
Add missing package-info.java class
All checks were successful
build-and-test / build (push) Successful in 1m33s
build-and-test / test (push) Successful in 1m30s
build-and-test / generate-javadoc (push) Successful in 1m34s
2024-10-16 13:06:24 +02:00
294ec217ea
Correct package structure inside GLFW subsystem 2024-10-16 13:06:17 +02:00
4c9bfb3732
Bump version 2024-10-16 13:05:40 +02:00
f6c99b66e8
Fix debugFrames check and Window#icons type
All checks were successful
build-and-test / build (push) Successful in 1m12s
build-and-test / test (push) Successful in 1m25s
build-and-test / generate-javadoc (push) Successful in 1m29s
2024-10-16 13:03:19 +02:00
643bda6c28
Update maven repository URL
All checks were successful
build-and-test / test (push) Successful in 1m2s
build-and-test / build (push) Successful in 1m8s
build-and-test / generate-javadoc (push) Successful in 1m14s
2024-10-15 13:53:16 +02:00
281e7db708
Update documentation 2024-10-15 13:51:02 +02:00
2d558f8482
Update and add README.md files 2024-10-15 13:49:02 +02:00
0d5f19ee31
Rename and update errorShortcodeConverter setting
All checks were successful
build-and-test / test (push) Successful in 57s
build-and-test / build (push) Successful in 1m17s
build-and-test / generate-javadoc (push) Successful in 1m18s
2024-10-15 13:16:59 +02:00
8456e92a52
Fix EngineConfiguration test
All checks were successful
build-and-test / test (push) Successful in 1m15s
build-and-test / generate-javadoc (push) Successful in 1m31s
build-and-test / build (push) Successful in 1m33s
2024-10-15 04:07:08 +02:00
d0a68b22d2
Fix Javadoc documentation 2024-10-15 04:07:01 +02:00
2cf769b599
Fix LWJGL initialization error handling 2024-10-15 04:06:52 +02:00
25a944baf4
Fix null value crash 2024-10-15 04:06:31 +02:00
f4019455cc
Fix LWJGL native load error 2024-10-15 04:06:05 +02:00
cdde093b31
Update notification dismissal system a bit 2024-10-15 04:05:37 +02:00
8a52e991fd
Fixed LWJGL natives switch 2024-10-15 03:38:35 +02:00
6cd38377b2
Reorganize build scripts
Some checks failed
build-and-test / build (push) Failing after 37s
build-and-test / generate-javadoc (push) Failing after 39s
build-and-test / test (push) Failing after 44s
2024-10-15 03:36:50 +02:00
bed5811b70
Add notification subsystem
Some checks failed
build-and-test / generate-javadoc (push) Failing after 1m5s
build-and-test / test (push) Failing after 1m4s
build-and-test / build (push) Failing after 1m10s
2024-10-15 03:30:55 +02:00
1e6fa79716
Implement experimental window icon support 2024-10-15 03:30:49 +02:00
cdd68833cb
Fix double Engine initialization 2024-10-15 03:29:13 +02:00
175b0248d9
Fix Window.Builder#setMonitor visibility
Some checks failed
build-and-test / test (push) Failing after 1s
build-and-test / generate-javadoc (push) Failing after 4s
build-and-test / build (push) Failing after 15s
2024-10-14 16:08:44 +02:00
b3ef38b6be
Change type of Window#windows from Set to List 2024-10-14 16:08:29 +02:00
10e3b26ac0
Respect 'debugFrames' subsystem config option
Some checks failed
build-and-test / generate-javadoc (push) Failing after 58s
build-and-test / build (push) Failing after 1m4s
build-and-test / test (push) Has been cancelled
2024-10-14 16:02:35 +02:00
7a7da3729c
Respect a window's rendering flag state 2024-10-14 16:01:50 +02:00
2f0bc19e7c
Update/Fix engine init exception handling + errors
Some checks failed
build-and-test / generate-javadoc (push) Failing after 1m6s
build-and-test / build (push) Failing after 1m11s
build-and-test / test (push) Has been cancelled
2024-10-14 15:48:54 +02:00
9d19dd8b57
Remove ShortcodeParser debug logging 2024-10-14 15:47:56 +02:00
bd05235af9
'final'ize 'testing' classes
Some checks failed
build-and-test / test (push) Successful in 1m41s
build-and-test / generate-javadoc (push) Failing after 1m44s
build-and-test / build (push) Failing after 1m56s
2024-10-07 01:32:23 +02:00
a0fdfd2722
Fix TestBase engine initialization 2024-10-07 01:32:05 +02:00
a77794b105
Update gradle wrapper
Some checks failed
build-and-test / generate-javadoc (push) Failing after 3m18s
build-and-test / build (push) Failing after 3m21s
build-and-test / test (push) Failing after 3m18s
2024-10-03 21:38:01 +02:00
3bd6a26e59
Remove unused methods, finalize class
Some checks failed
build-and-test / build (push) Failing after 30s
build-and-test / test (push) Failing after 31s
build-and-test / generate-javadoc (push) Failing after 39s
2024-09-28 21:47:15 +02:00
5e829771a7
Rename LogLevel -> LogLevelEvent
The source code now looks better :)
2024-09-28 21:46:20 +02:00
9922c672f6
Encapsulate windowing.glfw.implementable package 2024-09-28 21:45:47 +02:00
0075b465cd
Update Javadoc and class constructors 2024-09-28 21:45:09 +02:00
46b52173fd
Remove HSV from Color class description
Some checks failed
build-and-test / build (push) Failing after 28s
build-and-test / generate-javadoc (push) Failing after 31s
build-and-test / test (push) Successful in 49s
2024-09-28 17:54:06 +02:00
26294b3fa0
Add Color class
Some checks failed
build-and-test / build (push) Failing after 30s
build-and-test / generate-javadoc (push) Failing after 46s
build-and-test / test (push) Successful in 49s
2024-09-28 17:08:35 +02:00
f81d27060a
Add 4D vectors 2024-09-28 17:08:27 +02:00
dd4ebcd88a
Mark all arrays as @NotNull
Some checks failed
build-and-test / build (push) Failing after 46s
build-and-test / generate-javadoc (push) Failing after 44s
build-and-test / test (push) Successful in 58s
2024-09-28 16:59:45 +02:00
02aa744098
Rename de.staropensource.sosengine package
All checks were successful
build-and-test / test (push) Successful in 1m4s
build-and-test / build (push) Successful in 1m21s
build-and-test / generate-javadoc (push) Successful in 1m27s
2024-09-27 23:16:25 +02:00
a4224f9c51
Fix copyright notice copyright attribution
Some checks failed
build-and-test / generate-javadoc (push) Has been cancelled
build-and-test / build (push) Has been cancelled
build-and-test / test (push) Has been cancelled
2024-09-27 23:02:16 +02:00
b68a7855dc
Fix development documentation link
All checks were successful
build-and-test / test (push) Successful in 1m57s
build-and-test / build (push) Successful in 2m9s
build-and-test / generate-javadoc (push) Successful in 2m27s
2024-09-22 14:20:17 +02:00
f1b3bb5b88
Bump version and add v1-alpha5 API doc links
All checks were successful
build-and-test / test (push) Successful in 1m24s
build-and-test / build (push) Successful in 1m30s
build-and-test / generate-javadoc (push) Successful in 1m39s
2024-09-22 14:08:58 +02:00
38d8deefa7
Fix @since tags
All checks were successful
build-and-test / test (push) Successful in 1m30s
build-and-test / build (push) Successful in 1m36s
build-and-test / generate-javadoc (push) Successful in 1m35s
2024-09-22 13:48:33 +02:00
b26517958a
Add "-Xlog:gc" flag
All checks were successful
build-and-test / test (push) Successful in 1m27s
build-and-test / generate-javadoc (push) Successful in 1m43s
build-and-test / build (push) Successful in 1m45s
2024-09-22 13:40:48 +02:00
b675a5ffb2
[noci] Change wording in Substrate VM error message 2024-09-21 21:09:24 +02:00
796eb9c8f9
Fix Javadoc API generation warnings and errors
All checks were successful
build-and-test / build (push) Successful in 1m27s
build-and-test / test (push) Successful in 1m23s
build-and-test / generate-javadoc (push) Successful in 1m36s
2024-09-21 21:01:57 +02:00
a9125c9bea
How did this get into the code? 2024-09-21 20:48:03 +02:00
3d3f21e217
Rename setting 'optimizeSubsystemInitialization'
Some checks failed
build-and-test / build (push) Failing after 1m7s
build-and-test / generate-javadoc (push) Failing after 1m6s
build-and-test / test (push) Successful in 1m24s
2024-09-21 17:24:27 +02:00
a00fdea6f5
Add initialization error when running in Substrate VM 2024-09-21 17:22:17 +02:00
0fed87328a
Shorten width of variable descriptions 2024-09-21 17:21:17 +02:00
0fbfe8f4e3
Add support for disabling classpath scanning
This commit however does not implement support for Substrate VM/native-image,
which I've already tested. Sad.
2024-09-21 17:20:14 +02:00
ebbc1778ae
Fix crashes not shutting down engine 2024-09-21 17:09:42 +02:00
a9cfc8c810
Add static Tristate#toTristate method 2024-09-21 17:08:59 +02:00
45f02bdd5a
Add de.staropensource.sosengine.dynamic package 2024-09-21 17:08:41 +02:00
a3ea583e41
Switch implementation dependencies to runtimeOnly 2024-09-21 17:08:18 +02:00
c14e34cd81
Rename fix InvalidMethodSignatureException naming 2024-09-20 18:35:59 +02:00
c473c27298
Inline EventHelper#logCall
All checks were successful
build-and-test / test (push) Successful in 2m41s
build-and-test / build (push) Successful in 3m11s
build-and-test / generate-javadoc (push) Successful in 3m12s
2024-09-20 17:10:50 +02:00
54b7b9a695
Remove code duplication (returns in conf classes) 2024-09-20 17:10:33 +02:00
5766072fd7
Make Tristate#toBoolean no longer static
All checks were successful
build-and-test / test (push) Successful in 1m25s
build-and-test / build (push) Successful in 1m42s
build-and-test / generate-javadoc (push) Successful in 1m41s
2024-09-07 16:52:17 +02:00
b49ff9a569
Fix crash reporter exception (yes really) 2024-09-07 16:51:55 +02:00
f342555b8a
Update API documentation 2024-09-07 16:51:37 +02:00
9be753b4df
[no ci] Update module-info.java comments 2024-09-07 16:51:10 +02:00
f96584ccd9
'final'lize slf4j-compat classes
All checks were successful
build-and-test / test (push) Successful in 1m24s
build-and-test / build (push) Successful in 1m38s
build-and-test / generate-javadoc (push) Successful in 1m42s
2024-09-06 21:00:22 +02:00
a870cbe11b
Fix copyright replace regex
All checks were successful
build-and-test / test (push) Successful in 1m55s
build-and-test / build (push) Successful in 2m10s
build-and-test / generate-javadoc (push) Successful in 2m11s
2024-09-06 01:28:34 +02:00
dffd24d8bb
Add Javadoc files for testing subproject
All checks were successful
build-and-test / test (push) Successful in 1m47s
build-and-test / build (push) Successful in 1m54s
build-and-test / generate-javadoc (push) Successful in 1m56s
2024-09-05 02:03:59 +02:00
e9e57a732a
Add API documentation links for v1-alpha4
All checks were successful
build-and-test / build (push) Successful in 2m11s
build-and-test / test (push) Successful in 2m7s
build-and-test / generate-javadoc (push) Successful in 2m10s
2024-09-05 02:01:13 +02:00
6696dc5700
Bump to v1-alpha5
All checks were successful
build-and-test / test (push) Successful in 1m39s
build-and-test / build (push) Successful in 1m55s
build-and-test / generate-javadoc (push) Successful in 2m3s
2024-09-05 01:58:21 +02:00
403 changed files with 9524 additions and 43730 deletions

View file

@ -1,125 +1,104 @@
name: build-and-test
name: "PRs & Pushes"
on:
- pull_request
- push
- push
- pull_request
jobs:
build:
runs-on: docker
container:
image: git.staropensource.de/staropensource/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 jar javadocJar sourceJar
- 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 library JARs
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: jars-libraries
path: |
**/build/libs/*.jar
!**/build/libs/*-javadoc.jar
!**/build/libs/*-sources.jar
if-no-files-found: error
- name: Upload API documentation JARs
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: jars-apidocs
path: |
**/build/libs/*-javadoc.jar
if-no-files-found: error
- name: Upload source JARs
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: jars-sources
path: |
**/build/libs/*-sources.jar
if-no-files-found: error
generate-javadoc:
runs-on: docker
container:
image: git.staropensource.de/staropensource/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: Generate javadoc
run: ./gradlew --no-daemon javadoc javadocAll
- 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 separate javadoc
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: javadoc-separate
path: |
**/build/docs/javadoc/*
if-no-files-found: error
- name: Upload combined javadoc
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: javadoc-combined
path: |
build/docs/javadoc/*
if-no-files-found: error
test:
runs-on: docker
container:
image: git.staropensource.de/staropensource/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 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:
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
- 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
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-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 dokkaHtmlJar dokkaJavadocJar
- 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

View file

@ -1,60 +0,0 @@
name: build-and-test
on:
- pull_request
jobs:
generate-javadoc:
runs-on: docker
container:
image: git.staropensource.de/staropensource/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: Generate javadoc
run: ./gradlew --no-daemon javadoc
- 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 }}-
test:
runs-on: docker
container:
image: git.staropensource.de/staropensource/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 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 }}-

18
.gitattributes vendored
View file

@ -1,15 +1,19 @@
# Documentation
# Linguist metadata
# -> Documentation
*.md linguist-documentation
docs/* linguist-documentation
# Licensing information
# -> Licensing information
COPYING linguist-documentation
LICENSE linguist-documentation
# Javadoc
# -> HTML, CSS, etc.
*.html linguist-documentation
*.css linguist-documentation
# Gradle configuration
# -> Configuration
*.properties linguist-configuration
*.gradle linguist-configuration
# Line endings
/gradlew text eol=lf
*.bat text eol=crlf
*.cmd text oel=crlf
*.jar binary

16
.gitignore vendored
View file

@ -1,4 +1,4 @@
### Gradle ###
# Gradle
.gradle
build/
run/
@ -6,7 +6,7 @@ run/
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
# IntelliJ IDEA
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
@ -19,7 +19,7 @@ out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
# Eclipse
.apt_generated
.classpath
.factorypath
@ -31,14 +31,18 @@ bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
# NetBeans
/nbproject/private/
/nbbuild/
/nbdist/
/.nb-gradle/
### VS Code ###
# Visual Studio Code
.vscode/
### Mac OS ###
# macOS
.DS_Store
# Java & Kotlin
hs_err_pid*.log
.kotlin

View file

@ -1,7 +1,7 @@
<component name="CopyrightManager">
<copyright>
<option name="allowReplaceRegexp" value="Copyright .* The StarOpenSource Engine Contributors" />
<option name="notice" value="STAROPENSOURCE ENGINE SOURCE FILE&#10;Copyright (c) &amp;#36;today.year The StarOpenSource Engine Authors&#10;Licensed under the GNU Affero General Public License v3&#10;&#10;This program is free software: you can redistribute it and/or modify&#10;it under the terms of the GNU Affero General Public License as&#10;published by the Free Software Foundation, either version 3 of the&#10;License, or (at your option) any later version.&#10;&#10;This program is distributed in the hope that it will be useful,&#10;but WITHOUT ANY WARRANTY; without even the implied warranty of&#10;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the&#10;GNU Affero General Public License for more details.&#10;&#10;You should have received a copy of the GNU Affero General Public License&#10;along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;." />
<option name="allowReplaceRegexp" value="Copyright .* The StarOpenSource Engine Authors" />
<option name="notice" value="STAROPENSOURCE ENGINE SOURCE FILE&#10;Copyright (c) &amp;#36;today.year The StarOpenSource Engine Authors&#10;Licensed under the GNU General Public License v3.&#10;&#10;This program is free software: you can redistribute it and/or modify&#10;it under the terms of the GNU General Public License as&#10;published by the Free Software Foundation, either version 3 of the&#10;License, or (at your option) any later version.&#10;&#10;This program is distributed in the hope that it will be useful,&#10;but WITHOUT ANY WARRANTY; without even the implied warranty of&#10;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the&#10;GNU Affero General Public License for more details.&#10;&#10;You should have received a copy of the GNU Affero General Public License&#10;along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;." />
<option name="myName" value="sos!engine" />
</copyright>
</component>

View file

@ -1,191 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunManager">
<configuration name="Build test application (native)" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="testapp:nativeImage" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
<configuration name="Build test application" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="shadowJar" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
<configuration name="Clean" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="clean" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
<configuration name="Generate JavaDoc (combined)" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="javadocAll" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
<configuration name="Generate Javadoc (separate)" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="javadoc" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
<configuration name="Run test application (native)" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="testapp:runNativeimage" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
<configuration name="Run test application" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="testapp:runShadow" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
<configuration name="Run tests" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="test" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
<list>
<item itemvalue="Gradle.Clean" />
<item itemvalue="Gradle.Run tests" />
<item itemvalue="Gradle.Build test application" />
<item itemvalue="Gradle.Run test application" />
<item itemvalue="Gradle.Build test application (native)" />
<item itemvalue="Gradle.Run test application (native)" />
<item itemvalue="Gradle.Generate Javadoc (separate)" />
<item itemvalue="Gradle.Generate JavaDoc (combined)" />
</list>
</component>
</project>

141
LICENSE
View file

@ -1,5 +1,5 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
@ -7,15 +7,17 @@
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 GNU General Public License is a free, copyleft license for
software and other kinds of works.
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
the GNU General Public License is 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.
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
@ -24,34 +26,44 @@ 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.
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.
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.
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.
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.
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.
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.
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.
@ -60,7 +72,7 @@ modification follow.
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"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.
@ -537,45 +549,35 @@ 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.
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 General Public License into a single
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 work with which it is combined will remain governed by version
3 of the GNU General Public License.
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 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
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 Affero General
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 Affero General Public License, you may choose any version ever published
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 Affero General Public License can be used, that proxy's
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.
@ -633,29 +635,40 @@ the "copyright" line and a pointer to where the full notice is found.
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
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 Affero General Public License for more details.
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
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 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.
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 AGPL, see
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>.

145
README.md
View file

@ -1,89 +1,72 @@
# StarOpenSource Engine
The StarOpenSource Engine (or sos!engine for short) is a modular, extensible and easy to use Java game and application engine.
<div align="center">
<a href="https://git.staropensource.de/StarOpenSource/Engine">
<img alt="StarOpenSource Engine" width="856px" height="auto" src="https://fs.staropensource.de/imgs/branding/engine/v2/extended-brand.png"/>
</a>
## WARNING
The StarOpenSource Engine is under heavy development and is extremely unstable. Code will break often, prepare for potential major refactors when trying the engine out.
<p align="center"><a href="https://git.staropensource.de/StarOpenSource/Engine">Repository</a> | <a href="https://engine.staropensource.de">Documentation</a> | <a href="https://develop.engine.staropensource.de">Documentation (development)</a></p>
</div>
## Index
# Index
- [About](#about)
- [... the engine](#-the-engine)
- [... the repository](#-the-repository)
- [Priorities](#priorities)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [Requirements](#requirements)
- [What IDE to use?](#what-ide-to-use)
- [Code style](#code-style)
- [Pull request guidelines](#pull-request-guidelines)
- [Making your first contribution](#making-your-first-contribution)
- [Gradle properties](#gradle-properties)
- [Gradle properties](#gradle-properties)
- [Skipping the Java toolchain specification](#skipping-the-java-toolchain-specification)
- [JVM arguments](#jvm-arguments)
- [`jvm.logGC`](#jvm-loggc)
- [`jvm.logJITandAOT`](#jvm-logjitandaot)
- [`jvm.garbageCollector`](#jvm-garbagecollector)
## About
### ... the engine
The StarOpenSource Engine is a modular and extensible framework for building applications and games written in [one of the multiple JVM programming languages](https://en.wikipedia.org/wiki/List_of_JVM_languages).
The engine consists of various subsystems, each separate and responsible for only a few closely-related tasks.
\
Not only that. The engine also features various useful classes, interfaces and methods making development fun and simpler, while being lightweight.
### ... the repository
The sos!engine repository is a monorepo, consisting of [the core engine](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/base), multiple official subsystems and [their documentation](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/docs).
### Priorities
These are in no particular order.
# About
The StarOpenSource Engine is a game and application
framework written in Kotlin, primarily targeting the JVM.
The engine is designed to be modular, configurable
and extensible while being lightweight and fast.
- configurable
- [do one thing and do it well](https://en.wikipedia.org/wiki/Unix_philosophy) (subsystems concept)
- fast
- few runtime dependencies (note: we will cut down on some of them during development)
- modular & extensible
- small & lightweight
In this repository you can find the
[core engine](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/base), official
subsystems, [their documentation (TODO)](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/docs)
and [some miscellaneous files](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/dist).
## Documentation
You can view the engine documentation at [engine.staropensource.de](https://engine.staropensource.de). It provides information, guides and tutorials about the core engine and subsystems.
If you want the API reference, you can [visit the Javadoc](https://jd.engine.staropensource.de) for the engine and it's subsystems.
# Documentation
The documentation is not yet available. We will create one soon.
## Contributing
### Requirements
You need the following things to be able to contribute code to the StarOpenSource Engine:
- knowledge of Java
- knowledge about the internals of engine
### What IDE to use?
We recommend and are using [IntelliJ IDEA Community Edition](https://github.com/JetBrains/intellij-community) for development because it is flexible, extendable, customizable, provides good completions and error detection. It's also open source.
### Code style
We recommend looking at existing classes and code for a good understanding on how we'd like code to be written.
Here's a quick rundown on the most important things:
- Document EVERYTHING. Every single class, field and method, even if private.
- Make comments about your code, unless it's extremely simple and easy to understand.
- Make sure to add and update `@since` in javadoc comments (update if the javadoc changes a good amount).
- Keep stuff simple, no need to elaborate what a logger is. Though remember to not make it *too* simple.
- Make sure every field and method has a newline to separate it.
- Files must end with a newline or cats might get angry.
- Use your brain.
### Pull request guidelines
Before creating a pull request, make sure you've:
- created tests for the functionality you've added, changed or removed (if applicable),
- tested your changes,
- made sure that everything works,
- is compatible with other code in the monorepo, and
- is compatible with other applications. If not, tell us in your pull request description.
### Making your first contribution
TODO
### Gradle properties
Gradle's behaviour can be changed by changing gradle project properties.
To change them, simply append `-P<property>` or `-P<property>=<value>`, like this: `./gradlew -Pjobs=4 test`.
#### Parallelism
Use the `jobs` property to control how many jobs will get executed simultaneously.
On Linux, specify `-Pjobs=$(nproc)`. Defaults to `8`.
#### JVM Home
You can use the `graalHome` property to specify the `$JAVA_HOME` of your local GraalVM installation.
Only used in the `nativeImage` task. Useful if you aren't using GraalVM as your primary JDK.
#### Testing
You can use the following properties to modify the behaviour of the `test`-task:
- `test.control.mode` (default *empty*)
- `force-enable`: Disables all test classes except the ones specified
- `force-disable`: Enables all test classes except the ones specified
- *everything else*: Enables all test classes
- `test.control.classes` (default *empty*): A comma-separated, case-sensitive list of test classes
which (depending on `test.control.mode`'s value) enable or disable the specified classes.
Example: `-Ptest.control.mode=MiscellaneousTest,DependencyResolverTest,EngineConfigurationTest`
- `test.control.warning` (default `false`): If `true`, will emit a warning before a restricted test method exits
- `test.loggerLevel` (default `silent_warning`): Will set `UnitLogger`'s logger level.
Works like `-Dsosengine.base.loggerLevel`. See `UnitLogger#loggerLevel` for more information
# Contributing
TODO, waiting for [Infrastructure/website-docs#1](https://git.staropensource.de/Infrastructure/website-docs/issues/1). Sorry :c
# Gradle properties
You can modify Gradle's behaviour by passing one or multiple *project properties*.
These are read by our `build.gradle.kts` files and actively change the build behaviour.
You can pass one by adding `-P<property>=<value>` to your Gradle command line.
## Skipping the Java toolchain specification
Setting `java.skipToolchainSpecification` to `true` disables the
JDK version check & download step performed by Gradle. Useful when
automating things or if you're facing the `No locally installed
toolchains match and toolchain download repositories have not
been defined` error.
Please note however that you should only pass this option if your
default, installed JDK is matching Java 21 or you will experience
issues.
## JVM arguments
You can pass the following arguments to modify the
behaviour of JVMs used for executing projects.
### `jvm.logGC`
Enables garbage collection logging.
Takes effect if set to `true`.
### `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).

2
ansi/README.md Normal file
View file

@ -0,0 +1,2 @@
# `/ansi`
The ANSI subsystem, which hides all the ANSI escape sequences stuff behind a nice to use API.

View file

@ -1,141 +0,0 @@
/*
* 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") //
addStringOption("Xwerror", "-quiet") // Fail build on warning
setJFlags([
"-Duser.language=en_US" // See above
])
}
}
}
// Unit testing configuration
test {
useJUnitPlatform()
// Pass test configuration to test VMs
Map<String, String> testConfiguration = new HashMap<>();
for (String property : project.properties.keySet())
if (property.startsWith("test."))
testConfiguration.put(property, project.properties.get(property).toString())
systemProperties(testConfiguration)
setMaxParallelForks(project.hasProperty("jobs") ? Integer.parseInt((String) project.property("jobs")) : 8)
setForkEvery(1)
setFailFast(true)
testLogging {
events("passed", "skipped", "failed")
}
}
// Include javadoc and source jar during publishing
java {
withJavadocJar()
withSourcesJar()
}
// Build publishing configuration
// Note: You can safely ignore any errors or warnings thrown by your IDE here
publishing {
repositories {
maven {
name = "staropensource"
url = uri("https://mvn.staropensource.de/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
}
}
}

24
ansi/build.gradle.kts Normal file
View file

@ -0,0 +1,24 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 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 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/>.
*/
// Dependencies
dependencies {
// sos!engine
implementation(project(":base"))
}

View file

@ -1 +0,0 @@
../gradle

1
ansi/gradlew vendored
View file

@ -1 +0,0 @@
../gradlew

1
ansi/gradlew.bat vendored
View file

@ -1 +0,0 @@
../gradlew.bat

View file

@ -1,74 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.ansi;
import de.staropensource.sosengine.base.EngineConfiguration;
import de.staropensource.sosengine.base.implementable.LoggingAdapter;
import de.staropensource.sosengine.base.logging.Logger;
import de.staropensource.sosengine.base.type.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 LoggingAdapter
* @since v1-alpha2
*/
public class AnsiLoggingAdapter implements LoggingAdapter {
/**
* Constructs this class.
*
* @since v1-alpha2
*/
public AnsiLoggingAdapter() {}
/** {@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);
}
}

View file

@ -1,106 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.ansi;
import de.staropensource.sosengine.base.implementable.ShortcodeParser;
import de.staropensource.sosengine.base.exception.ParserException;
import org.fusesource.jansi.Ansi;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
/**
* Converts shortcodes such as {@code <bold>} or {@code <blink>} into a usable {@link Ansi} escape sequence.
*
* @see ShortcodeParser
* @since v1-alpha2
*/
public final class AnsiShortcodeConverter extends ShortcodeParser {
/**
* 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();
Set<@NotNull String> status = new HashSet<>();
for (String component : components)
if (component.equals("RESET")) {
ansi.a(Ansi.Attribute.RESET);
status.clear();
} else if (component.startsWith("TEXT:"))
ansi.a(component.substring(5));
else if (component.startsWith("COLOR:"))
if (component.startsWith("COLOR:FOREGROUND:"))
ansi.fg(Ansi.Color.valueOf(component.substring(17)));
else if (component.startsWith("COLOR:BACKGROUND:"))
ansi.bg(Ansi.Color.valueOf(component.substring(17)));
else if (component.startsWith("ATTRIBUTE:"))
if (component.startsWith("ATTRIBUTE:BLINK")) {
if (status.contains("ATTRIBUTE:BLINK"))
continue;
ansi.a(Ansi.Attribute.BLINK_SLOW);
status.add("ATTRIBUTE:BLINK");
} else if (component.startsWith("ATTRIBUTE:BOLD")) {
if (status.contains("ATTRIBUTE:BOLD"))
continue;
ansi.a(Ansi.Attribute.INTENSITY_BOLD);
status.add("ATTRIBUTE:BOLD");
} else if (component.startsWith("ATTRIBUTE:ITALIC")) {
if (status.contains("ATTRIBUTE:ITALIC"))
continue;
ansi.a(Ansi.Attribute.ITALIC);
status.add("ATTRIBUTE:ITALIC");
} else if (component.startsWith("ATTRIBUTE:STRIKETHROUGH")) {
if (status.contains("ATTRIBUTE:STRIKETHROUGH"))
continue;
ansi.a(Ansi.Attribute.STRIKETHROUGH_ON);
status.add("ATTRIBUTE:STRIKETHROUGH");
} else if (component.startsWith("ATTRIBUTE:UNDERLINE")) {
if (status.contains("ATTRIBUTE:UNDERLINE"))
continue;
ansi.a(Ansi.Attribute.UNDERLINE);
status.add("ATTRIBUTE:UNDERLINE");
}
return ansi;
}
}

View file

@ -1,86 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.ansi;
import de.staropensource.sosengine.base.annotation.EngineSubsystem;
import de.staropensource.sosengine.base.implementable.SubsystemClass;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import de.staropensource.sosengine.base.implementation.versioning.StarOpenSourceVersioningSystem;
import de.staropensource.sosengine.base.logging.Logger;
import de.staropensource.sosengine.base.type.DependencyVector;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
/**
* Main object for the ANSI Compatibility subsystem.
*
* @since v1-alpha2
*/
@EngineSubsystem
@SuppressWarnings({ "JavadocDeclaration" })
public final class AnsiSubsystem extends SubsystemClass {
/**
* Contains the class instance.
*
* @since v1-alpha2
* -- GETTER --
* Returns the class instance.
*
* @return class instance unless the subsystem is uninitialized
* @since v1-alpha2
*/
@Getter
private static AnsiSubsystem instance = null;
/**
* 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.setLoggingAdapter(new AnsiLoggingAdapter());
}
/** {@inheritDoc} */
@Override
public @NotNull DependencyVector getDependencyVector() {
return new DependencyVector.Builder()
.setIdentifier("ansi")
.setVersioningSystem(StarOpenSourceVersioningSystem.class)
.setVersion(EngineInformation.getVersioningString())
.build();
}
}

View file

@ -1,27 +0,0 @@
/**
* The ANSI subsystem, allowing the engine to
* use ANSI escape codes using the Jansi library.
*
* @since v1-alpha2
*/
module sosengine.ansi {
// Dependencies
// -> Java <-
requires transitive java.management;
// -> Engine <-
requires transitive sosengine.base;
// -> 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;
}

View file

@ -1,23 +0,0 @@
<!--
~ 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>

View file

@ -1 +0,0 @@
../../../../src/main/javadoc/theme.css

View file

@ -0,0 +1,145 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.ansi
import de.staropensource.engine.ansi.AnsiSubsystem.Companion.logger
import de.staropensource.engine.base.implementable.formatter.TwoCycleFormatterImpl
/**
* Formats a string using ANSI
* escape sequences.
*
* @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
}
}

View file

@ -0,0 +1,98 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.ansi
import de.staropensource.engine.base.Engine
import de.staropensource.engine.base.implementable.Subsystem
import de.staropensource.engine.base.logging.Logger
import de.staropensource.engine.base.utility.dnihbd.BuildInformation
/**
* The ANSI 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
}
}

2
ansi/src/main/resources/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
sosengine-*-git.properties
sosengine-*-gradle.properties

1
base/.gitignore vendored
View file

@ -1 +0,0 @@
src/main/resources/git.properties

View file

@ -1,2 +1,2 @@
# The `base` subsystem
This is not just a subsystem, this is the core engine. It contains data types, logging infrastructure, an event system, a crash reporter and much more stuff required for basic applications.
# `/base`
The core engine. The grand piece of code which makes everything work.

View file

@ -1,183 +0,0 @@
/*
* 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")
// -> Project <-
testImplementation(project(":testing"))
}
// 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") //
addStringOption("Xwerror", "-quiet") // Fail build on warning
setJFlags([
"-Duser.language=en_US" // See above
])
}
}
}
// Unit testing configuration
test {
useJUnitPlatform()
// Pass test configuration to test VMs
Map<String, String> testConfiguration = new HashMap<>();
for (String property : project.properties.keySet())
if (property.startsWith("test."))
testConfiguration.put(property, project.properties.get(property).toString())
systemProperties(testConfiguration)
setMaxParallelForks(project.hasProperty("jobs") ? Integer.parseInt((String) project.property("jobs")) : 8)
setForkEvery(1)
setFailFast(true)
testLogging {
events("passed", "skipped", "failed")
}
}
// Include javadoc and source jar during publishing
java {
withJavadocJar()
withSourcesJar()
}
// Build publishing configuration
// Note: You can safely ignore any errors or warnings thrown by your IDE here
publishing {
repositories {
maven {
name = "staropensource"
url = uri("https://mvn.staropensource.de/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
}
}
}

View file

@ -1,10 +1,10 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
* 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 Affero General Public License as
* 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.
*
@ -17,9 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* Exceptions thrown by the engine, subsystems and applications.
*
* @since v1-alpha1
*/
package de.staropensource.sosengine.base.exception;
// Dependencies
dependencies {
// OSHI
implementation("${property("dependencyOshiIdentifier") as String}:${property("dependencyOshiVersion") as String}")
}

View file

@ -1 +0,0 @@
../gradle

1
base/gradlew vendored
View file

@ -1 +0,0 @@
../gradlew

1
base/gradlew.bat vendored
View file

@ -1 +0,0 @@
../gradlew.bat

View file

@ -1,570 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base;
import de.staropensource.sosengine.base.annotation.EngineSubsystem;
import de.staropensource.sosengine.base.implementable.ShutdownHandler;
import de.staropensource.sosengine.base.implementable.SubsystemClass;
import de.staropensource.sosengine.base.implementable.helper.EventHelper;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import de.staropensource.sosengine.base.utility.information.JvmInformation;
import de.staropensource.sosengine.base.implementation.versioning.StarOpenSourceVersioningSystem;
import de.staropensource.sosengine.base.event.*;
import de.staropensource.sosengine.base.exception.IllegalAccessException;
import de.staropensource.sosengine.base.exception.dependency.UnmetDependenciesException;
import de.staropensource.sosengine.base.internal.event.InternalEngineShutdownEvent;
import de.staropensource.sosengine.base.internal.type.DependencySubsystemVector;
import de.staropensource.sosengine.base.logging.*;
import de.staropensource.sosengine.base.type.DependencyVector;
import de.staropensource.sosengine.base.type.EngineState;
import de.staropensource.sosengine.base.type.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.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Range;
import org.reflections.Reflections;
import org.reflections.scanners.Scanners;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import java.util.*;
/**
* Main class of the sos!engine.
*
* @see EngineConfiguration
* @since v1-alpha0
*/
@EngineSubsystem
@SuppressWarnings({ "JavadocDeclaration" })
public final class Engine extends SubsystemClass {
/**
* Contains the class instance.
*
* @since v1-alpha0
* -- GETTER --
* Returns the class instance.
*
* @return class instance unless {@link Engine} is uninitialized
* @since v1-alpha0
*/
@Getter
private static Engine instance = null;
/**
* Contains the thread group of the engine.
*
* @since v1-alpha2
* -- GETTER --
* Returns the thread group of the engine.
*
* @return engine thread group
* @since v1-alpha2
*/
@Getter
private static final ThreadGroup threadGroup = new ThreadGroup("sos!engine");
/**
* Contains the {@link LoggerInstance} for this instance.
*
* @see LoggerInstance
* @since v1-alpha0
*/
private static final LoggerInstance logger = new LoggerInstance.Builder().setClazz(Engine.class).setOrigin("ENGINE").setMetadata(EngineInformation.getVersioningCodename()).build();
/**
* 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 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<>();
/**
* Contains the engine's shutdown handler.
* The shutdown handler is responsible for
* shutting down the JVM safely.
*
* @see ShutdownHandler
* @since v1-alpha2
* -- GETTER --
* Returns the engine's shutdown handler.
* The shutdown handler is responsible for
* shutting down the JVM safely.
*
* @return shutdown handler
* @see ShutdownHandler
* @since v1-alpha2
* -- SETTER --
* Sets the engine's shutdown handler.
* The shutdown handler is responsible for
* shutting down the JVM safely.
*
* @param shutdownHandler new shutdown handler
* @see ShutdownHandler
* @since v1-alpha2
*/
@Getter(value = AccessLevel.MODULE)
@Setter(value = AccessLevel.MODULE)
private @NotNull ShutdownHandler shutdownHandler = new Engine.JvmShutdownHandler();
/**
* Contains the JVM shutdown hook thread,
* which ensures that the engine is fully shut
* down before the JVM exits.
*
* @see EngineInternals#installSafetyShutdownHook(boolean)
* @since v1-alpha4
*/
@Getter(AccessLevel.MODULE)
private final @NotNull Thread safetyShutdownHook = Thread.ofPlatform()
.name("Engine shutdown thread")
.group(getThreadGroup())
.unstarted(() -> {
// Check if already shutting down
switch (state) {
case UNKNOWN, SHUTDOWN, CRASHED -> {
return;
}
}
// Print warning about shutdown
logger.warn("Trying to shut down engine using shutdown hook.\nThis approach to shutting down the engine and JVM is NOT RECOMMENDED, please use Engine#shutdown() instead.");
// Shutdown
Engine.getInstance().shutdown();
// Print last message
InitLogger.warn(getClass(), "ENGINE", EngineInformation.getVersioningCodename(), "Engine successfully shut down using shutdown hook. PLEASE USE Engine#shutdown() INSTEAD OF System#exit() or Runtime#exit()!");
});
/**
* Initializes the StarOpenSource Engine.
*
* @throws IllegalStateException when running in an incompatible environment
* @since v1-alpha0
*/
public Engine() throws IllegalStateException {
if (instance == null)
instance = this;
else
return;
long initTime = Miscellaneous.measureExecutionTime(() -> {
state = EngineState.EARLY_STARTUP;
new EngineConfiguration();
EngineConfiguration.getInstance().loadConfiguration();
logger.info("Initializing engine");
initializeClasses(); // Initialize classes
if (checkEnvironment()) // Check environment
throw new IllegalStateException("Running in an incompatible environment");
ensureEnvironment(); // Prepare the environment and ensure safety
populateCrashContent(); // Populate crash content
cacheEvents(); // Cache event listeners
startThreads(); // Start threads
logger.verb("Completing early initialization stage");
state = EngineState.STARTUP;
// 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);
}
}
});
logger.verb("Completing late initialization stage");
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\nThe StarOpenSource Engine is licensed under the GNU AGPL v3. Copyright (c) 2024 The StarOpenSource Engine Authors.");
}
/**
* Initializes all classes.
*
* @since v1-alpha0
*/
private void initializeClasses() {
logger.verb("Initializing engine classes");
new EngineInternals();
new PlaceholderEngine();
EngineInformation.update();
PrintStreamService.initializeStreams();
}
/**
* Checks if the environment is compatible with the engine build.
*
* @since v1-alpha4
*/
private boolean checkEnvironment() {
logger.diag("Checking environment");
if (JvmInformation.getJavaVersion() > EngineInformation.getJavaSource())
logger.warn("The StarOpenSource Engine is running on an untested Java version.\nThings may not work as expected or features which can improve performance, stability, compatibility or ease of use may be missing.\nIf you encounter issues, try running a JVM implementing Java " + EngineInformation.getJavaSource());
return false;
}
/**
* Ensures the execution safety of the environment.
*
* @since v1-alpha4
*/
private void ensureEnvironment() {
EngineInternals.getInstance().installSafetyShutdownHook(true);
}
/**
* This method populates {@link CrashHandler#crashContent} with content.
*
* @see CrashHandler#getCrashContent()
* @since v1-alpha0
*/
@SuppressWarnings({ "ExtractMethodRecommender" })
private void populateCrashContent() {
logger.diag("Populating crash content");
// 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() {
logger.diag("Caching events");
// 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.diag("Starting threads");
LoggingThread.startThread();
}
/**
* 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'
Object initializedClassRaw;
SubsystemClass initializedClass;
for (Class<?> clazz : annotatedClasses) {
try {
// Create new instance
initializedClassRaw = clazz.getDeclaredConstructor().newInstance();
initializedClass = null;
// Check if class implements SubsystemMainClass
if (initializedClassRaw instanceof SubsystemClass)
initializedClass = (SubsystemClass) initializedClassRaw;
else
logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Does not implement " + SubsystemClass.class.getName());
//noinspection DataFlowIssue // the crash call will prevent a NullPointerException
subsystemsMutable.add(new DependencySubsystemVector(initializedClass.getDependencyVector(), initializedClass));
} catch (Exception exception) {
if (exception.getClass() == IllegalStateException.class && exception.getMessage().startsWith("The version string is invalid: "))
logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Invalid version string: " + exception.getMessage().replace("The version string is invalid: ", ""));
logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Method invocation error", exception);
}
}
// Update 'subsystems'
subsystems = 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) {
List<@NotNull String> unmetDependencies = exception.getUnmetDependencies();
StringBuilder list = new StringBuilder();
for (String error : unmetDependencies)
list
.append("\n")
.append("- ")
.append(error);
logger.crash("Found unresolved dependencies:" + list, throwable);
return;
}
logger.crash("An error occurred trying to resolve subsystem dependencies: " + throwable.getClass().getName() + (throwable.getMessage() == null ? "" : ": " + throwable.getMessage()));
throw throwable;
}
// Initialize subsystems
logger.verb("Initializing engine subsystems");
long initTime;
for (DependencySubsystemVector vector : subsystems) {
logger.diag("Initializing subsystem " + vector.getSubsystemClass().getName() + " (" + vector.getSubsystemClass().getClass().getName() + ")");
try {
initTime = Miscellaneous.measureExecutionTime(() -> vector.getSubsystemClass().initializeSubsystem());
} catch (Throwable throwable) {
logger.crash("An error occurred trying to initialize subsystem " + vector.getSubsystemClass().getName() + " (" + vector.getSubsystemClass().getClass().getName() + "): " + throwable.getClass().getName() + (throwable.getMessage() == null ? "" : ": " + throwable.getMessage()));
throw throwable;
}
logger.diag("Initialized subsystem " + vector.getSubsystemClass().getName() + " (" + vector.getSubsystemClass().getClass().getName() + ") in " + initTime + "ms");
}
// Update 'subsystems'
subsystems = 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) {
switch (state) {
case UNKNOWN, SHUTDOWN, CRASHED -> {
return;
}
}
logger.info("Shutting engine down");
if (state != EngineState.CRASHED)
state = EngineState.SHUTDOWN;
// Make engine single-threaded
Properties properties = new Properties();
properties.setProperty("sosengine.base.optimizeLogging", "false");
properties.setProperty("sosengine.base.optimizeEvents", "false");
EngineConfiguration.getInstance().loadConfiguration(properties);
// Flush log messages
Logger.flushLogMessages();
// Disable safety shutdown hook
try {
Runtime.getRuntime().removeShutdownHook(safetyShutdownHook);
} catch (Exception ignored) {}
// Send events
logger.verb("Notifying classes about shutdown");
new EngineShutdownEvent().callEvent();
logger.verb("Notifying subsystems about shutdown");
new InternalEngineShutdownEvent().callEvent();
// Invoke shutdown handler
logger.verb("Invoking shutdown handler (code " + exitCode + ")");
shutdownHandler.shutdown((short) exitCode);
}
/**
* Shuts the engine down.
*
* @since v1-alpha0
*/
public void shutdown() {
if (instance != null)
instance.shutdown(0);
}
/** {@inheritDoc} */
@Override
public @NotNull String getName() {
return "base";
}
/** {@inheritDoc} */
@Override
public void initializeSubsystem() {}
/** {@inheritDoc} */
@Override
public @NotNull DependencyVector getDependencyVector() {
return new DependencyVector.Builder()
.setIdentifier("engine")
.setVersioningSystem(StarOpenSourceVersioningSystem.class)
.setVersion(EngineInformation.getVersioningString())
.build();
}
/**
* Sets the engine state.
*
* @param state new state
* @throws IllegalAccessException if the caller class is unauthorized
* @since v1-alpha2
*/
public void setState(@NotNull EngineState state) throws IllegalAccessException {
if (!Thread.currentThread().getStackTrace()[2].getClassName().startsWith("de.staropensource.sosengine.base."))
throw new IllegalAccessException("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) {
// Check if already shutting down
try {
Thread thread = Thread.ofVirtual().unstarted(() -> {});
Runtime.getRuntime().addShutdownHook(thread);
Runtime.getRuntime().removeShutdownHook(thread);
} catch (IllegalStateException exception) {
logger.warn("Terminating JVM: Already shutting down, skipping");
return;
}
logger.warn("Terminating JVM");
System.exit(exitCode);
}
}
}

View file

@ -1,416 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base;
import de.staropensource.sosengine.base.implementable.ShortcodeParser;
import de.staropensource.sosengine.base.implementable.Configuration;
import de.staropensource.sosengine.base.implementable.helper.EventHelper;
import de.staropensource.sosengine.base.logging.CrashHandler;
import de.staropensource.sosengine.base.logging.Logger;
import de.staropensource.sosengine.base.logging.LoggingThread;
import de.staropensource.sosengine.base.type.EngineState;
import de.staropensource.sosengine.base.type.logging.LogLevel;
import de.staropensource.sosengine.base.type.vector.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({ "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 ShortcodeParser}'s internals will be printed.
* Don't enable unless you want to work on it.
*
* @see ShortcodeParser
* @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 ShortcodeParser}.
* The message will be printed as a {@link LogLevel#SILENT_WARNING}.
*
* @see ShortcodeParser
* @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;
/**
* Contains how fast the logging thread will poll for queued messages.
* This also causes messages to be buffered.
* <p>
* Only applies if {@code optimizeLogging} is turned on.
* Values below {@code 1} will poll for queued messages as fast as it can.
* This however has pretty much no benefit. Leave it at {@code 5}, it works quite well.
*
* @see #optimizeLogging
* @since v1-alpha4
* -- GETTER --
* Gets the value for {@link #loggerPollingSpeed}.
*
* @return variable value
* @see #loggerPollingSpeed
* @since v1-alpha4
*/
private int loggerPollingSpeed;
/**
* 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;
/**
* If enabled, will enable support for printing log messages on multiple lines.
* By enabling this configuration setting, logger throughput will be decreased slightly when encountering a log message with newlines found in it.
* This performance hit is negligible though and should not affect application performance, especially with logger multi-threading turned on (see {@link #optimizeLogging}).
*
* @since v1-alpha4
* -- GETTER --
* Gets the value for {@link #loggerEnableNewlineSupport}.
*
* @return variable value
* @see #loggerEnableNewlineSupport
* @since v1-alpha4
*/
private boolean loggerEnableNewlineSupport;
/**
* 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;
/**
* 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)
LoggingThread.startThread();
}
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 "loggerPollingSpeed" -> loggerPollingSpeed = parser.getInteger(group + property, true);
case "loggerForceStandardOutput" -> loggerForceStandardOutput = parser.getBoolean(group + property);
case "loggerEnableNewlineSupport" -> loggerEnableNewlineSupport = parser.getBoolean(group + property);
case "loggerImmediateShutdown" -> loggerImmediateShutdown = parser.getBoolean(group + property);
case "hideFullTypePath" -> hideFullTypePath = parser.getBoolean(group + property);
}
} catch (NullPointerException ignored) {}
}
/** {@inheritDoc} */
@Override
protected void processSettings(@NotNull PropertiesReader parser) {
// Disable all debugging switches if 'debug' is disabled
if (!debug) {
debugEvents = false;
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_message_prefix%%log_color_primary%%log_color_secondary%%log_message%<reset>";
loggerPollingSpeed = 5;
loggerForceStandardOutput = false;
loggerEnableNewlineSupport = true;
loggerImmediateShutdown = false;
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 "loggerPollingSpeed" -> { return loggerPollingSpeed; }
case "loggerForceStandardOutput" -> { return loggerForceStandardOutput; }
case "loggerEnableNewlineSupport" -> { return loggerEnableNewlineSupport; }
case "loggerImmediateShutdown" -> { return loggerImmediateShutdown; }
case "hideFullTypePath" -> { return hideFullTypePath; }
default -> { return null; }
}
}
}

View file

@ -1,169 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base;
import de.staropensource.sosengine.base.implementable.ShutdownHandler;
import de.staropensource.sosengine.base.exception.IllegalAccessException;
import de.staropensource.sosengine.base.logging.LoggerInstance;
import de.staropensource.sosengine.base.type.InternalAccessArea;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Class which allows access to the internals
* and changing the behaviour of the engine.
*
* @since v1-alpha4
*/
@SuppressWarnings({ "JavadocDeclaration" })
public final class EngineInternals {
/**
* Contains the class instance.
*
* @since v1-alpha4
* -- GETTER --
* Returns the class instance.
*
* @return class instance unless the engine is uninitialized
* @since v1-alpha4
*/
@Getter
private static EngineInternals instance;
/**
* Contains the {@link LoggerInstance} for this instance.
*
* @see LoggerInstance
* @since v1-alpha4
*/
private static final LoggerInstance logger = new LoggerInstance.Builder().setClazz(EngineInternals.class).setOrigin("ENGINE").build();
/**
* Contains all disabled internal access areas.
*
* @since v1-alpha4
* -- GETTER --
* Returns all disabled internal access areas.
*
* @return restricted areas
* @since v1-alpha4
*/
@Getter
private final @NotNull List<@NotNull InternalAccessArea> restrictedAreas = new ArrayList<>();
/**
* Constructs this class.
*
* @since v1-alpha4
*/
public EngineInternals() {
// Only allow one instance
if (instance == null && Engine.getInstance() != null)
instance = this;
else
logger.crash("Only one instance of this class is allowed, use getInstance() instead of creating a new instance");
}
/**
* Determines whether access to the specified area is allowed.
*
* @param area internal access area to check
* @throws IllegalAccessException when restricted
* @since v1-alpha4
*/
private void isRestricted(@NotNull InternalAccessArea area) throws IllegalAccessException {
if (restrictedAreas.contains(area))
throw new IllegalAccessException("The internal access area " + area.name() + " has been restricted");
}
/**
* Restricts access to certain areas of this class.
*
* @param area area to restrict
* @since v1-alpha4
*/
public void restrictAccess(@NotNull InternalAccessArea area) {
switch (area) {
case ALL -> {
List<@NotNull InternalAccessArea> areas = new ArrayList<>(List.of(InternalAccessArea.values()));
areas.remove(InternalAccessArea.ALL);
areas.remove(InternalAccessArea.ALL_READ);
areas.remove(InternalAccessArea.ALL_WRITE);
restrictedAreas.addAll(areas);
}
case ALL_READ -> restrictedAreas.addAll(Arrays.stream(InternalAccessArea.valuesReadOnly()).toList());
case ALL_WRITE -> restrictedAreas.addAll(Arrays.stream(InternalAccessArea.valuesWriteOnly()).toList());
default -> restrictedAreas.add(area);
}
}
/**
* Installs or uninstalls the JVM shutdown
* hook, which prevents the JVM from exiting
* before the engine has fully shut down.
* Highly recommended to keep enabled.
*
* @param status {@code true} to install, {@code false} otherwise
* @throws IllegalAccessException when restricted
* @since v1-alpha4
*/
public void installSafetyShutdownHook(boolean status) throws IllegalAccessException {
isRestricted(InternalAccessArea.SAFETY_SHUTDOWN_HOOK);
try {
if (status)
Runtime.getRuntime().addShutdownHook(Engine.getInstance().getSafetyShutdownHook());
else
Runtime.getRuntime().removeShutdownHook(Engine.getInstance().getSafetyShutdownHook());
} catch (IllegalArgumentException | IllegalStateException ignored) {}
}
/**
* Sets the engine's shutdown handler.
* The shutdown handler is responsible for
* shutting down the JVM safely.
*
* @param shutdownHandler new shutdown handler
* @throws IllegalAccessException when restricted
* @since v1-alpha4
*/
public void setShutdownHandler(@NotNull ShutdownHandler shutdownHandler) throws IllegalAccessException {
isRestricted(InternalAccessArea.SHUTDOWN_HANDLER_UPDATE);
Engine.getInstance().setShutdownHandler(shutdownHandler);
}
/**
* Gets the engine's shutdown handler.
* The shutdown handler is responsible for
* shutting down the JVM safely.
*
* @return shutdown handler
* @throws IllegalAccessException when restricted
* @since v1-alpha4
*/
public @NotNull ShutdownHandler getShutdownHandler() throws IllegalAccessException {
isRestricted(InternalAccessArea.SHUTDOWN_HANDLER_GET);
return Engine.getInstance().getShutdownHandler();
}
}

View file

@ -1,36 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.annotation;
import de.staropensource.sosengine.base.implementable.SubsystemClass;
import java.lang.annotation.*;
/**
* Marks a class as a subsystem main class.
* Make sure your subsystem implements {@link SubsystemClass}.
*
* @see SubsystemClass
* @since v1-alpha1
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
public @interface EngineSubsystem {}

View file

@ -1,55 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.annotation;
import de.staropensource.sosengine.base.implementable.Event;
import de.staropensource.sosengine.base.type.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
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;
}

View file

@ -1,43 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.event;
import de.staropensource.sosengine.base.implementable.Event;
import de.staropensource.sosengine.base.implementable.helper.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());
}
}

View file

@ -1,47 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.event;
import de.staropensource.sosengine.base.implementable.Event;
import de.staropensource.sosengine.base.implementable.helper.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
*/
public final class EngineSoftCrashEvent implements Event {
/**
* Constructs this event.
*
* @since v1-alpha0
*/
public EngineSoftCrashEvent() {}
/** {@inheritDoc} */
@Override
public void callEvent() {
EventHelper.invokeAnnotatedMethods(getClass());
}
}

View file

@ -1,64 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.event;
import de.staropensource.sosengine.base.implementable.Event;
import de.staropensource.sosengine.base.implementable.helper.EventHelper;
import de.staropensource.sosengine.base.type.logging.LogLevel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called before a new log message is printed.
*
* @since v1-alpha0
*/
public final class LogEvent implements Event {
/**
* 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);
}
}

View file

@ -1,61 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.event;
import de.staropensource.sosengine.base.implementable.Event;
import de.staropensource.sosengine.base.implementable.helper.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);
}
}

View file

@ -1,42 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.exception;
import de.staropensource.sosengine.base.type.Tristate;
/**
* Thrown when converting a {@link Tristate} into a {@link Boolean} fails.
* <p>
* This exception inherits {@link RuntimeException} on purpose,
* as sometimes you may sure/have already validated that the
* {@link Tristate} is not {@link Tristate#UNSET}.
*
* @since v1-alpha2
*/
public class TristateConversionException extends RuntimeException {
/**
* Constructs this exception.
*
* @since v1-alpha2
*/
public TristateConversionException() {
super("Tristate.UNSET cannot be converted into a boolean");
}
}

View file

@ -1,48 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.exception;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when a sequence of if checks or switch cases fail unexpectedly.
*
* @since v1-alpha2
*/
public class UnexpectedCheckEndException extends RuntimeException {
/**
* 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");
}
}

View file

@ -1,40 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.exception.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
*/
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);
}
}

View file

@ -1,60 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.exception.dependency;
import de.staropensource.sosengine.base.type.DependencyVector;
import de.staropensource.sosengine.base.utility.DependencyResolver;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* Thrown when the {@link DependencyResolver} cannot resolve one
* or more {@link DependencyVector}s due to unmet dependencies.
*
* @since v1-alpha1
*/
@Getter
@SuppressWarnings({ "JavadocDeclaration" })
public class UnmetDependenciesException extends Exception {
/**
* Contains the unmet dependencies list supplied to the constructor.
*
* @since v1-alpha4
* -- GETTER --
* Returns the unmet dependencies list supplied to the constructor.
*
* @return unmet dependencies list
* @since v1-alpha4
*/
private final @NotNull List<@NotNull String> unmetDependencies;
/**
* Constructs this exception.
*
* @param unmetDependencies map of all unmet dependencies
* @see #unmetDependencies
* @since v1-alpha4
*/
public UnmetDependenciesException(@NotNull List<@NotNull String> unmetDependencies) {
this.unmetDependencies = unmetDependencies;
}
}

View file

@ -1,53 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.exception.reflection;
import de.staropensource.sosengine.base.type.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
*/
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());
}
}

View file

@ -1,39 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.exception.reflection;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when trying to call an instance (non-static) method from a static context.
*
* @since v1-alpha2
*/
public class InstanceMethodFromStaticContextException extends Exception {
/**
* 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");
}
}

View file

@ -1,40 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.exception.reflection;
import de.staropensource.sosengine.base.reflection.ReflectionClass;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when a field could not be found.
*
* @since v1-alpha2
*/
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());
}
}

View file

@ -1,40 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.exception.reflection;
import de.staropensource.sosengine.base.reflection.ReflectionClass;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when a method could not be found.
*
* @since v1-alpha2
*/
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());
}
}

View file

@ -1,40 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.exception.reflection;
import org.jetbrains.annotations.NotNull;
/**
* Thrown if access to some class, method or field has been denied.
*
* @since v1-alpha2
*/
public class NoAccessException extends Exception {
/**
* 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");
}
}

View file

@ -1,54 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.exception.reflection;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when an exception is thrown by a static initializer.
*
* @since v1-alpha2
*/
@Getter
@SuppressWarnings({ "JavadocDeclaration" })
public class StaticInitializerException extends Exception {
/**
* Contains the throwable thrown by the static initializer.
*
* @since v1-alpha2
* -- GETTER --
* Returns the throwable thrown by the static initializer.
*
* @return throwable thrown by the static initializer
* @since v1-alpha2
*/
private final @NotNull Throwable throwable;
/**
* Constructs this exception.
*
* @param throwable throwable thrown by the static initializer
* @since v1-alpha2
*/
public StaticInitializerException(@NotNull Throwable throwable) {
this.throwable = throwable;
}
}

View file

@ -1,26 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* Exceptions related to reflection.
*
* @see de.staropensource.sosengine.base.reflection
* @since v1-alpha2
*/
package de.staropensource.sosengine.base.exception.reflection;

View file

@ -1,41 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.exception.versioning;
import de.staropensource.sosengine.base.implementable.VersioningSystem;
/**
* Thrown when trying to compare a {@link VersioningSystem} against another
* {@link VersioningSystem}, which it does not support.
*
* @since v1-alpha1
*/
public class IncompatibleVersioningSystemException extends RuntimeException {
/**
* 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);
}
}

View file

@ -1,104 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.exception.versioning;
import de.staropensource.sosengine.base.implementable.VersioningSystem;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Thrown when an invalid version string is supplied
* to an implementation of {@link VersioningSystem}.
*
* @since v1-alpha1
*/
@Getter
@SuppressWarnings({ "JavadocDeclaration" })
public class InvalidVersionStringException extends Exception {
/**
* Contains the throwable supplied to the constructor.
*
* @see #InvalidVersionStringException(VersioningSystem, String, Throwable)
* @see #InvalidVersionStringException(VersioningSystem, String, String, Throwable)
* @since v1-alpha1
* -- GETTER --
* Returns the throwable supplied by the constructor.
*
* @return throwable
* @see #InvalidVersionStringException(VersioningSystem, String, Throwable)
* @see #InvalidVersionStringException(VersioningSystem, String, String, Throwable)
* @since v1-alpha1
*/
private final @Nullable Throwable throwable;
/**
* 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;
}
}

View file

@ -1,26 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* Exceptions thrown by implementations of {@link de.staropensource.sosengine.base.implementable.VersioningSystem}s.
*
* @see de.staropensource.sosengine.base.implementable.VersioningSystem
* @since v1-alpha1
*/
package de.staropensource.sosengine.base.exception.versioning;

View file

@ -1,145 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementable;
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
*/
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);
}

View file

@ -1,74 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementable;
import de.staropensource.sosengine.base.logging.Logger;
import de.staropensource.sosengine.base.type.logging.LogLevel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Interface for implementing custom logger implementations.
*
* @see Logger#setLoggingAdapter(LoggingAdapter)
* @since v1-alpha0
*/
public interface LoggingAdapter {
/**
* 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);
}

View file

@ -1,40 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementable;
import de.staropensource.sosengine.base.utility.PlaceholderEngine;
import org.jetbrains.annotations.NotNull;
/**
* Interface for implementing placeholders.
*
* @see PlaceholderEngine
* @since v1-alpha0
*/
public interface Placeholder {
/**
* Replaces the placeholder with content.
*
* @param text text to process
* @return processed text
* @since v1-alpha2
*/
@NotNull String replace(@NotNull String text);
}

View file

@ -1,291 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementable;
import de.staropensource.sosengine.base.EngineConfiguration;
import de.staropensource.sosengine.base.exception.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({ "JavadocDeclaration" })
public abstract class ShortcodeParser {
/**
* 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 ShortcodeParser(@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;
};
}
}

View file

@ -1,42 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementable;
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);
}

View file

@ -1,88 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementable;
import de.staropensource.sosengine.base.Engine;
import de.staropensource.sosengine.base.annotation.EngineSubsystem;
import de.staropensource.sosengine.base.annotation.EventListener;
import de.staropensource.sosengine.base.internal.event.InternalEngineShutdownEvent;
import de.staropensource.sosengine.base.logging.LoggerInstance;
import de.staropensource.sosengine.base.type.DependencyVector;
import org.jetbrains.annotations.NotNull;
/**
* Interface for building subsystem main classes.
*
* @see EngineSubsystem
* @since v1-alpha0
*/
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
* @throws IllegalStateException when building the DependencyVector fails, see {@link DependencyVector.Builder#build()}
* @see DependencyVector
* @since v1-alpha4
*/
public abstract @NotNull DependencyVector getDependencyVector() throws IllegalStateException;
/**
* Called on engine shutdown.
*
* @see Engine#shutdown()
* @see Engine#shutdown(int)
* @since v1-alpha0
*/
@EventListener(event = InternalEngineShutdownEvent.class)
@SuppressWarnings({ "unused" })
protected static void shutdownSubsystem() {}
}

View file

@ -1,50 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementable;
import de.staropensource.sosengine.base.exception.versioning.IncompatibleVersioningSystemException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Range;
/**
* Interface for building a versioning system (parser).
*
* @since v1-alpha1
*/
public interface VersioningSystem {
/**
* Returns the name of the versioning system.
*
* @return versioning system name
* @since v1-alpha1
*/
@NotNull String getName();
/**
* Compares a {@link VersioningSystem} with another.
*
* @param version {@link VersioningSystem} to compare against
* @return {@code 0} if the supplied version is bigger, {@code 1} if equal and {@code 2} if smaller
* @throws IncompatibleVersioningSystemException incompatible with the supplied versioning system
* @since v1-alpha1
*/
@Range(from = 0, to = 2)
int compare(@NotNull VersioningSystem version) throws IncompatibleVersioningSystemException;
}

View file

@ -1,216 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementable.helper;
import de.staropensource.sosengine.base.EngineConfiguration;
import de.staropensource.sosengine.base.annotation.EventListener;
import de.staropensource.sosengine.base.event.LogEvent;
import de.staropensource.sosengine.base.exception.reflection.InstanceMethodFromStaticContextException;
import de.staropensource.sosengine.base.exception.reflection.InvalidMethodSignature;
import de.staropensource.sosengine.base.exception.reflection.NoAccessException;
import de.staropensource.sosengine.base.exception.reflection.StaticInitializerException;
import de.staropensource.sosengine.base.implementable.Event;
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
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 (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);
} catch (Exception exception) {
logger.crash("Event listener method " + method.getName() + " could not be called as an error occurred during reflection", exception, true);
}
}
};
if (EngineConfiguration.getInstance().isOptimizeEvents())
Thread
.ofVirtual()
.name("Event " + event.getName())
.start(eventCode);
else
eventCode.run();
}
/**
* (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);
}
}

View file

@ -1,26 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* Not necessarily interfaces or extendable classes. Rather, they
* support implementing classes by providing useful or complex code.
*
* @since v1-alpha0
*/
package de.staropensource.sosengine.base.implementable.helper;

View file

@ -1,27 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* Interfaces and abstract classes which can be used for implementing classes.
* <p>
* These are not to be confused with data types. See {@link de.staropensource.sosengine.base.type}.
*
* @since v1-alpha0
*/
package de.staropensource.sosengine.base.implementable;

View file

@ -1,69 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementation.logging;
import de.staropensource.sosengine.base.EngineConfiguration;
import de.staropensource.sosengine.base.implementable.LoggingAdapter;
import de.staropensource.sosengine.base.logging.Logger;
import de.staropensource.sosengine.base.type.logging.LogLevel;
import de.staropensource.sosengine.base.implementation.shortcode.EmptyShortcodeConverter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Prints log messages to the console, without any fancy colors or formatting.
*
* @see Logger
* @see LoggingAdapter
* @since v1-alpha1
*/
public class PlainLoggingAdapter implements LoggingAdapter {
/**
* Constructs this class.
*
* @since v1-alpha1
*/
public PlainLoggingAdapter() {}
/** {@inheritDoc} */
@Override
public @Nullable String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
return null; // 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
public void print(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
format = new EmptyShortcodeConverter(format, true).getClean();
if (level == LogLevel.ERROR || level == LogLevel.CRASH)
if (EngineConfiguration.getInstance().isLoggerForceStandardOutput())
System.out.println(format);
else
System.err.println(format);
else
System.out.println(format);
}
}

View file

@ -1,56 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementation.logging;
import de.staropensource.sosengine.base.implementable.LoggingAdapter;
import de.staropensource.sosengine.base.type.logging.LogLevel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* An implementation of {@link LoggingAdapter}, which does nothing.
* Useful if you want to silence engine startup messages.
*
* @since v1-alpha4
*/
public class QuietLoggingAdapter implements LoggingAdapter {
/**
* Constructs this class.
*
* @since v1-alpha4
*/
public QuietLoggingAdapter() {}
/** {@inheritDoc} */
@Override
public @Nullable String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
return null;
}
/** {@inheritDoc} */
@Override
public @NotNull String postPlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
return format;
}
/** {@inheritDoc} */
@Override
public void print(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {}
}

View file

@ -1,68 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementation.logging;
import de.staropensource.sosengine.base.EngineConfiguration;
import de.staropensource.sosengine.base.implementable.LoggingAdapter;
import de.staropensource.sosengine.base.logging.Logger;
import de.staropensource.sosengine.base.type.logging.LogLevel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Prints log messages to the console, without performing any message changes.
* Will reveal shortcodes as they will not be replaced.
*
* @see Logger
* @see LoggingAdapter
* @since v1-alpha1
*/
public class RawLoggingAdapter implements LoggingAdapter {
/**
* Constructs this class.
*
* @since v1-alpha1
*/
public RawLoggingAdapter() {}
/** {@inheritDoc} */
@Override
public @Nullable String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
return null; // 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
public void print(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
if (level == LogLevel.ERROR || level == LogLevel.CRASH)
if (EngineConfiguration.getInstance().isLoggerForceStandardOutput())
System.out.println(format);
else
System.err.println(format);
else
System.out.println(format);
}
}

View file

@ -1,60 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementation.shortcode;
import de.staropensource.sosengine.base.implementable.ShortcodeParser;
import de.staropensource.sosengine.base.exception.ParserException;
import org.jetbrains.annotations.NotNull;
/**
* Cleans the string of any tags.
*
* @see ShortcodeParser
* @since v1-alpha1
*/
public final class EmptyShortcodeConverter extends ShortcodeParser {
/**
* 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-alpha1
*/
public EmptyShortcodeConverter(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
super(string, ignoreInvalidEscapes);
}
/**
* Returns the parsed string without any tags.
*
* @return cleaned input string
* @since v1-alpha1
*/
public @NotNull String getClean() {
StringBuilder output = new StringBuilder();
for (String component : components)
if (component.startsWith("TEXT:"))
output.append(component.substring(5));
return output.toString();
}
}

View file

@ -1,153 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementation.versioning;
import de.staropensource.sosengine.base.implementable.VersioningSystem;
import de.staropensource.sosengine.base.exception.versioning.IncompatibleVersioningSystemException;
import de.staropensource.sosengine.base.exception.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({ "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);
}
}

View file

@ -1,84 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementation.versioning;
import de.staropensource.sosengine.base.implementable.VersioningSystem;
import de.staropensource.sosengine.base.exception.versioning.IncompatibleVersioningSystemException;
import de.staropensource.sosengine.base.exception.versioning.InvalidVersionStringException;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Range;
/**
* Represents a one-numbered versioning system, where an application or work is versioned by one arbitrary number.
*
* @since v1-alpha1
*/
@Getter
@SuppressWarnings({ "JavadocDeclaration" })
public final class OneNumberVersioningSystem implements VersioningSystem {
/**
* Contains the number vector.
*
* @since v1-alpha1
* -- GETTER --
* Returns the number vector.
*
* @return number vector
* @since v1-alpha1
*/
private final int number;
/** {@inheritDoc} */
@Override
public @NotNull String getName() {
return "n1";
}
/**
* 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);
}
}

View file

@ -1,222 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementation.versioning;
import de.staropensource.sosengine.base.implementable.VersioningSystem;
import de.staropensource.sosengine.base.exception.versioning.IncompatibleVersioningSystemException;
import de.staropensource.sosengine.base.exception.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({ "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);
}
}

View file

@ -1,263 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementation.versioning;
import de.staropensource.sosengine.base.implementable.VersioningSystem;
import de.staropensource.sosengine.base.exception.versioning.IncompatibleVersioningSystemException;
import de.staropensource.sosengine.base.exception.versioning.InvalidVersionStringException;
import de.staropensource.sosengine.base.type.VersionType;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Range;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* Represents the StarOpenSource versioning system (version 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({ "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 characters
for (Character character : versionString.toCharArray()) {
switch (parsingId) {
case 0 -> { // 'v' character
if (character != 'v')
throw new InvalidVersionStringException(this, versionString, "Does not start with the character 'v'");
parsingId++;
}
case 1 -> { // Version vector
if (character == '-') {
versionStringSplit.add(charSequence.toString());
charSequence = new StringBuilder();
parsingId++;
} else
charSequence.append(character);
}
case 2 -> { // Type vector
charSequence.append(character);
if (charSequence.toString().equals("alpha") || charSequence.toString().equals("beta") || charSequence.toString().equals("release")) {
versionStringSplit.add(charSequence.toString());
charSequence = new StringBuilder();
parsingId++;
} else if (versionStringSplit.size() == 2 && versionStringSplit.get(1).contains("releasec") && charSequence.toString().equals("andidate")) {
versionStringSplit.set(1, versionStringSplit.get(1) + charSequence);
charSequence = new StringBuilder();
parsingId++;
}
}
case 3 -> { // Typerelease vector
if (character == '-' || character == '+') {
versionStringSplit.add(charSequence.toString());
charSequence = new StringBuilder();
parsingId++;
if (character == '+')
parsingId++;
} else
if (character == 'c' && versionStringSplit.get(1).equals("release")) {
versionStringSplit.set(1, versionStringSplit.get(1) + character);
parsingId--;
} else
charSequence.append(character);
}
case 4 -> { // Fork vector
if (character == '+') {
fork = charSequence.toString();
charSequence = new StringBuilder();
parsingId++;
} else
charSequence.append(character);
}
case 5 -> // Companion vector
charSequence.append(character);
}
}
switch (parsingId) {
case 0, 1, 2 -> throw new InvalidVersionStringException(this, versionString, "Required vectors not found");
case 3 -> {
if (charSequence.isEmpty())
throw new InvalidVersionStringException(this, versionString, "Required vectors not found");
else {
if (versionStringSplit.size() == 2 && versionStringSplit.get(1).contains("releasec") && charSequence.toString().equals("andidate")) {
versionStringSplit.set(1, versionStringSplit.get(1) + charSequence);
} else
versionStringSplit.add(charSequence.toString());
}
}
case 5 -> {
if (charSequence.isEmpty())
throw new InvalidVersionStringException(this, versionString, "Fork vector not found");
else
fork = charSequence.toString();
}
case 6 -> {
if (charSequence.isEmpty())
throw new InvalidVersionStringException(this, versionString, "Companion vector not found");
else
companion = charSequence.toString();
}
}
// Rewrite type
if (versionStringSplit.get(1).equals("releasecandidate"))
versionStringSplit.set(1, "RELEASE_CANDIDATE");
else
versionStringSplit.set(1, versionStringSplit.get(1).toUpperCase(Locale.ROOT));
// Update variables
try {
this.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);
}
}

View file

@ -1,135 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementation.versioning;
import de.staropensource.sosengine.base.implementable.VersioningSystem;
import de.staropensource.sosengine.base.exception.versioning.IncompatibleVersioningSystemException;
import de.staropensource.sosengine.base.exception.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({ "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);
}
}

View file

@ -1,117 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.implementation.versioning;
import de.staropensource.sosengine.base.implementable.VersioningSystem;
import de.staropensource.sosengine.base.exception.versioning.IncompatibleVersioningSystemException;
import de.staropensource.sosengine.base.exception.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({ "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);
}
}

View file

@ -1,26 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* Built-in versioning systems which
* can be used to represent versions of some work.
*
* @since v1-alpha1
*/
package de.staropensource.sosengine.base.implementation.versioning;

View file

@ -1,45 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.event;
import de.staropensource.sosengine.base.implementable.Event;
import de.staropensource.sosengine.base.implementable.helper.EventHelper;
/**
* Called when the engine is about to shutdown, after {@link de.staropensource.sosengine.base.event.EngineShutdownEvent}.
* <p>
* Meant for subsystems to perform cleanup and shutdown routines, not for applications.
*
* @since v1-alpha0
*/
public final class InternalEngineShutdownEvent implements Event {
/**
* Constructs this event.
*
* @since v1-alpha0
*/
public InternalEngineShutdownEvent() {}
/** {@inheritDoc} */
@Override
public void callEvent() {
EventHelper.invokeAnnotatedMethods(getClass());
}
}

View file

@ -1,24 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* 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.event;

View file

@ -1,48 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.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));
}
}

View file

@ -1,48 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.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));
}
}

View file

@ -1,48 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.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));
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_dependency_jansi} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineDependencyJansi implements Placeholder {
/**
* 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());
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_dependency_lwjgl} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineDependencyLwjgl implements Placeholder {
/**
* 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());
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_dependency_reflections} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineDependencyReflections implements Placeholder {
/**
* 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());
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_dependency_slf4j} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineDependencySlf4j implements Placeholder {
/**
* 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());
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_branch} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitBranch implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitBranch() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_branch%", EngineInformation.getGitBranch());
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_header} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitHeader implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitCommitHeader() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_commit_header%", EngineInformation.getGitCommitHeader());
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_id_long} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitIdLong implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitCommitIdLong() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_commit_id_long%", EngineInformation.getGitCommitIdentifierLong());
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_id_short} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitIdShort implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitCommitIdShort() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_commit_id_short%", EngineInformation.getGitCommitIdentifierShort());
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_time_day} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitTimeDay implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitCommitTimeDay() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_commit_time_day%", String.valueOf(EngineInformation.getGitCommitTime().getDayOfMonth()));
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_time_hour} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitTimeHour implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitCommitTimeHour() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_commit_time_hour%", String.valueOf(EngineInformation.getGitCommitTime().getHour()));
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_time_minute} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitTimeMinute implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitCommitTimeMinute() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_commit_time_minute%", String.valueOf(EngineInformation.getGitCommitTime().getMinute()));
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_time_month} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitTimeMonth implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitCommitTimeMonth() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_commit_time_month%", String.valueOf(EngineInformation.getGitCommitTime().getMonth()));
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_time_second} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitTimeSecond implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitCommitTimeSecond() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_commit_time_second%", String.valueOf(EngineInformation.getGitCommitTime().getSecond()));
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_time_year} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitTimeYear implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitCommitTimeYear() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_commit_time_year%", String.valueOf(EngineInformation.getGitCommitTime().getYear()));
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commits} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommits implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitCommits() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_commits%", String.valueOf(EngineInformation.getGitCommitCount()));
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_committer_email} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitterEmail implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitCommitterEmail() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_committer_email%", EngineInformation.getGitCommitterEmail());
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_committer_name} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitterName implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitCommitterName() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_committer_name%", EngineInformation.getGitCommitterName());
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_dirty} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitDirty implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineGitDirty() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_git_dirty%", String.valueOf(EngineInformation.isGitDirty()));
}
}

View file

@ -1,45 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_version} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineVersion implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineVersion() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_version%", "v%engine_version_version%-%engine_version_type%%engine_version_typerelease%%engine_version_fork%");
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_version_fork} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineVersionFork implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineVersionFork() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_version_fork%", EngineInformation.getVersioningFork());
}
}

View file

@ -1,46 +0,0 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.implementable.Placeholder;
import de.staropensource.sosengine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_version_type} placeholder.
*
* @see Placeholder
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineVersionType implements Placeholder {
/**
* Constructs this class.
*
* @since v1-alpha0
*/
public EngineVersionType() {}
/** {@inheritDoc} */
@Override
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_version_type%", EngineInformation.getVersioningType().name().toLowerCase());
}
}

Some files were not shown because too many files have changed in this diff Show more