CraftIRC

42.7k Downloads

Cannot determine number of bots

turt2live opened this issue ยท 5 comments

commented

Code Used:

int i = 0;
while(true){
    try{
        Minebot bot = craftirc.getBot(i);
        if(bot == null){
            break;
        }
        bot.sendMessage(channel, message);
        i++;
    }catch(ArrayIndexOutOfBoundsException e){
        break;
    }
}

The AIOOB exception is thrown within the CraftIRC plugin, making it not catchable.

2013-09-13 10:57:32 [WARNING] Unexpected exception while parsing console command "xmail test"
org.bukkit.command.CommandException: Unhandled exception executing command 'xmail' in plugin xMail v1.8.0-SNAPSHOT
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:192)
    at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchCommand(CraftServer.java:523)
    at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchServerCommand(CraftServer.java:512)
    at net.minecraft.server.v1_6_R2.DedicatedServer.ar(DedicatedServer.java:262)
    at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:227)
    at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:486)
    at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:419)
    at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
    at java.util.ArrayList.rangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at com.ensifera.animosity.craftirc.CraftIRC.getBot(CraftIRC.java:825)
    at com.turt2live.xmail.compatibility.irc.IrcCraftIRC.sendMessage(IrcCraftIRC.java:31)
    at com.turt2live.xmail.commands.command.TestCommand.runArgument(TestCommand.java:34)
    at com.turt2live.xmail.commands.XMailCommandHandler.onCommand(XMailCommandHandler.java:155)
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
    ... 8 more

Edit: Line 31 of IrcCraftIRC is Minebot bot = craftirc.getBot(i);

commented

Your code

ArrayIndexOutOfBoundsException

The exception

IndexOutOfBoundsException

Picture of a cat

http://upload.wikimedia.org/wikipedia/commons/2/22/Turkish_Van_Cat.jpg

commented

Though I should add a getBotCount or something to avoid exception games.

commented

...

rage_table_flip

commented
commented

3 months later :3

Thanks :D