Merge pull request #103 from 4drian3d/feat/modern-tabcomplete
Implement support for modern TabCompletion blocking
This commit is contained in:
commit
5c89804190
@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.velocity)
|
||||
compileOnly(libs.velocity.api)
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
@ -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
|
||||
|
@ -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,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();
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user