[ERROR]: Could not pass event AsyncPlayerChatEvent to MidiaCraft v0.1 org.bukkit.event.Even

Discussion in 'Plugin Help/Development/Requests' started by mariusvnh, Dec 14, 2014.

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

    mariusvnh

    [ERROR]: Could not pass event AsyncPlayerChatEvent to MidiaCraft v0.1
    org.bukkit.event.EventException
    this is my error:
    Code:
    [00:01:42] [Async Chat Thread - #11/ERROR]: Could not pass event AsyncPlayerChatEvent to MidiaCraft v0.1
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-1646]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-1646]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:514) [spigot.jar:git-Spigot-1646]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:496) [spigot.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.PlayerConnection.chat(PlayerConnection.java:965) [spigot.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:905) [spigot.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.PacketPlayInChat.a(PacketPlayInChat.java:28) [spigot.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.PacketPlayInChat$1.run(PacketPlayInChat.java:59) [spigot.jar:git-Spigot-1646]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.7.0_67]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.7.0_67]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.7.0_67]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.7.0_67]
        at java.lang.Thread.run(Unknown Source) [?:1.7.0_67]
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
        at be.drgeek.midiacraft.midiacraftChat.onPlayerChat(midiacraftChat.java:22) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_67]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_67]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_67]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_67]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:298) ~[spigot.jar:git-Spigot-1646]
        ... 12 more
    this is my code :

    Code:
    package be.drgeek.midiacraft;
    
    import org.bukkit.event.Listener;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.player.AsyncPlayerChatEvent;
    import org.bukkit.entity.Player;
    
    public class midiacraftChat implements Listener{
        midiacraftPlugin plugin;
       
        public void ChatListener(midiacraftPlugin plugin){
            this.plugin = plugin;
        }
       
               
        @EventHandler
        public void onPlayerChat(AsyncPlayerChatEvent event){
            Player p = event.getPlayer();
            String msg = event.getMessage().toLowerCase();
            String[] injures = {"bite", "lol", "penis"};
            for(int i = 0; i <= injures.length; i++){
                if(msg.contains(injures[i])){
                    p.sendMessage(String.format("§cCe mot n'est pas autorisé : %s", injures[i]));
                    event.setCancelled(true);
                }
            }
        }
       
    }
    snif...
    just a sensure code :) in french
     
    Last edited by a moderator: Dec 14, 2014
  2. Offline

    tcvs

    @mariusvnh You have a <= which means i will go up to 3. but injures only goes up to 2 because arrays start at 0 not 1. So remove the = in the for loop.
     
    mariusvnh likes this.
  3. Offline

    mariusvnh

    Thx i will test it :)

    It works :)

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Dec 15, 2014
  4. Offline

    mrCookieSlime

    Moved to Alternatives Section.
     
Thread Status:
Not open for further replies.

Share This Page