@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"));
          }
        }
      }
    }
  }
Exemple #2
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void SignChangeEvent(SignChangeEvent e) {
   if (e.getLine(0).equals("[CustomEnchant]"))
     if (!e.getPlayer().isOp()) e.setCancelled(true);
     else {
       String ench = e.getLine(1);
       CEnchantment ce = Tools.getEnchantmentByDisplayname(ench);
       if (ce == null) ce = Tools.getEnchantmentByOriginalname(ench);
       if (ce == null)
         for (CEnchantment ceT : Main.enchantments)
           if (Tools.checkForEnchantment(ench, ceT)) ce = ceT;
       if (ce == null) {
         e.getPlayer()
             .sendMessage(ChatColor.RED + "[CE] Could not find Custom Enchantment " + ench + ".");
         e.setCancelled(true);
         return;
       }
       try {
         Integer.parseInt(e.getLine(3).replaceAll("\\D+", ""));
       } catch (NumberFormatException ex) {
         e.getPlayer().sendMessage(ChatColor.RED + "[CE] The cost you entered is invalid.");
         e.setCancelled(true);
         return;
       }
       e.getPlayer()
           .sendMessage(
               ChatColor.GREEN
                   + "[CE] Successfully created a sign shop for the enchantment "
                   + ench
                   + ".");
     }
 }
Exemple #3
0
 @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);
       }
     }
   }
 }
  /** Called when a sign is changed. */
  @Override
  public void onSignChange(SignChangeEvent event) {

    Player player = event.getPlayer();
    WorldConfiguration wcfg = getWorldConfig(player);

    if (wcfg.signChestProtection) {
      if (event.getLine(0).equalsIgnoreCase("[Lock]")) {
        if (event.getBlock().getType() != Material.SIGN_POST) {
          player.sendMessage(
              ChatColor.RED + "The [Lock] sign must be a sign post, not a wall sign.");

          dropSign(event.getBlock());
          event.setCancelled(true);
          return;
        } else if (!event.getLine(1).equalsIgnoreCase(player.getName())) {
          player.sendMessage(ChatColor.RED + "The first owner line must be your name.");

          dropSign(event.getBlock());
          event.setCancelled(true);
          return;
        } else {
          event.setLine(0, "[Lock]");
          player.sendMessage(ChatColor.YELLOW + "A chest or double chest above is now protected.");
        }
      }
    } else {
      if (event.getLine(0).equalsIgnoreCase("[Lock]")) {
        player.sendMessage(ChatColor.RED + "WorldGuard's sign chest protection is disabled.");

        dropSign(event.getBlock());
        event.setCancelled(true);
        return;
      }
    }
  }
  @EventHandler(priority = EventPriority.NORMAL)
  public void onSignChange(SignChangeEvent event) {
    if (event.isCancelled()) return;

    String line = event.getLine(1);
    Pair<String> data = idMap.get(line);
    if (data != null) {
      if (PermissionHandler.getInstance()
          .playerHasNode(event.getPlayer(), data.getSecond() + ".build")) {
        event.setLine(1, data.getFirst());
      } else {
        event.setCancelled(true);
      }
    }
  }
Exemple #6
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);
      }
    }
  }
