Пример #1
0
 private String uuidSetToString(DefaultDomain domain) {
   UUIDControl uuidControl = SlapPlayers.getUUIDController();
   Set<UUID> set = domain.getUniqueIds();
   if (set.isEmpty()) {
     return ChatColor.RED + "(none)";
   } else {
     HashSet<String> names = new HashSet<>();
     for (UUID owner : domain.getUniqueIds()) {
       names.add(uuidControl.getProfile(owner).getCurrentName());
     }
     return ChatColor.YELLOW + Util.buildString(names, ", ");
   }
 }
Пример #2
0
 /**
  * Teleport a player to a location (using Essentials /back)
  *
  * @param p The player
  * @param loc The location
  * @throws CommandException if user not found or failed to teleport
  */
 public void teleportToLocation(Player p, Location loc) throws CommandException {
   Util.setBackLocation(p);
   p.teleport(loc);
 }
Пример #3
0
  @Override
  protected void action() throws CommandException {
    ProtectedRegion region = null;
    if (args.length == 1
        || (args.length == 2
            && args[1].equalsIgnoreCase("sel"))) { // No regionname specified. Get highest priority
      if (all) { // Allowed to get all regions
        region = getHighestPriorityRegion();
      } else { // Only allowed to get their own regions
        region = getHighestOwnedPriorityRegion(true);
      }
    } else {
      validateRegionID(args[1]); // Check if valid region
      region = getRegion(args[1]); // Get the region by name
      if (!all) { // If not acces to all regions
        String playername = p.getName();
        if (!region.getMembers().contains(p.getUniqueId())
            && !region.getOwners().contains(p.getUniqueId())) { // Check if owner or member
          throw new IRGException("You are not the owner or member of the specified region.");
        }
      }
    }

    if (args[args.length - 1].equalsIgnoreCase("sel")) { // Select region
      if (p.hasPermission(Perm.select.toString())) {
        setPlayerSelection(region);
      }
    }

    RegionPrintoutBuilder builder = new RegionPrintoutBuilder(region, null); // Build the string
    try {
      // First line
      builder.append(ChatColor.GRAY);
      builder.append(
          "\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
      builder.append(" Region Info ");
      builder.append(
          "\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
      builder.append("\n");
      // Basic info
      builder.appendBasics();
      builder.appendFlags();
      builder.appendParents();

      // Users
      builder.append(ChatColor.BLUE + "Owners: ");
      builder.append(uuidSetToString(region.getOwners()));
      builder.append("\n");
      builder.append(ChatColor.BLUE + "Members: ");
      builder.append(uuidSetToString(region.getMembers()));
      builder.append("\n");

      // Bounds
      builder.appendBounds();

      // Send
      builder.send(p);
    } catch (Exception e) {
      Util.badMsg(p, "An error occurred, sorry!");
      Log.warn("Error occurred (IRG Info Command): " + e.getMessage());
    }
  }