示例#1
0
  @Command(
      name = "withdraw",
      permission = "mytown.cmd.assistant.bank.withdraw",
      parentName = "mytown.cmd.everyone.bank",
      syntax = "/town bank withdraw <amount>")
  public static CommandResponse bankWithdrawCommand(ICommandSender sender, List<String> args) {
    if (args.size() < 1) return CommandResponse.SEND_SYNTAX;

    if (!StringUtils.tryParseInt(args.get(0)))
      throw new MyTownCommandException("mytown.cmd.err.notPositiveInteger", args.get(0));

    Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
    Town town = getTownFromResident(res);

    if (town instanceof AdminTown)
      throw new MyTownCommandException("mytown.cmd.err.adminTown", town.getName());

    int amount = Integer.parseInt(args.get(0));
    if (town.bank.getAmount() < amount)
      throw new MyTownCommandException(
          "mytown.cmd.err.bank.withdraw", EconomyProxy.getCurrency(town.bank.getAmount()));

    makeRefund(res.getPlayer(), amount);
    town.bank.addAmount(-amount);
    getDatasource().saveTownBank(town.bank);
    return CommandResponse.DONE;
  }
示例#2
0
  @CommandNode(
      name = "unclaim",
      permission = "mytown.cmd.assistant.unclaim",
      parentName = "mytown.cmd")
  public static void unclaimCommand(ICommandSender sender, List<String> args) {
    EntityPlayer pl = (EntityPlayer) sender;
    Resident res = getDatasource().getOrMakeResident(pl);
    Block block = getBlockAtResident(res);
    Town town = block.getTown();

    if (!block.isPointIn(
        town.getSpawn().getDim(), town.getSpawn().getX(), town.getSpawn().getZ())) {
      getDatasource().deleteBlock(block);
      res.sendMessage(
          getLocal()
              .getLocalization(
                  "mytown.notification.block.removed",
                  block.getX() << 4,
                  block.getZ() << 4,
                  block.getX() << 4 + 15,
                  block.getZ() << 4 + 15,
                  town.getName()));
    } else {
      throw new CommandException("§cYou cannot delete the Block containing the spawn point!");
    }
  }
示例#3
0
  /**
   * Removes a Resident from the Datasource
   *
   * @param resident
   */
  public boolean removeResident(Resident resident) {
    boolean result = residents.remove(resident.getUUID()) != null;

    for (Town t : towns.values()) if (t.hasResident(resident)) t.removeResident(resident);

    return result;
  }
示例#4
0
  @Command(
      name = "delete",
      permission = "mytown.cmd.mayor.leave.delete",
      parentName = "mytown.cmd.everyone.leave",
      syntax = "/town leave delete")
  public static CommandResponse leaveDeleteCommand(ICommandSender sender, List<String> args) {
    Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
    Town town = getTownFromResident(res);
    EntityPlayer player = (EntityPlayer) sender;

    if (town.residentsMap.get(res).getType() == Rank.Type.MAYOR) {
      town.notifyEveryone(
          getLocal()
              .getLocalization(
                  "mytown.notification.town.deleted", town.getName(), res.getPlayerName()));
      int refund = 0;
      for (TownBlock block : town.townBlocksContainer) {
        refund += block.getPricePaid();
      }
      refund += town.bank.getAmount();
      makeRefund(player, refund);
      getDatasource().deleteTown(town);
    }
    return CommandResponse.DONE;
  }
示例#5
0
 public boolean hasPermission(Resident res, Segment segment, int dim, int x, int y, int z) {
   TownBlock townBlock = getDatasource().getBlock(dim, x >> 4, z >> 4);
   if (townBlock == null) {
     if (res == null) {
       return !Wild.instance.getValue(segment.getFlag()).equals(segment.getDenialValue());
     } else {
       if (!Wild.instance.hasPermission(res, segment.getFlag(), segment.getDenialValue())) {
         res.sendMessage(segment.getFlag().getLocalizedProtectionDenial());
         return false;
       }
     }
   } else {
     Town town = townBlock.getTown();
     if (res == null) {
       return !town.getValueAtCoords(dim, x, y, z, segment.getFlag())
           .equals(segment.getDenialValue());
     } else {
       if (!town.hasPermission(res, segment.getFlag(), segment.getDenialValue(), dim, x, y, z)) {
         res.protectionDenial(
             segment.getFlag().getLocalizedProtectionDenial(),
             Formatter.formatOwnersToString(town, dim, x, y, z));
         return false;
       }
     }
   }
   return true;
 }
