Merge pull request #103 from 4drian3d/feat/modern-tabcomplete

Implement support for modern TabCompletion blocking
This commit is contained in:
Adrian 2023-06-27 20:10:28 -05:00 committed by GitHub
commit 5c89804190
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 76 additions and 5 deletions

View File

@ -4,7 +4,7 @@ plugins {
} }
dependencies { dependencies {
compileOnly(libs.velocity) compileOnly(libs.velocity.api)
} }
tasks { tasks {

View File

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

View File

@ -17,6 +17,7 @@ blossom = "1.3.1"
geantyref = "1.3.13" geantyref = "1.3.13"
indra = "3.1.1" indra = "3.1.1"
runtask = "2.1.0" runtask = "2.1.0"
vpacketevents = "1.1.0"
# Test versions # Test versions
assertj = "3.24.2" assertj = "3.24.2"
@ -26,7 +27,8 @@ assertj = "3.24.2"
adventure = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" } adventure = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" } 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" } authme = { module = "fr.xephi:authme", version.ref = "authme" }
libby-core = { group = "net.byteflux", name = "libby-core", version.ref = "libby" } 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" } libby-velocity = { group = "net.byteflux", name = "libby-velocity", version.ref = "libby" }
miniplaceholders = { group = "io.github.miniplaceholders", name = "miniplaceholders-api", version.ref = "miniplaceholders" } 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" } fastlogin-velocity = { group = "com.github.games647", name = "fastlogin.velocity", version.ref = "fastlogin" }
bstats-velocity = { group = "org.bstats", name = "bstats-velocity", version.ref = "bstats" } bstats-velocity = { group = "org.bstats", name = "bstats-velocity", version.ref = "bstats" }

View File

@ -15,14 +15,17 @@ repositories {
includeGroup("net.byteflux") includeGroup("net.byteflux")
} }
} }
maven("https://maven.elytrium.net/repo/")
} }
dependencies { dependencies {
compileOnly(libs.velocity) compileOnly(libs.velocity.api)
annotationProcessor(libs.velocity) compileOnly(libs.velocity.proxy)
annotationProcessor(libs.velocity.api)
compileOnly(libs.miniplaceholders) compileOnly(libs.miniplaceholders)
compileOnly(libs.fastlogin.velocity) compileOnly(libs.fastlogin.velocity)
compileOnly(libs.vpacketevents)
implementation(projects.authmevelocityCommon) implementation(projects.authmevelocityCommon)
implementation(projects.authmevelocityApiVelocity) implementation(projects.authmevelocityApiVelocity)

View File

@ -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.data.PluginMessageListener;
import io.github._4drian3d.authmevelocity.velocity.listener.input.ChatListener; 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.CommandListener;
import io.github._4drian3d.authmevelocity.velocity.listener.input.CompletionPacketListener;
import io.github._4drian3d.authmevelocity.velocity.listener.input.TabCompleteListener; import io.github._4drian3d.authmevelocity.velocity.listener.input.TabCompleteListener;
import net.byteflux.libby.VelocityLibraryManager; import net.byteflux.libby.VelocityLibraryManager;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
@ -78,6 +79,10 @@ import java.util.stream.Stream;
@Dependency( @Dependency(
id = "fastlogin", id = "fastlogin",
optional = true optional = true
),
@Dependency(
id = "vpacketevents",
optional = true
) )
} }
) )
@ -151,6 +156,11 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
injector.getInstance(AuthMePlaceholders.class).getExpansion().register(); injector.getInstance(AuthMePlaceholders.class).getExpansion().register();
} }
final boolean vpacketevents = pluginManager.isLoaded("vpacketevents");
if (vpacketevents) {
injector.getInstance(CompletionPacketListener.class).register();
}
injector.getInstance(AuthMeCommand.class).register(); injector.getInstance(AuthMeCommand.class).register();
this.sendInfoMessage(); this.sendInfoMessage();

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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<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();
return EventTask.async(() -> {
if (plugin.isLogged(player)) {
plugin.logDebug("PacketSendEvent | TabCompleteResponse | Player is already logged");
return;
}
responsePacket.getOffers().clear();
});
}
}