Compare commits

..

No commits in common. "9ae4ee76cfca574f20866519f02b7876c970be18" and "ccd2903de8f069c3a8e16d92c291364c983b78f9" have entirely different histories.

21 changed files with 61 additions and 70 deletions

View File

@ -10,10 +10,10 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up JDK 16
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 16
java-version: 17
distribution: 'temurin'
cache: 'gradle'

View File

@ -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 16+
- Java 17+
## Features
- Prevent your players from executing commands or typing in the chat before they are logged in

View File

@ -5,7 +5,6 @@ plugins {
dependencies {
compileOnly(libs.paper)
compileOnly(libs.annotations)
}
tasks {

View File

@ -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);
super(who, !Bukkit.isPrimaryThread());
}
@Override

View File

@ -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);
super(player, !Bukkit.isPrimaryThread());
}
@Override
@ -50,11 +50,6 @@ 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;

View File

@ -14,6 +14,6 @@ repositories {
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(16))
languageVersion.set(JavaLanguageVersion.of(17))
}
}

View File

@ -3,10 +3,10 @@ allprojects {
tasks.withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name()
options.release.set(16)
options.release.set(17)
}
configure<JavaPluginExtension> {
toolchain.languageVersion.set(JavaLanguageVersion.of(16))
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
}

View File