示例#6
0
  @CommandNode(
      name = "promote",
      permission = "mytown.cmd.assistant.promote",
      parentName = "mytown.cmd",
      completionKeys = {"residentCompletion", "rankCompletion"})
  public static void promoteCommand(ICommandSender sender, List<String> args) {

    // /t promote <user> <rank>
    if (args.size() < 2)
      throw new WrongUsageException(getLocal().getLocalization("mytown.cmd.usage.promote"));
    Resident resSender = getDatasource().getOrMakeResident(sender);
    Resident resTarget = getResidentFromName(args.get(0));
    Town town = getTownFromResident(resSender);

    if (!resTarget.getTowns().contains(town))
      throw new CommandException(
          getLocal()
              .getLocalization("mytown.cmd.err.resident.notsametown", args.get(0), town.getName()));

    // TODO: implement this properly
    if (args.get(1).equalsIgnoreCase("mayor"))
      throw new CommandException(getLocal().getLocalization("mytown.cmd.err.promote.notMayor"));
    Rank rank = getRankFromTown(town, args.get(1));
    if (getDatasource().updateResidentToTownLink(resTarget, town, rank)) {
      resSender.sendMessage(getLocal().getLocalization("mytown.cmd.promote.success.sender"));
      resTarget.sendMessage(
          getLocal()
              .getLocalization(
                  "mytown.cmd.promote.success.target", rank.getName(), town.getName()));
    }
  }
示例#7
0
  @Command(
      name = "pass",
      permission = "mytown.cmd.mayor.pass",
      parentName = "mytown.cmd",
      syntax = "/town pass <resident>",
      completionKeys = {"residentCompletion"})
  public static CommandResponse passCommand(ICommandSender sender, List<String> args) {
    if (args.size() < 1) return CommandResponse.SEND_SYNTAX;

    Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
    Resident target = getResidentFromName(args.get(0));

    if (res == target) {
      throw new MyTownCommandException("mytown.cmd.err.resident.same");
    }

    Town town = getTownFromResident(res);

    if (!town.residentsMap.containsKey(target)) {
      throw new MyTownCommandException(
          "mytown.cmd.err.resident.notsametown", target.getPlayerName(), town.getName());
    }
    if (town.residentsMap.get(res).getType() == Rank.Type.MAYOR) {
      getDatasource().updateResidentToTownLink(target, town, town.ranksContainer.getMayorRank());
      target.sendMessage(getLocal().getLocalization("mytown.notification.town.mayorShip.passed"));
      getDatasource().updateResidentToTownLink(res, town, town.ranksContainer.getDefaultRank());
      res.sendMessage(getLocal().getLocalization("mytown.notification.town.mayorShip.taken"));
    } else {
      // ...
    }
    return CommandResponse.DONE;
  }
示例#8
0
  @Command(
      name = "kick",
      permission = "mytown.cmd.assistant.kick",
      parentName = "mytown.cmd",
      syntax = "/town kick <resident>",
      completionKeys = {"residentCompletion"})
  public static CommandResponse kickCommand(ICommandSender sender, List<String> args) {
    if (args.size() < 1) {
      return CommandResponse.SEND_SYNTAX;
    }
    Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
    Resident target = getResidentFromName(args.get(0));
    Town town = getTownFromResident(res);
    if (!target.townsContainer.contains(town)) {
      throw new MyTownCommandException(
          "mytown.cmd.err.resident.notsametown", args.get(0), town.getName());
    }
    if (target == res) {
      throw new MyTownCommandException("mytown.cmd.err.kick.self");
    }

    if (town.residentsMap.get(target) == town.ranksContainer.getMayorRank()) {
      throw new MyTownCommandException("mytown.cmd.err.kick.mayor");
    }

    getDatasource().unlinkResidentFromTown(target, town);
    target.sendMessage(
        getLocal().getLocalization("mytown.notification.town.kicked", town.getName()));
    town.notifyEveryone(
        getLocal()
            .getLocalization(
                "mytown.notification.town.left", target.getPlayerName(), town.getName()));
    return CommandResponse.DONE;
  }
