CraftIRC / 3

CraftIRC3
19 stars 35 forks source link

Cannot determine number of bots #48

Closed turt2live closed 10 years ago

turt2live commented 10 years ago

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);

mbax commented 10 years ago

Your code

ArrayIndexOutOfBoundsException

The exception

IndexOutOfBoundsException

Picture of a cat

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

mbax commented 10 years ago

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

turt2live commented 10 years ago

...

rage_table_flip

mbax commented 10 years ago

https://github.com/CraftIRC/CraftIRC3/commit/91004da30a4a8e5f831558caf43406503dd909f2

turt2live commented 10 years ago

3 months later :3

Thanks :D