diff --git a/api/velocity/build.gradle.kts b/api/velocity/build.gradle.kts
index 4fbd237..ad2df7d 100644
--- a/api/velocity/build.gradle.kts
+++ b/api/velocity/build.gradle.kts
@@ -4,7 +4,7 @@ plugins {
}
dependencies {
- compileOnly(libs.velocity)
+ compileOnly(libs.velocity.api)
}
tasks {
diff --git a/gradle.properties b/gradle.properties
index f03bf00..986747a 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,5 +1,5 @@
group = io.github.4drian3d
-version = 4.0.2
+version = 4.0.3-SNAPSHOT
description = AuthMeReloaded Support for Velocity
url = https://modrinth.com/plugin/authmevelocity
id = authmevelocity
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 8597409..71b669d 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -17,6 +17,7 @@ blossom = "1.3.1"
geantyref = "1.3.13"
indra = "3.1.1"
runtask = "2.1.0"
+vpacketevents = "1.1.0"
# Test versions
assertj = "3.24.2"
@@ -26,7 +27,8 @@ assertj = "3.24.2"
adventure = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
-velocity = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" }
+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" }
@@ -35,6 +37,7 @@ libby-paper = { group = "net.byteflux", name = "libby-paper", version.ref = "lib
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" }
fastlogin-velocity = { group = "com.github.games647", name = "fastlogin.velocity", version.ref = "fastlogin" }
bstats-velocity = { group = "org.bstats", name = "bstats-velocity", version.ref = "bstats" }
diff --git a/velocity/build.gradle.kts b/velocity/build.gradle.kts
index 684f788..f4629ff 100644
--- a/velocity/build.gradle.kts
+++ b/velocity/build.gradle.kts
@@ -15,14 +15,17 @@ repositories {
includeGroup("net.byteflux")
}
}
+ maven("https://maven.elytrium.net/repo/")
}
dependencies {
- compileOnly(libs.velocity)
- annotationProcessor(libs.velocity)
+ compileOnly(libs.velocity.api)
+ compileOnly(libs.velocity.proxy)
+ annotationProcessor(libs.velocity.api)
compileOnly(libs.miniplaceholders)
compileOnly(libs.fastlogin.velocity)
+ compileOnly(libs.vpacketevents)
implementation(projects.authmevelocityCommon)
implementation(projects.authmevelocityApiVelocity)
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 0eca487..63215df 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
@@ -48,6 +48,7 @@ import io.github._4drian3d.authmevelocity.velocity.listener.connection.PreConnec
import io.github._4drian3d.authmevelocity.velocity.listener.data.PluginMessageListener;
import io.github._4drian3d.authmevelocity.velocity.listener.input.ChatListener;
import io.github._4drian3d.authmevelocity.velocity.listener.input.CommandListener;
+import io.github._4drian3d.authmevelocity.velocity.listener.input.CompletionPacketListener;
import io.github._4drian3d.authmevelocity.velocity.listener.input.TabCompleteListener;
import net.byteflux.libby.VelocityLibraryManager;
import net.kyori.adventure.text.minimessage.MiniMessage;
@@ -78,6 +79,10 @@ import java.util.stream.Stream;
@Dependency(
id = "fastlogin",
optional = true
+ ),
+ @Dependency(
+ id = "vpacketevents",
+ optional = true
)
}
)
@@ -151,6 +156,11 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
injector.getInstance(AuthMePlaceholders.class).getExpansion().register();
}
+ final boolean vpacketevents = pluginManager.isLoaded("vpacketevents");
+ if (vpacketevents) {
+ injector.getInstance(CompletionPacketListener.class).register();
+ }
+
injector.getInstance(AuthMeCommand.class).register();
this.sendInfoMessage();
diff --git a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/input/CompletionPacketListener.java b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/input/CompletionPacketListener.java
new file mode 100644
index 0000000..4c7ef68
--- /dev/null
+++ b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/input/CompletionPacketListener.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2023 AuthMeVelocity Contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package io.github._4drian3d.authmevelocity.velocity.listener.input;
+
+import com.google.inject.Inject;
+import com.velocitypowered.api.event.EventManager;
+import com.velocitypowered.api.event.EventTask;
+import com.velocitypowered.api.proxy.Player;
+import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse;
+import io.github._4drian3d.authmevelocity.velocity.AuthMeVelocityPlugin;
+import io.github._4drian3d.authmevelocity.velocity.listener.Listener;
+import io.github._4drian3d.vpacketevents.api.event.PacketSendEvent;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+public final class CompletionPacketListener implements Listener {
+ @Inject
+ private EventManager eventManager;
+ @Inject
+ private AuthMeVelocityPlugin plugin;
+
+ @Override
+ public void register() {
+ eventManager.register(plugin, PacketSendEvent.class, this);
+ }
+
+ @Override
+ public @Nullable EventTask executeAsync(final PacketSendEvent event) {
+ if (!(event.getPacket() instanceof final TabCompleteResponse responsePacket)) {
+ return null;
+ }
+ final Player player = event.getPlayer();
+ return EventTask.async(() -> {
+ if (plugin.isLogged(player)) {
+ plugin.logDebug("PacketSendEvent | TabCompleteResponse | Player is already logged");
+ return;
+ }
+ responsePacket.getOffers().clear();
+ });
+ }
+}