示例#1
0
  // handle sign click
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onSignClick(PlayerInteractEvent e) {
    if (e.getAction() != Action.RIGHT_CLICK_BLOCK) {
      return;
    }
    if (!(e.getClickedBlock().getState() instanceof Sign)) {
      return;
    }
    Sign sign = (Sign) e.getClickedBlock().getState();
    Player player = e.getPlayer();
    if (sign.getLine(0).equalsIgnoreCase(ChatColor.BLUE + "[TNTRun]")) {
      if (!player.hasPermission("tntrun.game")) {
        player.sendMessage("You don't have permission to do this");
        e.setCancelled(true);
        return;
      }

      if (sign.getLine(1).equalsIgnoreCase("[join]") && sign.getLine(2) != null) {
        joinsign.handleClick(e);
      } else if (sign.getLine(1).equalsIgnoreCase("[leave]")) {
        leavesign.handleClick(e);
      } else if (sign.getLine(1).equalsIgnoreCase("[vote]")) {
        votesign.handleClick(e);
      }
    }
  }
示例#2
0
  // handle sign change
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onTNTRunSignCreate(SignChangeEvent e) {
    Player player = e.getPlayer();
    if (e.getLine(0).equalsIgnoreCase("[TNTRun]")) {
      if (!player.hasPermission("tntrun.setup")) {
        Messages.sendMessage(player, Messages.nopermission);
        e.setCancelled(true);
        e.getBlock().breakNaturally();
        return;
      }

      if (e.getLine(1).equalsIgnoreCase("[join]") && e.getLine(2) != null) {
        joinsign.handleCreation(e);
      } else if (e.getLine(1).equalsIgnoreCase("[leave]")) {
        leavesign.handleCreation(e);
      } else if (e.getLine(1).equalsIgnoreCase("[vote]")) {
        votesign.handleCreation(e);
      }
    }
  }