示例#9
0
    @Command(
        name = "remove",
        permission = "mytown.cmd.assistant.ranks.remove",
        parentName = "mytown.cmd.everyone.ranks",
        syntax = "/town ranks remove <rank>",
        completionKeys = {"rankCompletion"})
    public static CommandResponse ranksRemoveCommand(ICommandSender sender, List<String> args) {
      if (args.size() < 1) return CommandResponse.SEND_SYNTAX;

      Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
      Town town = getTownFromResident(res);
      Rank rank = getRankFromTown(town, args.get(0));

      if (rank.getType().unique) {
        throw new MyTownCommandException("mytown.cmd.err.ranks.cantDelete");
      }

      for (Rank residentRank : town.residentsMap.values()) {
        if (residentRank == rank) {
          throw new MyTownCommandException("mytown.cmd.err.ranks.assigned");
        }
      }

      getDatasource().deleteRank(rank);
      res.sendMessage(
          getLocal()
              .getLocalization("mytown.notification.town.ranks.rem", args.get(0), town.getName()));

      return CommandResponse.DONE;
    }
示例#10
0
  @CommandNode(
      name = "add",
      permission = "mytown.cmd.assistant.ranks.add",
      parentName = "mytown.cmd.everyone.ranks",
      completionKeys = {"-", "ranksCompletion"})
  public static void ranksAddCommand(ICommandSender sender, List<String> args) {

    if (args.size() < 2)
      throw new WrongUsageException(getLocal().getLocalization("mytown.cmd.usage.ranks"));
    Resident res = getDatasource().getOrMakeResident(sender);
    Town town = getTownFromResident(res);

    if (town.hasRankName(args.get(0)))
      throw new CommandException(
          getLocal().getLocalization("mytown.cmd.err.ranks.add.already", args.get(0)));
    if (!town.hasRankName(args.get(1)))
      throw new CommandException(
          getLocal().getLocalization("mytown.cmd.err.ranks.add.notexist", args.get(1)));

    Rank rank = new Rank(args.get(0), town.getRank(args.get(1)).getPermissions(), town);
    getDatasource().saveRank(rank, false); // TODO: Set default properly?
    res.sendMessage(
        getLocal()
            .getLocalization("mytown.notification.town.ranks.add", args.get(0), town.getName()));
  }
示例#11
0
  @Command(
      name = "promote",
      permission = "mytown.cmd.assistant.promote",
      parentName = "mytown.cmd",
      syntax = "/town promote <resident> <rank>",
      completionKeys = {"residentCompletion", "rankCompletion"})
  public static CommandResponse promoteCommand(ICommandSender sender, List<String> args) {
    if (args.size() < 2) return CommandResponse.SEND_SYNTAX;
    Resident resSender = MyTownUniverse.instance.getOrMakeResident(sender);
    Resident resTarget = getResidentFromName(args.get(0));
    Town town = getTownFromResident(resSender);

    if (!resTarget.townsContainer.contains(town))
      throw new MyTownCommandException(
          "mytown.cmd.err.resident.notsametown", args.get(0), town.getName());

    Rank mayorRank = town.ranksContainer.getMayorRank();
    if (args.get(1).equalsIgnoreCase(mayorRank.getName()))
      throw new MyTownCommandException("mytown.cmd.err.promote.notMayor");
    Rank rank = getRankFromTown(town, args.get(1));
    if (getDatasource().updateResidentToTownLink(resTarget, town, rank)) {
      resSender.sendMessage(
          getLocal()
              .getLocalization(
                  "mytown.cmd.promote.success.sender", resTarget.getPlayerName(), rank.getName()));
      resTarget.sendMessage(
          getLocal()
              .getLocalization(
                  "mytown.cmd.promote.success.target", rank.getName(), town.getName()));
    }
    return CommandResponse.DONE;
  }
