From 04264b0ebdff932e970807adc9ad16f410ca2ee7 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 8 Feb 2023 11:30:05 -0500 Subject: [PATCH 1/5] publish: Maven Central resolves #74 --- .github/dependabot.yml | 35 ------------------- .github/workflows/gradle.yml | 4 ++- api/paper/build.gradle.kts | 1 - api/velocity/build.gradle.kts | 3 +- .../authmevelocity.publishing.gradle.kts | 11 +++--- build.gradle.kts | 8 +++++ gradle.properties | 2 +- jitpack.yml | 7 ---- 8 files changed, 20 insertions(+), 51 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 jitpack.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 1e1b343..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,35 +0,0 @@ -# To get started with Dependabot version updates, you'll need to specify which -# package ecosystems to update and where the package manifests are located. -# Please see the documentation for all configuration options: -# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - -version: 2 -updates: - - package-ecosystem: "gradle" - directory: "/" - schedule: - interval: "weekly" - - package-ecosystem: "gradle" - directory: "/api/paper" - schedule: - interval: "weekly" - - package-ecosystem: "gradle" - directory: "/api/velocity" - schedule: - interval: "weekly" - - package-ecosystem: "gradle" - directory: "/velocity" - schedule: - interval: "weekly" - - package-ecosystem: "gradle" - directory: "/paper" - schedule: - interval: "weekly" - - package-ecosystem: "gradle" - directory: "/common" - schedule: - interval: "weekly" - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 94bffa1..ea963e7 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -28,4 +28,6 @@ jobs: uses: actions/upload-artifact@v3 with: name: AuthMeVelocity - path: build/libs/AuthMeVelocity.jar \ No newline at end of file + path: |- + velocity/build/libs/AuthMeVelocity-Velocity-*.jar + paper/build/libs/AuthMeVelocity-Paper-*.jar \ No newline at end of file diff --git a/api/paper/build.gradle.kts b/api/paper/build.gradle.kts index 92df27a..089372a 100644 --- a/api/paper/build.gradle.kts +++ b/api/paper/build.gradle.kts @@ -1,6 +1,5 @@ plugins { `java-library` - alias(libs.plugins.indra) id("authmevelocity.publishing") id("authmevelocity.spotless") } diff --git a/api/velocity/build.gradle.kts b/api/velocity/build.gradle.kts index bdcc68e..aa02e5f 100644 --- a/api/velocity/build.gradle.kts +++ b/api/velocity/build.gradle.kts @@ -1,6 +1,5 @@ plugins { `java-library` - alias(libs.plugins.indra) id("authmevelocity.publishing") id("authmevelocity.spotless") } @@ -24,5 +23,5 @@ tasks { "https://jd.papermc.io/velocity/3.0.0/" ) } - } + } } diff --git a/build-logic/src/main/kotlin/authmevelocity.publishing.gradle.kts b/build-logic/src/main/kotlin/authmevelocity.publishing.gradle.kts index 17e955d..15854b9 100644 --- a/build-logic/src/main/kotlin/authmevelocity.publishing.gradle.kts +++ b/build-logic/src/main/kotlin/authmevelocity.publishing.gradle.kts @@ -13,17 +13,20 @@ indra { gpl3OrLaterLicense() + publishReleasesTo("maven central", "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") + publishSnapshotsTo("sonatype snapshots", "https://s01.oss.sonatype.org/content/repositories/snapshots/") + configurePublications { - groupId = project.group as String - artifactId = project.name.replaceFirst("authmevelocity-", "") - version = project.version as String + artifactId = project.name + from(components["java"]) pom { developers { developer { id.set("4drian3d") - name.set("Adrian") + name.set("Adrian Gonzales") + email.set("adriangonzalesval@gmail.com") } } } diff --git a/build.gradle.kts b/build.gradle.kts index 91f84ba..377bf23 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,7 @@ +plugins { + id("net.kyori.indra.publishing.sonatype") version "3.0.1" +} + allprojects { apply() @@ -5,3 +9,7 @@ allprojects { maven("https://repo.papermc.io/repository/maven-public/") } } + +indraSonatype { + useAlternateSonatypeOSSHost("s01") +} diff --git a/gradle.properties b/gradle.properties index 9cee269..36a82f6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -group = io.github._4drian3d +group = io.github.4drian3d version = 4.0.0-SNAPSHOT description = AuthMeReloaded Support for Velocity url = https://modrinth.com/plugin/authmevelocity diff --git a/jitpack.yml b/jitpack.yml deleted file mode 100644 index e008e7f..0000000 --- a/jitpack.yml +++ /dev/null @@ -1,7 +0,0 @@ -jdk: - - openjdk17 -before_install: - - source "$HOME/.sdkman/bin/sdkman-init.sh" - - sdk update - - sdk install java 17.0.6.tem - - sdk use java 17.0.6.tem \ No newline at end of file From d294957fb762009693431cf0ef015ed2733d0861 Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 3 Mar 2023 15:44:44 -0500 Subject: [PATCH 2/5] publish: Maven Central resolves #74 --- api/paper/build.gradle.kts | 10 +-- api/velocity/build.gradle.kts | 12 +-- .../authmevelocity.publishing.gradle.kts | 85 ++++++++++++++----- build.gradle.kts | 8 -- .../authmevelocity/common/LibsManager.java | 2 +- 5 files changed, 68 insertions(+), 49 deletions(-) diff --git a/api/paper/build.gradle.kts b/api/paper/build.gradle.kts index 089372a..761a4b6 100644 --- a/api/paper/build.gradle.kts +++ b/api/paper/build.gradle.kts @@ -1,14 +1,8 @@ plugins { - `java-library` id("authmevelocity.publishing") id("authmevelocity.spotless") } -java { - withSourcesJar() - withJavadocJar() -} - dependencies { compileOnly(libs.paper) } @@ -18,8 +12,8 @@ tasks { (options as StandardJavadocDocletOptions).run { encoding = Charsets.UTF_8.name() links( - "https://jd.adventure.kyori.net/api/4.11.0/", - "https://jd.adventure.kyori.net/text-minimessage/4.11.0/", + "https://jd.advntr.dev/api/4.12.0/", + "https://jd.advntr.dev/text-minimessage/4.12.0/", "https://jd.papermc.io/paper/1.19/" ) } diff --git a/api/velocity/build.gradle.kts b/api/velocity/build.gradle.kts index aa02e5f..4fbd237 100644 --- a/api/velocity/build.gradle.kts +++ b/api/velocity/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - `java-library` id("authmevelocity.publishing") id("authmevelocity.spotless") } @@ -8,18 +7,13 @@ dependencies { compileOnly(libs.velocity) } -java { - withSourcesJar() - withJavadocJar() -} - tasks { javadoc { - (options as? StandardJavadocDocletOptions)?.run{ + (options as StandardJavadocDocletOptions).run{ encoding = Charsets.UTF_8.name() links( - "https://jd.adventure.kyori.net/api/4.12.0/", - "https://jd.adventure.kyori.net/text-minimessage/4.12.0/", + "https://jd.advntr.dev/api/4.12.0/", + "https://jd.advntr.dev/text-minimessage/4.12.0/", "https://jd.papermc.io/velocity/3.0.0/" ) } diff --git a/build-logic/src/main/kotlin/authmevelocity.publishing.gradle.kts b/build-logic/src/main/kotlin/authmevelocity.publishing.gradle.kts index 15854b9..b21fa73 100644 --- a/build-logic/src/main/kotlin/authmevelocity.publishing.gradle.kts +++ b/build-logic/src/main/kotlin/authmevelocity.publishing.gradle.kts @@ -1,34 +1,73 @@ plugins { - id("net.kyori.indra.publishing") + `java-library` + `maven-publish` + signing } -indra { - javaVersions { - testWith().add(17) - } +java { + withSourcesJar() + withJavadocJar() +} - github("4drian3d", "AuthMeVelocity") { - ci(true) - } +publishing { + publications { + create("mavenJava") { + repositories { + maven { + credentials(PasswordCredentials::class.java) - gpl3OrLaterLicense() + val central = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + val snapshots = "https://s01.oss.sonatype.org/content/repositories/snapshots/" - publishReleasesTo("maven central", "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") - publishSnapshotsTo("sonatype snapshots", "https://s01.oss.sonatype.org/content/repositories/snapshots/") - - configurePublications { - artifactId = project.name - - from(components["java"]) - - pom { - developers { - developer { - id.set("4drian3d") - name.set("Adrian Gonzales") - email.set("adriangonzalesval@gmail.com") + if (project.version.toString().endsWith("SNAPSHOT")) { + name = "SonatypeSnapshots" + setUrl(snapshots) + } else { + name = "OSSRH" + setUrl(central) + } } } + from(components["java"]) + pom { + url.set("https://github.com/4drian3d/AuthMeVelocity") + licenses { + license { + name.set("GNU General Public License version 3 or later") + url.set("https://opensource.org/licenses/GPL-3.0") + } + } + scm { + connection.set("scm:git:https://github.com/4drian3d/AuthMeVelocity.git") + developerConnection.set("scm:git:ssh://git@github.com/4drian3d/AuthMeVelocity.git") + url.set("https://github.com/4drian3d/AuthMeVelocity") + } + developers { + developer { + id.set("4drian3d") + name.set("Adrian Gonzales") + email.set("adriangonzalesval@gmail.com") + } + } + issueManagement { + name.set("GitHub") + url.set("https://github.com/4drian3d/AuthMeVelocity/issues") + } + ciManagement { + name.set("GitHub Actions") + url.set("https://github.com/4drian3d/AuthMeVelocity/actions") + } + name.set(project.name) + description.set(project.description) + url.set("https://github.com/4drian3d/AuthMeVelocity") + } } } } + +signing { + useGpgCmd() + sign(configurations.archives.get()) + sign(publishing.publications["mavenJava"]) +} + diff --git a/build.gradle.kts b/build.gradle.kts index 377bf23..91f84ba 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,3 @@ -plugins { - id("net.kyori.indra.publishing.sonatype") version "3.0.1" -} - allprojects { apply() @@ -9,7 +5,3 @@ allprojects { maven("https://repo.papermc.io/repository/maven-public/") } } - -indraSonatype { - useAlternateSonatypeOSSHost("s01") -} diff --git a/common/src/main/java/io/github/_4drian3d/authmevelocity/common/LibsManager.java b/common/src/main/java/io/github/_4drian3d/authmevelocity/common/LibsManager.java index 862a866..1be0c0b 100644 --- a/common/src/main/java/io/github/_4drian3d/authmevelocity/common/LibsManager.java +++ b/common/src/main/java/io/github/_4drian3d/authmevelocity/common/LibsManager.java @@ -24,7 +24,7 @@ import net.byteflux.libby.relocation.Relocation; public final class LibsManager { private final LibraryManager manager; - public LibsManager(LibraryManager manager) { + public LibsManager(final LibraryManager manager) { this.manager = manager; manager.addMavenCentral(); } From a5000907230273eb15e7b2bce99fc30e9f531e3c Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 3 Mar 2023 15:50:01 -0500 Subject: [PATCH 3/5] fix: removed ignore signed players option Now that my UnSignedVelocity plugin exists, this option is no longer needed --- .../authmevelocity.publishing.gradle.kts | 4 ++-- .../configuration/ProxyConfiguration.java | 14 +------------- .../velocity/listener/ProxyListener.java | 19 ------------------- 3 files changed, 3 insertions(+), 34 deletions(-) diff --git a/build-logic/src/main/kotlin/authmevelocity.publishing.gradle.kts b/build-logic/src/main/kotlin/authmevelocity.publishing.gradle.kts index b21fa73..e9d891c 100644 --- a/build-logic/src/main/kotlin/authmevelocity.publishing.gradle.kts +++ b/build-logic/src/main/kotlin/authmevelocity.publishing.gradle.kts @@ -8,7 +8,7 @@ java { withSourcesJar() withJavadocJar() } - +/* publishing { publications { create("mavenJava") { @@ -70,4 +70,4 @@ signing { sign(configurations.archives.get()) sign(publishing.publications["mavenJava"]) } - +*/ diff --git a/common/src/main/java/io/github/_4drian3d/authmevelocity/common/configuration/ProxyConfiguration.java b/common/src/main/java/io/github/_4drian3d/authmevelocity/common/configuration/ProxyConfiguration.java index 550fd3f..fed867f 100644 --- a/common/src/main/java/io/github/_4drian3d/authmevelocity/common/configuration/ProxyConfiguration.java +++ b/common/src/main/java/io/github/_4drian3d/authmevelocity/common/configuration/ProxyConfiguration.java @@ -24,6 +24,7 @@ import io.github._4drian3d.authmevelocity.common.enums.SendMode; import java.util.List; +@SuppressWarnings("FieldMayBeFinal") @ConfigSerializable public class ProxyConfiguration { @Comment("List of login/registration servers") @@ -128,18 +129,5 @@ public class ProxyConfiguration { public int randomAttempts() { return this.randomAttempts; } - - @Comment(""" - Ignore blocking of commands and chat messages to 1.19.1 clients with a valid signed key - When trying to block these executions, the proxy will kick the player out. - This option allows you to prevent the plugin from trying to block these executions, - avoiding the player to be kicked out""") - private boolean ignoreSignedPlayers = false; - public boolean ignoreSignedPlayers() { - return this.ignoreSignedPlayers; - } } - - - } diff --git a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/ProxyListener.java b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/ProxyListener.java index 293d604..37ef598 100644 --- a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/ProxyListener.java +++ b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/ProxyListener.java @@ -25,7 +25,6 @@ import com.velocitypowered.api.event.command.CommandExecuteEvent; import com.velocitypowered.api.event.connection.DisconnectEvent; import com.velocitypowered.api.event.player.PlayerChatEvent; import com.velocitypowered.api.event.player.TabCompleteEvent; -import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.Player; import io.github._4drian3d.authmevelocity.velocity.AuthMeVelocityPlugin; import io.github._4drian3d.authmevelocity.velocity.utils.AuthMeUtils; @@ -61,12 +60,6 @@ public final class ProxyListener { return; } - if (canBeIgnored(player)) { - plugin.logDebug("CommandExecuteEvent | Ignored signed player"); - continuation.resume(); - return; - } - if (plugin.isInAuthServer(player)) { plugin.logDebug("CommandExecuteEvent | Player is in Auth Server"); String command = AuthMeUtils.getFirstArgument(event.getCommand()); @@ -93,12 +86,6 @@ public final class ProxyListener { plugin.logDebug("PlayerChatEvent | Player is not logged"); - if (canBeIgnored(event.getPlayer())) { - plugin.logDebug("PlayerChatEvent | Ignored signed player"); - continuation.resume(); - return; - } - event.setResult(PlayerChatEvent.ChatResult.denied()); continuation.resume(); } @@ -128,10 +115,4 @@ public final class ProxyListener { } } - boolean canBeIgnored(Player player) { - return player.getIdentifiedKey() != null - && player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_1) >= 0 - && plugin.config().get().advanced().ignoreSignedPlayers(); - } - } From afda8ecbc344bc811321fa7f9c3ed7594b81a38f Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 3 Mar 2023 15:57:43 -0500 Subject: [PATCH 4/5] fix: fixed legacy minecraft version plugin message sending --- .../authmevelocity/velocity/AuthMeVelocityPlugin.java | 7 +++++-- .../velocity/listener/ConnectListener.java | 10 ++++++++-- .../velocity/listener/PluginMessageListener.java | 3 ++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/AuthMeVelocityPlugin.java b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/AuthMeVelocityPlugin.java index 38ce207..d0971bb 100644 --- a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/AuthMeVelocityPlugin.java +++ b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/AuthMeVelocityPlugin.java @@ -28,6 +28,7 @@ import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.ServerConnection; import com.velocitypowered.api.proxy.messages.ChannelIdentifier; +import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; import com.velocitypowered.api.proxy.server.RegisteredServer; import io.github._4drian3d.authmevelocity.api.velocity.AuthMeVelocityAPI; @@ -74,8 +75,10 @@ import java.util.function.Predicate; } ) public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI { - public static final ChannelIdentifier AUTHMEVELOCITY_CHANNEL + public static final ChannelIdentifier MODERN_CHANNEL = MinecraftChannelIdentifier.create("authmevelocity", "main"); + public static final ChannelIdentifier LEGACY_CHANNEL + = new LegacyChannelIdentifier("authmevelocity:main"); @Inject private ProxyServer proxy; @Inject @@ -109,7 +112,7 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI { final int pluginId = 16128; final Metrics metrics = metricsFactory.make(this, pluginId); - proxy.getChannelRegistrar().register(AUTHMEVELOCITY_CHANNEL); + proxy.getChannelRegistrar().register(MODERN_CHANNEL, LEGACY_CHANNEL); List.of( new ProxyListener(this), diff --git a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/ConnectListener.java b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/ConnectListener.java index dee9c9a..3835d7b 100644 --- a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/ConnectListener.java +++ b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/ConnectListener.java @@ -106,8 +106,14 @@ public final class ConnectListener { plugin.logDebug("ServerPostConnectEvent | Already logged player and connected to an Auth server"); final ByteArrayDataOutput buf = ByteStreams.newDataOutput(); buf.writeUTF("LOGIN"); - player.getCurrentServer().ifPresent(sv -> - sv.sendPluginMessage(AuthMeVelocityPlugin.AUTHMEVELOCITY_CHANNEL, buf.toByteArray())); + player.getCurrentServer().ifPresent(sv -> { + var byteArray = buf.toByteArray(); + if (!sv.sendPluginMessage(AuthMeVelocityPlugin.MODERN_CHANNEL, byteArray)) { + plugin.logDebug("ServerPostConnectEvent | Failed to send on Modern Channel"); + var legacyResult = sv.sendPluginMessage(AuthMeVelocityPlugin.LEGACY_CHANNEL, byteArray); + if(!legacyResult) plugin.logDebug("ServerPostConnectEvent | Failed to send on Legacy Channel"); + } + }); } } } diff --git a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/PluginMessageListener.java b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/PluginMessageListener.java index 608b95a..2ca3ead 100644 --- a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/PluginMessageListener.java +++ b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/PluginMessageListener.java @@ -50,7 +50,8 @@ public class PluginMessageListener { public void onPluginMessage(final PluginMessageEvent event, Continuation continuation) { final boolean cancelled = !event.getResult().isAllowed() || !(event.getSource() instanceof ServerConnection) - || !event.getIdentifier().equals(AuthMeVelocityPlugin.AUTHMEVELOCITY_CHANNEL); + || !(event.getIdentifier().equals(AuthMeVelocityPlugin.MODERN_CHANNEL) + || event.getIdentifier().equals(AuthMeVelocityPlugin.LEGACY_CHANNEL)); if (cancelled) { continuation.resume(); plugin.logDebug("PluginMessageEvent | Not allowed"); From 78447227ecfa381f423e0fa07646fa5a70b3fcf3 Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 3 Mar 2023 15:59:17 -0500 Subject: [PATCH 5/5] fix: fixed build logic compilation --- build-logic/build.gradle.kts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 70accc8..0b58780 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -12,7 +12,8 @@ repositories { gradlePluginPortal() } -java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 -} \ No newline at end of file +kotlin { + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(17)) + } +}