diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a7c31d..4aedf09 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,10 +16,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set up JDK 22 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: - java-version: '22' + java-version: '21' distribution: 'temurin' cache: gradle diff --git a/build.gradle b/build.gradle index bf75586..da513e9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,10 @@ plugins { id 'java' id 'eclipse' - id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.8' - id("xyz.jpenilla.run-velocity") version "2.3.1" + id 'org.jetbrains.gradle.plugin.idea-ext' version '1.4.1' + id("xyz.jpenilla.run-velocity") version "3.0.2" - id 'com.github.johnrengelman.shadow' version '8.1.1' + id 'com.gradleup.shadow' version '9.6.1' } group = 'org.lby123165' @@ -17,12 +17,12 @@ repositories { url = "https://repo.papermc.io/repository/maven-public/" } maven { - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/easybot-team/easybot-bridge") - credentials { - username = System.getenv("GITHUB_ACTOR") ?: project.findProperty("gpr.user") - password = System.getenv("GITHUB_TOKEN") ?: project.findProperty("gpr.key") - } + name = "Jitpack" + url = "https://www.jitpack.io" + } + maven { + name = "GeyserMC" + url = "https://repo.opencollab.dev/main/" } } @@ -30,12 +30,13 @@ dependencies { compileOnly("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT") annotationProcessor("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT") - implementation('com.springwater.easybot:easybot-bridge:1.7.1') { + implementation('com.github.easybot-team:easybot-bridge:1.7.1') { exclude group: 'com.google.code.gson', module: 'gson' exclude group: 'org.slf4j', module: 'slf4j-api' exclude group: 'org.projectlombok', module: 'lombok' } - + + compileOnly("io.github.4drian3d:authmevelocity-api-velocity:4.3.0") compileOnly(fileTree('libs')) implementation 'org.java-websocket:Java-WebSocket:1.5.3' @@ -61,9 +62,9 @@ tasks { } } -def targetJavaVersion = 17 +def targetJavaVersion = 21 java { - toolchain.languageVersion = JavaLanguageVersion.of(22) + toolchain.languageVersion = JavaLanguageVersion.of(21) } tasks.withType(JavaCompile).configureEach { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a441313..59d1379 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ +#Sun Aug 02 23:14:39 CST 2026 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip -networkTimeout=10000 -validateDistributionUrl=true +distributionUrl=https\://mirrors.aliyun.com/gradle/distributions/v9.3.0/gradle-9.3.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/org/lby123165/easyBotVelocity/EasyBotVelocity.java b/src/main/java/org/lby123165/easyBotVelocity/EasyBotVelocity.java index 07edd44..f531af8 100644 --- a/src/main/java/org/lby123165/easyBotVelocity/EasyBotVelocity.java +++ b/src/main/java/org/lby123165/easyBotVelocity/EasyBotVelocity.java @@ -24,7 +24,8 @@ authors = {"lby123165", "MiuxuE"}, dependencies = { @Dependency(id = "librelogin", optional = true), - @Dependency(id = "limboauth", optional = true) + @Dependency(id = "limboauth", optional = true), + @Dependency(id = "authmevelocity", optional = true) } ) diff --git a/src/main/java/org/lby123165/easyBotVelocity/VelocityBridgeBehavior.java b/src/main/java/org/lby123165/easyBotVelocity/VelocityBridgeBehavior.java index e3b6e1d..da2a44e 100644 --- a/src/main/java/org/lby123165/easyBotVelocity/VelocityBridgeBehavior.java +++ b/src/main/java/org/lby123165/easyBotVelocity/VelocityBridgeBehavior.java @@ -2,18 +2,14 @@ import com.springwater.easybot.bridge.BridgeBehavior; import com.springwater.easybot.bridge.message.Segment; -import com.springwater.easybot.bridge.message.TextSegment; import com.springwater.easybot.bridge.model.PlayerInfo; import com.springwater.easybot.bridge.model.ServerInfo; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ProxyServer; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.ComponentBuilder; import net.kyori.adventure.text.TextComponent; -import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.lby123165.easyBotVelocity.sender.EasyBotCommandSender; import org.lby123165.easyBotVelocity.utils.*; -import org.slf4j.Logger; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -109,6 +105,9 @@ public boolean isAuthenticated(String playerName) { if (LibreLoginUtils.hasLiberLogin()) { return LibreLoginUtils.isAuthenticated(player.get()); } + if (AuthMeVcUtils.hasAuthMeVelocity()) { + return AuthMeVcUtils.isAuthenticated(player.get()); + } return true; } diff --git a/src/main/java/org/lby123165/easyBotVelocity/utils/AuthMeVcUtils.java b/src/main/java/org/lby123165/easyBotVelocity/utils/AuthMeVcUtils.java new file mode 100644 index 0000000..c5d7748 --- /dev/null +++ b/src/main/java/org/lby123165/easyBotVelocity/utils/AuthMeVcUtils.java @@ -0,0 +1,29 @@ +package org.lby123165.easyBotVelocity.utils; + +import com.velocitypowered.api.proxy.Player; +import io.github._4drian3d.authmevelocity.api.velocity.AuthMeVelocityAPI; +import org.jetbrains.annotations.Nullable; +import org.lby123165.easyBotVelocity.EasyBotVelocity; + +public class AuthMeVcUtils { + private static @Nullable AuthMeVelocityAPI authMeVelocityAPI = null; + + public static boolean hasAuthMeVelocity() { + return EasyBotVelocity.getInstance().getServer().getPluginManager().isLoaded("authmevelocity"); + } + + public static AuthMeVelocityAPI getAuthMeVelocityAPI() { + if (authMeVelocityAPI == null) { + authMeVelocityAPI = (AuthMeVelocityAPI) EasyBotVelocity.getInstance().getServer().getPluginManager().getPlugin("authmevelocity").orElseThrow().getInstance().orElseThrow(); + } + return authMeVelocityAPI; + } + + @SuppressWarnings("unchecked") + public static boolean isAuthenticated(Player proxyPlayer) { + if (!hasAuthMeVelocity()) { + return true; + } + return getAuthMeVelocityAPI().isLogged(proxyPlayer); + } +}