示例#12
0
    @Command(
        name = "add",
        permission = "mytown.cmd.assistant.ranks.add",
        parentName = "mytown.cmd.everyone.ranks",
        syntax = "/town ranks add <name> [templateRank]",
        completionKeys = {"-", "ranksCompletion"})
    public static CommandResponse ranksAddCommand(ICommandSender sender, List<String> args) {
      if (args.size() < 1) return CommandResponse.SEND_SYNTAX;

      Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
      Town town = getTownFromResident(res);

      if (town.ranksContainer.contains(args.get(0)))
        throw new MyTownCommandException("mytown.cmd.err.ranks.add.already", args.get(0));

      Rank rank = new Rank(args.get(0), town, Rank.Type.REGULAR);
      if (args.size() == 2) {
        Rank template = getRankFromTown(town, args.get(1));
        rank.permissionsContainer.addAll(template.permissionsContainer);
      }

      getDatasource().saveRank(rank);

      res.sendMessage(
          getLocal()
              .getLocalization("mytown.notification.town.ranks.add", args.get(0), town.getName()));
      return CommandResponse.DONE;
    }
示例#13
0
  @CommandNode(
      name = "remove",
      permission = "mytown.cmd.assistant.ranks.remove",
      parentName = "mytown.cmd.everyone.ranks",
      completionKeys = {"rankCompletion"})
  public static void ranksRemoveCommand(ICommandSender sender, List<String> args) {

    if (args.size() < 1)
      throw new WrongUsageException(getLocal().getLocalization("mytown.cmd.usage.ranks"));
    Resident res = getDatasource().getOrMakeResident(sender);
    Town town = res.getSelectedTown();
    Rank rank = getRankFromTown(town, args.get(0));

    if (town.getDefaultRank().equals(rank))
      throw new CommandException(getLocal().getLocalization("mytown.cmd.err.rank.defaultDeletion"));

    if (getDatasource().deleteRank(rank)) {
      res.sendMessage(
          getLocal()
              .getLocalization("mytown.notification.town.ranks.rem", args.get(0), town.getName()));
    } else {
      res.sendMessage(
          getLocal().getLocalization("mytown.cmd.err.ranks.rem.notallowed", args.get(0)));
    }
  }
示例#14
0
  @Command(
      name = "unclaim",
      permission = "mytown.cmd.assistant.unclaim",
      parentName = "mytown.cmd",
      syntax = "/town unclaim")
  public static CommandResponse unclaimCommand(ICommandSender sender, List<String> args) {
    EntityPlayer player = (EntityPlayer) sender;
    Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
    TownBlock block = getBlockAtResident(res);
    Town town = getTownFromResident(res);

    if (town != block.getTown())
      throw new MyTownCommandException("mytown.cmd.err.unclaim.notInTown");
    if (block.isPointIn(town.getSpawn().getDim(), town.getSpawn().getX(), town.getSpawn().getZ()))
      throw new MyTownCommandException("mytown.cmd.err.unclaim.spawnPoint");
    if (!checkNearby(block.getDim(), block.getX(), block.getZ(), town)
        && town.townBlocksContainer.size() <= 1) {
      throw new MyTownCommandException("mytown.cmd.err.unclaim.lastClaim");
    }

    getDatasource().deleteBlock(block);
    res.sendMessage(
        getLocal()
            .getLocalization(
                "mytown.notification.block.removed",
                block.getX() << 4,
                block.getZ() << 4,
                block.getX() << 4 + 15,
                block.getZ() << 4 + 15,
                town.getName()));
    makeBankRefund(player, town, block.getPricePaid());
    return CommandResponse.DONE;
  }
