KaiKikuchi / QuickShop

A shop plugin for Bukkit
47 stars 41 forks source link

QuickShop not compatible with BungeeChat #166

Closed Brianetta closed 6 years ago

Brianetta commented 6 years ago

The problem

If the server is behind a Bungee proxy, and a Bungee plugin (such as BungeeChat) is being used to handle chat, it masks QuickShop's use of chat when creating or using a shop. Because Bungee is handling the chat, the required AsyncPlayerChatEvent is never triggered on the Bukkit server, and QuickShop's ChatListener.onChat() is never called. The player sees their digits in chat, as do all the other players, and QuickShop eventually gives up waiting for them when they walk away or log off.

Possible solutions

Do nothing.

The first, and most obvious, is to declare Bungee-level chat systems incompatible. This is simplest, and requires least work.

Use BungeeChat's passToClientServer feature, which sends the chat through to the player's current Bukkit server.

This has a couple of issues. First, without any changes, players see every chat line twice, once formatted by BungeeChat, once formatted by Bukkit, and whatever chat plugin it might be using. Secondly, players still see the digits typed in to QuickShop's chat, because Bungee sees it first, and QuickShop cannot see or cancel BungeeChat's chat events.

The duplicate chat messages can be suppressed, of course. ChatListener.onChat() could use a configuration setting to optionally cancel all chat regardless. This does leave the issue of QuickShop chat digits being seen in BungeeChat, but that's outside of the scope of this plugin.

A second plugin could be installed alongside QuickShop simply to cancel all chat events, but QuickShop is already running at the lowest non-Monitor priority, and it would risk cancelling events that we want QuickShop to see.

Create an option to use commands instead

The cleanest solution (from a chat pollution perspective) is not to pass chat through, but to require that players use a /qs command to provide numbers, rather than bare chat.

This gets past the chat issue, but breaks the "this plugin doesn't even have any commands that a player would ever need" promise. The behaviour could be enabled through configuration, meaning that servers that do not use Bungee to handle chat need not be affected at all.


I'm happy to try to work on this, but first an approach would have to be chosen. Your thoughts?

KaiKikuchi commented 6 years ago

Create an option to use commands instead

This is the only option that will actually work without any possible issue, and it's quick enough to be done in few minutes.

Please download latest release from here: https://github.com/KaiKikuchi/QuickShop/releases/

The command would be /qs amount [amount/price]

Another option would be not using BungeeChat :P. If you haven't already, take a look at https://github.com/KaiKikuchi/ServerRedirect

Brianetta commented 6 years ago

image Unfortunately, the command is failing somewhere. I have tried using punch to create a shop, and /qs create. Both prompt me, but /qs amount 4 or similar is failing.

I think the issue is here on QS.java line 350, where the argument index is 0 (it's sending the word "amount" which is causing a number format exception). I'd test it, but I'm missing a load of old CraftBukkit jars.

KaiKikuchi commented 6 years ago

Yes, unfortunately I mistyped the argument index. Unfortunately I do not have time to test.

Please redownload from https://github.com/KaiKikuchi/QuickShop/releases/

Brianetta commented 6 years ago

Tested. This is working properly, thanks.