Compare commits

...

421 commits

Author SHA1 Message Date
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
6ee1dc8e12
You know what? Yeet!
All checks were successful
build-and-test / test (push) Successful in 1m58s
build-and-test / build (push) Successful in 2m13s
build-and-test / generate-javadoc (push) Successful in 2m19s
2024-09-05 01:17:08 +02:00
104e378856
Move testing infrastructure into separate subproject
All checks were successful
build-and-test / test (push) Successful in 1m17s
build-and-test / build (push) Successful in 1m35s
build-and-test / generate-javadoc (push) Successful in 1m45s
2024-09-05 01:15:36 +02:00
4bbc1fd683
Add more documentation to loggerPollingSpeed setting
All checks were successful
build-and-test / test (push) Successful in 1m50s
build-and-test / build (push) Successful in 2m2s
build-and-test / generate-javadoc (push) Successful in 2m3s
2024-09-05 00:47:24 +02:00
770c9b5c6e
Add LoggingThread#getState method 2024-09-05 00:47:12 +02:00
c9bf6126a0
Rename LoggingThread#startLoggingThread method 2024-09-05 00:47:04 +02:00
e21ea102c7
Fix Javadoc warnings 2024-09-05 00:39:34 +02:00
21973ffe6c
Move logging thread-related stuff into separate class 2024-09-05 00:36:50 +02:00
390a5cd227
Fix newline identation in crash reports
All checks were successful
build-and-test / test (push) Successful in 1m32s
build-and-test / generate-javadoc (push) Successful in 1m35s
build-and-test / build (push) Successful in 1m38s
2024-09-04 22:26:43 +02:00
4f7a741088
The unmet dependencies map is now a list 2024-09-04 22:26:13 +02:00
ede254c7f4
Add "Gradle properties" section outlining project properties
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-09-04 21:38:56 +02:00
2b9487f2a9
Add dependency cycle detection, fix tests
All checks were successful
build-and-test / build (push) Successful in 1m33s
build-and-test / test (push) Successful in 1m34s
build-and-test / generate-javadoc (push) Successful in 1m40s
2024-09-04 19:55:32 +02:00
48b0126e5c
Nuke DependencySubsystemVector.Builder inner class
All checks were successful
build-and-test / test (push) Successful in 1m28s
build-and-test / build (push) Successful in 1m34s
build-and-test / generate-javadoc (push) Successful in 1m33s
2024-09-04 17:20:24 +02:00
9b97390a9c
Fix DependencyResolver tests
All checks were successful
build-and-test / test (push) Successful in 1m37s
build-and-test / build (push) Successful in 1m41s
build-and-test / generate-javadoc (push) Successful in 1m42s
2024-09-04 17:04:19 +02:00
6c3c449416
Correct DependencyResolver behaviour 2024-09-04 17:04:12 +02:00
9cd888299f
remove old code why did i commit this to the repo 2024-09-04 17:03:48 +02:00
07cbbb9bb3
Fix VersioningSystem and versioning system tests javadoc
Some checks failed
build-and-test / test (push) Failing after 1m13s
build-and-test / build (push) Successful in 1m42s
build-and-test / generate-javadoc (push) Successful in 1m42s
2024-09-04 17:03:06 +02:00
8caafd6d01
Fix assertions in DependencyResolverTest
Some checks failed
build-and-test / test (push) Failing after 53s
build-and-test / build (push) Successful in 1m14s
build-and-test / generate-javadoc (push) Successful in 1m19s
2024-09-01 21:51:39 +02:00
0252776195
Fix warnings and duplicate check 2024-09-01 21:50:25 +02:00
6785ec64d3
Add TestBase#performMethodCalls method
All checks were successful
build-and-test / test (push) Successful in 1m38s
build-and-test / build (push) Successful in 1m48s
build-and-test / generate-javadoc (push) Successful in 2m39s
2024-09-01 21:33:38 +02:00
fbcb00c481
Add failure test to DependencyResolverTest
All checks were successful
build-and-test / test (push) Successful in 1m15s
build-and-test / build (push) Successful in 1m26s
build-and-test / generate-javadoc (push) Successful in 1m25s
2024-09-01 21:21:26 +02:00
25c9f45817
Rewrite test control and configuration code
All checks were successful
build-and-test / test (push) Successful in 2m20s
build-and-test / generate-javadoc (push) Successful in 2m24s
build-and-test / build (push) Successful in 2m26s
2024-09-01 21:20:47 +02:00
d4c8494b34
Silence engine startup and shutdown messages in tests
All checks were successful
build-and-test / test (push) Successful in 1m24s
build-and-test / build (push) Successful in 1m35s
build-and-test / generate-javadoc (push) Successful in 1m45s
2024-09-01 19:01:44 +02:00
889d106470
Rename loggerImplementation in Logger class
All checks were successful
build-and-test / test (push) Successful in 1m16s
build-and-test / generate-javadoc (push) Successful in 1m30s
build-and-test / build (push) Successful in 1m33s
2024-09-01 16:58:49 +02:00
c33e3d3e27
Remove test layers four and five
All checks were successful
build-and-test / test (push) Successful in 1m26s
build-and-test / generate-javadoc (push) Successful in 1m35s
build-and-test / build (push) Successful in 1m37s
2024-09-01 16:40:17 +02:00
dedcdad002
Fix Javadoc generation warnings and errors
Some checks failed
build-and-test / test (push) Failing after 53s
build-and-test / build (push) Successful in 1m10s
build-and-test / generate-javadoc (push) Successful in 1m19s
2024-08-31 22:35:02 +02:00
2529898e19
Update version in documentation
Some checks failed
build-and-test / build (push) Failing after 47s
build-and-test / generate-javadoc (push) Failing after 57s
build-and-test / test (push) Failing after 56s
2024-08-31 22:26:08 +02:00
483afa1e45
Rename and nuke a few exceptions
Some checks failed
build-and-test / build (push) Failing after 1m0s
build-and-test / generate-javadoc (push) Failing after 59s
build-and-test / test (push) Failing after 1m7s
2024-08-31 22:24:22 +02:00
cfb52106dc
Rename LoggerImplementation and rename mainClass vars
Some checks failed
build-and-test / build (push) Failing after 46s
build-and-test / generate-javadoc (push) Failing after 53s
build-and-test / test (push) Failing after 53s
2024-08-31 22:06:40 +02:00
794f8bb471
Nuke StackTraceParser
Some checks failed
build-and-test / build (push) Failing after 50s
build-and-test / test (push) Failing after 56s
build-and-test / generate-javadoc (push) Failing after 59s
2024-08-31 19:32:00 +02:00
f25dd19e98
Rename pkg base.type.vectors -> base.type.vector
Some checks failed
build-and-test / test (push) Failing after 1m0s
build-and-test / build (push) Successful in 1m30s
build-and-test / generate-javadoc (push) Successful in 1m29s
2024-08-31 19:20:49 +02:00
07614d4519
Rename and move packages
Some checks failed
build-and-test / test (push) Failing after 57s
build-and-test / generate-javadoc (push) Successful in 1m18s
build-and-test / build (push) Successful in 17m43s
2024-08-31 14:02:05 +02:00
db10965c69
Rename name-conflicting NoAccessExceptions
Some checks failed
build-and-test / build (push) Failing after 36s
build-and-test / test (push) Failing after 36s
build-and-test / generate-javadoc (push) Failing after 42s
2024-08-31 13:53:39 +02:00
f578360395
Did I accidentally commit test code? 2024-08-31 13:23:35 +02:00
6e7d660d70
Rename packages
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-08-31 13:15:31 +02:00
a3ca81498e
Replace Thread#sleep calls with Thread#onSpinWait
All checks were successful
build-and-test / test (push) Successful in 1m28s
build-and-test / generate-javadoc (push) Successful in 1m36s
build-and-test / build (push) Successful in 1m52s
2024-08-30 03:06:36 +02:00
0d4fa85c91
Separate API documentation links
All checks were successful
build-and-test / test (push) Successful in 2m15s
build-and-test / build (push) Successful in 2m24s
build-and-test / generate-javadoc (push) Successful in 2m22s
2024-08-24 22:56:27 +02:00
b974ce22b0
Add licensing and copyright information to init message
All checks were successful
build-and-test / test (push) Successful in 1m47s
build-and-test / generate-javadoc (push) Successful in 1m49s
build-and-test / build (push) Successful in 1m54s
2024-08-21 21:45:43 +02:00
34be192d5b
[no ci] Update copyright notice 2024-08-21 21:41:28 +02:00
d1fa759d0a
Ensure engine shutdown after running tests
All checks were successful
build-and-test / test (push) Successful in 3m27s
build-and-test / generate-javadoc (push) Successful in 3m30s
build-and-test / build (push) Successful in 4m28s
2024-08-21 21:26:25 +02:00
6a2a18095b
Fix Javadoc warnings
Some checks failed
build-and-test / generate-javadoc (push) Successful in 3m48s
build-and-test / test (push) Failing after 4m1s
build-and-test / build (push) Successful in 4m23s
2024-08-21 21:19:22 +02:00
b4f5829375
Add PrintStreamService (implements #5)
Some checks failed
build-and-test / build (push) Failing after 1m46s
build-and-test / test (push) Failing after 3m25s
build-and-test / generate-javadoc (push) Failing after 3m27s
2024-08-21 19:35:05 +02:00
b3968d8469
Fix typo Notifiying -> Notifying
Some checks failed
build-and-test / build (push) Failing after 3m18s
build-and-test / generate-javadoc (push) Failing after 3m53s
build-and-test / test (push) Failing after 3m51s
2024-08-21 13:53:57 +02:00
d06f8a3dc3
Move ShutdownHandler code into EngineInternals
Some checks failed
build-and-test / build (push) Failing after 3m21s
build-and-test / generate-javadoc (push) Failing after 3m14s
build-and-test / test (push) Failing after 3m12s
2024-08-21 13:51:21 +02:00
f1fb21dbb1
Replace executeSafely with good 'ol try-catch
Some checks failed
build-and-test / build (push) Failing after 3m1s
build-and-test / test (push) Failing after 2m58s
build-and-test / generate-javadoc (push) Failing after 3m3s
2024-08-21 01:52:32 +02:00
5284dfe17b
Remove 1s thread sleep
Some checks failed
build-and-test / build (push) Failing after 2m46s
build-and-test / generate-javadoc (push) Failing after 2m3s
build-and-test / test (push) Failing after 2m57s
2024-08-21 01:51:13 +02:00
8ea4594e6f
Revert "Removed safety shutdown hook again"
Found a fix.
This reverts commit f880122add.
2024-08-21 01:50:49 +02:00
f880122add
Removed safety shutdown hook again
Some checks failed
build-and-test / test (push) Successful in 3m37s
build-and-test / generate-javadoc (push) Failing after 2m50s
build-and-test / build (push) Failing after 1m40s
2024-08-21 01:43:08 +02:00
2fedc981af
Add shutdown hook functionality (broken, #6)
Some checks failed
build-and-test / generate-javadoc (push) Failing after 1m54s
build-and-test / build (push) Failing after 2m6s
build-and-test / test (push) Failing after 2m26s
Doesn't really work right now, will likely be removed
2024-08-21 01:40:45 +02:00
5718f33d88
Fix PlaceholderEngine usage in Logger.java
All checks were successful
build-and-test / test (push) Successful in 2m22s
build-and-test / build (push) Successful in 2m29s
build-and-test / generate-javadoc (push) Successful in 2m27s
2024-08-20 22:32:21 +02:00
98ff132d27
Update Gradle wrapper to 8.10
All checks were successful
build-and-test / test (push) Successful in 2m15s
build-and-test / generate-javadoc (push) Successful in 2m33s
build-and-test / build (push) Successful in 2m37s
2024-08-20 22:09:27 +02:00
c90406dac9
Make GLFW subsystem standalone + remove unnecessary fluff
All checks were successful
build-and-test / test (push) Successful in 1m39s
build-and-test / build (push) Successful in 1m54s
build-and-test / generate-javadoc (push) Successful in 1m55s
2024-08-20 22:07:49 +02:00
ae790dbd18
Flush logs before printing crash report 2024-08-20 21:45:41 +02:00
701f316950
Nuke 'graphics', welcome 'windowing'
All checks were successful
build-and-test / test (push) Successful in 2m1s
build-and-test / generate-javadoc (push) Successful in 2m14s
build-and-test / build (push) Successful in 2m17s
2024-08-20 21:01:39 +02:00
a550f0a16a
Update docusaurus
All checks were successful
build-and-test / build (push) Successful in 1m49s
build-and-test / test (push) Successful in 1m49s
build-and-test / generate-javadoc (push) Successful in 2m1s
2024-08-20 20:54:46 +02:00
ef613acc59
[no ci] Fix typos, add link for JVM langs 2024-08-20 20:54:02 +02:00
29ac99c478
Remove size and position w/ decoration getters
All checks were successful
build-and-test / test (push) Successful in 1m56s
build-and-test / build (push) Successful in 2m3s
build-and-test / generate-javadoc (push) Successful in 2m1s
2024-08-20 20:31:27 +02:00
ca3bf94a48
Prevent allocation in loops
All checks were successful
build-and-test / test (push) Successful in 1m52s
build-and-test / generate-javadoc (push) Successful in 2m5s
build-and-test / build (push) Successful in 2m7s
2024-08-20 20:25:46 +02:00
ad7b3568cf
Add config setting for toggling newline support
All checks were successful
build-and-test / test (push) Successful in 1m58s
build-and-test / build (push) Successful in 2m7s
build-and-test / generate-javadoc (push) Successful in 2m21s
2024-08-19 20:28:40 +02:00
48c326ad71
[no ci] Remove breakpoint instruction 2024-08-19 20:28:13 +02:00
fb82c9c4b0
Rework logger placeholder replacement, add newline support
All checks were successful
build-and-test / build (push) Successful in 1m52s
build-and-test / test (push) Successful in 1m54s
build-and-test / generate-javadoc (push) Successful in 1m58s
This commit reworks how placeholders work in Logger.java and adds support for printing multiple lines.
2024-08-19 20:17:55 +02:00
971f81a626
Fix quirk of Jansi in AnsiShortcodeConverter
All checks were successful
build-and-test / test (push) Successful in 1m47s
build-and-test / generate-javadoc (push) Successful in 1m54s
build-and-test / build (push) Successful in 1m56s
This commit prevents toggling attributes when including them multiple times in a string and instead simply ignores them when specified multiple times without <reset>ting them.
2024-08-19 20:14:55 +02:00
70ff609b77
[no ci] Sort properties in gradle.properties 2024-08-19 15:17:39 +02:00
54cde09be3
Update test configuration in other build.gradle files
All checks were successful
build-and-test / test (push) Successful in 1m44s
build-and-test / generate-javadoc (push) Successful in 1m58s
build-and-test / build (push) Successful in 2m0s
2024-08-19 02:59:11 +02:00
43e038d3ec
Add correct @since tag to ListFormatter
All checks were successful
build-and-test / test (push) Successful in 1m33s
build-and-test / build (push) Successful in 1m40s
build-and-test / generate-javadoc (push) Successful in 4m18s
2024-08-19 02:49:46 +02:00
781f1c113c
Remove unused and leftover methods 2024-08-19 02:49:31 +02:00
f828d31094
Remove args from Main#run method 2024-08-19 02:49:14 +02:00
9ff4f96814
Remove many unused warning supressions
Why did I add this to every single class file in the first place...?
2024-08-19 02:49:00 +02:00
ed9c94f17c
Added hacky way for controlling the execution of tests
All checks were successful
build-and-test / test (push) Successful in 1m38s
build-and-test / build (push) Successful in 1m43s
build-and-test / generate-javadoc (push) Successful in 6m58s
2024-08-19 02:06:26 +02:00
94fb91197a
Add caching to workflows
All checks were successful
build-and-test / test (push) Successful in 1m41s
build-and-test / build (push) Successful in 1m50s
build-and-test / generate-javadoc (push) Successful in 2m0s
2024-08-18 20:25:09 +02:00
35cfc75a04
Separate build-and-test into PR & commit workflow
All checks were successful
build-and-test / build (push) Successful in 1m36s
build-and-test / test (push) Successful in 1m41s
build-and-test / generate-javadoc (push) Successful in 1m47s
2024-08-18 19:54:15 +02:00
03d53fc997
Fix Javadoc issues
All checks were successful
build-and-test / test (push) Successful in 1m33s
build-and-test / build (push) Successful in 1m39s
build-and-test / generate-javadoc (push) Successful in 1m53s
2024-08-18 19:47:41 +02:00
eb108495ea
Add option to fail doc when Javadoc throws a warning
Some checks failed
build-and-test / build (push) Failing after 1m21s
build-and-test / generate-javadoc (push) Failing after 1m25s
build-and-test / test (push) Successful in 1m26s
2024-08-18 19:34:15 +02:00
736dbed1f3
Remove weird @author and @since tags from base package-info.java
All checks were successful
build-and-test / build (push) Successful in 1m35s
build-and-test / test (push) Successful in 1m38s
build-and-test / generate-javadoc (push) Successful in 1m46s
2024-08-18 18:29:22 +02:00
b993124f41
[no ci] Move PR and issue templates to .forgejo 2024-08-18 18:27:48 +02:00
db56c0538a misc: add CI workflows for PRs and commits (#1)
All checks were successful
build-and-test / test (push) Successful in 1m30s
build-and-test / build (push) Successful in 1m37s
build-and-test / generate-javadoc (push) Successful in 1m45s
Reviewed-on: #1
Co-authored-by: JeremyStarTM <jeremystartm@staropensource.de>
Co-committed-by: JeremyStarTM <jeremystartm@staropensource.de>
2024-08-18 18:25:22 +02:00
99e0f77fd1
How THE FUCK does this not have @since in it's jd?!?! 2024-08-18 13:03:42 +02:00
1405c12626
Add .gitattributes file for language detection 2024-08-18 12:39:16 +02:00
b7afa4bb5e
Move label to right spot
Remember kids: Think before committing!
2024-08-18 12:34:08 +02:00
d5b7c599a8
Add label 2024-08-18 12:33:29 +02:00
649a3d7479
Add empty issue template 2024-08-18 12:32:54 +02:00
57b2f000c7
Fix smaller issues in issue templates 2024-08-18 12:11:21 +02:00
f03563229b
Fix formatting issues in featurerequest.yml 2024-08-18 12:11:12 +02:00
63a896874f
Remove obvious stuff 2024-08-18 12:04:24 +02:00
e95f6c8e71
Remove "Note: " 2024-08-18 12:01:02 +02:00
1bca312745
Add issue and pull request templates 2024-08-18 12:00:24 +02:00
05b9644eba
Set java source and target versions
This commit also introduces a warning when running the engine on a Java version higher than the engine source is on
2024-08-18 10:49:46 +02:00
081ac106f4
DependencyResolver rewrite, likely broken
This seems to work, but it probably has lots of bugs as I can't really test it efficiently. Need to write unit tests for this, aw man...

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
So we back in the mine
Got our pickaxe swinging from side to side
Side-side to side
This task, a grueling one
Hope to find some diamonds tonight, night, night
Diamonds tonight

Heads up
You hear a sound, turn around and look up
Total shock fills your body
Oh, no, it's you again
I can never forget those eyes, eyes, eyes
Eyes-eye-eyes

'Cause, baby, tonight
The creeper's tryna steal all our stuff again
'Cause, baby, tonight
You grab your pick, shoval and bolt again (Bolt again-gain)
And run, run until it's done, done
Until the sun comes up in the morn'
'Cause, baby, tonight
The creeper's tryna steal all our stuff again (Stuff again-gain)

Just when you think you're safe
Overhear some hissing from right behind
Right-right behind
THat's a nice life you have
Shame it's gotta end at this time, time, time
Time-time-time-time

Then your health bar drops and you could use a one-up
Get inside, don't be tardy
So, now you're stuck in there
Half a heart is left, but don't die, die, die
Die-die-die

'Cause, baby, tonight
The creeper's tryna steal all our stuff again
'Cause, baby, tonight
You grab your pick, shovel and bolt again (Bolt again-gain)

(Creepers, you're mine, haha)
Dig up diamonds and craft those diamonds
And make some armor, get it, baby
Go and forge that like you so MLG pro
The sword's made of diamonds, so come at me, bro, huh
Training in your room under the torchlight
Hone that form to get you ready for the big fight
Every single day and the whole night
Creeper's out prowlin', hoo, alright
Look at me, look at you
Take my revenge, that's what I'm gonna do
I'm a warrior, baby, what else is new?
And my blade's gonna tear through you, bring it

'Cause, baby, tonight
The creeper's tryna steal all our stuff again
(Gather your stuff, yeah, let's take back the world)
Yeah, baby, tonight (Haha)
Grab your sword, armor and go (It's on)
Take your revenge (Woo), oh-oh, oh-oh
So fight, fight, like it's the last, last night
Of your life, life, show them your bite (Woo)

'Cause, baby, tonight
The creeper's tryna steal all our stuff again
'Cause, baby, tonight
You grab your pick, shovel and bolt again (Bolt again-gain, woo)
And run, run until it's done, done
Until the sun comes up in the morn'
'Cause, baby, tonight (Come on, swing your sword up high)
The creeper's tryna steal all our stuff again (Come on, jab your sword down low)
(Woo)
2024-08-17 21:57:10 +02:00
72b40613b8
Escape crash message and stacktrace placeholders
This prevents warnings about '<init>' "tags" found in call stacks, or because of unescaped messages.
2024-08-17 21:37:45 +02:00
db52346168
Add check for invalid version strings 2024-08-17 14:09:27 +02:00
e8ec0ed530
Fix EngineInformation#versioningString being invalid 2024-08-17 14:09:03 +02:00
ae8010a271
Update version identifier to v1-alpha4 2024-08-17 14:01:01 +02:00
58b9b268a1
Update DependencyVector
This commit introduces a "Builder" nested class, adds a way to specify which other vector a vector provides and includes a few smaller changes to DependencyVectors.
This commit does not work at the moment as I'm in the process of rewriting the DependencyResolver to work correctly, as it should.
2024-08-17 13:26:12 +02:00
468e206fab
Add QuietLoggerImplementation, which does nothing 2024-08-17 12:42:05 +02:00
8f12e8b0c8
Add InitLogger and startup logging 2024-08-17 12:41:53 +02:00
78b12dee67
Remove duplicate 2024-08-17 11:55:25 +02:00
1713c9c8a8
Finalize ListConverter
after two months, it finally works
2024-08-12 20:51:37 +02:00
949655b020
Bump version to v1-alpha3 2024-08-03 17:13:43 +02:00
747d08d354
Rename git and gradle properties files
Useful in case the application bundles it's own files to avoid engine crashes and file name conflicts
2024-08-03 17:13:01 +02:00
34f61211d3
Fix maven publishing 2024-08-01 03:17:22 +02:00
2fc0f53b5d
Update overview.html & add ANSI theme.css symlink 2024-08-01 03:01:37 +02:00
669be13dfa
Enable publishing for :graphics and :graphics:glfw 2024-08-01 03:00:56 +02:00
30a32cad8c
Update to Gradle 8.9 2024-08-01 02:04:54 +02:00
b2027c8d8e
Remove "v" from version because of Maven versions 2024-08-01 02:02:19 +02:00
9db7f20c2e
Rename PropertyParser -> PropertiesReader 2024-07-31 21:05:09 +02:00
611d4b823e
Update crash content 2024-07-31 15:03:33 +02:00
1a56f42287
Document processCrashContent, add List support 2024-07-31 15:03:00 +02:00
c984974252
Implement logic for logging thread control
The logging thread now automatically starts or shuts down based on EngineConfiguration#optimizeLogging and Engine#state == EngineState.RUNNING
2024-07-31 15:02:29 +02:00
bd70b17236
Add engine state 2024-07-31 15:00:54 +02:00
f0c19010d9
Add ShutdownHandlers 2024-07-31 13:55:35 +02:00
a261d7914e
Update order of SuppressWarnings & other annotations 2024-07-31 04:20:05 +02:00
d406fa0e3d
Add additional newline to {@inheritDoc} multiliners 2024-07-31 04:07:51 +02:00
02001103d6
Align @throws and @param properly 2024-07-31 04:04:24 +02:00
8792813e34
Remove unecessary ReflectionField#invoke() method 2024-07-31 04:03:52 +02:00
5187b37e53
Add missing LogOrigin placeholder 2024-07-31 04:03:25 +02:00
6a821145a6
Fix log formatting 2024-07-31 04:03:01 +02:00
f383261ed9
MASSIVE CODE CHANGE
tl;dr I changed many Javadoc comments, some code, removed dumb or unused stuff and revamped the entire logging infrastructure by yeeting out LogIssuer and CodePart and much, much more
2024-07-31 03:53:44 +02:00
5be690fd38
Update README 2024-07-29 22:45:07 +02:00
9dc0f549d4
Move ANSI-related stuff into 'ansi' module 2024-07-29 21:34:10 +02:00
2d61b027b3
Fix MiscellaneousTest engine crash 2024-07-29 21:21:38 +02:00
3c09713867
Remove Jetbrains Annotations and Lombok deps info 2024-07-29 19:59:03 +02:00
cbf434ed45
Fix unit tests 2024-07-29 19:58:41 +02:00
006283acff
Fix wording 2024-07-27 12:42:34 +02:00
3503d10c44
Remove unecessary class OpenGlMonitor 2024-07-27 03:08:47 +02:00
d4c5b982df
Fix V-Sync rendering
Turns out I did not need the monitor API for that. Just reading glfwSwapInterval's documentation did the job and fixing my existing code did the job.
2024-07-27 02:28:00 +02:00
935bbaf7ce
Add monitor API and add UUIDs 2024-07-27 02:25:10 +02:00
45307ab842
Move a few exceptions from glfw to graphics subsystem 2024-07-26 13:42:00 +02:00
165e57083b
Move Api*Class to separate 'classes.api' package 2024-07-26 13:23:41 +02:00
9c48c3c756
Move continuous render loop to interface (now class) 2024-07-26 13:22:16 +02:00
7f324090c1
Add some 'final's 2024-07-26 13:20:56 +02:00
b529b7a7af
Make continuous render loop work (except V-Sync)
It works quite good now, but it is broken when V-Sync is turned on as it tries to render at the maximum FPS set and does not respect how fast the monitor renders. I first need to implement a monitor API for it to work.
2024-07-26 13:07:17 +02:00
4f9154f5fc
Make V-Sync global 2024-07-26 13:05:44 +02:00
e787680e8c
Create new Math utility class 2024-07-26 13:05:15 +02:00
e5f7b0e580
Migrate ShortcodeParserSkeleton to StringBuilder 2024-07-25 20:03:46 +02:00
b9d4196b8b
Add escape support to ShortcodeParserSkeleton 2024-07-25 20:00:32 +02:00
bbde2e9d2d
Add render loop 2024-07-25 19:46:50 +02:00
0b4502c3ce
Add MouseButtonCallback 2024-07-25 12:19:46 +02:00
6dc0566fed
Add UNKNOWN_MOUSE, rename UNKNOWN -> UNKNOWN_KEY 2024-07-25 12:19:32 +02:00
be144fb71b
Add working key input recieving 2024-07-25 04:14:43 +02:00
24e26e6a82
Move graphics initialization code around in method 2024-07-25 04:14:17 +02:00
f5af9b34a0
Add UNKNOWN and SPACE key 2024-07-25 04:13:44 +02:00
eea7fce13c
Fix updateState, add terminate methods 2024-07-25 04:13:33 +02:00
6c0244053b
Add *friendly* crash message for users and devs 2024-07-25 04:10:30 +02:00
ef40c04877
Customize thread creation 2024-07-25 04:10:15 +02:00
ee40ac5826
Add %stacktrace_all% crashhandler placeholder 2024-07-25 04:00:31 +02:00
b6a90eb795
Add update-deps task to docs/Makefile 2024-07-24 02:02:55 +02:00
2d8e896333
Fix (weird) wording 2024-07-23 20:43:08 +02:00
d49d54df3a
Add support for some GLFW init hints 2024-07-23 20:35:24 +02:00
81535ad701
Remove deleted event 2024-07-23 20:35:05 +02:00
5909a948b5
Update init logic of base, graphics and glfw 2024-07-23 20:24:57 +02:00
a07dc6db84
Add hideFullTypePath engine setting 2024-07-23 20:19:49 +02:00
062b68a93b
Update setting order 2024-07-23 19:51:00 +02:00
ae201f8729
Fix no window size limits not working at all 2024-07-23 19:33:01 +02:00
86e85356ba
Optimize startup and fix shutdown logic 2024-07-23 19:32:37 +02:00
2899ba2e8a
Sort methods in GLFW and OpenGL window classes 2024-07-23 17:48:10 +02:00
ec3ecc0113
Combine Mouse and KeyInputEvent 2024-07-23 17:47:21 +02:00
7b70cf8511
Fix typo
dum
2024-07-23 17:46:30 +02:00
2f963e86ef
Add clone method to vector data types 2024-07-23 17:45:37 +02:00
805574f677
Oops forgot to update imports here as well 2024-07-22 15:22:48 +02:00
e754c2c248
Add input event and type classes 2024-07-22 15:22:34 +02:00
48f910e78f
Forgot to update imports 2024-07-22 15:20:45 +02:00
e7e1abc510
Move Window-related classes into separate package 2024-07-22 15:20:26 +02:00
90b6dbcd31
Shrink down getSetting() size in configurations 2024-07-22 15:18:35 +02:00
e695235277
Make OpenGL compatibility test window invisible 2024-07-22 13:40:21 +02:00
42d0feb574
Update Window classes 2024-07-22 13:40:03 +02:00
260464d727
Make Miscellaneous#invokeGarbageCollector jd more verbose 2024-07-22 13:39:17 +02:00
a0a89d2f3c
Add boolean and integer conversion methods
This commit also reorganizes the method order inside Miscellaneous.java
2024-07-22 13:35:14 +02:00
67909e9cc3
Add Tristate#toBoolean method 2024-07-22 13:34:29 +02:00
ce97838c12
Add GLFW subsystem to subsystem list in documentation 2024-07-21 23:20:20 +02:00
071534eb1c
Move common GLFW code to new 'glfw' subsystem 2024-07-21 23:19:02 +02:00
bca45488d1
Encapsulate Main#run logic in try-catch block 2024-07-21 23:18:13 +02:00
b277587ec8
Cut down on Vulkan and OpenGL subsystem deps 2024-07-21 23:16:55 +02:00
fa8086f198
Fix vv1-alpha2 in startup message 2024-07-21 23:16:00 +02:00
4dbbee4efa
Add isClosureRequested() method 2024-07-21 22:41:41 +02:00
f3acca7456
Move logCall() invocation outside of Runnable
This ensures debug log messages are kept in order
2024-07-21 21:22:53 +02:00
e8b9642177
Fix Graphics API shutdown logic 2024-07-21 21:19:27 +02:00
aaa81e2f87
Disallow logCall() invocation on LogEvent 2024-07-21 21:19:10 +02:00
9d3397888d
Add OpenGL Core Profile requirement 2024-07-21 21:17:24 +02:00
8b09290c81
Require OpenGL version during window creation 2024-07-21 21:17:06 +02:00
80478e6a69
Improve Graphics API initialization 2024-07-21 21:12:59 +02:00
2469e124bd
Improve event system and reflection 2024-07-21 21:10:49 +02:00
350b18219b
Fix OpenGL Window#getIdentifierAsLong 2024-07-21 17:37:55 +02:00
5cb8350a41
Update stack trace placeholder 2024-07-21 17:37:42 +02:00
705f8a0623
Enclose window title in parenthesis 2024-07-21 17:37:17 +02:00
c194cf2001
Catch all throwables for Window.Builder.build() 2024-07-21 17:36:59 +02:00
55091d3cd1
Override getString() method in vector types 2024-07-21 17:35:56 +02:00
09b244ef74
Update de.staropensource.sosengine.base.types jd 2024-07-21 16:45:58 +02:00
b1a56ea6a4
Update Window class heavily 2024-07-21 16:45:46 +02:00
051f3eaacc
Add ApiInternalClass and OpenGL equivalent 2024-07-21 16:45:28 +02:00
7962a15c12
Sort methods in OpenGlSubsystem 2024-07-21 16:44:57 +02:00
311de39899
Remove createWindow and add mustRunOnMainThread 2024-07-21 16:44:18 +02:00
56743e9bf0
Add HIDDEN window mode 2024-07-21 16:43:13 +02:00
de0d5cb8a8
Add @since tag to VsyncMode javadoc 2024-07-21 16:43:07 +02:00
a3849f1813
Add package information 2024-07-21 16:42:40 +02:00
00a3017c1e
Nuked the Vulkan subsystem 2024-07-21 16:39:02 +02:00
bf7a450be5
Add Miscellaneous#onMainThread method 2024-07-21 16:38:47 +02:00
3964512979
Mark throwable with @NotNull instead of @Nullable 2024-07-21 16:38:37 +02:00
9f638c486c
Rename exception IncompatibleTypeReflection
was i drunk?
2024-07-20 18:22:48 +02:00
85e6cd69de
Add ImmutableHashSet 2024-07-20 18:22:14 +02:00
be74555064
Fix typos in immutable types 2024-07-20 18:22:07 +02:00
bd6cc73a94
Add missing package info files 2024-07-20 18:21:40 +02:00
0c626cc995
Add ParserException 2024-07-20 18:07:58 +02:00
0ce24d677f
Fix jansi build dependency for all projects 2024-07-18 14:14:21 +02:00
ccc6c31cc9
Allow for placeholder configuration 2024-07-18 01:58:00 +02:00
10abe1d3f0
Enable javadoc and source jar upload 2024-07-18 01:25:23 +02:00
d36e36a1d3
Forgot to include testapp back 2024-07-18 01:25:03 +02:00
b17d354a9b
Add v character to output (%engine_version%) 2024-07-18 01:24:38 +02:00
4752dd6918
Update Engine#populateCrashContent() 2024-07-18 01:23:58 +02:00
38c5f0e5b9
Remove unimportant plugin version identifiers 2024-07-18 01:15:10 +02:00
ca0274bbb1
Add 'run/' entry to gitignore 2024-07-16 14:53:17 +02:00
4d2a78af2b
Update GraphicsSubsystemConfiguration javadoc 2024-07-16 14:52:43 +02:00
050befbb73
Move ReflectionScanningHelper -> ClasspathAccess 2024-07-16 14:52:19 +02:00
97dcc5263b
Optimize DependencySubsystemVector 2024-07-16 14:51:21 +02:00
8470d37f37
Update visibility of fields in DependencyVector 2024-07-16 14:51:00 +02:00
bffe68c015
Add SubsystemMainClass#getName() & init time stat 2024-07-16 14:50:39 +02:00
481ce80535
Move some exceptions 2024-07-16 14:48:41 +02:00
31b1a2d199
Fix some stuff in ShortcodeParserSkeleton
This commit removes the <negative> tag, remove it from your sources.
2024-07-16 14:47:17 +02:00
0c77f50609
Fix UnresolvedDependenciesException 2024-07-16 14:45:35 +02:00
85bff3b14d
Allow for disabling automatic subsystem init 2024-07-16 14:44:32 +02:00
5697522641
Remove jOOR dependency, migrate tests 2024-07-15 13:13:55 +02:00
97a0218bf6
Add basic reflection support 2024-07-15 13:13:35 +02:00
dd7bc714b9
IncompatibleVersioningSystem can now be optional 2024-07-15 13:13:01 +02:00
4a8d58d6cc
Update message and javadoc in base tests 2024-07-13 00:08:16 +02:00
e65c3e2662
Prefix all @since values with 'v' 2024-07-12 02:30:20 +02:00
6cfaf88bca
Bump version after release to v1-alpha2 2024-07-11 23:45:53 +02:00
5998f55786
Update TODO 2024-07-11 23:29:35 +02:00
3742a3c2d4
Add classpath exception 2024-07-11 23:29:23 +02:00
19a87aee94
Fix javadocAll task 2024-07-11 22:56:50 +02:00
bfbe0b0053
Finish initializing.md 2024-07-11 22:39:05 +02:00
ec85882fde
Fix Java, Groovy and Kotlin code highlighting 2024-07-11 22:38:56 +02:00
36a89de985
Add v1-alpha1 javadoc link 2024-07-11 22:38:31 +02:00
a02011816b
Mark experimental methods 2024-07-11 22:07:04 +02:00
2b83a1885e
Graphics API init will now catch exceptions 2024-07-11 16:16:30 +02:00
005ebfbfae
Fix native-image a bit 2024-07-11 16:15:47 +02:00
d02e854d95
Fix module-info.java files 2024-07-11 15:51:51 +02:00
7c553c24f0
Move data types and classes around 2024-07-11 14:38:00 +02:00
3a734ece70
Fix display names of versioning system tests 2024-07-11 14:32:20 +02:00
165855c122
Add n1 versioning system 2024-07-11 14:31:42 +02:00
ff7c559a39
Add & update package-info.java files 2024-07-11 14:31:32 +02:00
97d1c391bf
Add soft-crash functionality 2024-07-11 05:43:42 +02:00
7d8d277bc1
Add JvmInformation#getMemoryUsed method 2024-07-11 05:31:11 +02:00
d3b09848b6
Add synchronized keyword to various methods 2024-07-11 05:29:32 +02:00
76b2a08804
Add memory and processor metrics to JvmInformation 2024-07-11 05:29:21 +02:00
ae04896e76
Throw exception instead of returning 2024-07-11 05:28:59 +02:00
e376e36eb3
Rename message -> format for LoggerImpl 2024-07-11 05:28:34 +02:00
fc24ebef39
Update Javadoc theme 2024-07-11 05:00:09 +02:00
b7282d5c7d
Update gradle.properties not found message 2024-07-11 05:00:00 +02:00
b4734841be
Update native-image arguments 2024-07-11 04:59:45 +02:00
c6b3af023f
Use copy task instead of symlinks for resources 2024-07-11 04:59:35 +02:00
9c1f5711a7
Update Javadoc and apply a few code fixes 2024-07-11 04:17:03 +02:00
10fa65b8e1
Update module names for all Graphics APIs 2024-07-11 04:16:20 +02:00
c7f498e281
Sort and add new tasks 2024-07-11 04:15:37 +02:00
fa3d2ec19d
Add comments and fix Javadoc generation 2024-07-11 04:03:08 +02:00
34e60b06dc
Oh god 2024-07-08 19:04:57 +02:00
ab5e12876a
I'm embarrased 2024-07-08 19:04:18 +02:00
0e28d746bd
Add GraalVM native-image tasks 2024-07-08 15:40:11 +02:00
867304b568
Update subsystem initialization logic 2024-07-08 14:29:02 +02:00
ba2e6ebecd
Add not-yet-working getOrder method 2024-07-08 14:28:55 +02:00
c91a2151e9
Update addVectors methods 2024-07-08 14:28:15 +02:00
0afe18d857
DependencyReso...ctor -> DependencySubsystemVector 2024-07-08 14:27:49 +02:00
9aba2e6281
Fix ImmutableLinkedList constructor 2024-07-08 14:26:25 +02:00
4d462d65f4
Mark getDependencyVector with @NotNull 2024-07-08 14:26:07 +02:00
8d9e1db8f2
Fix some ugly shit 2024-07-08 14:25:42 +02:00
2230c4018a
Update DependencyResolver a bit 2024-07-08 13:57:25 +02:00
3f7edd0968
Add more Immutable* types 2024-07-08 13:46:30 +02:00
ab46a25911
Update DependencyVector constructor javadoc 2024-07-08 12:40:40 +02:00
541919c891
Update build.gradle syntax 2024-07-08 12:39:04 +02:00
1e5f48f413
Add module-info.java for all subsystems 2024-07-08 11:32:27 +02:00
fd6c8851ad
Update package structure 2024-07-08 11:32:08 +02:00
000a7d3aca
Update EngineConfiguration ShortcodeConverter refs 2024-07-08 11:29:40 +02:00
d35ae5535c
Rewrite ShortcodeConverter (now with modularity!) 2024-07-07 17:34:16 +02:00
1e4a1e04a7
Remove unused stuff from slf4j-compat 2024-07-07 12:56:27 +02:00
ecf0f94784
Fix & complete automatic subsystem initialization 2024-07-07 12:55:56 +02:00
3e167ac260
Fix Map to ImmutableMap conversion 2024-07-07 12:54:52 +02:00
8ee805b2db
Update and extend JavaDoc for almost all classes 2024-07-07 12:52:36 +02:00
9add9330bb
Add completely broken automatic subsystem init 2024-06-29 22:18:09 +02:00
2cbac22792
Forgot to commit EngineSubsystem annotation :l 2024-06-29 22:17:44 +02:00
aa5b196fb3
Add annotation and new method for subsystems 2024-06-29 22:17:17 +02:00
4793d7aefe
Add probably broken dependency resolver 2024-06-29 22:16:18 +02:00
ef8cdb87cf
Add ImmutableMap 2024-06-29 22:15:56 +02:00
ae3075770d
Add EngineConfiguration#versioningString 2024-06-29 22:15:35 +02:00
87a7603c2e
Add versioning system support 2024-06-29 20:26:56 +02:00
5011fb8ae9
Add countOccurrences and getSeparator methods 2024-06-29 04:25:31 +02:00
e0db4be65a
mv base.data.placeholder -> base.data.placeholder 2024-06-28 23:34:39 +02:00
797052aa7d
Migrate to Goooler's shadow fork 2024-06-28 18:42:37 +02:00
f5c986848c
Correct fake commit time 2024-06-28 18:31:42 +02:00
7c21503532
Fix even more EngineInformation startup exceptions 2024-06-28 18:31:28 +02:00
1a42e4bbc6
Fix exception in EngineInformation during startup 2024-06-28 18:22:19 +02:00
116bc4b0b9
Add git information to EngineInformation 2024-06-28 18:21:59 +02:00
51f0405895
Update Window interface 2024-06-28 18:06:04 +02:00
0514329556
Update test javadoc 2024-06-28 02:17:53 +02:00
ef29a1f775
Add StackTraceParser unit test 2024-06-28 01:12:05 +02:00
bba645f69b
Add @since tag to classes in unittests package 2024-06-28 01:11:55 +02:00
f5075b9832
Plaster copyright notice over everything 2024-06-28 01:08:45 +02:00
fa6b3002ee
Update typerelease version
I forgor
2024-06-28 01:08:25 +02:00
20b6bbaf60
Correct order 2024-06-28 00:55:51 +02:00
8c566ad46d
Add clearInstance method 2024-06-27 22:27:21 +02:00
0d55b436da
Extend tests
... for Miscellaneous, PlaceholderEngine and PropertyParser
2024-06-27 22:27:11 +02:00
170f5fd372
Remove EngineTest 2024-06-27 22:26:52 +02:00
919edd3375
Rename Miscellaneous#getMapValue -> getMapValues 2024-06-27 21:14:49 +02:00
8c0ebacd2b
Fix EngineConfiguration unit test 2024-06-27 21:02:35 +02:00
2b689f8267
Fix a few javadoc issues 2024-06-27 20:43:05 +02:00
62ca80d5a9
Add newlines to copyright settings 2024-06-27 20:39:38 +02:00
ad9700987e
Add copyright Intellij IDEA settings 2024-06-27 20:39:20 +02:00
9cb5cbffd3
Update comments and javadoc 2024-06-27 20:29:08 +02:00
f39223b4da
Add READMEs to all subsystems 2024-06-27 20:25:32 +02:00
72a13adbcd
Add PropertyParser#getTristate 2024-06-27 20:10:15 +02:00
74d8978f20
Beautify Miscellaneous#getMapValue 2024-06-27 20:09:57 +02:00
5c1fba4ef6
JvmInformation#getJavaVersion may now crash 2024-06-27 20:09:43 +02:00
cc3cd52d22
Move interfaces, enums & classes around again 2024-06-27 20:08:34 +02:00
9202eaeb4a
Update javadoc for base.classes.helpers package 2024-06-27 19:28:29 +02:00
d9bf941cb9
Add Tristate type 2024-06-27 19:27:07 +02:00
79dbc65f63
Add log rules 2024-06-27 19:26:37 +02:00
9e4cfee89a
Fix codepart identification for logger instances 2024-06-27 19:26:25 +02:00
d40ba11266
Decrease default polling speed from 25 to 5 2024-06-27 19:25:53 +02:00
c812359e83
Clean up base.classes package 2024-06-27 19:25:28 +02:00
9de7f0f51d
Add ability to catch exceptions 2024-06-25 02:08:38 +02:00
41438dd6ea
Add missing maven-publish gradle plugin 2024-06-25 02:08:26 +02:00
994b71dbc4
Update javadocs overview pages 2024-06-25 02:08:07 +02:00
b45a8c9f9b
Update some comments and log messages 2024-06-25 02:07:46 +02:00
f31b083690
Update slf4j-compat subsystem dependencies 2024-06-23 12:45:57 +02:00
4ab050bf70
Add lombok plugin back to root build.gradle 2024-06-16 21:06:51 +02:00
9bc1882de3
Add missing javadoc 2024-06-16 21:06:32 +02:00
ac3e1e1224
Fix out of order log messages 2024-06-16 15:53:26 +02:00
62b4718ef4
Windows! Not really working! 2024-06-16 15:53:07 +02:00
9828409bb7
Add documentation 2024-06-16 15:52:33 +02:00
a26c8035c1
Add Engine#shuttingDown field 2024-06-16 15:52:14 +02:00
129537a60c
Add maven-publish plugin
Publishes to mvn.staropensource.de.
2024-06-16 13:36:06 +02:00
bb1831b900
Remove unused dependencies in root build.gradle 2024-06-16 13:35:29 +02:00
893f591d11
Add dist/ directory 2024-06-16 13:34:56 +02:00
426 changed files with 45082 additions and 7568 deletions

View file

@ -0,0 +1,117 @@
name: "⚠️ Bug report"
about: "Report a bug in the engine."
title: "bug: "
labels:
- "Bug/New"
body:
- type: "markdown"
id: "text-introduction"
attributes:
value: |
Hey there! Thank you for taking the time to report a bug to us. \
This means a lot to us, as that's the only way to get better... and many people don't file bug reports. \
Anyway, please answer the following questions accurately, otherwise we may not be able to diagnose the issue. \
\
**Please check if the same bug report already exists. If so, participate in that one instead. If another issue is similar, make sure to mention the related issues.** \
**Please don't censor anything *except* sensitive information. You don't need to be embarrased about your username. You censor your bug report, we censor our answers.**
- type: "textarea"
id: "bug-description"
attributes:
label: "Bug description"
description: "Explain what the bug is about. Include as many details as possible."
placeholder: "My cat spontaneously explodes when I try to download from `https://yourdick.zip`."
validations:
required: true
- type: "textarea"
id: "bug-log"
attributes:
label: "Bug log"
description: |
Please insert the ENTIRE log output here, so we can understand the problem at hand. \
You must give us `DIAGNOSTIC` level logs (pass `-Dsosengine.base.loggerLevel=diagnostic` to the JVM) with the default log template.
**This field can be left empty if the bug does not involve/require log output.**
placeholder: "Your log file here..."
value: |
```plain
Your log file here...
```
validations:
required: false
- type: "textarea"
id: "bug-snippet"
attributes:
label: "Bug snippet"
description: |
Please insert a snippet of the (application and/or engine) code which you think is causing the issue.
**This field can be left empty if you intend on supplying a reproduction project.**
value: |
```java
Your code snippet here...
```
validations:
required: false
- type: "textarea"
id: "bug-reproduce"
attributes:
label: "Bug reproduction guide"
description: |
Explain how we can reproduce this bug as easy as possible, step by step.
**This field can be left empty if the bug does not involve/require a reproduction guide.**
placeholder: |
1. Pass "-Dsosengine.base.optimizeLogging=false" to the JVM
2. Override logging implementation
2. Initialize engine
4. The nearest cat should explode in the next few seconds
validations:
required: false
- type: "input"
id: "bug-reproduce-project"
attributes:
label: "Bug reproduction project"
description: |
Drop a link to some repository or zip file of an example project showcasing the bug.
**Only supply a repro project if the bug is a bit more advanced, needs specific timing, etc..** \
**Also please make sure that the bug actually occurs in the example project!**"
placeholder: "https://your.reproduction.project/download/url/here"
validations:
required: false
- type: "input"
id: "engine-version"
attributes:
label: "Full engine version"
description: |
Input the full engine version here.
Simply copy the `Initialized sos!engine v<version> (commit <commit>-<branch>, dirty <dirty>) in <inittime>ms` message here.
placeholder: "Example: sos!engine v1-alpha4 (commit 05b9644eba5263809b6655dabb92669523a95805-develop, dirty true)"
validations:
required: true
- type: "dropdown"
id: "jvm-java"
attributes:
label: "Java version"
description: "Which Java version is your application compiled against?"
options:
- "20 and lower"
- "21"
- "22"
- "23"
validations:
required: true
- type: "input"
id: "os"
attributes:
label: "Operating system"
description: "Name the operating system, version (if applicable) and CPU architecture the error occurs on. This may be some Linux distribution, Android or Windoze on `amd64`/`aarch64`/`ppc64`/etc.."
placeholder: "Example: Debian trixie (amd64)"
validations:
required: true
- type: "markdown"
id: "text-tysm"
attributes:
value: |
Thank you for filling out this bug report.
Please check your answers for *mistaeks* or sensitive information before sending this report.

View file

@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: "📚 Documentation"
about: "Visit the documentation. Maybe you just skipped something important or just haven't found the page you're looking for yet."
url: "https://engine.staropensource.de"

View file

@ -0,0 +1,20 @@
name: "👾 Empty"
about: "A clean slate. Only use this one for specific, special cases."
title: "empty: "
labels:
- "Empty"
body:
- type: "markdown"
id: "introduction"
attributes:
value: |
This issue template is meant for specific, special cases, where an empty issue template may be wanted.
You should *NOT* use this template to write bug reports, feature or help requests.
This issue template should ideally only be used by the repository maintainer.
- type: "textarea"
id: "content"
attributes:
label: "Issue content"
description: "Write your issue content here."
validations:
required: true

View file

@ -0,0 +1,61 @@
name: "✨ Feature Request"
about: "Request a feature to be implemented in the engine."
title: "feat: "
labels:
- "FeatureRequest/New"
body:
- type: "markdown"
id: "text-introduction"
attributes:
value: |
Hey there! Thank you for taking the time to request a feature to us. \
Before filling any of this out, please think for one minute if the feature is really important and necessary enough to implement in the engine. If you're unsure, continue. \
Please answer the following questions accurately, or we may not be able to implement the feature as you requested it. \
\
**Please check if the same feature request already exists. If so, participate in that one instead. If another issue is similar, make sure to mention the related issues.** \
**Please don't censor anything *except* sensitive information. You don't need to be embarrased about your username. You censor your bug report, we censor our answers.** \
**Submitting a feature request will *not* gurantee it's inclusion into the engine. By submitting a feature request, you are at the grace of the community to pick up your suggestion.**
- type: "textarea"
id: "feature-description"
attributes:
label: "Feature description"
description: "Explain *what* you want added. Include as many details as possible."
placeholder: |
Example:
I want to do X in my project, which would simplify doing Y.
validations:
required: true
- type: "textarea"
id: "feature-implementation"
attributes:
label: "Feature implementation"
description: |
Explain *how* you want it added. Include as many details as possible.
Also explore alternative ways of implementing the feature in the engine (if possible).
placeholder: |
Example:
I would propose to <some description on how to implement your feature>.
I've also thought on simply <some other description on how to implement your feature>.
validations:
required: true
- type: "textarea"
id: "feature-alternatives"
attributes:
label: "Feature alternatives"
description: |
Explain how to implement the feature without building it into the engine directly. Include as many details as possible.
**Leave empty if it can't simply be solved by creating a subsystem.**
placeholder: |
Example:
I've considered writing a subsystem for this feature.
Otherwise it would be possible to use <link to some project> with some configuration.
I've also considered using the normal way of doing it by <how to do it using the normal way>.
validations:
required: false
- type: "markdown"
id: "text-tysm"
attributes:
value: |
Thank you for filling out this feature request form.
Please check your answers for *mistaeks* before sending this report.

View file

@ -0,0 +1,89 @@
name: "💬 Help"
about: "Request help."
title: "help: "
labels:
- "Help/Wanted"
body:
- type: "markdown"
id: "text-introduction"
attributes:
value: |
Hey there! Seems like you have some kind of issue with the StarOpenSource Engine. \
Please answer the following questions accurately, otherwise we may not be able to help you. \
\
**Please check if the same help request already exists. If so, participate in that one instead. If another issue is similar, make sure to mention the related issues.** \
**Please don't censor anything *except* sensitive information. You don't need to be embarrased about your username. You censor your stuff, we censor our answers.**
- type: "textarea"
id: "help-description"
attributes:
label: "Problem description"
description: "Explain what your problem is as detailed as possible."
placeholder: "How can I create a custom LoggerImplementation implementation?"
validations:
required: true
- type: "textarea"
id: "help-log"
attributes:
label: "Log"
description: |
Please insert the ENTIRE log output here, so we can understand the problem at hand. \
You must give us `DIAGNOSTIC` level logs (pass `-Dsosengine.base.loggerLevel=diagnostic` to the JVM) with the default log template.
*This field can be left empty if the problem you are faciing does not involve/require log output.**
placeholder: "Your log file here..."
value: |
```plain
Your log file here...
```
validations:
required: false
- type: "textarea"
id: "help-snippet"
attributes:
label: "Code snippet"
description: |
Please insert a snippet of the application code which you think is causing the issue.
**This field can be left empty if the problem you are faciing does not involve/require code.**
value: |
```java
Your code snippet here...
```
validations:
required: false
- type: "input"
id: "engine-version"
attributes:
label: "Full engine version"
description: |
Input the full engine version here.
Simply copy the `Initialized sos!engine v<version> (commit <commit>-<branch>, dirty <dirty>) in <inittime>ms` message here.
placeholder: "Example: sos!engine v1-alpha4 (commit 05b9644eba5263809b6655dabb92669523a95805-develop, dirty true)"
validations:
required: true
- type: "dropdown"
id: "jvm-java"
attributes:
label: "Java version"
description: "Which Java version is your application compiled against?"
options:
- "20 and lower"
- "21"
- "22"
- "23"
validations:
required: true
- type: "input"
id: "os"
attributes:
label: "Operating system"
description: "Name the operating system, version (if applicable) and CPU architecture the error occurs on. This may be some Linux distribution, Android or Windoze on `amd64`/`aarch64`/`ppc64`/etc.."
placeholder: "Example: Debian trixie (amd64)"
validations:
required: true
- type: "markdown"
id: "text-tysm"
attributes:
value: |
Thank you for filling out this help form.
Please check your answers for *mistaeks* or sensitive information before sending this help request.

View file

@ -0,0 +1,12 @@
---
name: 'Pull Request'
about: 'Submit a pull request.'
title: 'new: '
ref: 'develop'
labels:
- 'PRStatus/Open'
- 'PR/New'
---
<!--
Please list your changes here.
-->

View file

@ -0,0 +1,125 @@
name: build-and-test
on:
- pull_request
- push
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 }}-

View file

@ -0,0 +1,60 @@
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 }}-

15
.gitattributes vendored Normal file
View file

@ -0,0 +1,15 @@
# Documentation
*.md linguist-documentation
docs/* linguist-documentation
# Licensing information
COPYING linguist-documentation
LICENSE linguist-documentation
# Javadoc
*.html linguist-documentation
*.css linguist-documentation
# Gradle configuration
*.properties linguist-configuration
*.gradle linguist-configuration

2
.gitignore vendored
View file

@ -1,6 +1,7 @@
### Gradle ###
.gradle
build/
run/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
@ -33,7 +34,6 @@ bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

View file

@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="sos!engine" />
</component>

View file

@ -0,0 +1,7 @@
<component name="CopyrightManager">
<copyright>
<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 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="myName" value="sos!engine" />
</copyright>
</component>

View file

@ -1,6 +1,28 @@
<?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" />
@ -45,7 +67,29 @@
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
<configuration name="Generate Javadoc" type="GradleRunConfiguration" factoryName="Gradle">
<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$" />
@ -57,7 +101,28 @@
<option name="taskNames">
<list>
<option value="javadoc" />
<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="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" />
@ -79,8 +144,7 @@
</option>
<option name="taskNames">
<list>
<option value="shadowJar" />
<option value="testapp:run" />
<option value="testapp:runShadow" />
</list>
</option>
<option name="vmOptions" />
@ -114,11 +178,14 @@
<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.Run tests" />
<item itemvalue="Gradle.Generate Javadoc" />
<item itemvalue="Gradle.Clean" />
<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>

View file

@ -1,35 +1,44 @@
# StarOpenSource Engine
The StarOpenSource engine (or sos!engine for short) is a modular, extensible and easy to use Java game and application engine.
The StarOpenSource Engine (or sos!engine for short) is a modular, extensible and easy to use Java game and application engine.
## 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.
## Index
- [About](#about)
- [About the engine](#about-the-engine)
- [About the repository](#about-the-repository)
- [... 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)
- [Read this before creating a pull request](#read-this-before-creating-a-pull-request)
- [Pull request guidelines](#pull-request-guidelines)
- [Making your first contribution](#making-your-first-contribution)
- [Gradle properties](#gradle-properties)
## About
### About the engine
The sos!engine is a modular and extensible framework for building applications and games, written in the Java programming language.
The engine consists of various subsystems, each separate and responsible for only one thing. The engine also houses various useful utilities and classes making development fun, and all that while being lightweight.
### About the repository
The sos!engine repository is a monorepo, consisting of [the core engine](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/base), official subsystems and [their documentation](https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/docs).
### ... 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
- modular
- small & lightweight
- fast
These are in no particular order.
- configurable
- [do one thing and do it well](https://en.wikipedia.org/wiki/Unix_philosophy) (subsystems concept)
- have as few runtime dependencies as possible (note: we will cut down on some of them during development)
- fast
- few runtime dependencies (note: we will cut down on some of them during development)
- modular & extensible
- small & lightweight
## Documentation
The official documentation for the StarOpenSource Engine is not yet available, but is planned.
You can however [visit the Javadocs](https://jd.engine.staropensource.de).
You can view the engine documentation at [engine.staropensource.de](https://engine.staropensource.de). It provides information, guides and tutorials about the core engine and subsystems.
If you want the API reference, you can [visit the Javadoc](https://jd.engine.staropensource.de) for the engine and it's subsystems.
## Contributing
### Requirements
@ -37,15 +46,44 @@ You need the following things to be able to contribute code to the StarOpenSourc
- knowledge of Java
- knowledge about the internals of engine
### What IDE to use?
We use and recommend 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.
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.
### Read this before creating a pull request
Before creating a pull request, make sure you've
- created tests for the functionality you added, changed or removed (if applicable),
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 (probably) until v1-alpha0
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

112
ansi/build.gradle Normal file
View file

@ -0,0 +1,112 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Plugins
plugins {
id("java")
id("io.freefair.lombok") version("${pluginLombok}")
id("maven-publish")
}
// Dependencies
dependencies {
// Lombok
compileOnly("org.projectlombok:lombok:${dependencyLombok}")
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
// JetBrains Annotations
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// Jansi
implementation("org.fusesource.jansi:jansi:${dependencyJansi}")
// Project
implementation(project(":base"))
}
// Javadoc configuration
javadoc {
outputs.upToDateWhen { false } // Force task execution
dependsOn(delombok) // Make sure the source is delomboked first
javadoc {
setClasspath(files(project.sourceSets.main.compileClasspath)) // Include dependencies
options {
if (new File(projectDir, "src/main/javadoc/theme.css").exists())
stylesheetFile = new File(projectDir, "src/main/javadoc/theme.css") // Theming is cool :3
setMemberLevel(JavadocMemberLevel.PUBLIC) // Only display public stuff
setOverview("src/main/javadoc/overview.html") // We want a custom overview page to greet the visitor
setLocale("en_US") //
addStringOption("Xwerror", "-quiet") // Fail build on warning
setJFlags([
"-Duser.language=en_US" // See above
])
}
}
}
// Include javadoc and source jar during publishing
java {
withJavadocJar()
withSourcesJar()
}
// Build publishing configuration
// Note: You can safely ignore any errors or warnings thrown by your IDE here
publishing {
repositories {
maven {
name = "staropensource"
url = uri("https://mvn.staropensource.de/engine")
credentials(org.gradle.api.credentials.PasswordCredentials)
authentication {
//noinspection GroovyAssignabilityCheck
basic (BasicAuthentication)
}
}
}
publications {
//noinspection GroovyAssignabilityCheck
maven (MavenPublication) {
groupId = group
artifactId = project.getName()
version = version
//noinspection GroovyAssignabilityCheck
from components.java
}
}
}
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
source.renameTo(target)
}
delombok.doLast {
File target = file("${project.projectDir}/src/main/java/module-info.java")
File source = file("${project.projectDir}/src/main/module-info.java")
target.delete()
source.renameTo(target)
}

View file

View file

@ -0,0 +1,61 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.ansi;
import de.staropensource.engine.base.EngineConfiguration;
import de.staropensource.engine.base.implementable.LoggingAdapter;
import de.staropensource.engine.base.logging.Logger;
import de.staropensource.engine.base.type.logging.LogLevel;
import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.AnsiConsole;
import org.jetbrains.annotations.NotNull;
/**
* Prints colored log output using the Jansi library.
*
* @see Logger
* @see LoggingAdapter
* @since v1-alpha2
*/
public class AnsiLoggingAdapter implements LoggingAdapter {
/**
* Creates and initializes an instance of this class.
*
* @since v1-alpha2
*/
public AnsiLoggingAdapter() {}
/** {@inheritDoc} */
@Override
@SuppressWarnings({ "resource" }) // Using try-with-resources will cause issues here
public void print(@NotNull LogLevel level, @NotNull StackTraceElement issuer, @NotNull String message, @NotNull String format) {
// Convert to Ansi
Ansi output = new AnsiShortcodeParser(format, true).getAnsi();
// Print message
if (level == LogLevel.ERROR || level == LogLevel.CRASH)
if (EngineConfiguration.getInstance().isLogForceStandardOutput())
AnsiConsole.out().println(output);
else
AnsiConsole.err().println(output);
else
AnsiConsole.out().println(output);
}
}

View file

@ -0,0 +1,107 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.ansi;
import de.staropensource.engine.base.implementable.ShortcodeParser;
import de.staropensource.engine.base.exception.ParserException;
import org.fusesource.jansi.Ansi;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
/**
* Implementation of the {@link ShortcodeParser} class
* with ANSI support using the Jansi library.
*
* @see ShortcodeParser
* @since v1-alpha8
*/
public final class AnsiShortcodeParser extends ShortcodeParser {
/**
* Creates and initializes an instance of this class.
*
* @param string string to convert
* @param ignoreInvalidEscapes will ignore invalid escapes and print treat them like regular text
* @throws ParserException when parsing failed
* @since v1-alpha2
*/
public AnsiShortcodeParser(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
super(string, ignoreInvalidEscapes);
}
/**
* Returns the parsed string as an {@link Ansi} sequence.
*
* @return {@link Ansi} sequence
* @since v1-alpha2
*/
public @NotNull Ansi getAnsi() {
Ansi ansi = Ansi.ansi();
Set<@NotNull String> status = new HashSet<>();
for (String component : components)
if (component.equals("RESET")) {
ansi.a(Ansi.Attribute.RESET);
status.clear();
} else if (component.startsWith("TEXT:"))
ansi.a(component.substring(5));
else if (component.startsWith("COLOR:"))
if (component.startsWith("COLOR:FOREGROUND:"))
ansi.fg(Ansi.Color.valueOf(component.substring(17)));
else if (component.startsWith("COLOR:BACKGROUND:"))
ansi.bg(Ansi.Color.valueOf(component.substring(17)));
else if (component.startsWith("ATTRIBUTE:"))
if (component.startsWith("ATTRIBUTE:BLINK")) {
if (status.contains("ATTRIBUTE:BLINK"))
continue;
ansi.a(Ansi.Attribute.BLINK_SLOW);
status.add("ATTRIBUTE:BLINK");
} else if (component.startsWith("ATTRIBUTE:BOLD")) {
if (status.contains("ATTRIBUTE:BOLD"))
continue;
ansi.a(Ansi.Attribute.INTENSITY_BOLD);
status.add("ATTRIBUTE:BOLD");
} else if (component.startsWith("ATTRIBUTE:ITALIC")) {
if (status.contains("ATTRIBUTE:ITALIC"))
continue;
ansi.a(Ansi.Attribute.ITALIC);
status.add("ATTRIBUTE:ITALIC");
} else if (component.startsWith("ATTRIBUTE:STRIKETHROUGH")) {
if (status.contains("ATTRIBUTE:STRIKETHROUGH"))
continue;
ansi.a(Ansi.Attribute.STRIKETHROUGH_ON);
status.add("ATTRIBUTE:STRIKETHROUGH");
} else if (component.startsWith("ATTRIBUTE:UNDERLINE")) {
if (status.contains("ATTRIBUTE:UNDERLINE"))
continue;
ansi.a(Ansi.Attribute.UNDERLINE);
status.add("ATTRIBUTE:UNDERLINE");
}
return ansi;
}
}

View file

@ -0,0 +1,86 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.ansi;
import de.staropensource.engine.base.annotation.EngineSubsystem;
import de.staropensource.engine.base.implementable.SubsystemClass;
import de.staropensource.engine.base.utility.information.EngineInformation;
import de.staropensource.engine.base.implementation.versioning.StarOpenSourceVersioningSystem;
import de.staropensource.engine.base.logging.Logger;
import de.staropensource.engine.base.type.DependencyVector;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
/**
* Main class of the ANSI Compatibility subsystem.
*
* @since v1-alpha2
*/
@EngineSubsystem
@SuppressWarnings({ "JavadocDeclaration" })
public final class AnsiSubsystem extends SubsystemClass {
/**
* Contains the class instance.
*
* @since v1-alpha2
* -- GETTER --
* Returns the class instance.
*
* @return class instance unless the subsystem is uninitialized
* @since v1-alpha2
*/
@Getter
private static AnsiSubsystem instance = null;
/**
* Initializes this subsystem.
*
* @since v1-alpha2
*/
public AnsiSubsystem() {
// Check if subsystem has already initialized
if (instance == null)
instance = this;
else
Logger.crash("Only one instance of this class is allowed, use getInstance() instead of creating a new instance");
}
/** {@inheritDoc} */
@Override
public @NotNull String getName() {
return "ansi";
}
/** {@inheritDoc} */
@Override
public void initializeSubsystem() {
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,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -18,6 +18,6 @@
*/
/**
* Provides various classes that can be used to retrieve information about the engine or JVM.
* Contains the ANSI subsystem code.
*/
package de.staropensource.sosengine.base.data.info;
package de.staropensource.engine.ansi;

View file

@ -0,0 +1,23 @@
/**
* The ANSI subsystem, allowing the engine to
* use ANSI escape codes using the Jansi library.
*
* @since v1-alpha2
*/
module sosengine.ansi {
// Dependencies
// -> Java
requires transitive java.management;
// -> Engine
requires transitive sosengine.base;
// -> Libraries
requires transitive static lombok;
requires transitive org.jetbrains.annotations;
requires org.fusesource.jansi;
// API access
exports de.staropensource.engine.ansi;
// Reflection access
opens de.staropensource.engine.ansi;
}

View file

@ -0,0 +1,23 @@
<!--
~ STAROPENSOURCE ENGINE SOURCE FILE
~ Copyright (c) 2024 The StarOpenSource Engine Authors
~ Licensed under the GNU Affero General Public License v3
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as
~ published by the Free Software Foundation, either version 3 of the
~ License, or (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Affero General Public License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<body>
<p>Welcome to the sos!engine API documentation!<br/>
You are currently in the documentation for the <b>ansi</b> subsystem, allowing ANSI escape sequences to be used using Jansi.</p>
</body>

View file

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

1
base/.gitignore vendored Normal file
View file

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

2
base/README.md Normal file
View file

@ -0,0 +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.

View file

@ -1,49 +1,183 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import java.nio.file.Files
// Plugins
plugins {
id 'java'
id 'io.freefair.lombok' version "${pluginLombok}"
id("java")
id("io.freefair.lombok") version("${pluginLombok}")
id("com.gorylenko.gradle-git-properties") version("${pluginGitProperties}")
id("maven-publish")
}
// Dependencies
dependencies {
// -> Runtime <-
// -> Runtime
// Lombok
compileOnly 'org.projectlombok:lombok:' + project.dependencyLombok
annotationProcessor 'org.projectlombok:lombok:' + project.dependencyLombok
compileOnly("org.projectlombok:lombok:${dependencyLombok}")
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
// JetBrains Annotations
compileOnly 'org.jetbrains:annotations:' + project.dependencyJetbrainsAnnotations
// ANSI support
implementation 'org.fusesource.jansi:jansi:' + project.dependencyJansi
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// Reflections
implementation 'org.reflections:reflections:' + project.dependencyReflections
implementation("org.reflections:reflections:${dependencyReflections}")
// -> Testing <-
// -> Testing
// Jetbrains Annotations
testCompileOnly 'org.jetbrains:annotations:' + project.dependencyJetbrainsAnnotations
testCompileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// JUnit
testImplementation platform('org.junit:junit-bom:5.' + project.dependencyJunit)
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation(platform("org.junit:junit-bom:${dependencyJunit}"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// jOOR
testImplementation 'org.jooq:joor:' + project.dependencyJoor
// Project
testImplementation(project(":testing"))
}
javadoc.options {
setMemberLevel(JavadocMemberLevel.PUBLIC)
setOverview("src/main/javadoc/overview.html")
setLocale("en_US")
setJFlags([
// Force Javadoc to use English translations
"-Duser.language=en_US"
])
}
// Javadoc configuration
javadoc {
outputs.upToDateWhen { false } // Force task execution
dependsOn(delombok) // Make sure the source is delomboked first
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
javadoc {
setClasspath(files(project.sourceSets.main.compileClasspath)) // Include dependencies
options {
if (new File(projectDir, "src/main/javadoc/theme.css").exists())
stylesheetFile = new File(projectDir, "src/main/javadoc/theme.css") // Theming is cool :3
setMemberLevel(JavadocMemberLevel.PUBLIC) // Only display public stuff
setOverview("src/main/javadoc/overview.html") // We want a custom overview page to greet the visitor
setLocale("en_US") //
addStringOption("Xwerror", "-quiet") // Fail build on warning
setJFlags([
"-Duser.language=en_US" // See above
])
}
}
}
// Unit testing configuration
test {
useJUnitPlatform()
// Pass test configuration to test VMs
Map<String, String> testConfiguration = new HashMap<>();
for (String property : project.properties.keySet())
if (property.startsWith("test."))
testConfiguration.put(property, project.properties.get(property).toString())
systemProperties(testConfiguration)
setMaxParallelForks(project.hasProperty("jobs") ? Integer.parseInt((String) project.property("jobs")) : 8)
setForkEvery(1)
setFailFast(true)
testLogging {
events("passed", "skipped", "failed")
}
}
// Include javadoc and source jar during publishing
java {
withJavadocJar()
withSourcesJar()
}
// Build publishing configuration
// Note: You can safely ignore any errors or warnings thrown by your IDE here
publishing {
repositories {
maven {
name = "staropensource"
url = uri("https://mvn.staropensource.de/engine")
credentials(org.gradle.api.credentials.PasswordCredentials)
authentication {
//noinspection GroovyAssignabilityCheck
basic (BasicAuthentication)
}
}
}
publications {
//noinspection GroovyAssignabilityCheck
maven (MavenPublication) {
groupId = group
artifactId = project.getName()
version = version
//noinspection GroovyAssignabilityCheck
from components.java
}
}
}
// Copy gradle.properties file
// for inclusion in final build
tasks.register("copyGradleProperties") {
doFirst {
File target = file("${project.projectDir}/src/main/resources/sosengine-gradle.properties")
File source = file(project(":").projectDir.getPath() + "/gradle.properties")
target.delete()
Files.copy(source.toPath(), target.toPath())
}
outputs.upToDateWhen({ false }) // Force task execution
}
processResources.dependsOn(copyGradleProperties)
// Git properties configuration
// Allows us to embed git commit information in the engine build
gitProperties {
dotGitDirectory = file("${rootProject.rootDir}/.git")
failOnNoGitDirectory = false // Allow continuing if .git directory is missing for the few who use tarballs
extProperty = "gitProps"
dateFormat = "yyyy-MM-dd'T'HH:mmZ"
dateFormatTimeZone = "UTC"
}
tasks.register("writeGitProperties") { // This task's only purpose is to copy the git.properties from our git properties plugin to the resources directory so it's included in the final build
doLast {
File target = file("${project.projectDir}/src/main/resources/sosengine-git.properties")
File source = file("${project.projectDir}/build/resources/main/git.properties")
target.delete()
source.renameTo(target)
}
outputs.upToDateWhen({ false }) // Force task execution
}
generateGitProperties.outputs.upToDateWhen({ false }) // Force task execution
processResources.dependsOn(writeGitProperties) // Ensure git.properties file is present
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
source.renameTo(target)
}
delombok.doLast {
File target = file("${project.projectDir}/src/main/java/module-info.java")
File source = file("${project.projectDir}/src/main/module-info.java")
target.delete()
source.renameTo(target)
}

View file

@ -0,0 +1,618 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base;
import de.staropensource.engine.base.annotation.EngineSubsystem;
import de.staropensource.engine.base.event.*;
import de.staropensource.engine.base.exception.IllegalAccessException;
import de.staropensource.engine.base.exception.dependency.UnmetDependenciesException;
import de.staropensource.engine.base.implementable.ShutdownHandler;
import de.staropensource.engine.base.implementable.SubsystemClass;
import de.staropensource.engine.base.implementable.helper.EventHelper;
import de.staropensource.engine.base.implementation.versioning.StarOpenSourceVersioningSystem;
import de.staropensource.engine.base.event.InternalEngineShutdownEvent;
import de.staropensource.engine.base.internal.type.DependencySubsystemVector;
import de.staropensource.engine.base.logging.PrintStreamService;
import de.staropensource.engine.base.logging.*;
import de.staropensource.engine.base.logging.backend.async.LoggingQueue;
import de.staropensource.engine.base.logging.backend.async.LoggingThread;
import de.staropensource.engine.base.type.DependencyVector;
import de.staropensource.engine.base.type.EngineState;
import de.staropensource.engine.base.type.immutable.ImmutableLinkedList;
import de.staropensource.engine.base.utility.DependencyResolver;
import de.staropensource.engine.base.utility.FileAccess;
import de.staropensource.engine.base.utility.Miscellaneous;
import de.staropensource.engine.base.utility.PlaceholderEngine;
import de.staropensource.engine.base.utility.information.EngineInformation;
import de.staropensource.engine.base.utility.information.JvmInformation;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Range;
import org.reflections.Reflections;
import org.reflections.scanners.Scanners;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import java.util.*;
/**
* Main class of the sos!engine.
*
* @see EngineConfiguration
* @since v1-alpha0
*/
@SuppressWarnings({ "JavadocDeclaration" })
public final class Engine extends SubsystemClass {
/**
* Contains the class instance.
*
* @since v1-alpha0
* -- GETTER --
* Returns the class instance.
*
* @return class instance unless {@link Engine} is uninitialized
* @since v1-alpha0
*/
@Getter
private static Engine instance = null;
/**
* Contains the thread group of the engine.
*
* @since v1-alpha2
* -- GETTER --
* Returns the thread group of the engine.
*
* @return engine thread group
* @since v1-alpha2
*/
@Getter
private static final ThreadGroup threadGroup = new ThreadGroup("sos!engine");
/**
* Contains the engine state.
*
* @since v1-alpha2
* -- GETTER --
* Returns the engine state.
*
* @return shutdown state
* @since v1-alpha2
*/
@Getter
private @NotNull EngineState state;
/**
* Contains a list of all registered subsystems.
* The list is sorted after initialization order.
*
* @since v1-alpha1
* -- GETTER --
* Returns a list of all registered subsystems.
* The list is sorted after initialization order.
*
* @return subsystem list
* @since v1-alpha1
*/
@Getter
private @NotNull 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
Logger.warn("Engine successfully shut down using shutdown hook. PLEASE USE Engine#shutdown() INSTEAD OF System#exit() or Runtime#exit()!");
});
/**
* Initializes the StarOpenSource Engine.
*
* @throws RuntimeException for all exceptions thrown by this constructor
* @since v1-alpha8
*/
private Engine() throws RuntimeException {
try {
instance = this;
state = EngineState.EARLY_STARTUP;
// For measuring the initialization time
long initTimeEarly = System.currentTimeMillis();
long initTimeLate = initTimeEarly;
// Check for incompatible JVM implementations
checkJvmIncompatibilities();
// Display that the engine is initializing
Logger.verb("Initializing engine");
// Start the logging thread
Logger.diag("Starting logging infrastructure");
LoggingThread.startThread(false);
PrintStreamService.initializeStreams();
// Initialize EngineInternals
Logger.diag("Initializing EngineInternals class");
new EngineInternals();
// Load engine configuration
Logger.diag("Loading engine configuration");
new EngineConfiguration();
EngineConfiguration.getInstance().loadConfiguration();
// Load engine build information
Logger.diag("Loading engine build information");
EngineInformation.update();
// Check for reflective classpath scanning compatibility
checkReflectiveClasspathScanningCompatibility();
// Check for Java version incompatibilities
checkJavaVersion();
// Initialize PlaceholderEngine
Logger.diag("Initializing PlaceholderEngine");
PlaceholderEngine.initialize();
// Initialize static FileAccess instances
Logger.diag("Initializing static FileAccess instances");
FileAccess.initializeInstances();
// Install the safety shutdown hook
Logger.diag("Installing safety shutdown hook");
EngineInternals.getInstance().installSafetyShutdownHook(true);
// Cache events
Logger.diag("Caching event listeners");
cacheEvents();
// Complete early initialization stage
Logger.verb("Completing early initialization stage");
state = EngineState.STARTUP;
initTimeEarly = System.currentTimeMillis() - initTimeEarly;
// Perform automatic subsystem initialization
if (EngineConfiguration.getInstance().isInitialPerformSubsystemInitialization()) {
// Collect all subsystems
Logger.diag("Collecting subsystems");
collectSubsystems();
// Initialize subsystems
try {
initializeSubsystems();
} catch (Exception exception) {
Logger.error("Subsystem dependency resolution failed");
}
}
// Complete late initialization stage
Logger.verb("Completing late initialization stage");
state = EngineState.RUNNING;
initTimeLate = System.currentTimeMillis() - initTimeLate;
// Print welcome message
Logger.info(
"""
Welcome to the StarOpenSource Engine "%engine_version_codename%" %engine_version%!
Running commit %engine_git_commit_id_long% (dirty %engine_git_dirty%).
Initialization took %init_time_total%ms (early %init_time_early%ms, late %init_time_late%ms).
Copyright (c) 2024 The StarOpenSource Engine Authors
Licensed under the GNU Affero General Public License v3"""
.replace("%init_time_total%", String.valueOf(initTimeEarly + initTimeLate))
.replace("%init_time_early%", String.valueOf(initTimeEarly))
.replace("%init_time_late%", String.valueOf(initTimeLate))
);
} catch (Exception exception) {
throw new RuntimeException(exception);
}
}
/**
* Initializes the StarOpenSource
* Engine, if it isn't already.
*
* @throws IllegalStateException when running in an incompatible environment
* @throws RuntimeException on engine initialization failure
* @since v1-alpha6
*/
public static void initialize() throws RuntimeException {
try {
if (instance == null)
new Engine();
} catch (RuntimeException exception) {
Logger.error("Engine initialization failed");
Logger.error(Miscellaneous.getStackTraceHeader(exception.getCause()));
for (String line : Miscellaneous.getStackTraceAsString(exception.getCause(), true).split("\n"))
Logger.error(line);
throw new RuntimeException("Engine initialization failed", exception.getCause());
}
}
/**
* Checks if the running JVM implementation is not supported by the engine.
*
* @since v1-alpha8
*/
private void checkJvmIncompatibilities() {
if (System.getProperties().getProperty("sosengine.base.allowUnsupportedJVMInitialization", "false").equals("true")) {
Logger.warn("Skipping JVM implementation incompatibilities check");
return;
}
// Substrate VM (GraalVM Community)
if (JvmInformation.getImplementationName().equals("Substrate VM") && JvmInformation.getImplementationVendor().equals("GraalVM Community")) {
Logger.error("##############################################################################################");
Logger.error("## Running in Substrate VM, which is the name of the JVM used by GraalVM native-image. ##");
Logger.error("## The StarOpenSource Engine does not support native-image as using reflection in a certain ##");
Logger.error("## way seems to cause the Substrate JVM to crash. Workarounds have failed. ##");
Logger.error("## This has already been noted in issue #3, which you can view here: ##");
Logger.error("## https://git.staropensource.de/StarOpenSource/Engine/issues/3 ##");
Logger.error("## ##");
Logger.error("## While this is sad, we unfortunately can't do anything against it unless we introduce ##");
Logger.error("## annoying and stupid changes into the engine, which we don't want to do. ##");
Logger.error("## ##");
Logger.error("## We're truly sorry for this inconvenience. The sos!engine will now terminate. ##");
Logger.error("##############################################################################################");
Runtime.getRuntime().exit(255);
}
}
/**
* Checks if reflective classpath scanning is supported.
*
* @since v1-alpha8
*/
private void checkReflectiveClasspathScanningCompatibility() {
// Check if reflective classpath scanning is supported
if (System.getProperties().getProperty("sosengine.base.considerEnvironmentUnfriendlyToClasspathScanning", "false").equals("true")) {
Logger.warn("Running in an classpath scanning-unfriendly environment, disabling classpath scanning support.");
Logger.warn("If shit doesn't work and is expected to be discovered by annotations, you'll need to");
Logger.warn("either register it first or have to update some engine configuration setting.");
Logger.warn("Please consult sos!engine's documentation for more information about this issue.");
EngineInternals.getInstance().overrideReflectiveClasspathScanning(false);
}
}
/**
* Checks and warns if the Java version of the
* running JVM is higher than the engine supports.
*
* @since v1-alpha8
*/
private void checkJavaVersion() {
if (JvmInformation.getJavaVersion() > EngineInformation.getJavaSource())
Logger.warn("The StarOpenSource Engine is running on an untested Java version.\nThings may not work as expected or features which can improve performance, stability, compatibility or ease of use may be missing.\nIf you encounter issues, try running a JVM implementing Java " + EngineInformation.getJavaSource());
}
/**
* Caches all base engine events.
*
* @since v1-alpha0
*/
private void cacheEvents() {
EventHelper.cacheEvent(EngineCrashEvent.class);
EventHelper.cacheEvent(EngineShutdownEvent.class);
EventHelper.cacheEvent(EngineSoftCrashEvent.class);
EventHelper.cacheEvent(InternalEngineShutdownEvent.class);
EventHelper.cacheEvent(LogEvent.class);
EventHelper.cacheEvent(ThrowableCatchEvent.class);
}
/**
* Collects all subsystems by their {@link EngineSubsystem} annotation.
*
* @since v1-alpha1
*/
private void collectSubsystems() {
ArrayList<@NotNull DependencySubsystemVector> subsystemsMutable = new ArrayList<>();
Object initializedClassRaw;
SubsystemClass initializedClass;
// Check and initialize all classes, get dependency vector and check version, then add to 'subsystemsMutable'
for (Class<?> clazz : getRawSubsystemClasses())
try {
// Create new instance
initializedClassRaw = clazz.getDeclaredConstructor().newInstance();
initializedClass = null;
// Check if class implements SubsystemMainClass
if (initializedClassRaw instanceof SubsystemClass)
initializedClass = (SubsystemClass) initializedClassRaw;
else
Logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Does not implement " + SubsystemClass.class.getName());
//noinspection DataFlowIssue // the crash call will prevent a NullPointerException
subsystemsMutable.add(new DependencySubsystemVector(initializedClass.getDependencyVector(), initializedClass));
} catch (Exception exception) {
if (exception.getClass() == IllegalStateException.class && exception.getMessage().startsWith("The version string is invalid: "))
Logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Invalid version string: " + exception.getMessage().replace("The version string is invalid: ", ""));
Logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Method invocation error", exception);
}
// Update 'subsystems'
subsystems = new ImmutableLinkedList<>(subsystemsMutable);
}
/**
* Returns a list of classes which are potentially
* eligible for subsystem initialization.
*
* @return potential subsystem classes
* @since v1-alpha5
*/
private Set<@NotNull Class<?>> getRawSubsystemClasses() {
Set<@NotNull Class<?>> classes = new HashSet<>();
if (EngineInternals.getInstance().getReflectiveClasspathScanning()) {
// Scan entire classpath using the Reflections library
Reflections reflections = new Reflections(
new ConfigurationBuilder()
.setUrls(ClasspathHelper.forJavaClassPath())
.setScanners(Scanners.TypesAnnotated)
);
// Get annotated methods
classes = reflections.getTypesAnnotatedWith(EngineSubsystem.class);
} else
for (String path : EngineConfiguration.getInstance().getInitialIncludeSubsystemClasses())
try {
Logger.diag("Resolving class " + path);
classes.add(Class.forName(path));
} catch (ClassNotFoundException exception) {
Logger.error("Failed loading subsystem class " + path + ": Class not found");
}
return classes;
}
/**
* Initializes all subsystems.
*
* @throws Exception exceptions thrown by the {@link DependencyResolver}
* @since v1-alpha1
*/
private void initializeSubsystems() throws Exception {
DependencyResolver resolver = new DependencyResolver();
LinkedList<DependencySubsystemVector> order = new LinkedList<>();
// Add vectors
resolver.addVector(getDependencyVector());
resolver.addVectors(subsystems);
// Resolve dependencies and get order
Logger.diag("Resolving subsystem dependencies");
try {
for (DependencyVector vector : resolver.resolve().getOrder()) // smol workaround
order.add((DependencySubsystemVector) vector);
} catch (Throwable throwable) {
if (throwable instanceof UnmetDependenciesException exception) {
List<@NotNull String> unmetDependencies = exception.getUnmetDependencies();
StringBuilder list = new StringBuilder();
for (String error : unmetDependencies)
list
.append("\n")
.append("- ")
.append(error);
Logger.crash("Found unresolved dependencies:" + list, throwable);
return;
}
Logger.crash("An error occurred trying to resolve subsystem dependencies: " + throwable.getClass().getName() + (throwable.getMessage() == null ? "" : ": " + throwable.getMessage()));
throw throwable;
}
// Initialize subsystems
Logger.diag("Initializing engine subsystems");
long initTime;
for (DependencySubsystemVector vector : subsystems) {
Logger.diag("Initializing subsystem '" + vector.getSubsystemClass().getName() + "' (" + vector.getSubsystemClass().getClass().getName() + ")");
try {
initTime = Miscellaneous.measureExecutionTime(() -> vector.getSubsystemClass().initializeSubsystem());
} catch (Throwable throwable) {
Logger.crash("An error occurred trying to initialize subsystem " + vector.getSubsystemClass().getName() + " (" + vector.getSubsystemClass().getClass().getName() + "): " + throwable.getClass().getName() + (throwable.getMessage() == null ? "" : ": " + throwable.getMessage()));
throw throwable;
}
Logger.diag("Initialized subsystem '" + vector.getSubsystemClass().getName() + "' (" + vector.getSubsystemClass().getClass().getName() + ") in " + initTime + "ms");
}
// Update 'subsystems'
subsystems = 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) {
if (state == EngineState.UNKNOWN || state == EngineState.SHUTDOWN)
return;
Logger.info("Shutting engine down");
if (state != EngineState.CRASHED)
state = EngineState.SHUTDOWN;
// Make engine single-threaded
Properties properties = new Properties();
properties.setProperty("sosengine.base.optimizeLogging", "false");
properties.setProperty("sosengine.base.optimizeEvents", "false");
EngineConfiguration.getInstance().loadConfiguration(properties);
// Flush log messages
LoggingQueue.flush();
// Disable safety shutdown hook
try {
Runtime.getRuntime().removeShutdownHook(safetyShutdownHook);
} catch (Exception ignored) {}
// Send events
Logger.verb("Notifying classes about shutdown");
new EngineShutdownEvent().callEvent();
Logger.verb("Notifying subsystems about shutdown");
new InternalEngineShutdownEvent().callEvent();
// Delete scheduled files
FileAccess.deleteScheduled();
// Invoke shutdown handler
Logger.verb("Invoking shutdown handler (code " + exitCode + ")");
shutdownHandler.shutdown((short) exitCode);
}
/**
* Shuts the engine down.
*
* @since v1-alpha0
*/
public void shutdown() {
if (instance != null)
instance.shutdown(0);
}
/** {@inheritDoc} */
@Override
public @NotNull String getName() {
return "base";
}
/**
* This method does nothing.
*
* @since v1-alpha1
*/
@Override
public void initializeSubsystem() {}
/** {@inheritDoc} */
@Override
public @NotNull DependencyVector getDependencyVector() {
return new DependencyVector.Builder()
.setIdentifier("engine")
.setVersioningSystem(StarOpenSourceVersioningSystem.class)
.setVersion(EngineInformation.getVersioningString())
.build();
}
/**
* Sets the engine state.
*
* @param state new state
* @throws IllegalAccessException if the caller class is unauthorized
* @since v1-alpha2
*/
public void setState(@NotNull EngineState state) throws IllegalAccessException {
if (!Thread.currentThread().getStackTrace()[2].getClassName().startsWith("de.staropensource.engine.base."))
throw new IllegalAccessException("Only classes inside the \"de.staropensource.engine.base\" package are allowed to call this method.");
this.state = state;
}
/**
* The default shutdown handler, which causes the JVM to exit.
*
* @see ShutdownHandler
* @see System#exit(int)
* @since v1-alpha2
*/
public static final class JvmShutdownHandler implements ShutdownHandler {
/**
* Constructs this class.
*
* @since v1-alpha2
*/
public JvmShutdownHandler() {}
/** {@inheritDoc} */
@Override
public void shutdown(short exitCode) {
// Check if already shutting down
try {
Thread thread = Thread.ofVirtual().unstarted(() -> {});
Runtime.getRuntime().addShutdownHook(thread);
Runtime.getRuntime().removeShutdownHook(thread);
} catch (IllegalStateException exception) {
Logger.warn("Terminating JVM: Already shutting down, skipping");
return;
}
Logger.warn("Terminating JVM");
Runtime.getRuntime().exit(exitCode);
}
}
}

View file

@ -0,0 +1,414 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base;
import de.staropensource.engine.base.implementable.Configuration;
import de.staropensource.engine.base.implementable.ShortcodeParser;
import de.staropensource.engine.base.logging.Logger;
import de.staropensource.engine.base.logging.backend.async.LoggingThread;
import de.staropensource.engine.base.type.EngineState;
import de.staropensource.engine.base.type.logging.LogLevel;
import de.staropensource.engine.base.type.vector.Vec2f;
import de.staropensource.engine.base.type.vector.Vec2i;
import de.staropensource.engine.base.utility.PropertiesReader;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
/**
* Provides the base engine configuration.
* <p>
* This class does not only provide engine settings but is also
* responsible for loading them into memory from {@link Properties} objects.
* <p>
* Now you might ask why we didn't go with the string-based approach.
* The answer is simple: It's a maintenance burden.
* Having various settings strings scattered across many classes will cause
* trouble at some point, which will cause some strings to be undocumented
* or have an inconsistent naming scheme. Containing settings as variables in
* one centralized place mitigates this.
*
* @since v1-alpha0
*/
@Getter
@SuppressWarnings({ "JavadocDeclaration" })
public final class EngineConfiguration extends Configuration {
/**
* Contains the class instance.
*
* @since v1-alpha0
* -- GETTER --
* Returns the class instance.
*
* @return class instance unless {@link Engine} is uninitialized
* @since v1-alpha0
*/
@Getter
private static EngineConfiguration instance;
/**
* Contains prefix properties must begin with.
*
* @since v1-alpha0
* -- GETTER --
* Returns prefix properties must begin with.
*
* @return property group
* @since v1-alpha0
*/
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.
*
* @since v1-alpha0
* -- GETTER --
* Gets the value for {@link #debugEvents}.
*
* @return variable value
* @see #debugEvents
* @since v1-alpha0
*/
private boolean debugEvents;
/**
* 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
* won't be performed, be careful when initializing subsystems manually.
*
* @see Engine
* @since v1-alpha2
* -- GETTER --
* Gets the value for {@link #initialPerformSubsystemInitialization}.
*
* @return variable value
* @see #initialPerformSubsystemInitialization
* @since v1-alpha5
*/
private boolean initialPerformSubsystemInitialization;
/**
* Will try to load the specified classes as subsystems,
* if reflective classpath scanning is disabled.
*
* @since v1-alpha5
* -- GETTER --
* Gets the value for {@link #initialIncludeSubsystemClasses}.
*
* @return variable value
* @see #initialIncludeSubsystemClasses
* @since v1-alpha5
*/
private Set<@NotNull String> initialIncludeSubsystemClasses;
/**
* If enabled, will cause {@link ShortcodeParser} to print
* invalid shortcodes as {@link LogLevel#SILENT_WARNING}s.
*
* @see ShortcodeParser
* @see #logLevel
* @since v1-alpha0
* -- GETTER --
* Gets the value for {@link #errorShortcodeParser}.
*
* @return variable value
* @see #errorShortcodeParser
* @since v1-alpha0
*/
private boolean errorShortcodeParser;
/**
* 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 #logPollingSpeed
* @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;
/**
* Contains which logger levels are allowed
* by setting the minimum logger level.
*
* @see Logger
* @since v1-alpha0
* -- GETTER --
* Gets the value for {@link #logLevel}.
*
* @return variable value
* @see #logLevel
* @since v1-alpha0
*/
private LogLevel logLevel;
/**
* Contains a comma-separated list of optional
* features to add to the final log output.
* <p>
* Available features (in order of appearance):
* <ul>
* <li><code>formatting</code></li>
* <li><code>runtime</code></li>
* <li><code>date</code></li>
* <li><code>time</code></li>
* <li><code>shortIssuerClass</code></li>
* <li><code>moduleName</code></li>
* <li><code>moduleVersion</code> (requires <code>moduleName</code>)</li>
* <li><code>methodName</code></li>
* <li><code>lineNumber</code></li>
* </ul>
*
* @see Logger
* @since v1-alpha8
* -- GETTER --
* Gets the value for {@link #logFeatures}
*
* @return variable value
* @see #logFeatures
* @since v1-alpha8
*/
private Set<@NotNull String> logFeatures;
/**
* 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 #logPollingSpeed}.
*
* @return variable value
* @see #logPollingSpeed
* @since v1-alpha4
*/
private int logPollingSpeed;
/**
* If enabled, will force sos!engine's logging infrastructure 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 the {@code ERROR} and {@code CRASH} log levels.
*
* @since v1-alpha0
* -- GETTER --
* Gets the value for {@link #logForceStandardOutput}.
*
* @return variable value
* @see #logForceStandardOutput
* @since v1-alpha0
*/
private boolean logForceStandardOutput;
/**
* 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.engine.base.types.vectors.}{@link Vec2i}{@code (x=64 y=64)},
* with it however it would just return
* {@link Vec2i}{@code (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-alpha6
*/
EngineConfiguration() {
super();
instance = this;
// Load default configuration
loadDefaultConfiguration();
}
/** {@inheritDoc} */
@Override
protected void matchProperty(@NotNull PropertiesReader parser, @NotNull String property) {
try {
switch (property) {
case "debug" -> debug = parser.getBoolean(group + property);
case "debugEvents" -> debugEvents = parser.getBoolean(group + property);
case "initialPerformSubsystemInitialization" -> initialPerformSubsystemInitialization = parser.getBoolean(group + property);
case "initialIncludeSubsystemClasses" -> {
initialIncludeSubsystemClasses = new HashSet<>();
initialIncludeSubsystemClasses.addAll(Arrays.stream(parser.getString(group + property).split(",")).toList());
}
case "errorShortcodeParser" -> errorShortcodeParser = parser.getBoolean(group + property);
case "optimizeLogging" -> {
optimizeLogging = parser.getBoolean(group + property);
// Start logging thread automatically
if (optimizeLogging && Engine.getInstance().getState() == EngineState.RUNNING) {
LoggingThread.startThread(false);
}
}
case "optimizeEvents" -> optimizeEvents = parser.getBoolean(group + property);
case "logLevel" -> {
try {
logLevel = LogLevel.valueOf(parser.getString(group + property).toUpperCase());
} catch (IllegalArgumentException ignored) {
Logger.error("The log level '" + parser.getString(group + property) + "' is not valid");
}
}
case "logFeatures" -> logFeatures = Set.copyOf(Arrays.stream(parser.getString(group + property).split(",")).toList());
case "logPollingSpeed" -> logPollingSpeed = parser.getInteger(group + property, true);
case "logForceStandardOutput" -> logForceStandardOutput = parser.getBoolean(group + property);
case "hideFullTypePath" -> hideFullTypePath = parser.getBoolean(group + property);
}
} catch (NullPointerException ignored) {}
}
/** {@inheritDoc} */
@Override
protected void processSettings(@NotNull PropertiesReader parser) {
// Disable all debugging switches if 'debug' is disabled
if (!debug) {
debugEvents = false;
}
}
/** {@inheritDoc} */
@Override
public void loadDefaultConfiguration() {
debug = false;
debugEvents = false;
initialPerformSubsystemInitialization = true;
initialIncludeSubsystemClasses = new HashSet<>();
errorShortcodeParser = true;
optimizeLogging = true;
optimizeEvents = true;
logLevel = LogLevel.INFORMATIONAL;
logFeatures = Set.of("formatting", "time", "methodName", "lineNumber");
logPollingSpeed = 5;
logForceStandardOutput = false;
hideFullTypePath = false;
}
/** {@inheritDoc} */
@Override
public @Nullable Object getSetting(@NotNull String setting) {
return switch (setting) {
case "debug" -> debug;
case "debugEvents" -> debugEvents;
case "initialPerformSubsystemInitialization" -> initialPerformSubsystemInitialization;
case "initialIncludeSubsystemClasses" -> initialIncludeSubsystemClasses;
case "errorShortcodeParser" -> errorShortcodeParser;
case "optimizeLogging" -> optimizeLogging;
case "optimizeEvents" -> optimizeEvents;
case "logLevel" -> logLevel;
case "logFeatures" -> logFeatures;
case "logPollingSpeed" -> logPollingSpeed;
case "logForceStandardOutput" -> logForceStandardOutput;
case "hideFullTypePath" -> hideFullTypePath;
default -> null;
};
}
}

View file

@ -0,0 +1,226 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base;
import de.staropensource.engine.base.exception.IllegalAccessException;
import de.staropensource.engine.base.implementable.EventListenerCode;
import de.staropensource.engine.base.implementable.ShutdownHandler;
import de.staropensource.engine.base.implementable.helper.EventHelper;
import de.staropensource.engine.base.logging.Logger;
import de.staropensource.engine.base.type.EventPriority;
import de.staropensource.engine.base.type.InternalAccessArea;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Class which allows access to the internals
* and changing the behaviour of the engine.
*
* @since v1-alpha4
*/
@SuppressWarnings({ "JavadocDeclaration" })
public final class EngineInternals {
/**
* Contains the class instance.
*
* @since v1-alpha4
* -- GETTER --
* Returns the class instance.
*
* @return class instance unless the engine is uninitialized
* @since v1-alpha4
*/
@Getter
private static EngineInternals instance;
/**
* Contains all disabled internal access areas.
*
* @since v1-alpha4
* -- GETTER --
* Returns all disabled internal access areas.
*
* @return restricted areas
* @since v1-alpha4
*/
@Getter
private final @NotNull List<@NotNull InternalAccessArea> restrictedAreas = new ArrayList<>();
/**
* Contains whether the engine should reflectively
* search the classpath for events or other annotations.
* <p>
* If disabled, code will either have to manually call
* registration methods or certain classes have to
* be created in a certain package, depending on the
* use case and application.
*
* @see EventHelper#registerEvent(Class, EventListenerCode)
* @see EventHelper#registerEvent(Class, EventListenerCode, EventPriority)
* @since v1-alpha5
*/
private boolean reflectiveClasspathScanning = true;
/**
* Creates and initializes an instance of this class.
*
* @since v1-alpha6
*/
EngineInternals() {
// Only allow one instance
if (instance == null && Engine.getInstance() != null)
instance = this;
else
Logger.crash("Only one instance of this class is allowed, use getInstance() instead of creating a new instance");
}
/**
* Determines whether access to the specified area is allowed.
*
* @param area internal access area to check
* @throws IllegalAccessException when restricted
* @since v1-alpha4
*/
private void isRestricted(@NotNull InternalAccessArea area) throws IllegalAccessException {
if (restrictedAreas.contains(area))
throw new IllegalAccessException("The internal access area " + area.name() + " has been restricted");
}
/**
* Restricts access to certain areas of this class.
*
* @param area area to restrict
* @since v1-alpha4
*/
public void restrictAccess(@NotNull InternalAccessArea area) {
switch (area) {
case ALL -> {
List<@NotNull InternalAccessArea> areas = new ArrayList<>(List.of(InternalAccessArea.values()));
areas.remove(InternalAccessArea.ALL);
areas.remove(InternalAccessArea.ALL_READ);
areas.remove(InternalAccessArea.ALL_WRITE);
areas.remove(InternalAccessArea.ALL_READ_ESSENTIAL);
restrictedAreas.addAll(areas);
}
case ALL_WRITE -> restrictedAreas.addAll(Arrays.stream(InternalAccessArea.valuesWriteOnly()).toList());
case ALL_READ -> restrictedAreas.addAll(Arrays.stream(InternalAccessArea.valuesReadOnly()).toList());
case ALL_READ_ESSENTIAL -> restrictedAreas.addAll(Arrays.stream(InternalAccessArea.valuesEssentialReadOnly()).toList());
default -> restrictedAreas.add(area);
}
}
/**
* Installs or uninstalls the JVM shutdown
* hook, which prevents the JVM from exiting
* before the engine has fully shut down.
* Highly recommended to keep enabled.
*
* @param status {@code true} to install, {@code false} otherwise
* @throws IllegalAccessException when restricted ({@link InternalAccessArea#SAFETY_SHUTDOWN_HOOK_UPDATE})
* @since v1-alpha4
*/
public void installSafetyShutdownHook(boolean status) throws IllegalAccessException {
isRestricted(InternalAccessArea.SAFETY_SHUTDOWN_HOOK_UPDATE);
try {
if (status)
Runtime.getRuntime().addShutdownHook(Engine.getInstance().getSafetyShutdownHook());
else
Runtime.getRuntime().removeShutdownHook(Engine.getInstance().getSafetyShutdownHook());
} catch (IllegalArgumentException | IllegalStateException ignored) {}
}
/**
* Gets the engine's shutdown handler.
* The shutdown handler is responsible for
* shutting down the JVM safely.
*
* @return shutdown handler
* @throws IllegalAccessException when restricted ({@link InternalAccessArea#SHUTDOWN_HANDLER_GET})
* @since v1-alpha4
*/
public @NotNull ShutdownHandler getShutdownHandler() throws IllegalAccessException {
isRestricted(InternalAccessArea.SHUTDOWN_HANDLER_GET);
return Engine.getInstance().getShutdownHandler();
}
/**
* Sets the engine's shutdown handler.
* The shutdown handler is responsible for
* shutting down the JVM safely.
*
* @param shutdownHandler new shutdown handler
* @throws IllegalAccessException when restricted ({@link InternalAccessArea#SHUTDOWN_HANDLER_UPDATE})
* @since v1-alpha4
*/
public void setShutdownHandler(@NotNull ShutdownHandler shutdownHandler) throws IllegalAccessException {
isRestricted(InternalAccessArea.SHUTDOWN_HANDLER_UPDATE);
Engine.getInstance().setShutdownHandler(shutdownHandler);
}
/**
* Returns whether the engine should reflectively
* search the classpath for events or other annotations.
* <p>
* If disabled, code will either have to manually call
* registration methods or certain classes have to
* be created in a certain package, depending on the
* use case and application.
*
* @return reflective classpath scanning flag state
* @throws IllegalAccessException when restricted ({@link InternalAccessArea#REFLECTIVE_CLASSPATH_SCANNING_GET})
* @see EventHelper#registerEvent(Class, EventListenerCode)
* @see EventHelper#registerEvent(Class, EventListenerCode, EventPriority)
* @since v1-alpha5
*/
public boolean getReflectiveClasspathScanning() throws IllegalAccessException {
isRestricted(InternalAccessArea.REFLECTIVE_CLASSPATH_SCANNING_GET);
return reflectiveClasspathScanning;
}
/**
* Overrides whether the engine should reflectively
* search the classpath for events or other annotations.
* <p>
* If disabled, code will either have to manually call
* registration methods or certain classes have to
* be created in a certain package, depending on the
* use case and application.
* <p>
* Enabling reflective classpath scanning in an unsupported
* environment may cause minor to extreme side effects,
* including but not limited to <b>bugs, exceptions, engine
* or even whole JVM crashes</b>. <i>You have been warned!</i>
*
* @param reflectiveClasspathScanning new reflective classpath scanning
* @throws IllegalAccessException when restricted ({@link InternalAccessArea#REFLECTIVE_CLASSPATH_SCANNING_OVERRIDE})
* @see EventHelper#registerEvent(Class, EventListenerCode)
* @see EventHelper#registerEvent(Class, EventListenerCode, EventPriority)
* @since v1-alpha5
*/
public void overrideReflectiveClasspathScanning(boolean reflectiveClasspathScanning) throws IllegalAccessException {
isRestricted(InternalAccessArea.REFLECTIVE_CLASSPATH_SCANNING_OVERRIDE);
this.reflectiveClasspathScanning = reflectiveClasspathScanning;
}
}

View file

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

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,35 +17,39 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.annotations;
package de.staropensource.engine.base.annotation;
import de.staropensource.sosengine.base.classes.Event;
import de.staropensource.sosengine.base.classes.EventPriority;
import de.staropensource.engine.base.implementable.Event;
import de.staropensource.engine.base.type.EventPriority;
import org.jetbrains.annotations.NotNull;
import java.lang.annotation.*;
/**
* Annotation for registering events on methods.
* Marks a method as an event listener, allowing it
* to respond to an events when it is emitted.
*
* @since v1-alpha0
*/
@SuppressWarnings("unused")
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface EventListener {
/**
* The event to listen for.
* Specifies the event to listen for.
*
* @return the event the method listens for
* @return event to listen on
* @see Event
* @since v1-alpha0
*/
@NotNull
Class<? extends Event> event();
@NotNull Class<? extends Event> event();
/**
* The priority of the event.
* Specifies the priority of the event.
*
* @return the event priority
* @return event priority
* @see EventPriority
* @since v1-alpha0
*/
@NotNull
EventPriority priority() default EventPriority.DEFAULT;
@NotNull EventPriority priority() default EventPriority.DEFAULT;
}

View file

@ -0,0 +1,26 @@
/*
* 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/>.
*/
/**
* Annotations used by the sos!engine to access
* classes and methods using reflection.
*
* @since v1-alpha0
*/
package de.staropensource.engine.base.annotation;

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,20 +17,21 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.events;
package de.staropensource.engine.base.event;
import de.staropensource.sosengine.base.classes.Event;
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
import de.staropensource.engine.base.implementable.Event;
import de.staropensource.engine.base.implementable.helper.EventHelper;
/**
* Called in the event of an engine crash, just before the JVM exists.
* Called in the event of an engine crash.
*
* @since 1-alpha0
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineCrashEvent implements Event {
/**
* Constructor.
* Creates and initializes an instance of this event.
*
* @since v1-alpha0
*/
public EngineCrashEvent() {}

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,19 +17,21 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.events;
package de.staropensource.engine.base.event;
import de.staropensource.sosengine.base.classes.Event;
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
import de.staropensource.engine.base.implementable.Event;
import de.staropensource.engine.base.implementable.helper.EventHelper;
/**
* Called when the engine and JVM are about to shutdown.
* Called when the engine is about to shutdown.
*
* @since 1-alpha0
* @since v1-alpha0
*/
public class EngineShutdownEvent implements Event {
public final class EngineShutdownEvent implements Event {
/**
* Constructor.
* Creates and initializes an instance of this event.
*
* @since v1-alpha0
*/
public EngineShutdownEvent() {}

View file

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

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,23 +17,26 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.events.internal;
package de.staropensource.engine.base.event;
import de.staropensource.sosengine.base.classes.Event;
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
import de.staropensource.engine.base.implementable.Event;
import de.staropensource.engine.base.implementable.helper.EventHelper;
/**
* Called when the engine and JVM are about to shutdown, after {@link de.staropensource.sosengine.base.events.EngineShutdownEvent}.
* Called when the engine is about to shutdown, after {@link de.staropensource.engine.base.event.EngineShutdownEvent}.
* <p>
* Meant for subsystems to perform cleanup and shutdown routines, not for applications.
*
* @since 1-alpha0
* @since v1-alpha0
*/
public class InternalEngineShutdownEvent implements Event {
public final class InternalEngineShutdownEvent implements Event {
/**
* Constructor.
* Creates and initializes an instance of this event.
*
* @since v1-alpha0
*/
public InternalEngineShutdownEvent() {}
/** {@inheritDoc} */
@Override
public void callEvent() {

View file

@ -0,0 +1,64 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.event;
import de.staropensource.engine.base.implementable.Event;
import de.staropensource.engine.base.implementable.helper.EventHelper;
import de.staropensource.engine.base.type.logging.LogLevel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called before a new log message is printed.
*
* @since v1-alpha0
*/
public final class LogEvent implements Event {
/**
* Creates and initializes an instance of this event.
*
* @since v1-alpha0
*/
public LogEvent() {}
/**
* {@inheritDoc}
*
* @deprecated use the {@code callEvent} method with arguments
* @see #callEvent(LogLevel, Class, String, String, String)
*/
@Deprecated
@Override
public void callEvent() {}
/**
* Emits the event and calls all event listeners.
*
* @param level level
* @param issuerClass issuer class
* @param issuerOrigin issuer origin
* @param issuerMetadata issuer metadata
* @param message message
* @since v1-alpha0
*/
public void callEvent(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message) {
EventHelper.invokeAnnotatedMethods(getClass(), level, issuerClass, issuerOrigin, issuerMetadata, message);
}
}

View file

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

View file

@ -0,0 +1,46 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.exception;
import org.jetbrains.annotations.NotNull;
/**
* Thrown the throwing method is not allowed to be called.
*
* @since v1-alpha4
*/
public class IllegalAccessException extends RuntimeException {
/**
* Creates and initializes an instance of this exception.
*
* @since v1-alpha2
*/
public IllegalAccessException() {}
/**
* Creates and initializes an instance of this exception.
*
* @param message message
* @since v1-alpha2
*/
public IllegalAccessException(@NotNull String message) {
super(message);
}
}

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,23 +17,23 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.graphics.classes;
package de.staropensource.engine.base.exception;
import de.staropensource.sosengine.base.classes.Vec2i;
import org.jetbrains.annotations.NotNull;
/**
* The interface for Graphics API management classes.
* Thrown when something fails to parse.
*
* @since 1-alpha0
* @since v1-alpha2
*/
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
public interface ApiManagementClass {
public class ParserException extends RuntimeException {
/**
* Creates a new {@link Window}.
* Creates and initializes an instance of this exception.
*
* @since 1-alpha0
* @param message parsing error
* @since v1-alpha2
*/
@NotNull
Window createWindow(String title, Vec2i size);
public ParserException(@NotNull String message) {
super(message);
}
}

View file

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

View file

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

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,24 +17,24 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.graphics.opengl;
package de.staropensource.engine.base.exception.dependency;
import de.staropensource.sosengine.base.classes.Vec2i;
import de.staropensource.sosengine.graphics.classes.ApiManagementClass;
import de.staropensource.sosengine.graphics.opengl.classes.Window;
import de.staropensource.engine.base.utility.DependencyResolver;
import org.jetbrains.annotations.NotNull;
/**
* The OpenGL API management class.
* Thrown when the {@link DependencyResolver} detects a dependency cycle.
*
* @since 1-alpha0
* @since v1-alpha1
*/
@SuppressWarnings({ "unused" })
public final class OpenGlManagement implements ApiManagementClass {
/** {@inheritDoc} */
@NotNull
@Override
public Window createWindow(String title, Vec2i size) {
return new Window(title, size);
public class DependencyCycleException extends RuntimeException {
/**
* Creates and initializes an instance of this exception.
*
* @param path cycle path
* @since v1-alpha1
*/
public DependencyCycleException(@NotNull String path) {
super("Dependency cycle detected: " + path);
}
}

View file

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

View file

@ -0,0 +1,26 @@
/*
* 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 dependency resolving.
*
* @see de.staropensource.engine.base.utility.DependencyResolver
* @since v1-alpha1
*/
package de.staropensource.engine.base.exception.dependency;

View file

@ -0,0 +1,25 @@
/*
* 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 the engine, subsystems and applications.
*
* @since v1-alpha1
*/
package de.staropensource.engine.base.exception;

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.exception.reflection;
import de.staropensource.engine.base.type.reflection.ClassType;
import de.staropensource.engine.base.utility.ListFormatter;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when the invoked method does not apply to the type of the class.
*
* @since v1-alpha2
*/
public class IncompatibleTypeException extends RuntimeException {
/**
* Creates and initializes an instance of this exception.
*
* @param methodName name of the method that failed
* @param requiredClassType class type received by the method
* @param compatibleTypes class types the method is compatible with
*/
public IncompatibleTypeException(@NotNull String methodName, @NotNull ClassType requiredClassType, @NotNull ClassType @NotNull [] compatibleTypes) {
super("The method ReflectionClass#" + methodName + " only applies to type(s) " + ListFormatter.formatArray(compatibleTypes) + ", not " + requiredClassType.name());
}
/**
* Creates and initializes an instance of this exception.
*
* @param methodName name of the method that failed
* @param requiredClassType class type received by the method
* @param compatibleType class type the method is compatible with
*/
public IncompatibleTypeException(@NotNull String methodName, @NotNull ClassType requiredClassType, @NotNull ClassType compatibleType) {
super("The method ReflectionClass#" + methodName + " only applies to type(s) " + ListFormatter.formatArray(new ClassType[]{ compatibleType }) + ", not " + requiredClassType.name());
}
}

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,26 +17,23 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.graphics.opengl.events;
package de.staropensource.engine.base.exception.reflection;
import org.lwjgl.glfw.GLFWErrorCallbackI;
import org.jetbrains.annotations.NotNull;
/**
* Called when a graphics error occurs.
* Thrown when a method could not be found due to an invalid method signature.
*
* @since 1-alpha0
* @since v1-alpha5
*/
@SuppressWarnings({ "unused" })
public class GraphicsErrorEvent extends de.staropensource.sosengine.graphics.events.GraphicsErrorEvent implements GLFWErrorCallbackI {
public class InvalidMethodSignatureException extends Exception {
/**
* Constructor.
* Creates and initializes an instance of this exception.
*
* @param methodName method name
* @since v1-alpha5
*/
public GraphicsErrorEvent() {}
/** {@inheritDoc} */
@Override
public void invoke(int error, long description) {
callEvent(description + " (" + error + ")");
public InvalidMethodSignatureException(@NotNull String methodName) {
super("Method " + methodName + " has a different method signature");
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,132 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.implementable;
import de.staropensource.engine.base.utility.PropertiesReader;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Properties;
/**
* Interface for implementing configuration classes.
* <p>
* Configuration classes use {@link Properties} objects to modify
* their settings as they can be supplied to the JVM's arguments
* and can be written to and read from during runtime.
*
* @since v1-alpha2
*/
public abstract class Configuration {
/**
* Creates and initializes an instance of this abstract class.
*
* @since v1-alpha2
*/
protected Configuration() {
// Load default configuration
loadDefaultConfiguration();
}
/**
* Loads all settings from the specified {@link Properties} object.
* Unless you want to override settings, consider invoking {@link #loadDefaultConfiguration()} first.
*
* @param properties {@link Properties} to read from
* @see #loadDefaultConfiguration()
* @since v1-alpha2
*/
public void loadConfiguration(@NotNull Properties properties) {
PropertiesReader parser = new PropertiesReader(properties);
// Loop through all properties
for (String property : properties.stringPropertyNames()) {
// Check if property name starts with group
if (!property.startsWith(getGroup()))
continue;
// Remove group
property = property.substring(getGroup().length());
// Overwrite matching settings
try {
matchProperty(parser, property);
} catch (NullPointerException ignored) {}
}
processSettings(parser);
}
/**
* Loads all settings from the system properties.
* Useful if you want to allow the user to modify settings at startup.
*
* @see #loadConfiguration(Properties)
* @see System#getProperties()
* @since v1-alpha2
*/
public void loadConfiguration() {
loadConfiguration(System.getProperties());
}
/**
* Returns prefix properties must begin with.
*
* @return property group
* @since v1-alpha2
*/
public abstract @NotNull String getGroup();
/**
* Loads the default subsystem configuration.
*
* @see #loadConfiguration()
* @see #loadConfiguration(Properties)
* @since v1-alpha0
*/
public abstract void loadDefaultConfiguration();
/**
* Matches the given {@code property} against all settings.
* If a match has been found, the setting will be overwritten with the property's value.
*
* @param parser matching {@link PropertiesReader}
* @param property property to match
* @since v1-alpha2
*/
protected abstract void matchProperty(@NotNull PropertiesReader parser, @NotNull String property);
/**
* Allows the implementor to process all settings and potentially
* modify them before {@link #loadConfiguration(Properties)} returns.
*
* @param parser matching {@link PropertiesReader}
* @since v1-alpha2
*/
protected abstract void processSettings(@NotNull PropertiesReader parser);
/**
* Returns a configuration setting.
*
* @param setting setting name
* @return setting's value or {@code null} if not found
*/
public abstract @Nullable Object getSetting(@NotNull String setting);
}

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,17 +17,21 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.classes;
package de.staropensource.engine.base.implementable;
import de.staropensource.engine.base.implementable.helper.EventHelper;
/**
* Represents an event.
*
* @since 1-alpha0
* @see EventHelper
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public interface Event {
/**
* Calls the event and notifies all annotated methods.
* Emits the event and calls all event listeners.
*
* @since v1-alpha0
*/
void callEvent();
}

View file

@ -0,0 +1,59 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.implementable;
import de.staropensource.engine.base.implementable.helper.EventHelper;
import de.staropensource.engine.base.type.EventPriority;
import org.jetbrains.annotations.NotNull;
/**
* Used by {@link EventHelper} to execute event listeners.
*
* @see Runnable
* @since v1-alpha5
*/
public abstract class EventListenerCode {
/**
* Contains the priority of this
* event listener.
* <p>
* Set automatically by {@link EventHelper},
* do not change this manually.
*
* @since v1-alpha5
*/
public @NotNull EventPriority priority = EventPriority.DEFAULT;
/**
* Creates and initializes an instance of this abstract class.
*
* @since v1-alpha5
*/
protected EventListenerCode() {}
/**
* Invokes the event listener.
*
* @param arguments arguments passed along by the event
* @throws Exception exceptions thrown
* @since v1-alpha5
*/
public abstract void run(Object... arguments) throws Exception;
}

View file

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

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,18 +17,24 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.graphics.vulkan;
package de.staropensource.engine.base.implementable;
import de.staropensource.sosengine.base.classes.Vec2i;
import de.staropensource.sosengine.graphics.classes.ApiManagementClass;
import de.staropensource.sosengine.graphics.classes.Window;
import de.staropensource.engine.base.utility.PlaceholderEngine;
import org.jetbrains.annotations.NotNull;
public class VulkanManagement implements ApiManagementClass {
/** {@inheritDoc} */
@NotNull
@Override
public Window createWindow(String title, Vec2i size) {
return null;
}
/**
* 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

@ -0,0 +1,218 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.implementable;
import de.staropensource.engine.base.EngineConfiguration;
import de.staropensource.engine.base.exception.ParserException;
import de.staropensource.engine.base.logging.Logger;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import java.util.LinkedList;
import java.util.Locale;
/**
* Base class for implementing a shortcode parser.
* <p>
* This class parses a string and converts it into a list of
* components, which can then be in turn be converted to something
* else, for example, ANSI escape codes.
* <p>
* The following shortcodes are available and can be used:
* <ul>
* <li>reset</li>
* <li>fg:[black,red,green,yellow,blue,magenta,cyan,white]</li>
* <li>bg:[black,red,green,yellow,blue,magenta,cyan,white]</li>
* <li>bold</li>
* <li>italic</li>
* <li>strikethrough</li>
* <li>underline</li>
* </ul>
*
* @since v1-alpha1
*/
@Getter
@SuppressWarnings({ "JavadocDeclaration" })
public abstract class ShortcodeParser {
/**
* Contains a list of components the parsed text is made out of.
*
* @since v1-alpha1
* -- GETTER --
* Returns a list of components the parsed text is made out of.
*
* @return component list
* @since v1-alpha1
*/
protected final @NotNull LinkedList<String> components;
/**
* Creates and initializes an instance of this abstract class.
*
* @param string string to parse
* @param ignoreInvalidEscapes if {@code true}, will ignore and treat invalid escapes as text
* @throws ParserException on error
* @since v1-alpha2
*/
protected ShortcodeParser(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
components = parse(string, ignoreInvalidEscapes);
}
/**
* Parses the input string and returns a list
* of components the text is made out of.
*
* @param string string to parse
* @param ignoreInvalidEscapes if {@code true}, will ignore and treat invalid escapes as text
* @return list of components
* @throws ParserException on error
* @see EngineConfiguration#errorShortcodeParser
* @since v1-alpha2
*/
protected @NotNull LinkedList<@NotNull String> parse(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
LinkedList<String> components = new LinkedList<>(); // List of components
boolean tagActive = false; // Indicates that a tag is being parsed
boolean escape = false; // Indicates whether the last character was a \ character
StringBuilder part = new StringBuilder(); // Temporary string. May be a tag, may be regular text
// Iterate through every character
for (char character : string.toCharArray()) {
// Escaping
if (escape) {
if (character == '\\' || character == '<')
part.append(character);
else if (!(character == 'r' || character == 'n'))
if (ignoreInvalidEscapes)
part.append("\\").append(character);
else
throw new ParserException("Invalid escape \\" + character);
escape = false;
continue;
}
if (character == '\\') {
escape = true;
continue;
}
if (tagActive) {
// A tag is being parsed
if (character == '>') {
// Tag is ending, disable tag parsing
tagActive = false;
// fg:*
if (part.toString().startsWith("fg:"))
if (isValidColor(part.substring(3).toUpperCase()))
components.add("COLOR:FOREGROUND:" + part.substring(3).toUpperCase());
else {
// Complain about invalid shortcode
if (EngineConfiguration.getInstance() != null && EngineConfiguration.getInstance().isErrorShortcodeParser())
Logger.sarn("Invalid shortcode: " + part);
// Convert tag regular text
components.add("TEXT:" + "<" + part + ">");
}
// bg:*
else if (part.toString().startsWith("bg:"))
if (isValidColor(part.substring(3).toUpperCase()))
components.add("COLOR:BACKGROUND:" + part.substring(3).toUpperCase());
else {
// Complain about invalid shortcode
if (EngineConfiguration.getInstance() != null && EngineConfiguration.getInstance().isErrorShortcodeParser())
Logger.sarn("Invalid shortcode: " + part);
// Convert tag regular text
components.add("TEXT:" + "<" + part + ">");
}
// bold
else if (part.toString().equals("bold"))
components.add("ATTRIBUTE:BOLD");
// italic
else if (part.toString().equals("italic"))
components.add("ATTRIBUTE:ITALIC");
// strikethrough
else if (part.toString().equals("strikethrough"))
components.add("ATTRIBUTE:STRIKETHROUGH");
// underline
else if (part.toString().equals("underline"))
components.add("ATTRIBUTE:UNDERLINE");
// blink
else if (part.toString().equals("blink"))
components.add("ATTRIBUTE:BLINK");
// reset
else if (part.toString().equals("reset"))
components.add("RESET");
// error case
else {
// Complain about invalid shortcode
if (EngineConfiguration.getInstance() != null && EngineConfiguration.getInstance().isErrorShortcodeParser())
Logger.sarn("Invalid shortcode: " + part);
// Convert tag regular text
components.add("TEXT:" + "<" + part + ">");
}
// Empty 'part'
part = new StringBuilder();
} else
// Tag has not ended yet, add character to 'part'
// It bloats the code to do it with StringBuilder
part.append(character);
} else {
// Regular text is being parsed
if (character == '<') {
if (!part.isEmpty()) {
// Tag is starting, insert previous text
components.add("TEXT:" + part);
part = new StringBuilder();
}
tagActive = true; // Enable tag processing
} else
// Regular text, add character to 'part'
// It bloats the code to do it with StringBuilder
part.append(character);
}
}
// Processing ended, insert leftover text
if (!part.isEmpty())
components.add("TEXT:" + part);
return components;
}
/**
* Returns if the specified color is valid
*
* @return {@code true} if valid, {@code false} otherwise
* @since v1-alpha2
*/
private boolean isValidColor(@NotNull String color) {
return switch (color.toLowerCase(Locale.ROOT)) {
case "black", "white", "red",
"green", "blue", "yellow",
"magenta", "cyan" -> true;
default -> false;
};
}
}

View file

@ -0,0 +1,42 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.implementable;
import de.staropensource.engine.base.Engine;
import org.jetbrains.annotations.Range;
/**
* Interface for custom shutdown handlers.
* <p>
* Shutdown handlers are responsible for shutting down
* the platform safely after the engine has shut down.
*
* @see Engine#setShutdownHandler(ShutdownHandler)
* @since v1-alpha2
*/
public interface ShutdownHandler {
/**
* Executes the shutdown handler.
*
* @param exitCode exit code
* @since v1-alpha2
*/
void shutdown(@Range(from = 0, to = 255) short exitCode);
}

View file

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

View file

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

View file

@ -0,0 +1,257 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.implementable.helper;
import de.staropensource.engine.base.EngineConfiguration;
import de.staropensource.engine.base.EngineInternals;
import de.staropensource.engine.base.annotation.EventListener;
import de.staropensource.engine.base.event.LogEvent;
import de.staropensource.engine.base.exception.reflection.InstanceMethodFromStaticContextException;
import de.staropensource.engine.base.exception.reflection.InvalidMethodSignatureException;
import de.staropensource.engine.base.exception.reflection.NoAccessException;
import de.staropensource.engine.base.exception.reflection.StaticInitializerException;
import de.staropensource.engine.base.implementable.Event;
import de.staropensource.engine.base.implementable.EventListenerCode;
import de.staropensource.engine.base.internal.implementation.EventListenerMethod;
import de.staropensource.engine.base.logging.Logger;
import de.staropensource.engine.base.type.EventPriority;
import de.staropensource.engine.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.*;
/**
* Simplifies event logging and calling.
*
* @since v1-alpha0
*/
@Getter
public final class EventHelper {
/**
* Holds all cached events.
*
* @since v1-alpha5
*/
private static final @NotNull Map<@NotNull Class<? extends Event>, LinkedList<@NotNull EventListenerCode>> cachedEventListeners = new HashMap<>();
/**
* Creates and initializes an instance of this class.
*
* @since v1-alpha0
*/
private EventHelper() {}
/**
* Registers a new {@link Event}.
* <p>
* This method does nothing if classpath searching is disabled.
*
* @param event {@link Event} to register for
* @param eventListener {@link EventListenerCode} to register
* @param priority priority of the listener
* @see EngineInternals#getReflectiveClasspathScanning()
* @since v1-alpha5
*/
public static synchronized void registerEvent(@NotNull Class<? extends Event> event, @NotNull EventListenerCode eventListener, @NotNull EventPriority priority) {
if (EngineInternals.getInstance().getReflectiveClasspathScanning())
return;
// Update 'eventListener' priority
eventListener.priority = priority;
// Check if event already exists in map
// If not, create entry with a LinkedList
if (cachedEventListeners.containsKey(event))
if (cachedEventListeners.get(event).contains(eventListener))
return;
else
cachedEventListeners.get(event).add(eventListener);
else {
LinkedList<@NotNull EventListenerCode> list = new LinkedList<>();
list.add(eventListener);
cachedEventListeners.put(event, list);
}
Logger.diag("Registered event listener " + eventListener + " for event " + event + " with priority " + priority.name());
}
/**
* Registers a new {@link Event}.
* <p>
* This method does nothing if classpath searching is disabled.
*
* @param event {@link Event} to register for
* @param eventListener {@link EventListenerCode} to register
* @see EngineInternals#getReflectiveClasspathScanning()
* @since v1-alpha5
*/
public static void registerEvent(@NotNull Class<? extends Event> event, @NotNull EventListenerCode eventListener) {
registerEvent(event, eventListener, EventPriority.DEFAULT);
}
/**
* (Re-)Caches all event listeners for some {@link Event}.
* <p>
* This method does nothing if classpath searching is enabled.
*
* @param event event to (re-)cache. Set to {@code null} to recompute all cached events
* @see EngineInternals#getReflectiveClasspathScanning()
* @since v1-alpha5
*/
public static synchronized void cacheEvent(@Nullable Class<? extends Event> event) {
if (!EngineInternals.getInstance().getReflectiveClasspathScanning())
return;
if (event == null)
for (Class<? extends Event> cachedEvent : cachedEventListeners.keySet())
cacheEvent(cachedEvent);
else {
LinkedList<@NotNull EventListenerCode> annotatedMethods = getAnnotatedMethods(event);
if (cachedEventListeners.containsKey(event))
cachedEventListeners.replace(event, annotatedMethods);
else
cachedEventListeners.put(event, annotatedMethods);
}
}
/**
* Removes an event from the event listener cache.
* <p>
* This method does nothing if classpath searching is enabled.
*
* @param event event to uncache. Set to {@code null} to clear the entire cache
* @see EngineInternals#getReflectiveClasspathScanning()
* @since v1-alpha5
*/
public static synchronized void uncacheEvent(@Nullable Class<? extends Event> event) {
if (!EngineInternals.getInstance().getReflectiveClasspathScanning())
return;
if (event == null)
cachedEventListeners.clear();
else
cachedEventListeners.remove(event);
}
/**
* Invokes all event listeners.
*
* @param event event class
* @param arguments arguments to pass to event listeners
* @since v1-alpha5
*/
public static void invokeAnnotatedMethods(@NotNull Class<? extends Event> event, Object... arguments) {
if (event != LogEvent.class && EngineConfiguration.getInstance().isDebugEvents())
if (arguments.length == 0)
Logger.diag("Event " + event.getName() + " was emitted");
else
Logger.diag("Event " + event.getName() + " was emitted, passing arguments " + ListFormatter.formatArray(arguments));
Runnable eventCode = () -> {
for (EventListenerCode eventListener : getAnnotatedMethods(event)) {
try {
eventListener.run(arguments);
} catch (NoAccessException exception) {
Logger.warn("Event listener " + eventListener + " could not be called as the method could not be accessed");
} catch (InvalidMethodSignatureException exception) {
Logger.warn("Event listener " + eventListener + " has an invalid method signature");
} catch (InvocationTargetException exception) {
Logger.crash("Event listener " + eventListener + " threw a throwable", exception.getTargetException(), true);
} catch (InstanceMethodFromStaticContextException exception) {
Logger.warn("Event listener " + eventListener + " is not static. Event listener methods must be static for them to be called.");
} catch (StaticInitializerException exception) {
Logger.crash("Event listener " + eventListener + " could not be called as the static initializer failed", exception.getThrowable(), true);
} catch (Exception exception) {
Logger.crash("Event listener " + eventListener + " could not be called as an error occurred during reflection", exception, true);
}
}
};
if (EngineConfiguration.getInstance().isOptimizeEvents())
Thread
.ofVirtual()
.name("Event " + event.getName())
.start(eventCode);
else
eventCode.run();
}
/**
* Returns all {@link EventListener}s listening on some event.
* The classpath will be scanned for listeners, unless cached results exist and {@code !forceScanning}.
*
* @param event event class
* @param forceScanning forces scanning the classpath for listeners. not recommended due to a huge performance penalty
* @return list of event listeners
* @see #cacheEvent(Class)
* @since v1-alpha5
*/
public static @NotNull LinkedList<EventListenerCode> getAnnotatedMethods(@NotNull Class<? extends Event> event, boolean forceScanning) {
LinkedList<EventListenerCode> eventListeners = new LinkedList<>();
if (!EngineInternals.getInstance().getReflectiveClasspathScanning())
return Objects.requireNonNullElse(cachedEventListeners.get(event), eventListeners);
if (forceScanning || !cachedEventListeners.containsKey(event)) {
Reflections reflections = new Reflections(
new ConfigurationBuilder()
.setUrls(ClasspathHelper.forJavaClassPath())
.setScanners(Scanners.MethodsAnnotated)
);
// Get annotated methods
Set<@NotNull Method> annotatedMethods = reflections.getMethodsAnnotatedWith(EventListener.class);
// Sort event listeners not listening for the specified event out
for (Method method : annotatedMethods)
if (method.getAnnotation(EventListener.class).event() == event)
eventListeners.add(new EventListenerMethod(method));
// Sort list after event priority
eventListeners.sort(Comparator.comparing(method -> Objects.requireNonNull(((EventListenerMethod) method).getAnnotation(EventListener.class)).priority()));
} else
// Event listeners are cached and !forceScanning, return cached results
eventListeners = cachedEventListeners.get(event);
return eventListeners;
}
/**
* Returns all {@link EventListener}s listening on some event.
* The classpath will be scanned for listeners, unless cached results exist.
*
* @param event event class
* @return list of event listeners
* @since v1-alpha5
*/
public static @NotNull LinkedList<EventListenerCode> getAnnotatedMethods(@NotNull Class<? extends Event> event) {
return getAnnotatedMethods(event, false);
}
}

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -18,8 +18,9 @@
*/
/**
* Not necessarily interfaces or extendable classes. Rather, they support building classes using certain interfaces by providing useful code.
* Not necessarily interfaces or extendable classes. Rather, they
* support implementing classes by providing useful or complex code.
*
* @since 1-alpha0
* @since v1-alpha0
*/
package de.staropensource.sosengine.base.classes.helpers;
package de.staropensource.engine.base.implementable.helper;

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -18,8 +18,8 @@
*/
/**
* Contains various packages with tiny classes that provide or process information.
* Interfaces and abstract classes which can be used for implementing classes.
*
* @since 1-alpha0
* @since v1-alpha0
*/
package de.staropensource.sosengine.base.data;
package de.staropensource.engine.base.implementable;

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,25 @@
/*
* 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/>.
*/
/**
* Implementations for various interfaces and abstract classes.
*
* @since v1-alpha6
*/
package de.staropensource.engine.base.implementation;

View file

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

View file

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

View file

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

@ -0,0 +1,85 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.implementation.versioning;
import de.staropensource.engine.base.implementable.VersioningSystem;
import de.staropensource.engine.base.exception.versioning.IncompatibleVersioningSystemException;
import de.staropensource.engine.base.exception.versioning.InvalidVersionStringException;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Range;
/**
* Represents a one-numbered versioning system, where an application or work is versioned by one arbitrary number.
*
* @since v1-alpha1
*/
@Getter
@SuppressWarnings({ "JavadocDeclaration" })
public final class OneNumberVersioningSystem implements VersioningSystem {
/**
* Contains the number vector.
*
* @since v1-alpha1
* -- GETTER --
* Returns the number vector.
*
* @return number vector
* @since v1-alpha1
*/
private final int number;
/** {@inheritDoc} */
@Override
public @NotNull String getName() {
return "n1";
}
/**
* Tries to parse the specified version string
* and if successful, return a new instance.
*
* @param versionString version string to parse
* @throws InvalidVersionStringException if the version string is invalid
*/
public OneNumberVersioningSystem(@NotNull String versionString) throws InvalidVersionStringException {
// Convert to integers
try {
this.number = Integer.parseUnsignedInt(versionString);
} catch (NumberFormatException exception) {
throw new InvalidVersionStringException(this, versionString, "Failed converting the version string into an integer", exception);
}
}
/** {@inheritDoc} */
@Range(from = 0, to = 2)
@Override
public int compare(@NotNull VersioningSystem versionInterface) throws IncompatibleVersioningSystemException {
if (versionInterface instanceof OneNumberVersioningSystem version) {
if (version.getNumber() < number)
return 0;
if (version.getNumber() > number)
return 2;
return 1;
} else
throw new IncompatibleVersioningSystemException(this, versionInterface);
}
}

View file

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

@ -0,0 +1,264 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.implementation.versioning;
import de.staropensource.engine.base.implementable.VersioningSystem;
import de.staropensource.engine.base.exception.versioning.IncompatibleVersioningSystemException;
import de.staropensource.engine.base.exception.versioning.InvalidVersionStringException;
import de.staropensource.engine.base.type.VersionType;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Range;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* Represents the StarOpenSource versioning system (version 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";
}
/**
* Tries to parse the specified version string
* and if successful, return a new instance.
*
* @param versionString version string to parse
* @throws InvalidVersionStringException if the version string is invalid
*/
public StarOpenSourceVersioningSystem(@NotNull String versionString) throws InvalidVersionStringException {
// Split the version string at every separator
StringBuilder charSequence = new StringBuilder();
/*
* 0 = 'v'
* 1 = 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

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

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

@ -0,0 +1,26 @@
/*
* 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.engine.base.implementation.versioning;

View file

@ -0,0 +1,83 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.engine.base.internal.implementation;
import de.staropensource.engine.base.implementable.EventListenerCode;
import de.staropensource.engine.base.reflection.Reflect;
import de.staropensource.engine.base.reflection.ReflectionMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
/**
* Interface specifically for executing event listener methods.
*
* @since v1-alpha5
*/
public final class EventListenerMethod extends EventListenerCode {
/**
* Contains the method to call and get.
*
* @since v1-alpha5
*/
private final @NotNull ReflectionMethod method;
/**
* Creates and initializes an instance of this class.
*
* @param method method to execute
* @since v1-alpha5
*/
public EventListenerMethod(@NotNull Method method) {
this.method = Reflect.reflectOn(method);
}
/** {@inheritDoc} */
@Override
public void run(@Nullable Object @NotNull [] arguments) throws Exception {
method.invoke(arguments);
}
/**
* Forwards {@link ReflectionMethod#getAnnotation(Class)}
* to the internal {@link ReflectionMethod} instance.
*
* @param <T> annotation
* @param annotation annotation to get
* @return annotation or {@code null} on error
* @see ReflectionMethod#getAnnotation(Class)
* @since v1-alpha5
*/
public <T extends Annotation> @Nullable T getAnnotation(@NotNull Class<T> annotation) {
try {
return method.getAnnotation(annotation);
} catch (NullPointerException exception) {
return null;
}
}
/** {@inheritDoc} */
@Override
public String toString() {
return "method " + method.getMethod().getDeclaringClass().getName() + "#" + method.getName();
}
}

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -18,8 +18,8 @@
*/
/**
* Contains various data types using {@link java.lang.Enum}s and regular {@code Class}es.
* Interfaces and abstract classes which can be used for implementing classes.
*
* @since 1-alpha0
* @since v1-alpha5
*/
package de.staropensource.sosengine.base.types;
package de.staropensource.engine.base.internal.implementation;

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
package de.staropensource.engine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.utility.Miscellaneous;
import de.staropensource.engine.base.implementable.Placeholder;
import de.staropensource.engine.base.utility.Math;
import org.jetbrains.annotations.NotNull;
import java.util.Calendar;
@ -29,27 +29,20 @@ import java.util.Calendar;
* Implements the {@code date_day} placeholder.
*
* @see Placeholder
* @since 1-alpha0
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class DateDay implements Placeholder {
/**
* Constructor.
* Creates and initializes an instance of this event.
*
* @since 1-alpha0
* @since v1-alpha0
*/
public DateDay() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "date_day";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.DAY_OF_MONTH), 2));
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,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
package de.staropensource.engine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.utility.Miscellaneous;
import de.staropensource.engine.base.implementable.Placeholder;
import de.staropensource.engine.base.utility.Math;
import org.jetbrains.annotations.NotNull;
import java.util.Calendar;
@ -29,27 +29,20 @@ import java.util.Calendar;
* Implements the {@code date_month} placeholder.
*
* @see Placeholder
* @since 1-alpha0
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class DateMonth implements Placeholder {
/**
* Constructor.
* Creates and initializes an instance of this event.
*
* @since 1-alpha0
* @since v1-alpha0
*/
public DateMonth() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "date_month";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.MONTH), 2));
public @NotNull String replace(@NotNull String text) {
return text.replace("%date_month%", Math.padNumbers(Calendar.getInstance().get(Calendar.MONTH), 2));
}
}

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
package de.staropensource.engine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.utility.Miscellaneous;
import de.staropensource.engine.base.implementable.Placeholder;
import de.staropensource.engine.base.utility.Math;
import org.jetbrains.annotations.NotNull;
import java.util.Calendar;
@ -29,27 +29,20 @@ import java.util.Calendar;
* Implements the {@code date_year} placeholder.
*
* @see Placeholder
* @since 1-alpha0
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class DateYear implements Placeholder {
/**
* Constructor.
* Creates and initializes an instance of this event.
*
* @since 1-alpha0
* @since v1-alpha0
*/
public DateYear() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "date_year";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.YEAR), 4));
public @NotNull String replace(@NotNull String text) {
return text.replace("%date_year%", Math.padNumbers(Calendar.getInstance().get(Calendar.YEAR), 4));
}
}

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,37 +17,30 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
package de.staropensource.engine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import de.staropensource.engine.base.implementable.Placeholder;
import de.staropensource.engine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_dependency_jansi} placeholder.
*
* @see Placeholder
* @since 1-alpha0
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineDependencyJansi implements Placeholder {
/**
* Constructor.
* Creates and initializes an instance of this event.
*
* @since 1-alpha0
* @since v1-alpha0
*/
public EngineDependencyJansi() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_dependency_jansi";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", EngineInformation.getInstance().getDependencyJansi());
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_dependency_jansi%", EngineInformation.getDependencyJansi());
}
}

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,37 +17,30 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
package de.staropensource.engine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import de.staropensource.engine.base.implementable.Placeholder;
import de.staropensource.engine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_dependency_lwjgl} placeholder.
*
* @see Placeholder
* @since 1-alpha0
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineDependencyLwjgl implements Placeholder {
/**
* Constructor.
* Creates and initializes an instance of this event.
*
* @since 1-alpha0
* @since v1-alpha0
*/
public EngineDependencyLwjgl() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_dependency_lwjgl";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", EngineInformation.getInstance().getDependencyLwjgl());
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_dependency_lwjgl%", EngineInformation.getDependencyLwjgl());
}
}

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,37 +17,30 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
package de.staropensource.engine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import de.staropensource.engine.base.implementable.Placeholder;
import de.staropensource.engine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_dependency_reflections} placeholder.
*
* @see Placeholder
* @since 1-alpha0
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineDependencyReflections implements Placeholder {
/**
* Constructor.
* Creates and initializes an instance of this event.
*
* @since 1-alpha0
* @since v1-alpha0
*/
public EngineDependencyReflections() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_dependency_reflections";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", EngineInformation.getInstance().getDependencyReflections());
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_dependency_reflections%", EngineInformation.getDependencyReflections());
}
}

View file

@ -1,6 +1,6 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* 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
@ -17,37 +17,30 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
package de.staropensource.engine.base.internal.implementation.placeholder;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import de.staropensource.engine.base.implementable.Placeholder;
import de.staropensource.engine.base.utility.information.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_dependency_slf4j} placeholder.
*
* @see Placeholder
* @since 1-alpha0
* @since v1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineDependencySlf4j implements Placeholder {
/**
* Constructor.
* Creates and initializes an instance of this event.
*
* @since 1-alpha0
* @since v1-alpha0
*/
public EngineDependencySlf4j() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_dependency_slf4j";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", EngineInformation.getInstance().getDependencySlf4j());
public @NotNull String replace(@NotNull String text) {
return text.replace("%engine_dependency_slf4j%", EngineInformation.getDependencySlf4j());
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

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