Solved Sign Issues

Discussion in 'Spigot Plugin Development' started by Odogo, Jul 23, 2018.

Thread Status:
Not open for further replies.
  1. For some reason, and I have read the wiki on this, this line(s) of code,
    Code (Java):
     String warp = sign.getLine(2);
    doesn't work.

    I have no clue, because I never really used signs interaction before.

    Eclipse tells me to change it to this,
    Code (Java):
     ((Object) sign).getLines(0)
    Spigot Version: 1.12.2
     
  2. md_5

    Administrator Developer

    Need full code
     
  3. md_5

    Administrator Developer

    I don't see sign.getLine anywhere in your code
     
  4. I was changing a few things when that didn't work. I had to go get the code by undoing a lot.

    Here is the code:
    Code (Java):
    @EventHandler
    public void onSignClick(PlayerInteractEvent e) {

        if (e.getAction() != Action.RIGHT_CLICK_BLOCK) {
            return;
        }

        Player p = e.getPlayer();
        if (p.hasPermission("sign.use")) {
            Block b = e.getClickedBlock();
            if (b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN) {
     
                Sign sign = (Sign) b.getState();
                if (sign.getLine(0)).equalsIgnoreCase("[Space]")) { // here too

                    String line1 = sign.getLine(1); // here is the error.
                    if(line1 == "launch") {

                    }    
                }
     
            }
        }

    }
     
    #4 Odogo, Jul 23, 2018
    Last edited: Jul 23, 2018
  5. FrostedSnowman

    Resource Staff

    Show the entire class
     
  6. What does the errors say?
     
  7. If your error is not Null try my code
    Code (Text):
    //Change this          
    String line1 = sign.getLine(1); // here is the error.
                    if(line1 == "launch") {

                    }  
    //on this
    if(sign.getLine(1).equals("launch")) {

                            }
    P.S Pls, paste your error log on pastebin and add to post
     
  8. I'm pretty sure that wouldn't do anything in this case, from what i see the problem is "sign.getLine()" that's the problem but i don't know what the error is hence i asked what the errors said in my previous post.
     
  9. The parentheses in your if statement are off.
    Code (Text):
             if (sign.getLine(0).equalsIgnoreCase("[Space]")) { // you had a parentheses after the sign.getLine(0) which closed the if statement

                    String line1 = sign.getLine(1); // here is the error.
                    if(line1 == "launch") {

                    }    
     
  10. Oh yeah, nice find. :p
     
  11. There are no error when starting the plugin, because I never did. I will never start a plugin until all of the "errors" in the code are resolved.
    Plus, it would bring an error saying about some Invalid method.

    I would, but its pretty lengthy..

    As said in my first post, the only errors in this code is the 'sign.getLine(int);' code. None other code is fine.

    That is a nice find. But, this was directly from the wiki page for this tutorial.
    Plus, I was most likely importing the wrong import.


    And I now believe this thread is complete!
    End of Thread | Locked
     
Thread Status:
Not open for further replies.