Solved SignChangeEvent Error

Discussion in 'Plugin Development' started by superchris05326, Mar 21, 2015.

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

    superchris05326

    I am trying to make a buy sign and whenever I create a sign with the first line being "[Buy]", it does nothing.
    I checked using messages and when creating the sign, only zero showed up. Any ideas?
    My code:
    Code:
    @EventHandler
        public static void onSignChange(SignChangeEvent e){
            Sign s = (Sign) e.getBlock().getState();
            Player p = e.getPlayer();
            p.sendMessage("0");
            if(s.getLine(0).equalsIgnoreCase("[Buy]")){
                p.sendMessage("1");
                if(s.getLine(1).contains(":")){
                    p.sendMessage("2");
                    int id = Integer.parseInt(s.getLine(2));
                    if(WCSManager.isItem(id)){
                        p.sendMessage("3");
                        if(RankManager.isRank(s.getLine(3))){
                            p.sendMessage("4");
                            ChatUtilities.sendMessage(p, "You have successfully created a sign shop!");
                            s.setLine(0, ChatColor.GREEN + s.getLine(0));
                        }else{
                            ChatUtilities.sendMessage(p, "Incorrect Sign! Error on line 4!");
                            breakSign(s);
                            return;
                        }
                    }else{
                        ChatUtilities.sendMessage(p, "Incorrect Sign! Error on line 3!");
                        breakSign(s);
                        return;
                    }
                }else{
                    ChatUtilities.sendMessage(p, "Incorrect Sign! Error on line 2!");
                    breakSign(s);
                    return;
                }
            }
            return;
        }
     
  2. Offline

    MexMaster

    Send line 0 as a message to the player, then post what it says
    @superchris05326
     
  3. Offline

    guitargun

    @superchris05326 you can get the lines from the event by using event.getLine() perhaps that will solve it
     
  4. Offline

    superchris05326

    @MexMaster When I creating a sign with the top line being "[Buy]" it sent me a blank message...

    @guitargun Works! Thanks :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
Thread Status:
Not open for further replies.

Share This Page