Solved getPlayer() error?

Discussion in 'Plugin Development' started by ItsMas_, Dec 30, 2015.

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

    ItsMas_

    I am making a kick plugin, and I am getting an internal error when trying to kick people.
    I think it comes from where I used getPlayer() because it is in strikethrough. Could someone tell e how to fix this? Thanks :)

    [​IMG]
     
    Last edited: Dec 31, 2015
  2. Offline

    timtower Administrator Administrator Moderator

    @ItsMas_ Hover your mouse over it, it is probably saying that it is deprecated.
    For your error: please post the error using http://pastebin.com
    And edit your code block, copy the code into notepad first, then in here, there is a lot of bb code in the current code.
     
  3. The error is most likely what timtower said.

    However, you're going to encounter an error when you run the command anyway. It's:

    Code:
    for (int i = 0; i < args.length; i++) {
    
    Not 'i <= args.length'.

    Arrays start from index 0 and end at the (size - 1).
     
  4. Offline

    ItsMas_

    I have added a picture of the code.

    It says deprecated, so what do I do instead?

    The error I get in game when running the command is: "An internal error occurred whilst attempting to perform this command."

    Thanks, fixed.
     
  5. Offline

    timtower Administrator Administrator Moderator

    @ItsMas_ Deprecated generally means that the method will disappear. Not the case for getPlayer though, this was to get attention to the UUID change as far as I know.
    And that is the default message, but what is the error in the console?
     
  6. Offline

    mcdorli

    You don't check, if they were somebody with the provided username, because then, getPlayer returns a null. Do a null check on it.
     
  7. Uhhh what? They did do a null check for the player.
     
  8. Offline

    mcdorli

    Ohh, sorry, I overlooked that. My bad
     
  9. Offline

    ItsMas_

    Error: "An internal error occured whilst trying to perform this com
    The error in the console;
    Show Spoiler

    Code:
    [09:52:11 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'remove' in plugin MasPunishments v1.0.0
      at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-18fbb24]
      at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:140) ~[craftbukkit.jar:git-Bukkit-18fbb24]
      at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:620) ~[craftbukkit.jar:git-Bukkit-18fbb24]
      at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1106) [craftbukkit.jar:git-Bukkit-18fbb24]
      at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:966) [craftbukkit.jar:git-Bukkit-18fbb24]
      at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:37) [craftbukkit.jar:git-Bukkit-18fbb24]
      at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:9) [craftbukkit.jar:git-Bukkit-18fbb24]
      at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit.jar:git-Bukkit-18fbb24]
      at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_65]
      at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_65]
      at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [craftbukkit.jar:git-Bukkit-18fbb24]
      at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:673) [craftbukkit.jar:git-Bukkit-18fbb24]
      at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit.jar:git-Bukkit-18fbb24]
      at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:629) [craftbukkit.jar:git-Bukkit-18fbb24]
      at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:537) [craftbukkit.jar:git-Bukkit-18fbb24]
      at java.lang.Thread.run(Unknown Source) [?:1.8.0_65]
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
      at me.ItsMas_.maspunishments.Kick.onCommand(Kick.java:32) ~[?:?]
      at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-18fbb24]
      ... 15 more
    >
    
     
  10. Offline

    mcdorli

    1. Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
    2. at me.ItsMas_.maspunishments.Kick.onCommand(Kick.java:32) ~[?:?]
     
  11. Offline

    Xerox262

    Your error is what you said you fixed earlier, the error @KingFaris11 told you about. You're going higher than the array size. Also why check if the player is null after getting the kick message rather than before?
     
  12. Offline

    ItsMas_

    EDIT: Everything working now, thanks everyone :)
     
Thread Status:
Not open for further replies.

Share This Page