@ -9,7 +9,7 @@ dependencies {
compileOnly(libs.libby.core)
testImplementation(libs.configurate.hocon)
testImplementation(platform("org.junit:junit-bom:5.11.0"))
testImplementation(platform("org.junit:junit-bom:5.10.3"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation(libs.assertj)
}

View File

@ -1,5 +1,5 @@
group = io.github.4drian3d
version = 4.1.2
version = 4.1.1
description = AuthMeReloaded Support for Velocity
url = https://modrinth.com/plugin/authmevelocity
id = authmevelocity

View File

@ -2,24 +2,23 @@ metadata.format.version = "1.1"
[versions]
velocity = "3.1.0"
spigot = "1.16.5-R0.1-SNAPSHOT"
miniplaceholders = "2.0.0"
velocity = "3.3.0-SNAPSHOT"
paper = "1.20.4-R0.1-SNAPSHOT"
miniplaceholders = "2.2.3"
fastlogin = "1.12-SNAPSHOT"
authme = "5.6.0"
libby = "1.3.1"
pluginyml = "0.6.0"
bstats = "3.0.3"
bstats = "3.0.2"
shadow = "8.1.1"
configurate = "4.1.2"
adventure = "4.11.0"
adventure = "4.17.0"
blossom = "2.1.0"
geantyref = "1.3.13"
indra = "3.1.3"
runtask = "2.3.1"
vpacketevents = "1.0.1"
runtask = "2.3.0"
vpacketevents = "1.1.0"
luckperms = "5.4"
annotations = "26.0.1"
# Test versions
assertj = "3.26.3"
@ -27,18 +26,19 @@ 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 = "org.spigotmc", name = "spigot-api", version.ref = "spigot" }
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
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,8 +52,6 @@ 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" }

Binary file not shown.

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

View File

@ -12,11 +12,8 @@ dependencies {
implementation(projects.authmevelocityCommon)
implementation(projects.authmevelocityApiPaper)
implementation(libs.minimessage)
implementation(libs.logger.slf4j)
implementation(libs.adventure)
implementation(libs.libby.bukkit)
implementation(libs.libby.paper)
}
tasks {
@ -32,10 +29,10 @@ tasks {
dependsOn(shadowJar)
}
runServer {
minecraftVersion("1.16.5")
minecraftVersion("1.20.4")
}
processResources {
filesMatching("plugin.yml") {
filesMatching("paper-plugin.yml") {
expand("version" to project.version)
}
}

View File

@ -31,7 +31,7 @@ final class AuthMePlaceholders {
static Expansion getExpansion() {
return Expansion.builder("authme")
.filter((s) -> s instanceof Player)
.filter(Player.class)
.audiencePlaceholder("is_logged", (aud, queue, ctx) ->
Tag.selfClosingInserting(AuthMeApi.getInstance().isAuthenticated((Player)aud)
? TRUE_COMPONENT

View File

@ -17,9 +17,21 @@
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 extends JavaPlugin {
public class AuthMeVelocityBootstrap implements PluginBootstrap {
@Override
public void bootstrap(@NotNull BootstrapContext context) {
}
@Override
public @NotNull JavaPlugin createPlugin(@NotNull PluginProviderContext context) {
return new AuthMeVelocityPlugin(context.getDataDirectory());
}
}

View File

@ -19,29 +19,21 @@ 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.kyori.adventure.text.Component;
import net.byteflux.libby.PaperLibraryManager;
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;
@ -51,14 +43,14 @@ public final class AuthMeVelocityPlugin extends JavaPlugin {
private ComponentLogger componentLogger;
private ConfigurationContainer<PaperConfiguration> config;
public AuthMeVelocityPlugin() {
this.dataFolder = getDataFolder().toPath();
public AuthMeVelocityPlugin(final Path dataFolder) {
this.dataFolder = dataFolder;
}
@Override
public void onEnable() {
this.componentLogger = ComponentLogger.logger();
final LibraryManager libraryManager = new BukkitLibraryManager(this);
this.componentLogger = getComponentLogger();
final LibraryManager libraryManager = new PaperLibraryManager(this);
new LibsManager(libraryManager).loadLibraries();
try {
@ -79,11 +71,6 @@ public final class AuthMeVelocityPlugin extends JavaPlugin {
AuthMePlaceholders.getExpansion().register();
}
Set<Class<?>> classes;
String packageName = "net.kyori.adventure.text";
Class c = Component.class;
componentLogger.info(miniMessage().deserialize("<gradient:aqua:dark_aqua>AuthMeVelocity</gradient> <aqua>enabled"));
}

View File

@ -40,12 +40,12 @@ public final class AuthMeListener implements Listener {
final Player player = event.getPlayer();
plugin.logDebug("LoginEvent | Start");
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, task -> {
plugin.getServer().getAsyncScheduler().runDelayed(plugin, task -> {
if (new PreSendLoginEvent(player).callEvent()) {
plugin.sendMessageToProxy(player, MessageType.LOGIN, player.getName());
plugin.logDebug("LoginEvent | PreSendLoginEvent allowed");
}
}, 20);
}, 1, TimeUnit.SECONDS);
}
@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().getScheduler().runTaskLater(plugin, task -> {
plugin.getServer().getAsyncScheduler().runDelayed(plugin, task -> {
if (new PreSendLoginEvent(player).callEvent()) {
plugin.sendMessageToProxy(player, MessageType.LOGIN, player.getName());
plugin.logDebug("RestoreSessionEvent | PreSendLoginEvent allowed");
}
}, 20);
}, 1, TimeUnit.SECONDS);
}
@EventHandler

View File

@ -7,7 +7,7 @@ authors:
- xQuickGlare
- 4drian3d
website: https://modrinth.com/plugin/authmevelocity
api-version: '1.16'
api-version: '1.20'
folia-supported: true
dependencies:
server:

View File

@ -39,6 +39,5 @@ dependencyResolutionManagement {
includeGroup("net.byteflux")
}
}
mavenCentral()
}
}

View File

@ -6,10 +6,12 @@ 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)
@ -17,7 +19,7 @@ dependencies {
implementation(libs.bstats.velocity)
testImplementation(platform("org.junit:junit-bom:5.11.0"))
testImplementation(platform("org.junit:junit-bom:5.10.3"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation(libs.assertj)
}

View File

@ -17,6 +17,8 @@
package io.github._4drian3d.authmevelocity.velocity.listener.connection;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.google.inject.Inject;
import com.velocitypowered.api.event.EventManager;
import com.velocitypowered.api.event.EventTask;
@ -59,13 +61,13 @@ public final class PostConnectListener implements Listener<ServerPostConnectEven
}
plugin.logDebug("ServerPostConnectEvent | Already logged player and connected to an Auth server");
final boolean messageResult = server.sendPluginMessage(AuthMeVelocityPlugin.MODERN_CHANNEL, (encoder) -> {
plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Encoding LOGIN data");
encoder.writeUTF("LOGIN");
encoder.writeUTF(player.getUsername());
plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Sending LOGIN data");
});
if (messageResult) {
final ByteArrayDataOutput buf = ByteStreams.newDataOutput();
buf.writeUTF("LOGIN");
buf.writeUTF(player.getUsername());
final byte[] byteArray = buf.toByteArray();
plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Sending LOGIN data");
if (server.sendPluginMessage(AuthMeVelocityPlugin.MODERN_CHANNEL, byteArray)) {
plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Correctly send data");
} else {
plugin.logDebug("ServerPostConnectEvent | Failed to send data");