Plugin doesn't work

Discussion in 'Plugin Development' started by LucyUwU_, May 3, 2021 at 6:55 AM.

  1. Offline

    LucyUwU_

    I wrote a plugin for fly, when I give it to another player it works, but when I give it to myself it gives me an error, does anyone know how to fix it? Video of the error and the plugin:
     
  2. Offline

    timtower Administrator Administrator Moderator

    @LucyUwU_ Please post the code using pastebin or [code] < code here > [/code]
     
    LucyUwU_ likes this.
  3. Offline

    LucyUwU_

  4. Offline

    timtower Administrator Administrator Moderator

    @LucyUwU_ Is that a stacktrace in the video? If so: post it as well.
     
  5. Offline

    davidclue

    @timtower the error is an array out of bounds exception and it's on this line
    Code:
    Player cel = Bukkit.getPlayer(args[0]);
    Your problem is that you have no return statements in your code so when a player types /fly there are no args and that's why it's throwing that error.
     
  6. Offline

    timtower Administrator Administrator Moderator

    @davidclue Do a length check before using args[0]
     
  7. Offline

    davidclue

    That too, the code has a lot more issues than just the problems we mentioned though...
     
  8. Offline

    timtower Administrator Administrator Moderator

    Whoops, thought you was the thread poster
     
    davidclue likes this.

Share This Page