SpigotMC / BungeeCord

BungeeCord, the 6th in a generation of server portal suites. Efficiently proxies and maintains connections and transport between multiple Minecraft servers.
https://www.spigotmc.org/go/bungeecord
Other
1.57k stars 1.1k forks source link

Player locale can be null when queried in the PostLoginEvent #3680

Closed onebeastchris closed 4 months ago

onebeastchris commented 4 months ago

Bungeecord version

git:BungeeCord-Bootstrap:1.20-R0.3-SNAPSHOT:18eae8a:1842

Server version

1.20 Spigot

Client version

1.20

Bungeecord plugins

Floodgate (local build, with the event handler code provided below)

The bug

Hey! I noticed that the getLocale() method of the ProxiedPlayer can return null during the PostLoginEvent:

@EventHandler(priority = EventPriority.LOWEST)
public void onPostLogin(PostLoginEvent event) {
    System.out.println("LOGIN EVENT! " + event.getPlayer().getLocale());
}

Calling that e.g. when commands are ran, it returns the player locale as expected. Since this method is not marked as nullable, it would be expected that the locale is non-null (as it usually is).

I've also tested this on a 1.20.6 Java client & 1.20.6 paper server; same behavior.

Log output (links)

13:12:50 [INFO] Using standard Java JCE cipher.
13:12:50 [INFO] Using standard Java compressor.
13:12:50 [INFO] Enabled BungeeCord version git:BungeeCord-Bootstrap:1.20-R0.3-SNAPSHOT:18eae8a:1842
13:12:51 [INFO] Discovered module: ModuleSpec(name=cmd_alert, file=modules\cmd_alert.jar, provider=JenkinsModuleSource())
13:12:51 [INFO] Discovered module: ModuleSpec(name=cmd_find, file=modules\cmd_find.jar, provider=JenkinsModuleSource())
13:12:51 [INFO] Discovered module: ModuleSpec(name=cmd_list, file=modules\cmd_list.jar, provider=JenkinsModuleSource())
13:12:51 [INFO] Discovered module: ModuleSpec(name=cmd_send, file=modules\cmd_send.jar, provider=JenkinsModuleSource())
13:12:51 [INFO] Discovered module: ModuleSpec(name=cmd_server, file=modules\cmd_server.jar, provider=JenkinsModuleSource())
13:12:51 [INFO] Discovered module: ModuleSpec(name=reconnect_yaml, file=modules\reconnect_yaml.jar, provider=JenkinsModuleSource())
13:12:51 [INFO] Loaded plugin reconnect_yaml version git:reconnect_yaml:1.20-R0.3-SNAPSHOT:18eae8a:1842 by SpigotMC
13:12:51 [INFO] Loaded plugin cmd_find version git:cmd_find:1.20-R0.3-SNAPSHOT:18eae8a:1842 by SpigotMC
13:12:51 [INFO] Loaded plugin cmd_server version git:cmd_server:1.20-R0.3-SNAPSHOT:18eae8a:1842 by SpigotMC
13:12:51 [INFO] Loaded plugin cmd_alert version git:cmd_alert:1.20-R0.3-SNAPSHOT:18eae8a:1842 by SpigotMC
13:12:52 [INFO] [floodgate] Took 363ms to boot Floodgate
13:12:52 [INFO] Loaded plugin floodgate version 2.2.3-SNAPSHOT (b??-4404c15) by GeyserMC
13:12:52 [INFO] Loaded plugin cmd_send version git:cmd_send:1.20-R0.3-SNAPSHOT:18eae8a:1842 by SpigotMC
13:12:52 [INFO] Loaded plugin cmd_list version git:cmd_list:1.20-R0.3-SNAPSHOT:18eae8a:1842 by SpigotMC
13:12:52 [INFO] Enabled plugin reconnect_yaml version git:reconnect_yaml:1.20-R0.3-SNAPSHOT:18eae8a:1842 by SpigotMC
13:12:52 [INFO] Enabled plugin cmd_find version git:cmd_find:1.20-R0.3-SNAPSHOT:18eae8a:1842 by SpigotMC
13:12:52 [INFO] Enabled plugin cmd_server version git:cmd_server:1.20-R0.3-SNAPSHOT:18eae8a:1842 by SpigotMC
13:12:52 [INFO] Enabled plugin cmd_alert version git:cmd_alert:1.20-R0.3-SNAPSHOT:18eae8a:1842 by SpigotMC
13:12:52 [INFO] Enabled plugin floodgate version 2.2.3-SNAPSHOT (b??-4404c15) by GeyserMC
13:12:52 [INFO] Enabled plugin cmd_send version git:cmd_send:1.20-R0.3-SNAPSHOT:18eae8a:1842 by SpigotMC
13:12:52 [INFO] Enabled plugin cmd_list version git:cmd_list:1.20-R0.3-SNAPSHOT:18eae8a:1842 by SpigotMC
13:12:52 [INFO] Listening on /0.0.0.0:25565
13:12:54 [INFO] Netty is not using direct IO buffers.
13:13:01 [INFO] [onebeastofchris,/127.0.0.1:60790] <-> InitialHandler has connected
13:13:01 [INFO] LOGIN EVENT! null // result of getLocale() during PostLoginEvent 
13:13:01 [INFO] [onebeastofchris] <-> ServerConnector [lobby-1] has connected
13:13:03 [INFO] [onebeastofchris] -> UpstreamBridge has disconnected
13:13:03 [INFO] [onebeastofchris] <-> DownstreamBridge <-> [lobby-1] has disconnected

Checking

md-5 commented 4 months ago

Yes, because it is only set in the ClientSettings packet which has not been sent by the client at this point.

Not sure what you expect bungee to do about this

onebeastchris commented 4 months ago

Ah, would be neat to see the method being marked as Nullable then - otherwise, it's easy to assume it being NonNull :)

Tim203 commented 4 months ago

Or otherwise specify it in for example the comment, which is also the case on other methods like: getReconnectServer, getUniqueId and getViewDistance

Janmm14 commented 4 months ago

BungeeCord has no consistent nullability annotations. At most, BungeeCord does have a few @NonNull annotations.

With Bungee re-using the same interfaces & Objects during the connectino establishment, for many getters any kind of nullability annotation seems unfitting.