From 9ae4ee76cfca574f20866519f02b7876c970be18 Mon Sep 17 00:00:00 2001 From: RedGuy Date: Thu, 19 Dec 2024 17:12:04 +0300 Subject: [PATCH] update --- .github/workflows/gradle.yml | 4 ++-- README.md | 2 +- api/paper/build.gradle.kts | 1 + .../api/paper/event/LoginByProxyEvent.java | 2 +- .../api/paper/event/PreSendLoginEvent.java | 7 +++++- build-logic/build.gradle.kts | 2 +- build.gradle.kts | 4 ++-- gradle/libs.versions.toml | 20 ++++++++-------- paper/build.gradle.kts | 9 +++++--- .../paper/AuthMePlaceholders.java | 2 +- .../paper/AuthMeVelocityBootstrap.java | 14 +---------- .../paper/AuthMeVelocityPlugin.java | 23 +++++++++++++++---- .../paper/listeners/AuthMeListener.java | 8 +++---- .../{paper-plugin.yml => plugin.yml} | 2 +- settings.gradle.kts | 1 + velocity/build.gradle.kts | 2 -- 16 files changed, 57 insertions(+), 46 deletions(-) rename paper/src/main/resources/{paper-plugin.yml => plugin.yml} (96%) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index a2f55ee..8a70729 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -10,10 +10,10 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 16 uses: actions/setup-java@v4 with: - java-version: 17 + java-version: 16 distribution: 'temurin' cache: 'gradle' diff --git a/README.md b/README.md index e9c702b..f715c84 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This plugin adds the support for [Velocity](https://velocitypowered.com/) to [Au ## Requirements - Paper or Folia 1.20+ - Velocity 3.3.0+ -- Java 17+ +- Java 16+ ## Features - Prevent your players from executing commands or typing in the chat before they are logged in diff --git a/api/paper/build.gradle.kts b/api/paper/build.gradle.kts index ca17b0a..247e40e 100644 --- a/api/paper/build.gradle.kts +++ b/api/paper/build.gradle.kts @@ -5,6 +5,7 @@ plugins { dependencies { compileOnly(libs.paper) + compileOnly(libs.annotations) } tasks { diff --git a/api/paper/src/main/java/io/github/_4drian3d/authmevelocity/api/paper/event/LoginByProxyEvent.java b/api/paper/src/main/java/io/github/_4drian3d/authmevelocity/api/paper/event/LoginByProxyEvent.java index 51c448b..c173546 100644 --- a/api/paper/src/main/java/io/github/_4drian3d/authmevelocity/api/paper/event/LoginByProxyEvent.java +++ b/api/paper/src/main/java/io/github/_4drian3d/authmevelocity/api/paper/event/LoginByProxyEvent.java @@ -37,7 +37,7 @@ public final class LoginByProxyEvent extends PlayerEvent { * @param who the player to be logged in */ public LoginByProxyEvent(@NotNull Player who) { - super(who, !Bukkit.isPrimaryThread()); + super(who); } @Override diff --git a/api/paper/src/main/java/io/github/_4drian3d/authmevelocity/api/paper/event/PreSendLoginEvent.java b/api/paper/src/main/java/io/github/_4drian3d/authmevelocity/api/paper/event/PreSendLoginEvent.java index 0cdb017..f2e93d5 100644 --- a/api/paper/src/main/java/io/github/_4drian3d/authmevelocity/api/paper/event/PreSendLoginEvent.java +++ b/api/paper/src/main/java/io/github/_4drian3d/authmevelocity/api/paper/event/PreSendLoginEvent.java @@ -37,7 +37,7 @@ public final class PreSendLoginEvent extends PlayerEvent implements Cancellable * @param player the player to be sent */ public PreSendLoginEvent(@NotNull Player player) { - super(player, !Bukkit.isPrimaryThread()); + super(player); } @Override @@ -50,6 +50,11 @@ public final class PreSendLoginEvent extends PlayerEvent implements Cancellable this.isCancelled = cancelled; } + public boolean callEvent() { + Bukkit.getPluginManager().callEvent(this); + return !isCancelled(); + } + @Override public @NotNull HandlerList getHandlers() { return HANDLERS; diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 0b58780..467f71c 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -14,6 +14,6 @@ repositories { kotlin { jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(16)) } } diff --git a/build.gradle.kts b/build.gradle.kts index 87a7e9c..b345283 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,10 +3,10 @@ allprojects { tasks.withType { options.encoding = Charsets.UTF_8.name() - options.release.set(17) + options.release.set(16) } configure { - toolchain.languageVersion.set(JavaLanguageVersion.of(17)) + toolchain.languageVersion.set(JavaLanguageVersion.of(16)) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9ede96f..5da08b7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,9 +2,9 @@ metadata.format.version = "1.1" [versions] -velocity = "3.3.0-SNAPSHOT" -paper = "1.20.4-R0.1-SNAPSHOT" -miniplaceholders = "2.2.3" +velocity = "3.1.0" +spigot = "1.16.5-R0.1-SNAPSHOT" +miniplaceholders = "2.0.0" fastlogin = "1.12-SNAPSHOT" authme = "5.6.0" libby = "1.3.1" @@ -12,13 +12,14 @@ pluginyml = "0.6.0" bstats = "3.0.3" shadow = "8.1.1" configurate = "4.1.2" -adventure = "4.17.0" +adventure = "4.11.0" blossom = "2.1.0" geantyref = "1.3.13" indra = "3.1.3" runtask = "2.3.1" -vpacketevents = "1.1.0" +vpacketevents = "1.0.1" luckperms = "5.4" +annotations = "26.0.1" # Test versions assertj = "3.26.3" @@ -26,19 +27,18 @@ assertj = "3.26.3" [libraries] adventure = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" } +minimessage = { group = "net.kyori", name = "adventure-text-minimessage", version.ref = "adventure" } +logger-slf4j = { group = "net.kyori", name = "adventure-text-logger-slf4j", version.ref = "adventure" } -paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" } +paper = { group = "org.spigotmc", name = "spigot-api", version.ref = "spigot" } velocity-api = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" } -velocity-proxy = { group = "com.velocitypowered", name = "velocity-proxy", version.ref = "velocity" } authme = { module = "fr.xephi:authme", version.ref = "authme" } libby-core = { group = "net.byteflux", name = "libby-core", version.ref = "libby" } libby-bukkit = { group = "net.byteflux", name = "libby-bukkit", version.ref = "libby" } -libby-paper = { group = "net.byteflux", name = "libby-paper", version.ref = "libby" } libby-velocity = { group = "net.byteflux", name = "libby-velocity", version.ref = "libby" } miniplaceholders = { group = "io.github.miniplaceholders", name = "miniplaceholders-api", version.ref = "miniplaceholders" } -vpacketevents = { group = "io.github.4drian3d", name = "vpacketevents-api", version.ref = "vpacketevents" } luckperms = { module = "net.luckperms:api", version.ref = "luckperms" } fastlogin-velocity = { group = "com.github.games647", name = "fastlogin.velocity", version.ref = "fastlogin" } @@ -52,6 +52,8 @@ plugin-shadow = { group = "com.github.johnrengelman", name = "shadow", version.r assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" } +annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" } + [plugins] pluginyml-bukkit = { id = "net.minecrell.plugin-yml.bukkit", version.ref = "pluginyml" } diff --git a/paper/build.gradle.kts b/paper/build.gradle.kts index e56913e..3fbb399 100644 --- a/paper/build.gradle.kts +++ b/paper/build.gradle.kts @@ -12,8 +12,11 @@ dependencies { implementation(projects.authmevelocityCommon) implementation(projects.authmevelocityApiPaper) + implementation(libs.minimessage) + implementation(libs.logger.slf4j) + implementation(libs.adventure) - implementation(libs.libby.paper) + implementation(libs.libby.bukkit) } tasks { @@ -29,10 +32,10 @@ tasks { dependsOn(shadowJar) } runServer { - minecraftVersion("1.20.4") + minecraftVersion("1.16.5") } processResources { - filesMatching("paper-plugin.yml") { + filesMatching("plugin.yml") { expand("version" to project.version) } } diff --git a/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/AuthMePlaceholders.java b/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/AuthMePlaceholders.java index f560db1..f11944f 100644 --- a/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/AuthMePlaceholders.java +++ b/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/AuthMePlaceholders.java @@ -31,7 +31,7 @@ final class AuthMePlaceholders { static Expansion getExpansion() { return Expansion.builder("authme") - .filter(Player.class) + .filter((s) -> s instanceof Player) .audiencePlaceholder("is_logged", (aud, queue, ctx) -> Tag.selfClosingInserting(AuthMeApi.getInstance().isAuthenticated((Player)aud) ? TRUE_COMPONENT diff --git a/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/AuthMeVelocityBootstrap.java b/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/AuthMeVelocityBootstrap.java index 5b03390..3dce787 100644 --- a/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/AuthMeVelocityBootstrap.java +++ b/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/AuthMeVelocityBootstrap.java @@ -17,21 +17,9 @@ package io.github._4drian3d.authmevelocity.paper; -import io.papermc.paper.plugin.bootstrap.BootstrapContext; -import io.papermc.paper.plugin.bootstrap.PluginBootstrap; -import io.papermc.paper.plugin.bootstrap.PluginProviderContext; import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; @SuppressWarnings("all") -public class AuthMeVelocityBootstrap implements PluginBootstrap { - @Override - public void bootstrap(@NotNull BootstrapContext context) { +public class AuthMeVelocityBootstrap extends JavaPlugin { - } - - @Override - public @NotNull JavaPlugin createPlugin(@NotNull PluginProviderContext context) { - return new AuthMeVelocityPlugin(context.getDataDirectory()); - } } diff --git a/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/AuthMeVelocityPlugin.java b/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/AuthMeVelocityPlugin.java index 1d1b426..263804d 100644 --- a/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/AuthMeVelocityPlugin.java +++ b/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/AuthMeVelocityPlugin.java @@ -19,21 +19,29 @@ package io.github._4drian3d.authmevelocity.paper; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; +import com.google.common.reflect.ClassPath; import io.github._4drian3d.authmevelocity.common.LibsManager; import io.github._4drian3d.authmevelocity.common.MessageType; import io.github._4drian3d.authmevelocity.common.configuration.ConfigurationContainer; import io.github._4drian3d.authmevelocity.common.configuration.PaperConfiguration; import io.github._4drian3d.authmevelocity.paper.listeners.AuthMeListener; import io.github._4drian3d.authmevelocity.paper.listeners.MessageListener; +import net.byteflux.libby.BukkitLibraryManager; import net.byteflux.libby.LibraryManager; -import net.byteflux.libby.PaperLibraryManager; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.logger.slf4j.ComponentLogger; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.nio.file.Path; +import java.util.Set; +import java.util.stream.Collectors; import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage; @@ -43,14 +51,14 @@ public final class AuthMeVelocityPlugin extends JavaPlugin { private ComponentLogger componentLogger; private ConfigurationContainer config; - public AuthMeVelocityPlugin(final Path dataFolder) { - this.dataFolder = dataFolder; + public AuthMeVelocityPlugin() { + this.dataFolder = getDataFolder().toPath(); } @Override public void onEnable() { - this.componentLogger = getComponentLogger(); - final LibraryManager libraryManager = new PaperLibraryManager(this); + this.componentLogger = ComponentLogger.logger(); + final LibraryManager libraryManager = new BukkitLibraryManager(this); new LibsManager(libraryManager).loadLibraries(); try { @@ -71,6 +79,11 @@ public final class AuthMeVelocityPlugin extends JavaPlugin { AuthMePlaceholders.getExpansion().register(); } + Set> classes; + String packageName = "net.kyori.adventure.text"; + + Class c = Component.class; + componentLogger.info(miniMessage().deserialize("AuthMeVelocity enabled")); } diff --git a/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/listeners/AuthMeListener.java b/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/listeners/AuthMeListener.java index f3034ba..4b54263 100644 --- a/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/listeners/AuthMeListener.java +++ b/paper/src/main/java/io/github/_4drian3d/authmevelocity/paper/listeners/AuthMeListener.java @@ -40,12 +40,12 @@ public final class AuthMeListener implements Listener { final Player player = event.getPlayer(); plugin.logDebug("LoginEvent | Start"); - plugin.getServer().getAsyncScheduler().runDelayed(plugin, task -> { + plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, task -> { if (new PreSendLoginEvent(player).callEvent()) { plugin.sendMessageToProxy(player, MessageType.LOGIN, player.getName()); plugin.logDebug("LoginEvent | PreSendLoginEvent allowed"); } - }, 1, TimeUnit.SECONDS); + }, 20); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -53,12 +53,12 @@ public final class AuthMeListener implements Listener { final Player player = event.getPlayer(); plugin.logDebug("RestoreSessionEvent | Start"); - plugin.getServer().getAsyncScheduler().runDelayed(plugin, task -> { + plugin.getServer().getScheduler().runTaskLater(plugin, task -> { if (new PreSendLoginEvent(player).callEvent()) { plugin.sendMessageToProxy(player, MessageType.LOGIN, player.getName()); plugin.logDebug("RestoreSessionEvent | PreSendLoginEvent allowed"); } - }, 1, TimeUnit.SECONDS); + }, 20); } @EventHandler diff --git a/paper/src/main/resources/paper-plugin.yml b/paper/src/main/resources/plugin.yml similarity index 96% rename from paper/src/main/resources/paper-plugin.yml rename to paper/src/main/resources/plugin.yml index 71391c5..462970d 100644 --- a/paper/src/main/resources/paper-plugin.yml +++ b/paper/src/main/resources/plugin.yml @@ -7,7 +7,7 @@ authors: - xQuickGlare - 4drian3d website: https://modrinth.com/plugin/authmevelocity -api-version: '1.20' +api-version: '1.16' folia-supported: true dependencies: server: diff --git a/settings.gradle.kts b/settings.gradle.kts index 31e1afc..235cde4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -39,5 +39,6 @@ dependencyResolutionManagement { includeGroup("net.byteflux") } } + mavenCentral() } } diff --git a/velocity/build.gradle.kts b/velocity/build.gradle.kts index 0f7b04f..e980d00 100644 --- a/velocity/build.gradle.kts +++ b/velocity/build.gradle.kts @@ -6,12 +6,10 @@ plugins { dependencies { compileOnly(libs.velocity.api) - compileOnly(libs.velocity.proxy) annotationProcessor(libs.velocity.api) compileOnly(libs.miniplaceholders) compileOnly(libs.fastlogin.velocity) - compileOnly(libs.vpacketevents) compileOnly(libs.luckperms) implementation(projects.authmevelocityCommon)