Solved An internal error occured

Discussion in 'Plugin Development' started by Maxx_Qc, Apr 25, 2015.

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

    Maxx_Qc

    Hello, I have a command (/pay player amount) and when I do like (/pay Notch 9999999999) it says An internal error occured while trying to perform this command and the console gets filled with "logs".

    I want to know how can I limit the player to 9 digitals number & how to get riped off the "logs" in the console.
    I tried this but it doesn't work:

    if(Integer.valueOf(args[1]) <= 10000 && Integer.valueOf(args[1]) < 2147483647){
    }

    2147483647 is the int limit
    10000 is the limit of money to send.

    I have also tried:
    if(Integer.valueOf(args[1]) <= 10000 && String.valueOf(args[1]).length <= 9){
    }

    Nothing worked.
    Thank you for your help.
     
  2. Offline

    dlange

  3. Offline

    Maxx_Qc

    Code:
    [23:55:15] [Server thread/INFO]: Maxx_Qc issued server command: /paytokens Toby_Sama 9999999999
    [23:55:15] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'paytokens' in plugin MysteriousCommands v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServer.java:645) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerConnection.java:1115) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:950) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:26) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:53) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.7.0_75]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.7.0_75]
        at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:683) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:623) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:526) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at java.lang.Thread.run(Unknown Source) [?:1.7.0_75]
    Caused by: java.lang.NumberFormatException: For input string: "9999999999"
        at java.lang.NumberFormatException.forInputString(Unknown Source) ~[?:1.7.0_75]
        at java.lang.Integer.parseInt(Unknown Source) ~[?:1.7.0_75]
        at java.lang.Integer.valueOf(Unknown Source) ~[?:1.7.0_75]
        at com.commands.maxx.Main.onCommand(Main.java:196) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        ... 14 more
    
     
  4. Offline

    teej107

    @Maxx_Qc
     
  5. Offline

    Maxx_Qc

    @teej107 @dlange
    Ligne 196 : if(Integer.valueOf(args[1]) <= 10000){

    And how do we call these numbers after the ':' -> Item id 584:12 ??
     
    Last edited: Apr 25, 2015
  6. Offline

    pie_flavor

    @Maxx_Qc Before you parse the string into an int, check how many characters are in it. If it's too much, then nope
     
  7. Offline

    1Rogue

    if a number is larger than the maximum for int you can't parse it into one. Use long.
     
  8. Offline

    mythbusterma

    @Maxx_Qc

    You should surround this with try/catch, and catch the "NumberFormatException," and when you catch it, send the player a message that either what they've sent isn't a number, or is too large.
     
    Maxx_Qc likes this.
  9. Offline

    Maxx_Qc

    @mythbusterma Thank you really much man, is there a link or something where I can get every exception for further use?

    Nevermind I just need to read the stack trace, Solved!
     
    Last edited by a moderator: Apr 26, 2015
Thread Status:
Not open for further replies.

Share This Page