Sign Command Help

Discussion in 'Plugin Development' started by Epicballzy, Mar 27, 2014.

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

    Epicballzy

    I'm trying to execute a command when a specific sign is set... But when I set down the sign, it doesn't execute the command.

    Here's what I've got:
    Code:
    @EventHandler
        public void onSignChange(SignChangeEvent e) {
            if(e.getLine(0).equalsIgnoreCase("[PvpKit]") && e.getLine(1).equalsIgnoreCase("Mage")) {
                e.setLine(0, "§8[§3Mage§8]");
                e.setLine(1, "§8§l--------");
                e.setLine(2, "§b§lClick Here");
            }
            if(e.getLine(0).equalsIgnoreCase("[PvpKit]") && e.getLine(1).equalsIgnoreCase("Archer")) {
                e.setLine(0, "§3§l[PvpKit]");
                e.setLine(1, "§b§lArcher");
                e.setLine(2, "§c§lClick Here");
            }
        }
     
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent e) {
            if(!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
            if(e.getClickedBlock().getState() instanceof Sign) {
                Sign s = (Sign) e.getClickedBlock().getState();
                if(s.getLine(0).equalsIgnoreCase("[PvpKit]") && s.getLine(1).equalsIgnoreCase("Mage")) {
                    e.getPlayer().performCommand("pvpkit mage");
                }
                Sign s1 = (Sign) e.getClickedBlock().getState();
                if(s1.getLine(0).equalsIgnoreCase("[PvpKit]") && s1.getLine(1).equalsIgnoreCase("Archer")) {
                    e.getPlayer().performCommand("pvpkit archer");
                }
            }
        }
     
  2. Offline

    tommykins20

    Epicballzy Remember to include the colour codes when checking the first line of the sign in the player interact event.
     
  3. Offline

    Epicballzy

    What do you mean by including colour codes when checking the first line?
     
  4. Offline

    tommykins20

    Epicballzy
    including the "§3§l" before the [Pvpkit] thingy in the if statement
     
  5. Offline

    Epicballzy

    Oh... It worked lol thanks :)
     
Thread Status:
Not open for further replies.

Share This Page