got problem with Index '$'

Discussion in 'Spigot Plugin Development' started by OfirTIM, Jul 11, 2015.

  1. hey guys its me OfirTIM again with another problem today... soo i wanted to update some stuff on my AdvancedChatManagerPlus plugin... i updated the Broadcast, the Shout and the Chat Formats!
    but i got this problem that when i type in any of them "$" its make an Index Error and its just making it not working or changing the chat to the Original Chat, can someone please tell me what is it? i talked with my boddies about it and they did'nt know aswell, help me please!

    The Error from the chat format problem:
    Code (Text):
    [21:43:27] [Async Chat Thread - #2/ERROR]: Could not pass event AsyncPlayerChatEvent to AdvancedChatManagerPlus v1.2
        at$1.execute( ~[spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at org.bukkit.plugin.RegisteredListener.callEvent( ~[spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at org.bukkit.plugin.SimplePluginManager.fireEvent( [spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at org.bukkit.plugin.SimplePluginManager.callEvent( [spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at [spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at net.minecraft.server.v1_7_R4.PlayerConnection.a( [spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at net.minecraft.server.v1_7_R4.PacketPlayInChat.a( [spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at net.minecraft.server.v1_7_R4.PacketPlayInChat$ [spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at java.util.concurrent.Executors$ Source) [?:1.8.0_40]
        at Source) [?:1.8.0_40]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_40]
        at java.util.concurrent.ThreadPoolExecutor$ Source) [?:1.8.0_40]
        at Source) [?:1.8.0_40]
    Caused by: java.lang.IllegalArgumentException: Illegal group reference: group index is missing
        at java.util.regex.Matcher.appendReplacement(Unknown Source) ~[?:1.8.0_40]
        at java.util.regex.Matcher.replaceAll(Unknown Source) ~[?:1.8.0_40]
        at java.lang.String.replaceAll(Unknown Source) ~[?:1.8.0_40]
        at me.OfirTIM.AdvancedChatManagerPlus.Main.playerchat( ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_40]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_40]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_40]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_40]
        at$1.execute( ~[spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        ... 12 more
    Thanks for Answers!
    Regards, OfirTIM.
  2. Your string is being passed to java's formatter, how are you setting the message format?
  3. i kinda think i done the string stupid... idk...

    Code (Text):
      event.setFormat(ChatColor.translateAlternateColorCodes('&', getConfig().getString("AdvancedChatManagerPlus.Settings.Chat Format").replaceAll("<Message>", event.getMessage()).replaceAll("<Player>", e.getPlayer().getName())));
  4. Nevermind, it wasn't bukkit's. Use Matcher#quoteReplacement on the string you are setting.

    Additionally, #setFormat is for the message format only, you do not put the contents of the message or player name inside of it.