Solved Arraylist // Chat Coloring Help?

Discussion in 'Plugin Help/Development/Requests' started by SergeantBud, Mar 22, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    SergeantBud

    Commands:
    ./ChatColor


    Arguments:
    Pink
    Lime
    Aqua


    Code:
    Code:
    -*- CODE REMOVED SO IT ISN'T STOLEN -*-
    
    
    Console Error:
    Code:
    22.03 12:07:34 [Server] INFO ... 14 more
    22.03 12:07:34 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO at me.SgtBud.ColoredChat.ColoredChat.onCommand(ColoredChat.java:51) ~[?:?]
    22.03 12:07:34 [Server] INFO Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
    22.03 12:07:34 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_31]
    22.03 12:07:34 [Server] INFO at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:526) [spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:623) [spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:683) [spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_31]
    22.03 12:07:34 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_31]
    22.03 12:07:34 [Server] INFO at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:53) [spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:26) [spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:950) [spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerConnection.java:1115) [spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServer.java:645) ~[spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot25.jar:git-Spigot-b1e6da1-1092acb]
    22.03 12:07:34 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'chatcolor' in plugin ColoredChat v1.0
    
    Halp :3
     
    Last edited: Mar 22, 2015
  2. Offline

    DJSkepter

    @SergeantBud You need to put return true between line 50 and 51. If not, it's continuing the expression (therefore, if the args.length == 0, it will still try and get args[0] which doesn't exist.
     
  3. Offline

    mythbusterma

    @SergeantBud

    Also, good luck with those ConcurrentModficiationExceptions. You shouldn't access ArrayLists from multiple threads, either use the correct event (PlayerChatEvent) or use a thread safe Collection (like CopyOnWriteArrayList).
     
  4. Offline

    SergeantBud

    @DJSkepter
    @mythbusterma
    Thanks!

    @mythbusterma
    Code:
    -*- CODE REMOVED SO IT ISN'T STOLEN -*-
    
    New code: But when I type a argument in game an internal error occurs? Help please?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  5. Offline

    FisheyLP

    you wrote args[01] on line 54
     
  6. Offline

    SergeantBud

    I know I tried args[0], args [01], args [1], and I still got internal errors so I just kept guessing. What do I do instead of that?
     
  7. Offline

    FisheyLP

  8. Offline

    SergeantBud

    Thanks! :)
    I see my error now.
    However; now there is no console error, yet there is a error.
    Either something around
    Code:
    -*- CODE REMOVED SO IT ISN'T STOLEN -*-
    
    is wrong or something around
    Code:
    -*- CODE REMOVED SO IT ISN'T STOLEN -*-
    
    is wrong. It works 90%, it just doesn't change the chat color. Help?
     
    Last edited: Mar 22, 2015
  9. Offline

    Protophite

    @SergeantBud your mistake is at if(args.length == 0)
    it should be args.length == 1

    EDIT: IGNORE this made a mistake myself :/
     
  10. Offline

    SergeantBud

    ... How is that a mistake ?
     
  11. Offline

    FisheyLP

    Did you register the events?

    @Protophite
    array.length returns the amount of objects in it
    array[k] returns the object at k place. It begins with 0
     
  12. Offline

    Protophite

    @SergeantBud yeah my bad I didn't read it correctly.

    You didn't register your events.
     
  13. Offline

    SergeantBud

    @FisheyLP Ah yes! Thanks it works now :)!
    *DELETING CODE SO IT CAN NOT BE STOLEN*
     
  14. Offline

    FisheyLP

    Sorry but your code can be easily remade and is a little bit useless xD
     
Thread Status:
Not open for further replies.

Share This Page