Solved Unreachable statement

Discussion in 'Plugin Development' started by Batkee12345, Aug 12, 2022.

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

    Batkee12345

    if (join == null) {
    MSG.tell(sender, MSG.getString("Missing.NextGame", "There are no good servers to send you to."));
    break Label_12095;
    }
    player.teleport(join.getSpawnLocation());
    break Label_12095;
    try {
    final int page = Integer.valueOf(args[0]);
    MSG.sendHelp(sender, page - 1, "default", label);
    }
    catch (Exception e5) {
    MSG.tell(sender, MSG.getString("UnknownCommand", "Unknown Command"));
    }
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    Batkee12345

    I want to understand how to solve the Unreachable statement, it writes these lines in the logs, can you help?

    final int page = Integer.valueOf(args[0]);
    MSG.sendHelp(sender, page - 1, "default", label);

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Aug 14, 2022
  4. Offline

    timtower Administrator Administrator Moderator

    And I want to know where you got the code.
    That looks like decompiled code.
     
  5. Offline

    Batkee12345

    difference Where is the code from? I am asking how to solve this error. If you can't help - Don't write
     
  6. Offline

    timtower Administrator Administrator Moderator

    Because I am thinking that you are trying to do something you should not be doing in the first place.
    The decompiled code be very well be the cause of your problem.
     
  7. Offline

    Batkee12345

    This is not decompiled code. A self-written plugin that is written 50% from scratch. And which I abandoned and forgot about this error and how to solve it.
     
  8. Offline

    timtower Administrator Administrator Moderator

    Then we at least need the entire function.
    And your naming is terrible, "Label_12095" is not really descriptive.
     
  9. Offline

    Batkee12345

    what is this? 1. why do you need the whole function if there is an error in these lines. 2. I like my name.
     
  10. Offline

    timtower Administrator Administrator Moderator

    1. Because I have no idea what statements you are using above.
    You are not even showing what is unreachable.
     
  11. Offline

    Batkee12345

    Error not in public, etc. Error on line 2. If you understand how to solve this error, then you know that this error does not change the class, method, public, etc. e. Changes only 2 lines.
     
  12. Offline

    timtower Administrator Administrator Moderator

    And how am I supposed to know what checks you do before that null check?
    If there is another null check there (with the same parameters) then it will never reach that one.
    Why are you so keen on protecting your code? The same code that most here write in 5 minutes.
     
  13. Offline

    Batkee12345

    I can't tell why I don't give my code. Since you didn’t catch the method anyway, the code is written completely on a different engine and this code is not the one that you invent “we write in 5 minutes” The error does not connect to the method (2), so I don’t see the point in giving the whole code. I gave the code where there is an error. This error seems to be responsible for the command, when I write the /game command, it does nothing, it only duplicates the same command in the chat. Return this code, but the command will not work.
     
    Last edited by a moderator: Aug 16, 2022
  14. Offline

    timtower Administrator Administrator Moderator

    It has no use trying to help you.
    There is no different engine that you can use for Bukkit. It is not a car that goes "vroem vroem"
    If you don't post your code that could contain the checks responsible for your issue then there is nothing we can do.
    Can't know if I can write it in 5 minutes: you never posted anything to begin with.
    The command returning itself in chat is due to a return false in your onCommand handler.
     
  15. Offline

    Batkee12345

    So I told you ... There is no sense in publishing the code. You don't even know engines. The engine that is used for Bukkit, etc. does not support all functions. Many people write engines for themselves. Thank you for trying to help, I will look for another fory ... (xs is it allowed to write or not "You have the same rules .... Even translation is not possible").
     
  16. Offline

    timtower Administrator Administrator Moderator

    So, if I have this:
    Code:
    if(join == null){
    return;
    }
    if(join == null){
    // your code here
    }
    Then your code is unreachable.
    Having just your piece says nothing on its own about that.
    Having the lines above it says a lot.
    I don't care that I am not knowing all methods.
     
  17. Offline

    Batkee12345

    I'm not talking about the method, I'm talking about the engine and that the engine and this code are not related to the method and should not be related. The error itself is 2 lines.
    I wrote them for you. I don't know how to solve. Since I am offered to delete these 2 lines, but then the command will not work either
     
  18. Offline

    timtower Administrator Administrator Moderator

    Dont care about the engine now.
    And unreachable code means that you have statements somewhere that trigger before this one, which cause the code to never run.
     
  19. Offline

    Batkee12345

    The code is running. Everything is working. Only through this error, the /game command duplicates the same thing (/game).
    upload_2022-8-17_11-20-59.png
     
  20. Offline

    timtower Administrator Administrator Moderator

    Can't help with this then.
     
    bennie3211 likes this.
Thread Status:
Not open for further replies.

Share This Page