feat: Experimental support for modern TabCompletion blocking
This commit is contained in:
parent
34a643b2b5
commit
f878060b4b
@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.velocity)
|
||||
compileOnly(libs.velocity.api)
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
@ -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" }
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -0,0 +1,42 @@
|
||||
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.network.ProtocolVersion;
|
||||
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<PacketSendEvent> {
|
||||
@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();
|
||||
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_13) < 0) {
|
||||
return null;
|
||||
}
|
||||
return EventTask.async(() -> {
|
||||
if (plugin.isLogged(player)) {
|
||||
plugin.logDebug("PacketSendEvent | TabCompleteResponse | Player is already logged");
|
||||
return;
|
||||
}
|
||||
responsePacket.getOffers().clear();
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user