示例#15
0
  @CommandNode(name = "claim", permission = "mytown.cmd.assistant.claim", parentName = "mytown.cmd")
  public static void claimCommand(ICommandSender sender, List<String> args) {
    EntityPlayer player = (EntityPlayer) sender;
    Resident res = getDatasource().getOrMakeResident(player);
    Town town = getTownFromResident(res);

    if (getDatasource().hasBlock(player.dimension, player.chunkCoordX, player.chunkCoordZ))
      throw new CommandException(getLocal().getLocalization("mytown.cmd.err.claim.already"));
    if (checkNearby(
        player.dimension,
        player.chunkCoordX,
        player.chunkCoordZ,
        town)) // Checks if the player can claim far
    Assert.Perm(player, "mytown.cmd.assistant.claim.far");
    Block block =
        getDatasource().newBlock(player.dimension, player.chunkCoordX, player.chunkCoordZ, town);
    if (block == null) throw new CommandException("Failed to create Block"); // TODO Localize
    getDatasource().saveBlock(block);
    res.sendMessage(
        getLocal()
            .getLocalization(
                "mytown.notification.block.added",
                block.getX() * 16,
                block.getZ() * 16,
                block.getX() * 16 + 15,
                block.getZ() * 16 + 15,
                town.getName()));
  }
示例#16
0
 public static <T> T getFlagValueAtLocation(FlagType<T> flagType, int dim, int x, int y, int z) {
   if (MyTownUniverse.instance.blocks.contains(dim, x >> 4, z >> 4)) {
     Town town = MyTownUniverse.instance.blocks.get(dim, x >> 4, z >> 4).getTown();
     return town.getValueAtCoords(dim, x, y, z, flagType);
   } else {
     return flagType.isWildPerm ? Wild.instance.flagsContainer.get(flagType).value : null;
   }
 }
示例#17
0
  /**
   * Removes a Town from the Datasource
   *
   * @param town
   */
  public boolean removeTown(Town town) {
    boolean result = towns.remove(town.getName()) != null;

    for (Nation n : nations.values()) if (n.hasTown(town)) n.removeTown(town);

    for (Resident r : town.getResidents()) r.removeResidentFromTown(town);

    return result;
  }
示例#18
0
 public static boolean hasPermission(
     Resident res, FlagType<Boolean> flagType, int dim, int x, int y, int z) {
   if (MyTownUniverse.instance.blocks.contains(dim, x >> 4, z >> 4)) {
     Town town = MyTownUniverse.instance.blocks.get(dim, x >> 4, z >> 4).getTown();
     return town.hasPermission(res, flagType, dim, x, y, z);
   } else {
     return !flagType.isWildPerm || Wild.instance.hasPermission(res, flagType);
   }
 }
示例#19
0
  public static boolean hasPermission(
      Resident res, FlagType<Boolean> flagType, int dim, Volume volume) {
    boolean inWild = false;

    for (int townBlockX = volume.getMinX() >> 4;
        townBlockX <= volume.getMaxX() >> 4;
        townBlockX++) {
      for (int townBlockZ = volume.getMinZ() >> 4;
          townBlockZ <= volume.getMaxZ() >> 4;
          townBlockZ++) {
        TownBlock townBlock = MyTownUniverse.instance.blocks.get(dim, townBlockX, townBlockZ);

        if (townBlock == null) {
          inWild = true;
          continue;
        }

        Town town = townBlock.getTown();
        Volume rangeBox = volume.intersect(townBlock.toVolume());

        // If the range volume intersects the TownBlock, check Town/Plot permissions
        if (rangeBox != null) {
          int totalIntersectArea = 0;

          // Check every plot in the current TownBlock and sum all plot areas
          for (Plot plot : townBlock.plotsContainer) {
            Volume plotIntersection = volume.intersect(plot.toVolume());
            if (plotIntersection != null) {
              if (!plot.hasPermission(res, flagType)) {
                return false;
              }
              totalIntersectArea += plotIntersection.getVolumeAmount();
            }
          }

          // If plot area sum is not equal to range area, check town permission
          if (totalIntersectArea != rangeBox.getVolumeAmount()) {
            if (!town.hasPermission(res, flagType)) {
              return false;
            }
          }
        }
      }
    }

    if (inWild) {
      return Wild.instance.hasPermission(res, flagType);
    }

    return true;
  }
示例#20
0
 public static Rank getRankFromTown(Town town, String rankName) {
   Rank rank = town.ranksContainer.get(rankName);
   if (rank == null) {
     throw new MyTownCommandException("mytown.cmd.err.rank.notexist", rankName, town.getName());
   }
   return rank;
 }
