diff --git a/Fossil/build.gradle b/Fossil/build.gradle index 609c4f3..ac24e5c 100644 --- a/Fossil/build.gradle +++ b/Fossil/build.gradle @@ -16,6 +16,8 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter' } +var buildOrder = 2; + test { useJUnitPlatform() } \ No newline at end of file diff --git a/Obsidian/.gitignore b/Obsidian/.gitignore new file mode 100644 index 0000000..3c37caf --- /dev/null +++ b/Obsidian/.gitignore @@ -0,0 +1,118 @@ +# User-specific stuff +.idea/ + +*.iml +*.ipr +*.iws + +# IntelliJ +out/ +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +.gradle +build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Cache of project +.gradletasknamecache + +**/build/ + +# Common working directory +run/ + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar diff --git a/Obsidian/build.gradle b/Obsidian/build.gradle new file mode 100644 index 0000000..8c7faca --- /dev/null +++ b/Obsidian/build.gradle @@ -0,0 +1,27 @@ +plugins { + id 'java' +} + +group = 'me.totalfreedom' +version = '1.0' + +repositories { + mavenCentral() + maven { + name = "spigotmc-repo" + url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" + } + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/groups/public/" + } +} + +dependencies { + compileOnly "org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT" + compileOnly "io.projectreactor:reactor-core:3.5.7" + implementation "org.jetbrains:annotations:23.0.0" + implementation "com.google.errorprone:error_prone_annotations:2.11.0" +} + +var buildOrder = 0; diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/core/Disposable.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/core/Disposable.java new file mode 100644 index 0000000..121b3e1 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/core/Disposable.java @@ -0,0 +1,9 @@ +package me.totalfreedom.obsidian.core; + +public interface Disposable +{ + void dispose(); + + boolean isDisposed(); +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/core/Observable.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/core/Observable.java new file mode 100644 index 0000000..902c5a7 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/core/Observable.java @@ -0,0 +1,5 @@ +package me.totalfreedom.obsidian.core; + +public interface Observable { + void subscribe(Observer observer); +} diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/core/Observer.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/core/Observer.java new file mode 100644 index 0000000..5ef97bb --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/core/Observer.java @@ -0,0 +1,11 @@ +package me.totalfreedom.obsidian.core; + +public interface Observer +{ + void onNext(T item); + + void onError(Throwable throwable); + + void onComplete(); +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/core/Scheduler.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/core/Scheduler.java new file mode 100644 index 0000000..65ea049 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/core/Scheduler.java @@ -0,0 +1,15 @@ +package me.totalfreedom.obsidian.core; + +import java.util.concurrent.TimeUnit; + +public interface Scheduler +{ + Disposable schedule(Runnable task); + + Disposable schedule(Runnable task, long delay, TimeUnit unit); + + Disposable schedulePeriodically(Runnable task, long initialDelay, long period, TimeUnit unit); + + void dispose(); +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebClient.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebClient.java new file mode 100644 index 0000000..f5ea771 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebClient.java @@ -0,0 +1,8 @@ +package me.totalfreedom.obsidian.http; + +import reactor.core.publisher.Mono; + +public interface WebClient { + Mono sendRequest(WebRequest request); +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebHandler.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebHandler.java new file mode 100644 index 0000000..8119958 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebHandler.java @@ -0,0 +1,8 @@ +package me.totalfreedom.obsidian.http; + +import reactor.core.publisher.Mono; + +public interface WebHandler { + Mono handleRequest(WebRequest request); +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebHeaders.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebHeaders.java new file mode 100644 index 0000000..a7d5129 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebHeaders.java @@ -0,0 +1,20 @@ +package me.totalfreedom.obsidian.http; + +import java.util.List; +import java.util.Set; + +public interface WebHeaders +{ + List getHeader(String name); + + void addHeader(String name, String value); + + void setHeader(String name, String value); + + void removeHeader(String name); + + boolean containsHeader(String name); + + Set getHeaderNames(); +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebMethod.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebMethod.java new file mode 100644 index 0000000..e84e8c0 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebMethod.java @@ -0,0 +1,12 @@ +package me.totalfreedom.obsidian.http; + +public enum WebMethod { + GET, + POST, + PUT, + DELETE, + PATCH, + HEAD, + OPTIONS +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebRequest.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebRequest.java new file mode 100644 index 0000000..dbb2c70 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebRequest.java @@ -0,0 +1,15 @@ +package me.totalfreedom.obsidian.http; + +import java.awt.image.DataBuffer; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public interface WebRequest { + WebMethod getMethod(); + String getUri(); + WebHeaders getHeaders(); + Mono getBody(); + Flux getBodyFlux(); +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebResponse.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebResponse.java new file mode 100644 index 0000000..9ca9857 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebResponse.java @@ -0,0 +1,17 @@ +package me.totalfreedom.obsidian.http; + +import java.awt.image.DataBuffer; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public interface WebResponse { + WebStatus getStatus(); + WebHeaders getHeaders(); + void setStatus(WebStatus status); + void setHeader(String name, String value); + Mono write(ByteBuffer data); + Mono write(DataBuffer dataBuffer); + Mono write(Flux dataFlux); +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebServer.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebServer.java new file mode 100644 index 0000000..4dfe307 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebServer.java @@ -0,0 +1,9 @@ +package me.totalfreedom.obsidian.http; + +public interface WebServer { + void start(); + void stop(); + void registerHandler(String uri, WebHandler handler); + void unregisterHandler(String uri); +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebStatus.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebStatus.java new file mode 100644 index 0000000..29db703 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/http/WebStatus.java @@ -0,0 +1,26 @@ +package me.totalfreedom.obsidian.http; + +public enum WebStatus +{ + OK(200), + CREATED(201), + NO_CONTENT(204), + BAD_REQUEST(400), + UNAUTHORIZED(401), + FORBIDDEN(403), + NOT_FOUND(404), + INTERNAL_SERVER_ERROR(500); + + private final int code; + + WebStatus(final int code) + { + this.code = code; + } + + public int getCode() + { + return code; + } +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/security/OAuth2Credentials.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/security/OAuth2Credentials.java new file mode 100644 index 0000000..b1e6b56 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/security/OAuth2Credentials.java @@ -0,0 +1,15 @@ +package me.totalfreedom.obsidian.security; + +public interface OAuth2Credentials +{ + String getClientId(); + + String getClientSecret(); + + String getUsername(); + + String getPassword(); + + String getScope(); +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/security/OAuth2Service.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/security/OAuth2Service.java new file mode 100644 index 0000000..7a359b1 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/security/OAuth2Service.java @@ -0,0 +1,12 @@ +package me.totalfreedom.obsidian.security; + +import reactor.core.publisher.Mono; + +public interface OAuth2Service +{ + Mono authenticate(OAuth2Credentials credentials); + + Mono validateToken(OAuth2Token token); + + Mono refreshAccessToken(OAuth2Token token); +} diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/security/OAuth2Token.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/security/OAuth2Token.java new file mode 100644 index 0000000..d6bc5a9 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/security/OAuth2Token.java @@ -0,0 +1,22 @@ +package me.totalfreedom.obsidian.security; + +import java.time.Instant; + +public interface OAuth2Token +{ + String getAccessToken(); + + void setAccessToken(String accessToken); + + String getRefreshToken(); + + void setRefreshToken(String refreshToken); + + String getTokenType(); + + void setTokenType(String tokenType); + + Instant getExpiresAt(); + + void setExpiresAt(Instant expiresAt); +} diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/sql/SQLConnection.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/sql/SQLConnection.java new file mode 100644 index 0000000..440404c --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/sql/SQLConnection.java @@ -0,0 +1,13 @@ +package me.totalfreedom.obsidian.sql; + +import reactor.core.publisher.Mono; + +public interface SQLConnection +{ + Mono executeQuery(SQLQuery query); + + Mono executeUpdate(SQLQuery query); + + void close(); +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/sql/SQLQuery.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/sql/SQLQuery.java new file mode 100644 index 0000000..52311f8 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/sql/SQLQuery.java @@ -0,0 +1,10 @@ +package me.totalfreedom.obsidian.sql; + +import java.util.List; + +public interface SQLQuery { + String getQuery(); + List getParameters(); + void setParameter(int index, Object value); +} + diff --git a/Obsidian/src/main/java/me/totalfreedom/obsidian/sql/SQLResult.java b/Obsidian/src/main/java/me/totalfreedom/obsidian/sql/SQLResult.java new file mode 100644 index 0000000..14b6288 --- /dev/null +++ b/Obsidian/src/main/java/me/totalfreedom/obsidian/sql/SQLResult.java @@ -0,0 +1,8 @@ +package me.totalfreedom.obsidian.sql; + +public interface SQLResult +{ + boolean next(); + + T getColumn(int index, Class type); +} \ No newline at end of file diff --git a/Obsidian/src/main/resources/plugin.yml b/Obsidian/src/main/resources/plugin.yml new file mode 100644 index 0000000..7eff9d2 --- /dev/null +++ b/Obsidian/src/main/resources/plugin.yml @@ -0,0 +1,7 @@ +name: Obsidian +version: '${version}' +main: me.totalfreedom.obsidian.Obsidian +api-version: '1.20' +load: STARTUP +libraries: + - io.projectreactor:reactor-core:3.5.4 diff --git a/build.gradle b/build.gradle index f6090f2..fb95669 100644 --- a/build.gradle +++ b/build.gradle @@ -52,19 +52,23 @@ subprojects { useJUnitPlatform() } - var weight = -1; + var buildOrder = -1; afterEvaluate { - if (weight == -1) { - weight = 0 + if (buildOrder == -1) { + buildOrder = 0 } } } tasks.register('buildChain') { - dependsOn subprojects.sort { - a, b -> a.properties.weight <=> b.properties.weight + dependsOn subprojects.sort { a, b -> + def buildOrderA = a.hasProperty('buildOrder') ? a.buildOrder : 0 + def buildOrderB = b.hasProperty('buildOrder') ? b.buildOrder : 0 + + buildOrderA <=> buildOrderB }.collect { ":${it.path}:build" } } + diff --git a/settings.gradle b/settings.gradle index d401c15..7799dc2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,4 +3,5 @@ include 'Patchwork' include 'Datura' include 'Fossil' include 'Corvo' +include 'Obsidian'