Solved Comparing Sign Values?

Discussion in 'Plugin Development' started by B3N909, May 17, 2015.

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

    B3N909

    Hello I am trying to make a script where if you right click a sign then it toggles the second line(1) from saying 'true' and 'false'.
    Code:
    Code:
    public void onClick(PlayerInteractEvent){
      if(e.getAction == Action.RIGHT_CLICK_BLOCK){
        if(e.getTargetBlock(null, 10).getType().equals(Material.WALL_SIGN)){
                        Sign s = (Sign)e.getPlayer().getTargetBlock(null, 10).getState();
                        if(s.getLine(1).equalsIgnoreCase("true")){
                            this.value = false;
                            s.setLine(1, "false");
                            s.update();
                        }else{
                            this.value = true;
                            s.setLine(1, "true");
                            s.update();
                            Bukkit.getLogger().info(s.getLine(1));
                        }
        }
      }
    }
    
    EDIT: The problem is that It only changes the sign to say 'true' and dosent change if I keep clicking it...
     
  2. Offline

    I Al Istannen

    @B3N909 This code has so many errors, you can't compile it. Is this pseudo code?
    Why do you use this player.getTargetBlock.... and not event.getClickedBlock()? I wrote my own little method, worked perfectly fine using the getClickedBlock...
     
  3. Offline

    B3N909

    @I Al Istannen It appears that I cannot get a WALL_SIGN if I use PlayerInteractEvent.getClickedBlock() on a Action.RIGHT_CLICK_BLOCK?
     
  4. Offline

    I Al Istannen

    @B3N909 I'm sorry, but I don't understand the question.
     
  5. Offline

    B3N909

    @I Al Istannen If I right click a sign then e.getClickedBlock() does not return anything... Can I see a snippet of your code?

    Thread Solved.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  6. Offline

    I Al Istannen

    @B3N909 You did it? Just be careful as the event.getClickedBlock() can return null.
     
Thread Status:
Not open for further replies.

Share This Page