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.58k stars 1.11k forks source link

1.19 ChatEvent#setMessage() doesn't affect message on Spigot #3336

Open ChickenSaysBak opened 2 years ago

ChickenSaysBak commented 2 years ago

When using ChatEvent to modify a message via setMessage(), the message is changed on the Bungee side, but not on the underlying Spigot servers. Canceling the message works, but not changing the message content. In 1.18.2 and below, it works as intended, but not on 1.19.

I made 2 simple plugins for testing:

Bungee

public class BungeeChatTest extends Plugin implements Listener {

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

    @EventHandler
    public void onChat(ChatEvent event) {
        event.setMessage("Test " + event.getMessage());
        getProxy().broadcast(TextComponent.fromLegacyText("Bungee: " + event.getMessage()));
    }

}

Spigot

public class BungeeChatTest2 extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        Bukkit.getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onChat(AsyncPlayerChatEvent event) {
        Bukkit.broadcastMessage("Spigot: " + event.getMessage());
    }

}

Output in chat: image

Bungee Version: This server is running BungeeCord version git:BungeeCord-Bootstrap:1.19-R0.1-SNAPSHOT:ff5727c:1644 by md_5 Spigot Version: This server is running CraftBukkit version 3528-Spigot-56be6a8-031eaad (MC: 1.19) (Implementing API version 1.19-R0.1-SNAPSHOT)

No other plugins installed

Janmm14 commented 2 years ago

Intended due to chat signing

ChickenSaysBak commented 2 years ago

That's kinda what I wondered. However, does ChatEvent#setMessage have any purpose then? If not, I feel like that should be mentioned on the docs.

Also, why does AsyncPlayerChatEvent#setMessage work normally? Would chat signing not apply?

Janmm14 commented 2 years ago

Intended due to chat signing

That's kinda what I wondered. However, does ChatEvent#setMessage have any purpose then? If not, I feel like that should be mentioned on the docs.

Also, why does AsyncPlayerChatEvent#setMessage work normally? Would chat signing not apply?

Because the chat crypto is not activated in spigot afaik.

ChickenSaysBak commented 2 years ago

So even if I have enforce-secure-profile disabled, there's no way it can modify the message?

Janmm14 commented 2 years ago

Currently not

Xayanix commented 2 years ago

https://github.com/Xayanix/BringBackChatEdit

ChickenSaysBak commented 2 years ago

https://github.com/Xayanix/BringBackChatEdit

After making a couple bug fixes, that works perfectly. Thank you!

I'm going to leave this open for now, because I still feel like this should be addressed on the Bungee javadoc.

Xayanix commented 2 years ago

because

Thanks for PR, i didnt test it before releasing because i copy&pasted it from my own network's core and it was implemented there in some different way (thats why payload tag was invaild xD).

ChickenSaysBak commented 2 years ago

because

Thanks for PR, i didnt test it before releasing because i copy&pasted it from my own network's core and it was implemented there in some different way (thats why payload tag was invaild xD).

I made another PR because 1.17 servers were complaining about commons-io, although I deleted the fork before it was merged and that closed the PR. I'm still a bit new to GitHub, so I'm not sure if it still lets you merge it once closed, but if not, I can redo it.