diff --git a/.gradle/8.4/checksums/checksums.lock b/.gradle/8.4/checksums/checksums.lock index 21145f43f22d432f1ca21841bfb56896bf25d877..3942d3372ae939e5ae597101d4d0b8f488c77862 100644 Binary files a/.gradle/8.4/checksums/checksums.lock and b/.gradle/8.4/checksums/checksums.lock differ diff --git a/.gradle/8.4/checksums/md5-checksums.bin b/.gradle/8.4/checksums/md5-checksums.bin index 7bd557f6811d1159c5e82a8a9eab8bbc2e08385c..a74fb0a613bf5dc7699173af1dec1127c03887ee 100644 Binary files a/.gradle/8.4/checksums/md5-checksums.bin and b/.gradle/8.4/checksums/md5-checksums.bin differ diff --git a/.gradle/8.4/checksums/sha1-checksums.bin b/.gradle/8.4/checksums/sha1-checksums.bin index d2bb349bb4c258c7fde3ce33a587d8f0ee7296e1..e70aaa0519866fe70e8b71d89506d007449298ea 100644 Binary files a/.gradle/8.4/checksums/sha1-checksums.bin and b/.gradle/8.4/checksums/sha1-checksums.bin differ diff --git a/.gradle/8.4/executionHistory/executionHistory.bin b/.gradle/8.4/executionHistory/executionHistory.bin index 2860b5ad8db1eaaba3ab8a04b4ea20f547e54938..c0adb7d3701d718893089b5939b3c498515ede4f 100644 Binary files a/.gradle/8.4/executionHistory/executionHistory.bin and b/.gradle/8.4/executionHistory/executionHistory.bin differ diff --git a/.gradle/8.4/executionHistory/executionHistory.lock b/.gradle/8.4/executionHistory/executionHistory.lock index 415c1df60e9d29d6c070a84563bd1d8886d27ba5..0cc0a1b93f0288182680b90f1de6da02738b503e 100644 Binary files a/.gradle/8.4/executionHistory/executionHistory.lock and b/.gradle/8.4/executionHistory/executionHistory.lock differ diff --git a/.gradle/8.4/fileHashes/fileHashes.bin b/.gradle/8.4/fileHashes/fileHashes.bin index f9bee2717ce60e5847a0856cc3707a54aa42da19..f61f5bc1d0d74469b25a7b4b2a3566925b70cb6d 100644 Binary files a/.gradle/8.4/fileHashes/fileHashes.bin and b/.gradle/8.4/fileHashes/fileHashes.bin differ diff --git a/.gradle/8.4/fileHashes/fileHashes.lock b/.gradle/8.4/fileHashes/fileHashes.lock index d707fa81aea764b0f0abf00743be7980591f100d..5a24748f2df06d3c1dce38068e01cd1a16261612 100644 Binary files a/.gradle/8.4/fileHashes/fileHashes.lock and b/.gradle/8.4/fileHashes/fileHashes.lock differ diff --git a/.gradle/8.4/fileHashes/resourceHashesCache.bin b/.gradle/8.4/fileHashes/resourceHashesCache.bin index 27c3d972a9477a076e02b67dd685ac17da28e22d..a73b5ca37ebacef4840ee15ac60272a01fc2c155 100644 Binary files a/.gradle/8.4/fileHashes/resourceHashesCache.bin and b/.gradle/8.4/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/8.5/checksums/checksums.lock b/.gradle/8.5/checksums/checksums.lock new file mode 100644 index 0000000000000000000000000000000000000000..2ed3f7b874ad0d38a2c569e1406a271a58940623 Binary files /dev/null and b/.gradle/8.5/checksums/checksums.lock differ diff --git a/.gradle/8.5/checksums/md5-checksums.bin b/.gradle/8.5/checksums/md5-checksums.bin new file mode 100644 index 0000000000000000000000000000000000000000..36e5aa28fc39318ed2097d3643f96a1e39831db4 Binary files /dev/null and b/.gradle/8.5/checksums/md5-checksums.bin differ diff --git a/.gradle/8.5/checksums/sha1-checksums.bin b/.gradle/8.5/checksums/sha1-checksums.bin new file mode 100644 index 0000000000000000000000000000000000000000..e36890910cd3f830572ee00935774e8a5c3a77a3 Binary files /dev/null and b/.gradle/8.5/checksums/sha1-checksums.bin differ diff --git a/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock b/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000000000000000000000000000000000000..2ad19c34b92cfd7dcd44377dd3894f8b37684f41 Binary files /dev/null and b/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock differ diff --git a/.gradle/8.5/dependencies-accessors/gc.properties b/.gradle/8.5/dependencies-accessors/gc.properties new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.gradle/8.5/executionHistory/executionHistory.bin b/.gradle/8.5/executionHistory/executionHistory.bin new file mode 100644 index 0000000000000000000000000000000000000000..f495bf53736d6effc70a31a152f14f0448412883 Binary files /dev/null and b/.gradle/8.5/executionHistory/executionHistory.bin differ diff --git a/.gradle/8.5/executionHistory/executionHistory.lock b/.gradle/8.5/executionHistory/executionHistory.lock new file mode 100644 index 0000000000000000000000000000000000000000..b67f2216c4b360d569f5847ae35247ecc8594c5b Binary files /dev/null and b/.gradle/8.5/executionHistory/executionHistory.lock differ diff --git a/.gradle/8.5/fileChanges/last-build.bin b/.gradle/8.5/fileChanges/last-build.bin new file mode 100644 index 0000000000000000000000000000000000000000..f76dd238ade08917e6712764a16a22005a50573d Binary files /dev/null and b/.gradle/8.5/fileChanges/last-build.bin differ diff --git a/.gradle/8.5/fileHashes/fileHashes.bin b/.gradle/8.5/fileHashes/fileHashes.bin new file mode 100644 index 0000000000000000000000000000000000000000..ad9f282d767d0244be25347833bc891bb5be57cd Binary files /dev/null and b/.gradle/8.5/fileHashes/fileHashes.bin differ diff --git a/.gradle/8.5/fileHashes/fileHashes.lock b/.gradle/8.5/fileHashes/fileHashes.lock new file mode 100644 index 0000000000000000000000000000000000000000..03070e4a75b608ad66abb0dd711f6634383175b5 Binary files /dev/null and b/.gradle/8.5/fileHashes/fileHashes.lock differ diff --git a/.gradle/8.5/fileHashes/resourceHashesCache.bin b/.gradle/8.5/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000000000000000000000000000000000000..4867ff4916198c6a42a973f2b964a6481369c901 Binary files /dev/null and b/.gradle/8.5/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/8.5/gc.properties b/.gradle/8.5/gc.properties new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index b2026c4464da2a06ca3dd2d4a58874c2be6c25c9..536468c34cfdbba84062b026f2b5a819a34e2d58 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties index f38e7afc381444d61109f621345130a09c80cc6a..4fcfcd40f92bbe5f9e6661963f6e44c95146aaf6 100644 --- a/.gradle/buildOutputCleanup/cache.properties +++ b/.gradle/buildOutputCleanup/cache.properties @@ -1,2 +1,2 @@ -#Tue Feb 20 19:28:11 CET 2024 -gradle.version=8.4 +#Mon Mar 04 19:32:03 CET 2024 +gradle.version=8.5 diff --git a/.idea/compiler.xml b/.idea/compiler.xml index b2775cf687d8855c2f2cbbed30dc7b331187759f..c080663e86d6d64f97fb1df870013848e7a53fff 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -5,7 +5,7 @@ <profile name="Gradle Imported" enabled="true"> <outputRelativeToContentRoot value="true" /> <processorPath useClasspath="false"> - <entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.velocitypowered/velocity-api/3.3.0-SNAPSHOT/8059f7df2108d84ea9cdca685c57214cac31fb83/velocity-api-3.3.0-SNAPSHOT.jar" /> + <entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.velocitypowered/velocity-api/3.3.0-SNAPSHOT/9859cf46f3041294b10fd8554f4f950f0bf739c4/velocity-api-3.3.0-SNAPSHOT.jar" /> <entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.moandjiezana.toml/toml4j/0.7.2/a03337911d0bd2c40932aca3946edb30d0e7d0c/toml4j-0.7.2.jar" /> <entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.spongepowered/configurate-gson/4.1.2/3e5c7a0ea73e95ce6139fa72f1b6d36eb531ab81/configurate-gson-4.1.2.jar" /> <entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/net.kyori/adventure-text-logger-slf4j/4.16.0/a2e7eadb8d26481fb3da619a761cf3a47a1da43f/adventure-text-logger-slf4j-4.16.0.jar" /> @@ -46,6 +46,6 @@ <module name="PixelcampusProxy.main" /> </profile> </annotationProcessing> - <bytecodeTargetLevel target="17" /> + <bytecodeTargetLevel target="21" /> </component> </project> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index fe0b0daba3685a9869f4eefd652f61d798561ef7..f16dea79be7fe2ee579dca95f5ff94749545a30a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,7 +4,7 @@ <component name="FrameworkDetectionExcludesConfiguration"> <file type="web" url="file://$PROJECT_DIR$" /> </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/out" /> </component> </project> \ No newline at end of file diff --git a/build.gradle b/build.gradle index d822feab918aece047687a1b58ab768c7be5637a..4ba3beae7437f9d7771f77e8d6a5a2739bdd6c27 100644 --- a/build.gradle +++ b/build.gradle @@ -16,12 +16,27 @@ repositories { } dependencies { + implementation("io.javalin:javalin:6.1.3") implementation('org.spongepowered:configurate-hocon:4.0.0') compileOnly("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT") annotationProcessor("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT") + implementation("com.fasterxml.jackson.core:jackson-databind:2.16.1") } -def targetJavaVersion = 17 +jar { + duplicatesStrategy = 'exclude' + + manifest{ + attributes 'Main-Class' : 'org.fsi.pixelcampusproxy.PixelcampusProxy' + } + + from(configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }) { + exclude 'META-INF/**' + } +} + +def targetJavaVersion = 21 + java { def javaVersion = JavaVersion.toVersion(targetJavaVersion) sourceCompatibility = javaVersion @@ -29,7 +44,7 @@ java { if (JavaVersion.current() < javaVersion) { toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) } - toolchain.languageVersion.set(JavaLanguageVersion.of(17)) + } tasks.withType(JavaCompile).configureEach { diff --git a/build/classes/java/main/API/PixelcampusProxyApiService.class b/build/classes/java/main/API/PixelcampusProxyApiService.class new file mode 100644 index 0000000000000000000000000000000000000000..a8bfadd4e4b2e4477a6e96259acd5fbad11a7de1 Binary files /dev/null and b/build/classes/java/main/API/PixelcampusProxyApiService.class differ diff --git a/build/classes/java/main/CommandDisable/CommandDisable.class b/build/classes/java/main/CommandDisable/CommandDisable.class deleted file mode 100644 index 60bfcee106bd74a140ea016ea0d619c30faa6aad..0000000000000000000000000000000000000000 Binary files a/build/classes/java/main/CommandDisable/CommandDisable.class and /dev/null differ diff --git a/build/classes/java/main/HubCommand/HubCommand.class b/build/classes/java/main/HubCommand/HubCommand.class index 71388a72025c55ec9bfd74b557adfe84ea6cf7c1..13a6dd58ae44042b7db382525ea3de4debf35284 100644 Binary files a/build/classes/java/main/HubCommand/HubCommand.class and b/build/classes/java/main/HubCommand/HubCommand.class differ diff --git a/build/classes/java/main/org/fsi/pixelcampusproxy/BuildConstants.class b/build/classes/java/main/org/fsi/pixelcampusproxy/BuildConstants.class index 052261a6e11f70ed85fe65572c5ab4ee43cce7dd..394cb07d4e8e7f8ca325cce81c9f9ad822a78ce2 100644 Binary files a/build/classes/java/main/org/fsi/pixelcampusproxy/BuildConstants.class and b/build/classes/java/main/org/fsi/pixelcampusproxy/BuildConstants.class differ diff --git a/build/classes/java/main/org/fsi/pixelcampusproxy/PixelcampusProxy.class b/build/classes/java/main/org/fsi/pixelcampusproxy/PixelcampusProxy.class index befd271b0a8290a0816debb8973c6a53acb5ce25..66f6fff5a63c6cdccbf0d23f48f1def59fb2f654 100644 Binary files a/build/classes/java/main/org/fsi/pixelcampusproxy/PixelcampusProxy.class and b/build/classes/java/main/org/fsi/pixelcampusproxy/PixelcampusProxy.class differ diff --git a/build/libs/PixelcampusProxy-1.0.jar b/build/libs/PixelcampusProxy-1.0.jar index bda558d61707d33dced8f1274726704fc174d71d..cf6076ed1522b32d72b34014cf56d59b23e1362b 100644 Binary files a/build/libs/PixelcampusProxy-1.0.jar and b/build/libs/PixelcampusProxy-1.0.jar differ diff --git a/build/tmp/.cache/expanded.lock b/build/tmp/.cache/expanded.lock new file mode 100644 index 0000000000000000000000000000000000000000..610b1fdfab85fbe6794bb1dc2b460c03f660d7d2 Binary files /dev/null and b/build/tmp/.cache/expanded.lock differ diff --git a/build/tmp/.cache/expanded/expanded.lock b/build/tmp/.cache/expanded/expanded.lock new file mode 100644 index 0000000000000000000000000000000000000000..1efdf97ccac532df38096e45fe79288be858ce51 Binary files /dev/null and b/build/tmp/.cache/expanded/expanded.lock differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index dbed214889e96173708e9b9b060a62143d50cf59..e0c502fbec2e969955477825ca4b904726e886ad 100644 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/build/tmp/jar/MANIFEST.MF b/build/tmp/jar/MANIFEST.MF index 59499bce4a2bd51cba227b7c00fcf745b19c95a4..f7f675cf74092bf1cae92d09c45e8751457899d0 100644 --- a/build/tmp/jar/MANIFEST.MF +++ b/build/tmp/jar/MANIFEST.MF @@ -1,2 +1,3 @@ Manifest-Version: 1.0 +Main-Class: org.fsi.pixelcampusproxy.PixelcampusProxy diff --git a/gradle.properties b/gradle.properties index a8390783af149e4c3243c3f97be11bfaec19c04e..0536f341dbcb9b581d6be40c3cddd51d8a7ee173 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -javaVersion=11 +javaVersion=21 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135c49b765f8051ef9d0a6055ff8e46073d8..d64cd4917707c1f8861d8cb53dd15194d4248596 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3fa8f862f753336d4fabfd607678a7a2317e8a06..1af9e0930b89b3294ea6a195f0808aafd36fafe8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/out/artifacts/unnamed/unnamed.jar b/out/artifacts/unnamed/unnamed.jar new file mode 100644 index 0000000000000000000000000000000000000000..8ada997a310b24679ad5c1be82a895d23119352b Binary files /dev/null and b/out/artifacts/unnamed/unnamed.jar differ diff --git a/src/main/java/API/PixelcampusProxyApiService.java b/src/main/java/API/PixelcampusProxyApiService.java new file mode 100644 index 0000000000000000000000000000000000000000..1e02dabe3a8ed019ee240ae37743e35f2c71a684 --- /dev/null +++ b/src/main/java/API/PixelcampusProxyApiService.java @@ -0,0 +1,61 @@ +package API; + + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.server.RegisteredServer; +import org.fsi.pixelcampusproxy.PixelcampusProxy; + +import java.util.concurrent.ExecutionException; + +public class PixelcampusProxyApiService { + + public static String getOnlinePlayers(){ + + JsonArray onlinePlayers = new JsonArray(); + JsonObject player; + + for (Player p : PixelcampusProxy.getProxy().getAllPlayers()) { + + + player = new JsonObject(); + player.addProperty("name",p.getUsername()); + player.addProperty("uuid",p.getUniqueId().toString()); + player.addProperty("server",p.getCurrentServer().get().getServer().getServerInfo().getName()); + player.addProperty("ping",p.getPing()); + player.addProperty("client",p.getClientBrand()); + player.addProperty("ip",p.getRemoteAddress().toString()); + + onlinePlayers.add(player); + } + + return onlinePlayers.toString(); + } + + public static String getNetworkServers(){ + + JsonArray networkServers = new JsonArray(); + JsonObject server; + + for (RegisteredServer s : PixelcampusProxy.getProxy().getAllServers()) { + + + server = new JsonObject(); + server.addProperty("name",s.getServerInfo().getName()); + server.addProperty("online",s.getPlayersConnected().size()); + try { + server.addProperty("max",s.ping().get().getPlayers().get().getMax()); + server.addProperty("version", s.ping().get().getVersion().getName()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } catch (ExecutionException e) { + throw new RuntimeException(e); + } + + networkServers.add(server); + } + + return networkServers.toString(); + } +} diff --git a/src/main/java/org/fsi/pixelcampusproxy/PixelcampusProxy.java b/src/main/java/org/fsi/pixelcampusproxy/PixelcampusProxy.java index f60a280d6764a18b29a2c9ed79ba05c2bbc67cab..6a7f4c0d0f94fd55e2f564ffce8817247cb0ac42 100644 --- a/src/main/java/org/fsi/pixelcampusproxy/PixelcampusProxy.java +++ b/src/main/java/org/fsi/pixelcampusproxy/PixelcampusProxy.java @@ -1,5 +1,6 @@ package org.fsi.pixelcampusproxy; +import API.PixelcampusProxyApiService; import HubCommand.HubCommand; import com.google.inject.Inject; import com.velocitypowered.api.command.CommandManager; @@ -9,6 +10,7 @@ import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.proxy.ProxyServer; +import io.javalin.Javalin; import org.slf4j.Logger; @Plugin( @@ -35,6 +37,14 @@ public class PixelcampusProxy { @Subscribe public void onProxyInitialization(ProxyInitializeEvent event) { + //Proxy API + Javalin.create(/*config*/) + .get("/players", ctx -> ctx.json(PixelcampusProxyApiService.getOnlinePlayers())) + .get("/servers", ctx -> ctx.json(PixelcampusProxyApiService.getNetworkServers())) + .start(7070); + + + //hub command CommandManager commandManager = proxy.getCommandManager(); CommandMeta commandMeta = commandManager.metaBuilder("hub") .aliases("lobby", "l")