Skip to content

[Bug] Cannot send Forms to players in configuration phase #605

@KabanFriends

Description

@KabanFriends

When a player is in the configuration phase, trying to use sendForm fails with the following error:

[21:26:24 WARN]: java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Player.sendPluginMessage(org.bukkit.plugin.Plugin, String, byte[])" because the return value of "org.bukkit.Bukkit.getPlayer(java.util.UUID)" is null
[21:26:24 WARN]:        at floodgate-spigot.jar//org.geysermc.floodgate.pluginmessage.SpigotPluginMessageUtils.sendMessage(SpigotPluginMessageUtils.java:41)
21:26:24 WARN]:        at floodgate-spigot.jar//org.geysermc.floodgate.pluginmessage.channel.FormChannel.sendForm(FormChannel.java:102)
[21:26:24 WARN]:        at floodgate-spigot.jar//org.geysermc.floodgate.api.SimpleFloodgateApi.sendForm(SimpleFloodgateApi.java:120)

This seems to be a fundamental issue in how Floodgate handles sending forms, as Floodgate uses plugin messaging to send form data to Geyser. Plugin messaging requires a Player instance, and connections in configuration phase don't have a Player instance to begin with.

However, as demonstrated in Geyser's Dialog to Form translation, sending forms to configuration phase sessions should be supported in Floodgate API too.

I tried to use GeyserAPI's version of sendForm which doesn't use plugin messaging, but as there is a loader constraint violation between Form classes bundled in Geyser and Floodgate, my plugin is unable to use GeyserAPI's sendForm. (This is supposedly expcted to be fixed when Floodgate 3.0 is out, but I assume that would have to come with a significant waiting time...)

// Connections can end up in configuration phase in some events, for example AsyncPlayerConnectionConfigureEvent in Paper

SimpleForm form = SimpleForm.builder()
    .title("Form title")
    .content("Content")
    .button("Click me");

FloodgateApi.getInstance().sendForm(uuid, form);

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs verificationThis issue has not yet been reproduced

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions