Uhhh

Discussion in 'Plugin Development' started by Ethan Rocks 365, Feb 17, 2016.

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

    Ethan Rocks 365

    Here is the code
    Code:
    @EventHandler
        public void onInventoryClick(InventoryClickEvent event){
            if(!ChatColor.stripColor(event.getInventory().getName()).equalsIgnoreCase("Test GUI"));
               return;
            Player player = (Player) event.getWhoClicked();
            event.setCancelled(true);
    Its saying that
    Code:
    Player player = (Player) event.getWhoClicked();
    is wrong. Screenshot (12).png
     
  2. Offline

    Gerov

    @Ethan Rocks 365 Ethan. Ethan, Ethan, Ethan, you really need to learn Java before you try Bukkit.


    The unreachable code error is given when the compiler knows that it will never get to that code.

    Now, I am not going to tell you why that is, I want you to tell me why that is.

    And if you just don't get Java, then try a smaller, simpler language so you can learn the bare concepts of what programming is, and then come back.
     
    Last edited: Feb 17, 2016
    teej107 likes this.
  3. Offline

    Zombie_Striker

    Gerov likes this.
  4. Watch closely where you need to put or not put a ;
     
  5. Offline

    MOMOTHEREAL

    @Ethan Rocks 365
    Although the previous fine gents certainly do not appreciate your probable lack of Java experience from what I can see, I will go straight to the answer since this might of been an error like any other developer could have unintentionally committed without knowing the exception's significance.

    On line 32, you have an extra semicolon at the end of your if statement. This makes it so that "return;" is actually called outside of the if's statement body, which tells the compiler to end the method there. This means anything after that is straight up never going to happen. Removing the semicolon will make the if statement body single-lined, so that the return call is actually in its scope, and the code pursues.

    I do agree with what the aforementioned gents said about how to actually learn Java before jumping in an API made entirely out of it, but try using Google next time and re-read your code more than needed. This will come in handy, trust my words for it. Some very helpful websites like StackOverflow have plenty of answers for new developers.
     
    Skylandz likes this.
Thread Status:
Not open for further replies.

Share This Page