示例#21
0
  @CommandNode(
      name = "setspawn",
      permission = "mytown.cmd.assistant.setspawn",
      parentName = "mytown.cmd")
  public static void setSpawnCommand(ICommandSender sender, List<String> args) {
    EntityPlayer player = (EntityPlayer) sender;
    Resident res = getDatasource().getOrMakeResident(player);
    Town town = getTownFromResident(res);

    town.getSpawn()
        .setDim(player.dimension)
        .setPosition((float) player.posX, (float) player.posY, (float) player.posZ)
        .setRotation(player.cameraYaw, player.cameraPitch);

    getDatasource().saveTown(town);

    res.sendMessage(getLocal().getLocalization("mytown.notification.town.setspawn"));
  }
示例#22
0
  @Command(
      name = "rename",
      permission = "mytown.cmd.assistant.rename",
      parentName = "mytown.cmd",
      syntax = "/town rename <name>")
  public static CommandResponse renameCommand(ICommandSender sender, List<String> args) {
    if (args.size() < 1) return CommandResponse.SEND_SYNTAX;

    Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
    Town town = getTownFromResident(res);

    if (getUniverse().towns.contains(args.get(0))) // Is the town name already in use?
    throw new MyTownCommandException("mytown.cmd.err.newtown.nameinuse", args.get(0));

    town.rename(args.get(0));
    getDatasource().saveTown(town);
    res.sendMessage(getLocal().getLocalization("mytown.notification.town.renamed"));
    return CommandResponse.DONE;
  }
示例#23
0
  @CommandNode(
      name = "whitelist",
      permission = "mytown.cmd.assistant.perm.town.whitelist",
      parentName = "mytown.cmd.assistant.perm.town",
      completionKeys = {"flagCompletionWhitelist"})
  public static void permTownWhitelistCommand(
      ICommandSender sender, List<String> args, List<String> subCommands) {
    if (args.size() == 0)
      throw new CommandException(getLocal().getLocalization("mytown.cmd.usage.plot.whitelist.add"));

    Resident res = getDatasource().getOrMakeResident(sender);
    Town town = getTownFromResident(res);
    String flagName = args.get(0);

    if (Flag.flagsForWhitelist.contains(flagName))
      res.startBlockSelection(flagName, town.getName(), false);
    else
      throw new CommandException(getLocal().getLocalization("mytown.cmd.err.flag.notForWhitelist"));
  }
示例#24
0
 public Rank getRank(String rank, Town town) {
   for (Rank r : Constants.DEFAULT_RANKS) {
     if (r.parse(rank)) return r;
   }
   if (town != null)
     for (Rank r : town.getAdditionalRanks()) {
       if (r.parse(rank)) return r;
     }
   return Constants.DEFAULT_RANKS[0]; // TODO Change later?
 }
示例#25
0
  /** Populates the tab completion map. */
  public static void populateCompletionMap() {

    List<String> populator = new ArrayList<String>();
    for (Town town : getUniverse().towns) {
      populator.add(town.getName());
    }

    CommandCompletion.addCompletions("townCompletionAndAll", populator);
    CommandCompletion.addCompletion("townCompletionAndAll", "@a");

    CommandCompletion.addCompletions("townCompletion", populator);

    populator = new ArrayList<String>();
    for (Resident res : getUniverse().residents) {
      populator.add(res.getPlayerName());
    }
    CommandCompletion.addCompletions("residentCompletion", populator);

    populator = new ArrayList<String>();
    for (FlagType flag : FlagType.values()) {
      populator.add(flag.name.toLowerCase());
    }
    CommandCompletion.addCompletions("flagCompletion", populator);

    populator = new ArrayList<String>();
    for (FlagType flag : FlagType.values()) {
      if (flag.isWhitelistable) populator.add(flag.name.toLowerCase());
    }
    CommandCompletion.addCompletions("flagCompletionWhitelist", populator);

    populator = new ArrayList<String>();
    for (Plot plot : MyTownUniverse.instance.plots) {
      populator.add(plot.toString());
    }
    CommandCompletion.addCompletions("plotCompletion", populator);

    populator = new ArrayList<String>();
    for (Rank rank : Rank.defaultRanks) {
      populator.add(rank.getName());
    }
    CommandCompletion.addCompletions("rankCompletion", populator);
  }
