Problem with Sign Event

Discussion in 'Spigot Plugin Development' started by Ehrenmann, Apr 30, 2017.

  1. public class HBSignChangeEvent implements Listener {

    @EventHandler
    public void SignChange(SignChangeEvent sc) {
    Player p = sc.getPlayer();
    Sign s = (Sign) sc.getBlock().getState();
    if(sc.getLine(0).equalsIgnoreCase("[HB1]")) {
    sc.setLine(0, "§5[Join-HB1]");
    sc.setLine(1, "Voting");
    sc.setLine(2, "§8§l0/13");
    sc.setLine(3, "§5§l● Lobby ●");
    s.update();
    }
    }

    @EventHandler
    public void onSignInteract(PlayerInteractEvent e) {
    Player p = e.getPlayer();
    if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    if(e.getClickedBlock().getState() instanceof Sign) {
    Sign s = (Sign)e.getClickedBlock().getState();
    if(s.getLine(0).equalsIgnoreCase("§5[Join-HB1]")) {
    if(s.getLine(1).equalsIgnoreCase("Voting")) {
    if(s.getLine(2).equalsIgnoreCase("§8§l0/13")) {
    if(s.getLine(3).equalsIgnoreCase("§5§l● Lobby ●")) {
    p.sendMessage("§6Erfolg!");
    }
    }
    }
    }
    }
    }
    }

    }

    It wont work
     
  2. Have you registered the listener?
    Does it give you any errors?
    Can you please use the code tags?
     
  3. This won't fix your problem, but in the future use the ChatColor enum, it helps a lot and makes things much easier
     
  4. No errors, i registered listeners
     
  5. I just tested it (copy-paste) and this works...
    I imported "org.bukkit.block.Sign", but if you imported the other one, it would have given errors.
    My listener was registered and my plugin was active. I would double, triple check these two in your case.