Floodgate icon indicating copy to clipboard operation
Floodgate copied to clipboard

Floodgate player name prefixes break after registering an Async Start Listener using ProtocolLib

Open Smart123s opened this issue 3 years ago • 2 comments

Summary

After registering an Asynchronous Packet Handler for the START type with ProtocolLib, Floodgate name prefixes won't be present. If I make the handler Synchronous or register another type of async Packet Handler (ex. ENCRYPTION_BEGIN) then the prefixes will work fine.

Server Details

Java Version: OpenJDK 15.0.2 OS: Arch Linux (up to date packages as of 2021-05-08 10:00AM CEST) Minecraft Server: Paper 1.16.5 #​650 Plguins:

  • Floodgate-spigot (branch: dev/2.0; master also affected) #​36
  • Geyser-Spigot (branch: floodgate-2.0) #​13
  • ProtocolLib v4.6.0
  • The example plugin from below

Example Code

A ready to compile version of the code with plugin.yml and everything can be found at https://github.com/Smart123s/ProtocolLib-Dummy-Listener

Alternatively you can download a precompiled JAR file from the Releases section to test it on a server.

EmptyListener.java:

public class EmptyListener extends PacketAdapter {

	public EmptyListener(Plugin plugin) {
		super(params().plugin(plugin).types(START).optionAsync());
	}

	public static void register(Plugin plugin) {
		// Register async Listener
		ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new EmptyListener(plugin))
				.start();
	}

	@Override
	public void onPacketReceiving(PacketEvent packetEvent) {
		// It deosn't matter if you do anything here or not.
		Bukkit.getLogger().info("[ProtocolLib-Dummy-Listener] Caught START PacketEvent from ProtocolLib");
		Bukkit.getLogger().info("[ProtocolLib-Dummy-Listener] Floodgate name prefixes should be broken now");
	}

}

Main Class:

public void onEnable() {
	if (Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")) {
		EmptyListener.register(this);
	}
}

Logs

*IPs, Ports, and UUIDs have been removed

With async handler registered:

[09:57:13 INFO]: [Geyser-Spigot] /192.168.0.0:0000 tried to connect!
[09:57:14 INFO]: [Geyser-Spigot] Player connected with username Smart123s
[09:57:24 INFO]: [Geyser-Spigot] Attempting to login using floodgate mode... authentication will be encrypted.
[09:57:24 INFO]: [Geyser-Spigot] Smart123s (logged in as: Smart123s) has connected to remote java server on address 192.168.0.0
[09:57:24 INFO]: [ProtocolLib-Dummy-Listener] Caught START PacketEvent from ProtocolLib
[09:57:24 INFO]: [ProtocolLib-Dummy-Listener] Floodgate name prefixes should be broken now
[09:57:24 INFO]: UUID of player Smart123s is 00000000-0000-0000-000*-************
[09:57:24 INFO]: [floodgate] Floodgate player logged in as .Smart123s joined (UUID: 00000000-0000-0000-000*-************)
[09:57:24 INFO]: [Geyser-Spigot] Registering bedrock skin for Smart123s (00000000-0000-0000-000*-************)
[09:57:24 INFO]: [Geyser-Spigot] Unable to load bedrock skin for 'Smart123s' as they are likely using a customised skin
[09:57:24 INFO]: Smart123s joined the game
[09:57:24 INFO]: Smart123s[/192.168.0.0:0000] logged in with entity id 436 at ([world]-265.5, 66.0, -62.5)

Without async handler:

[10:02:21 INFO]: [Geyser-Spigot] /192.168.0.0:0000 tried to connect!
[10:02:22 INFO]: [Geyser-Spigot] Player connected with username Smart123s
[10:02:31 INFO]: [Geyser-Spigot] Attempting to login using floodgate mode... authentication will be encrypted.
[10:02:31 INFO]: [Geyser-Spigot] Smart123s (logged in as: Smart123s) has connected to remote java server on address 192.168.1.210
[10:02:32 INFO]: UUID of player .Smart123s is 00000000-0000-0000-000*-************
[10:02:32 INFO]: [floodgate] Floodgate player logged in as .Smart123s joined (UUID: 00000000-0000-0000-000*-************)
[10:02:32 INFO]: [Geyser-Spigot] Registering bedrock skin for .Smart123s (00000000-0000-0000-000*-************)
[10:02:32 INFO]: [Geyser-Spigot] Unable to load bedrock skin for '.Smart123s' as they are likely using a customised skin
[10:02:32 INFO]: .Smart123s joined the game
[10:02:32 INFO]: .Smart123s[/192.168.0.0:0000] logged in with entity id 236 at ([world]-265.5, 66.0, -62.5)

Smart123s avatar May 08 '21 08:05 Smart123s

The problem is that protocollib is broken with floodgate prefix, so we should wait for update from protocollib. The only solution is to install another plugin for api called protocolsupport. This plugin won't work with the most of the plugin so i think it's not a solution. FastLogin loads the player before floodgate and doesn't let it loads the prefix.

SalomonPicos avatar Aug 12 '21 20:08 SalomonPicos

In ProtocolLib, if an async listener is registered to a PacketEvent, then then original event (which Floodgate inject into) will get canceled, and ProtocolLib will create a new event if the asynchronous processing has finished.

https://github.com/dmulloy2/ProtocolLib/blob/96155b10651df1c8c37431774cd5b02b252150cc/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java#L552-L559=

And canceled events aren't fired down the pipeline, so the code injected by Floodgate will never get executed.

https://github.com/dmulloy2/ProtocolLib/blob/073bfa2b86048aade0a0f32638f0255fdbd3f282/src/main/java/com/comphenix/protocol/injector/netty/channel/InboundPacketInterceptor.java#L37-L39=

Smart123s avatar Jul 23 '22 10:07 Smart123s