コード例 #1
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void onSignChange(SignChangeEvent event) {
    Player player = event.getPlayer();
    Block block = event.getBlock();
    String[] lines = event.getLines();
    EditWorld eworld = EditWorld.get(player.getWorld());

    // Group Signs
    if (eworld == null) {
      if (player.isOp() || P.p.permission.has(player, "dxl.sign")) {
        if (lines[0].equalsIgnoreCase("[DXL]")) {
          if (lines[1].equalsIgnoreCase("Group")) {
            String dungeonName = lines[2];

            String[] data = lines[3].split("\\,");
            if (data.length == 2) {
              int maxGroups = P.p.parseInt(data[0]);
              int maxPlayersPerGroup = P.p.parseInt(data[1]);
              if (maxGroups > 0 && maxPlayersPerGroup > 0) {
                if (DGSign.tryToCreate(event.getBlock(), dungeonName, maxGroups, maxPlayersPerGroup)
                    != null) {
                  event.setCancelled(true);
                }
              }
            }
          } else if (lines[1].equalsIgnoreCase("Leave")) {
            if (block.getState() instanceof Sign) {
              Sign sign = (Sign) block.getState();
              new LeaveSign(sign);
            }
            event.setCancelled(true);
          }
        }
      }
    } else { // Editworld Signs
      Sign sign = (Sign) block.getState();
      if (sign != null) {
        sign.setLine(0, lines[0]);
        sign.setLine(1, lines[1]);
        sign.setLine(2, lines[2]);
        sign.setLine(3, lines[3]);

        DSign dsign = DSign.create(sign, null);

        if (dsign != null) {
          if (player.isOp() || P.p.permission.has(player, dsign.getPermissions())) {
            if (dsign.check()) {
              eworld.checkSign(block);
              eworld.sign.add(block);
              P.p.msg(player, P.p.language.get("Player_SignCreated"));
            } else {
              P.p.msg(player, P.p.language.get("Error_SignWrongFormat"));
            }
          } else {
            P.p.msg(player, P.p.language.get("Error_NoPermissions"));
          }
        }
      }
    }
  }
コード例 #2
0
ファイル: SignListener.java プロジェクト: Noraaron1/TNTTag
  @EventHandler
  public void onSignChange(SignChangeEvent e) {
    if (e.getLines().length == 0) {

    } else if (e.getLine(0).equalsIgnoreCase("[TNTTag]")
        && e.getLine(1).equalsIgnoreCase("1")
        && e.getPlayer().hasPermission("TNTTag.Sign.Create")) {
      e.getPlayer().sendMessage("You created a TNTTag sign for arena: 1");
      e.setLine(0, ChatColor.GREEN + "[Join]");
      e.setLine(1, ChatColor.BLACK + "1");
      e.setLine(2, ChatColor.BLACK + "0:10");
      e.setLine(3, ChatColor.BLACK + "TntTag");
    } else if (e.getLine(0).equalsIgnoreCase("[TNTTag]")
        && e.getPlayer().hasPermission("TNTTag.Sign.create")) {
      e.getPlayer().sendMessage("A TNTTag sign must a valid number for the arena on line 2! ");
      e.getBlock().breakNaturally();
    } else if (e.getLine(0).equalsIgnoreCase("[TNTTag]")
        && e.getLine(1).equalsIgnoreCase("spectate 1")
        && e.getPlayer().hasPermission("TNTTag.Sign.Create")) {
      // same code lines as [Join] Sign, but changed to [Spectate]
    } else if (e.getLine(0).equalsIgnoreCase("[TNTTag]")
        && e.getPlayer().hasPermission("TNTTag.Sign.Create")) {
      // same code lines as Error
    }
  }
コード例 #3
0
ファイル: BlockListener.java プロジェクト: Grafe/BukkitBridge
 @EventHandler
 public void onSignChange(SignUpdateEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (!(event.getSource() instanceof Player)) {
     return;
   }
   SignChangeEvent signChangeEvent =
       new SignChangeEvent(
           BukkitUtil.fromBlock(event.getSign().getBlock()),
           new BridgePlayer((Player) event.getSource()),
           event.getLines());
   Bukkit.getPluginManager().callEvent(signChangeEvent);
   event.setLines(signChangeEvent.getLines());
   event.setCancelled(signChangeEvent.isCancelled());
 }
コード例 #4
0
ファイル: SBlockListener.java プロジェクト: Lolmewn/Sortal
 @EventHandler(priority = EventPriority.NORMAL)
 public void onSignChange(SignChangeEvent event) {
   Player p = event.getPlayer();
   for (int i = 0; i < event.getLines().length; i++) {
     if (event.getLine(i).toLowerCase().contains("[sortal]")
         || event.getLine(i).toLowerCase().contains(plugin.signContains)) {
       if (event.getPlayer().hasPermission("sortal.placesign")) {
         if (this.pay(p)) {
           plugin.log.info("Sign placed by " + p.getDisplayName() + ", AKA " + p.getName() + "!");
         } else {
           event.setCancelled(true);
         }
       } else {
         p.sendMessage("You are not allowed to place a [Sortal] sign!");
         event.setCancelled(true);
       }
     }
   }
 }