Exemple #7
0
  @EventHandler
  public void onSignChange(SignChangeEvent e) {
    Player p = e.getPlayer();

    if (e.getLine(0).equalsIgnoreCase("[Rankup]"))
      if (p.hasPermission("rankup.sign")) {

        if (e.getLine(1).isEmpty() && e.getLine(2).isEmpty() && e.getLine(3).isEmpty()) {
          e.setLine(0, ChatColor.DARK_BLUE + "[Rankup]");
          e.setLine(1, "Right click me");
          e.setLine(2, "to rank up!");

          Language.send(p, "&7Successfully created a rankup sign.");
        }

      } else {
        Language.send(p, "&cYou do not have permission to create a rankup sign.");
        e.setCancelled(true);
      }
  }
  /*
   * Called when a sign is changed.
   */
  @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  public void onSignChange(SignChangeEvent event) {
    Player player = event.getPlayer();
    WorldConfiguration wcfg = getWorldConfig(player);

    if (wcfg.signChestProtection) {
      if (event.getLine(0).equalsIgnoreCase("[Lock]")) {
        if (wcfg.isChestProtectedPlacement(event.getBlock(), player)) {
          player.sendMessage(ChatColor.DARK_RED + "You do not own the adjacent chest.");
          event.getBlock().breakNaturally();
          event.setCancelled(true);
          return;
        }

        if (event.getBlock().getTypeId() != BlockID.SIGN_POST) {
          player.sendMessage(
              ChatColor.RED + "The [Lock] sign must be a sign post, not a wall sign.");

          event.getBlock().breakNaturally();
          event.setCancelled(true);
          return;
        }

        if (!event.getLine(1).equalsIgnoreCase(player.getName())) {
          player.sendMessage(ChatColor.RED + "The first owner line must be your name.");

          event.getBlock().breakNaturally();
          event.setCancelled(true);
          return;
        }

        int below = event.getBlock().getRelative(0, -1, 0).getTypeId();

        if (below == BlockID.TNT
            || below == BlockID.SAND
            || below == BlockID.GRAVEL
            || below == BlockID.SIGN_POST) {
          player.sendMessage(
              ChatColor.RED + "That is not a safe block that you're putting this sign on.");

          event.getBlock().breakNaturally();
          event.setCancelled(true);
          return;
        }

        event.setLine(0, "[Lock]");
        player.sendMessage(ChatColor.YELLOW + "A chest or double chest above is now protected.");
      }
    } else if (!wcfg.disableSignChestProtectionCheck) {
      if (event.getLine(0).equalsIgnoreCase("[Lock]")) {
        player.sendMessage(ChatColor.RED + "WorldGuard's sign chest protection is disabled.");

        event.getBlock().breakNaturally();
        event.setCancelled(true);
        return;
      }
    }

    if (!plugin.getGlobalRegionManager().canBuild(player, event.getBlock())) {
      player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
      event.setCancelled(true);
      return;
    }
  }
Exemple #9
0
  protected void declare(boolean reload, SignChangeEvent event) {
    PSPlayer psp = this.main.players.safelyGet(this.getOwnerName(), main);

    String[] lines = this.getLines(event);

    if (lines[1].trim().equals("") && lines[2].trim().equals("")) {
      if (psp.l1 && (psp.loc2 != null)) {
        from = psp.loc1;
        to = psp.loc2;
      } else {
        this.main.alert(
            this.getOwnerName(),
            "You did not supply enough location arguments. You must either designate the from and to locations on lines two and three, or set them by right clicking with a piece of lightstone dust.");
        if (!reload) {
          event.setCancelled(true);
        }
        return;
      }
    } else {
      String[] split1 = lines[1].split(" ");
      String[] split2 = lines[2].split(" ");

      try {

        int x1 = Integer.parseInt(split1[0]);
        int y1 = Integer.parseInt(split1[1]);
        int z1 = Integer.parseInt(split1[2]);

        int x2 = Integer.parseInt(split2[0]);
        int y2 = Integer.parseInt(split2[1]);
        int z2 = Integer.parseInt(split2[2]);

        Location h = this.getHostLocation();

        from =
            new Location(
                this.getWorld(), h.getBlockX() + x1, h.getBlockY() + y1, h.getBlockZ() + z1);
        to =
            new Location(
                this.getWorld(), h.getBlockX() + x2, h.getBlockY() + y2, h.getBlockZ() + z2);

      } catch (Exception e) {

        this.main.alert(
            this.getOwnerName(),
            "The coordinates you specified are either invalid or not formatted properly.");
        if (!reload) {
          event.setCancelled(true);
        }
        return;
      }
    }

    Direction.center(from);
    Direction.center(to);

    System.out.println(from.getX() + " " + from.getY() + " " + from.getZ());

    String modLine = lines[3];

    if (!modLine.trim().equals("")) {
      String[] modArgs = modLine.split(" ");
      try {
        arrows = Integer.parseInt(modArgs[0]);

        if (modArgs.length >= 2) {
          speed = Float.parseFloat(modArgs[1]);
        }

        if (modArgs.length >= 3) {
          variance = Float.parseFloat(modArgs[2]);
        }
      } catch (Exception e) {
        this.main.alert(this.getOwnerName(), "Error parsing line 3.");
      }
    }

    if (!reload) {
      this.clearArgLines(event);
      this.setLine(1, coordLine(from, this.getHostLocation()), event);
      this.setLine(2, coordLine(to, this.getHostLocation()), event);
      this.setLine(3, arrows + " " + speed + " " + variance, event);
    }

    main.sgc.register(this, TriggerType.REDSTONE_CHANGE);
    if (!reload) {
      this.init("Arrow sign accepted.");
    }
  }