Skip to content

Conversation

@Outfluencer
Copy link
Collaborator

@Outfluencer Outfluencer commented Sep 6, 2025

I have tested this on latest, also tested switching servers.

Tested with this sample plugin

import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.dialog.DialogBase;
import net.md_5.bungee.api.dialog.NoticeDialog;
import net.md_5.bungee.api.dialog.action.ActionButton;
import net.md_5.bungee.api.dialog.action.CustomClickAction;
import net.md_5.bungee.api.event.CustomClickEvent;
import net.md_5.bungee.api.event.PlayerConfigurationEvent;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class Main extends Plugin implements Listener {

    @Override
    public void onEnable() {
        getProxy().getPluginManager().registerListener(this, this);
    }

    private Map<ProxiedPlayer, PlayerConfigurationEvent> awaitingPlayers = Collections.synchronizedMap(new HashMap<>());

    @EventHandler
    public void onConfig(PlayerConfigurationEvent event) {
        event.registerIntent(this);
        event.getPlayer().showDialog(new NoticeDialog(new DialogBase(new TextComponent("HALLO!!")), new ActionButton(new TextComponent("test"), new CustomClickAction("bert:bert"))));
        awaitingPlayers.put(event.getPlayer(), event);
    }

    @EventHandler
    public void onDialog(CustomClickEvent event) {
        PlayerConfigurationEvent configEvent = awaitingPlayers.get(event.getPlayer());
        if (configEvent != null) {
            configEvent.completeIntent(this);
            event.getPlayer().sendMessage(new TextComponent("You clicked!"));
        }
    }

    @EventHandler
    public void onDisconnect(PlayerDisconnectEvent event) {
        awaitingPlayers.remove(event.getPlayer());
    }
}

@Outfluencer
Copy link
Collaborator Author

Closes #3869

@Outfluencer
Copy link
Collaborator Author

I have tested this heavily now on 1.21.8, joining, switching servers & backend reconfigiring works all perfectly fine.

Also slightly tested the other versions, and encounter no problems

@Outfluencer
Copy link
Collaborator Author

@md-5 what do you think about this impl?

@md-5
Copy link
Member

md-5 commented Sep 25, 2025

Let's look after 1.21.9. I'm worried about making the configuration phase even more complicated

@SpigotMC SpigotMC deleted a comment from NotYourReturn Oct 10, 2025
@Outfluencer
Copy link
Collaborator Author

time to take a look @md-5?

if ( packet.packet == null && packet.protocol == Protocol.CONFIGURATION && server.isQueuingConfigPackets() )
{
// I want to be 100% sure this does not leak, so we use an unpooled copy.
ByteBuf unpooled = Unpooled.copiedBuffer( packet.buf );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just .retain the original?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but we have to release them if the connection unexpectedly closes then

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unpooled buffer can leak too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought unpooled heap buffers are always just garbage collected without any problems, anyways i habe changed it to retain the buffer and release them in the channels close future


receivedLogin = true;
ServerConnector.handleLogin( bungee, server.getCh(), con, server.getInfo(), null, server, login );
// if the backend reconfigures the connection it can send multiple login packets
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we handle those multiple packets then?

Copy link
Collaborator Author

@Outfluencer Outfluencer Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd say no, if we would calll ServerConnector.handleLogin again it would break api and call ServerConnected Event multiple times for the server just because its reconfiguring. also it would clear scoreboards and tablist then, even if the client has not really switched the server

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also as fas as i know vanilla/datapacks do not reconfigure the client and spigot has no api for it, to reconfigure the client you would have to use nms or paper api

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we disconnect then? The server is doing something and we're just ignoring it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why, the backend reconfiguring the client shouldn’t break anything. We can just let it happen.

I am not sure what specificly should we handle in this case

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend is sending a packet and we're just blocking it from doing anything

Copy link
Collaborator Author

@Outfluencer Outfluencer Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we blocking it if its not the first packet it does not throw CancelSendSignal

the packet just goes through or not?

@Outfluencer Outfluencer requested a review from md-5 November 22, 2025 11:29
@Outfluencer Outfluencer linked an issue Dec 3, 2025 that may be closed by this pull request
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A new asynchronous event (ConfigurationEvent) for sending dialogs

3 participants