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
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:509) [spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:491) [spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at net.minecraft.server.v1_7_R4.PlayerConnection.chat(PlayerConnection.java:965) [spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:905) [spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at net.minecraft.server.v1_7_R4.PacketPlayInChat.a(PacketPlayInChat.java:28) [spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at net.minecraft.server.v1_7_R4.PacketPlayInChat$1.run(PacketPlayInChat.java:59) [spigot.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_40]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_40]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_40]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_40]
        at java.lang.Thread.run(Unknown 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(Main.java:141) ~[?:?]
        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 org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:298) ~[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.