示例#26
0
 /** Adds to the whitelist of the specified town. Used when placing blocks. */
 public static void addToBlockWhitelist(
     Class<? extends TileEntity> te, int dim, int x, int y, int z, Town town) {
   for (Protection prot : Protections.instance.getProtectionList()) {
     if (prot.isTileTracked(te))
       for (FlagType flagType : prot.getFlagsForTile(te)) {
         if (!town.hasBlockWhitelist(dim, x, y, z, flagType)) {
           BlockWhitelist bw = new BlockWhitelist(dim, x, y, z, flagType);
           DatasourceProxy.getDatasource().saveBlockWhitelist(bw, town);
         }
       }
   }
 }
示例#27
0
  @CommandNode(
      name = "invite",
      permission = "mytown.cmd.assistant.invite",
      parentName = "mytown.cmd",
      completionKeys = {"residentCompletion"})
  public static void inviteCommand(ICommandSender sender, List<String> args) {
    Resident res = getDatasource().getOrMakeResident(sender);
    Town town = getTownFromResident(res);
    if (args.size() < 1)
      throw new WrongUsageException(getLocal().getLocalization("mytown.cmd.usage.invite"));
    Resident target = getResidentFromName(args.get(0));
    if (town.hasResident(args.get(0)))
      throw new CommandException(
          getLocal().getLocalization("mytown.cmd.err.invite.already", args.get(0), town.getName()));

    target.addInvite(town);
    target.sendMessage(
        getLocal().getLocalization("mytown.notification.town.invited", town.getName()));
    res.sendMessage(
        getLocal().getLocalization("mytown.notification.town.invite.sent", args.get(0)));
  }
示例#28
0
 /** Removes from the whitelist. Used when breaking blocks. */
 public static void removeFromWhitelist(
     Class<? extends TileEntity> te, int dim, int x, int y, int z, Town town) {
   for (Protection prot : Protections.instance.getProtectionList()) {
     if (prot.isTileTracked(te))
       for (FlagType flagType : prot.getFlagsForTile(te)) {
         BlockWhitelist bw = town.getBlockWhitelist(dim, x, y, z, flagType);
         if (bw != null) {
           bw.delete();
         }
       }
   }
 }
示例#29
0
  @Command(
      name = "invite",
      permission = "mytown.cmd.assistant.invite",
      parentName = "mytown.cmd",
      syntax = "/town invite <resident>",
      completionKeys = {"residentCompletion"})
  public static CommandResponse inviteCommand(ICommandSender sender, List<String> args) {
    Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
    Town town = getTownFromResident(res);
    if (args.size() < 1) return CommandResponse.SEND_SYNTAX;
    Resident target = getResidentFromName(args.get(0));
    if (town.residentsMap.contains(args.get(0)))
      throw new MyTownCommandException(
          "mytown.cmd.err.invite.already", args.get(0), town.getName());

    getDatasource().saveTownInvite(target, town);
    target.sendMessage(
        getLocal().getLocalization("mytown.notification.town.invited", town.getName()));
    res.sendMessage(
        getLocal().getLocalization("mytown.notification.town.invite.sent", args.get(0)));
    return CommandResponse.DONE;
  }
示例#30
0
  @Command(
      name = "list",
      permission = "mytown.cmd.assistant.ranks.perm.list",
      parentName = "mytown.cmd.assistant.ranks.perm",
      syntax = "/town ranks perm list [rank]")
  public static CommandResponse ranksPermListCommand(ICommandSender sender, List<String> args) {
    Rank rank;
    Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
    Town town = getTownFromResident(res);
    if (args.isEmpty()) {
      rank = getRankFromResident(res);
    } else {
      rank = getRankFromTown(town, args.get(0));
    }

    res.sendMessage(
        getLocal()
            .getLocalization(
                "mytown.notification.town.ranks.perm.list",
                rank.getName(),
                town.getName(),
                rank.permissionsContainer.toString()));
    return CommandResponse.DONE;
  }