Checking for sign content

Discussion in 'Plugin Development' started by Lolmen, Mar 31, 2011.

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

    Lolmewn

    How to let it check the content of a sign AFTER it has been placed? So when you've added some text to the sign and click Done! -- It will check the content?
     
  2. Offline

    Edward Hand

    That would be the SIGN_CHANGE event.
     
  3. Offline

    Lolmewn

    Darn, it aint working.
    Code:
        pm.registerEvent(Event.Type.SIGN_CHANGE, blockListener, Priority.Normal, this);
    Code:
    public void onSignChange(SignChangeEvent event){
            Player player = event.getPlayer();
            String line2 = event.getLine(1);
            if(line2 == "[sortal]"){
                if(Sortal.Permissions == null || Sortal.Permissions.has(player, "sortal.coords")){
                    Sortal.log.info("[Sortal] Sign placed!");
                }else{
                    player.sendMessage("You are not allowed to place a [sortal] sign!");
                }
            }
        }
     
  4. Offline

    Edward Hand

    You can't use == for string equality in Java.
    Use:
    Code:
    if(string1.equals(string2))
    or
    Code:
    if(string1.equalsIgnoreCase(string2))
     
    Lolmen likes this.
  5. Offline

    Lolmewn

    yaay! thnx
     
Thread Status:
Not open for further replies.

Share This Page