minekube / gate

High-performance, resource-efficient Minecraft reverse proxy with robust multi-protocol version support. Designed as a scalable Velocity/BungeeCord alternative, suitable for both development and large-scale deployments. Proven in production environments, powering our global Connect edge proxy network.
https://gate.minekube.com
Apache License 2.0
653 stars 56 forks source link

Custom tablist display name #79

Open iimrudy opened 2 years ago

iimrudy commented 2 years ago

Hi, i wanted to ask if it is possible to change a player's display name on the tablist for everyone or create a team and add suffix and/or prefix to it, in order to always change the tablist, because i would like to add global prefixes/suffixes for a custom ranks and permissions system.

Thanks in advance, have a nice day

robinbraemer commented 2 years ago

Yes, this functionality is supported. Every player has it's own TabList. Then you can modify the display name for every player. I haven't tried it yet but I think you should set the display names for a player on the ServerPostConnectEvent.

robinbraemer commented 2 years ago

There is currently no other straight forward way to modify the player entries packet sent from the server to the proxy so right now the player would receive the normal tablist and then receive your display name update packets shortly after.

iimrudy commented 2 years ago

thank you, ill try that asap

iimrudy commented 2 years ago

it works! but i must wait for like 100/200 milliseconds after the ServerPostConnect event otherwise the player's Entries() list it's empty

p.Proxy().Event().Subscribe(&proxy.ServerPostConnectEvent{}, 0, func(ev event.Event) {
    e := ev.(*proxy.ServerPostConnectEvent)
    go func() {
    time.Sleep(time.Second) // i've pute a second just to be sure to find elments inside the  e.Player().Entries()
    // change display names here 
    }()
}
robinbraemer commented 2 years ago

Let me know if that's enough or you want smth like a "TabListEvent" to do it properly.

iimrudy commented 2 years ago

actually i think that a proper event might be the best way and it could be very useful to me, but right now it's not critical as "ServerPostConnectEvent" doesn't seem to cause much trouble.