crashdemons / DisplayItem-Spigot

rewrite of DisplayItem for use in Spigot 1.13+ (uses BungeeChat components)
5 stars 0 forks source link

DisplayItem doesn't work with ChatManager #11

Open ChrisTaylor201 opened 4 years ago

ChrisTaylor201 commented 4 years ago

Versions

Server core – PaperMC 1.15.2 build 380 DisplayItem – 2.8.0 ChatManager – 3.6.6

Description

If a player tries to post an item to chat, it will result in an exception:

[14:54:16] [Async Chat Thread - #0/ERROR]: Could not pass event AsyncPlayerChatEvent to DisplayItem v2.8.0-SNAPSHOT-20200719234117User
java.lang.IllegalArgumentException: The requested element-string was not located in the message: <[[DI-MESG-MARKER]]>, <§4§l[§c§lAdmin§4§l] §4ChrisTaylor §7» §r[i]>
    at com.github.crashdemons.displayitem_spigot.SplitChatMessage.fromWithExternalReplacement(SplitChatMessage.java:27) ~[?:?]
    at com.github.crashdemons.displayitem_spigot.SplitChatMessage.from(SplitChatMessage.java:45) ~[?:?]
    at com.github.crashdemons.displayitem_spigot.ChatLineFormatter.chatLineInsertItem(ChatLineFormatter.java:55) ~[?:?]
    at com.github.crashdemons.displayitem_spigot.ChatEventExecutor.replaceItem(ChatEventExecutor.java:78) ~[?:?]
    at com.github.crashdemons.displayitem_spigot.ChatEventExecutor.onChat(ChatEventExecutor.java:107) ~[?:?]
    at com.github.crashdemons.displayitem_spigot.ChatEventExecutor.onChat(ChatEventExecutor.java:82) ~[?:?]
    at com.github.crashdemons.displayitem_spigot.ChatEventExecutor.execute(ChatEventExecutor.java:52) ~[?:?]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:76) ~[patched_1.15.2.jar:git-Paper-380]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.15.2.jar:git-Paper-380]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607) ~[patched_1.15.2.jar:git-Paper-380]
    at net.minecraft.server.v1_15_R1.PlayerConnection.chat(PlayerConnection.java:1782) ~[patched_1.15.2.jar:git-Paper-380]
    at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:1697) ~[patched_1.15.2.jar:git-Paper-380]
    at net.minecraft.server.v1_15_R1.PacketPlayInChat$1.run(PacketPlayInChat.java:41) ~[patched_1.15.2.jar:git-Paper-380]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_252]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_252]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]

I had to set listenerpriority to HIGH, otherwise the default vanilla formatting would be used which, however, works without a problem. Other chat plugins, namely EssentialsX Chat, don't cause this issue.

ChrisTaylor201 commented 4 years ago

An update

After trying out different combinations of the configuration I was able to get it working, or more precisely, I had to set listenerpriority to LOW and overridechatformat to true, however there are two issues with this:

  1. The bold formatting code (&l) is applied to the entire message, not just the prefix.
  2. Placeholder %XamountPL% isn't translated.

You can see what I mean in the screenshot below:

Wrong formatting

This is the chat formatting:

format: '%vault_prefix%%displayname% &7» &r%message%'
crashdemons commented 4 years ago

looks like your chat plugins are changing the macro %XamountPL% to lowercase, breaking it... does %amount% work? I suppose a future version could just accept lowercase macros as a workaround?

crashdemons commented 4 years ago

Please try the following development build https://ci.meme.tips/job/DisplayItem-Spigot/27/ (v2.9.1 development build 27 - may differ from 2.9.1 release)

this should add case-insensitive macros to workaround your issue. Personally I'm not able to reproduce the issue with bold formatting with newer versions but I didn't attempt with ChatManager yet.

EDIT: regardless of whether this solves your formatting issues, I am still investigating why the original exception occured in a new ticket (#13) - regarding this matter, could you post your full DisplayItem/config.yml that creates the original error? thank you.

ChrisTaylor201 commented 4 years ago

I think you're right because placeholder %amount% works without any issues in version 2.8.0, however the workaround introduced in build 27 fixes the issue, thank you very much!


The exception can be reproduced with the default configuration, these are the steps:

  1. Start a server.
  2. Try to display an item using [i] placeholder – it works.
  3. Reload the plugin using /direload command.
  4. Try to display an item using [i] placeholder again – it will cause the mentioned exception.