Class AreaSelectionUtil

java.lang.Object
com.palmergames.bukkit.towny.utils.AreaSelectionUtil

public class AreaSelectionUtil extends Object
  • Constructor Details

    • AreaSelectionUtil

      public AreaSelectionUtil()
  • Method Details

    • selectWorldCoordArea

      public static List<WorldCoord> selectWorldCoordArea(TownBlockOwner owner, WorldCoord pos, String[] args) throws TownyException
      Method to select a List<WorldCoord> of coordinates. Area claims can be either circular or rectangular.
      Parameters:
      owner - - TownBlockOwner making the selection.
      pos - - WorldCoord where the selection is being made from.
      args - - Subcommands like rect, circle, auto or #.
      Returns:
      List<WorldCoord> of WorldCoord.
      Throws:
      TownyException - - Thrown when invalid subcommands are given.
    • selectWorldCoordArea

      public static List<WorldCoord> selectWorldCoordArea(TownBlockOwner owner, WorldCoord pos, String[] args, boolean claim) throws TownyException
      Method to select a List<WorldCoord> of coordinates. Area claims can be either circular or rectangular.
      Parameters:
      owner - - TownBlockOwner making the selection.
      pos - - WorldCoord where the selection is being made from.
      args - - Subcommands like rect, circle, auto or #.
      claim - - This selection will result in claiming for a resident or town.
      Returns:
      List<WorldCoord> of WorldCoord.
      Throws:
      TownyException - - Thrown when invalid subcommands are given.
    • filterInvalidProximityTownBlocks

      public static List<WorldCoord> filterInvalidProximityTownBlocks(List<WorldCoord> selection, Town town)
      Returns a list containing only townblocks that can be claimed. Filters out townblocks too close to other towns as set in the config.
      Parameters:
      selection - - List<WorldCoord> of coordinates
      town - - Town to check distance from
      Returns:
      List of WorldCoord
    • filterInvalidProximityToHomeblock

      public static List<WorldCoord> filterInvalidProximityToHomeblock(List<WorldCoord> selection, Town town)
      Returns a list containing only townblocks that can be claimed. Filters out townblocks too close to other town homeblocks as set in the config.
      Parameters:
      selection - List<WorldCoord> of coordinates
      town - Town to check distance from
      Returns:
      List of WorldCoord
    • isTooCloseToHomeBlock

      public static boolean isTooCloseToHomeBlock(WorldCoord wc, Town town)
      Is the WorldCoord too close to another town's HomeBlock.
      Parameters:
      wc - WorldCoord to check distance from.
      town - Town whos homeblock we don't have to account for.
      Returns:
      true if the WorldCoord is too close to a homeblock.
    • filterOutTownOwnedBlocks

      public static List<WorldCoord> filterOutTownOwnedBlocks(List<WorldCoord> selection)
      Returns a list containing only wilderness townblocks.
      Parameters:
      selection - List of Coordinates (List<WorldCoord>)
      Returns:
      List of WorldCoord.
    • filterOutWildernessBlocks

      public static List<WorldCoord> filterOutWildernessBlocks(List<WorldCoord> selection)
      Returns a List containing only claimed townblocks.
      Parameters:
      selection - List of Coordinates (List<WorldCoord>)
      Returns:
      List of WorldCoord
    • filterOwnedBlocks

      public static List<WorldCoord> filterOwnedBlocks(TownBlockOwner owner, List<WorldCoord> selection)
      Returns a List containing only claimed townblocks, owned by the given owner.
      Parameters:
      owner - TownBlockOwner which owns the townblock.
      selection - List of Coordinates (List<WorldCoord>)
      Returns:
      List of WorldCoord owned by the given owner.
    • filterUnownedBlocks

      public static List<WorldCoord> filterUnownedBlocks(TownBlockOwner owner, List<WorldCoord> selection)
      Returns a List containing only claimed townblocks, which are not owned by the given owner.
      Parameters:
      owner - TownBlockOwner which owns the townblock.
      selection - List of Coordinates (List<WorldCoord>)
      Returns:
      List of WorldCoord not owned by the given owner.
    • filterHomeBlock

      public static boolean filterHomeBlock(Town town, List<WorldCoord> selection)
    • filterPlotsByGroup

      public static List<WorldCoord> filterPlotsByGroup(PlotGroup group, List<WorldCoord> selection)
      Gives a list of townblocks that have membership to the specified group.
      Parameters:
      group - The plot group to filter against.
      selection - The selection of townblocks.
      Returns:
      A List of WorldCoord that contains the coordinates of townblocks part of the specified group.
    • getPlotGroupsFromSelection

      public static HashSet<PlotGroup> getPlotGroupsFromSelection(List<WorldCoord> selection)
    • filterPlotsForSale

      public static List<WorldCoord> filterPlotsForSale(Resident resident, List<WorldCoord> selection)
      Gather plots that are for sale only, using a resident to determine whether they can be bought.
      Parameters:
      resident - Resident who would be buying the plots.
      selection - List<WorldCoord> from which to get plots that are for sale.
      Returns:
      List<WorldCoord> that are all for sale.
    • filterPlotsForSale

      public static List<WorldCoord> filterPlotsForSale(List<WorldCoord> selection)
      Gather plots that are for sale only, currently used only for setting plots to notforsale.
      Parameters:
      selection - List<WorldCoord> from which to get plots that are for sale.
      Returns:
      List<WorldCoord> that are all for sale.
    • filterPlotsNotForSale

      public static List<WorldCoord> filterPlotsNotForSale(List<WorldCoord> selection)
      Gather plots that are not for sale only.
      Parameters:
      selection - List<WorldCoord> from which to get plots that are not for sale.
      Returns:
      List<WorldCoord> that are all not for sale.
    • filterOutResidentBlocks

      public static List<WorldCoord> filterOutResidentBlocks(Resident resident, List<WorldCoord> selection)
      Returns a List containing only claimed townblocks, which are: - not personally owned by a resident who isn't the given resident
      Parameters:
      resident - The Resident to ignore.
      selection - List of Coordinates (List<WorldCoord>)
      Returns:
      List of townblocks which does not includes townblocks owned by players who aren't the given resident.
    • filterOutUnwantedBiomeWorldCoords

      public static List<WorldCoord> filterOutUnwantedBiomeWorldCoords(org.bukkit.entity.Player player, List<WorldCoord> selection)
      Returns a List containing only WorldCoords which are not composed of "too much" bad biomes, with the threshold determined by the config.
      Parameters:
      player - Player trying to claim.
      selection - List of WorldCoords.
      Returns:
      a List of WorldCoords which have passed the biome requirements.
    • filterOutOceanBiomeWorldCoords

      public static List<WorldCoord> filterOutOceanBiomeWorldCoords(org.bukkit.entity.Player player, List<WorldCoord> selection)
      Returns a List containing only WorldCoords which are not composed of "too much" ocean biomes, with the threshold determined by the config.
      Parameters:
      player - Player trying to claim.
      selection - List of WorldCoords.
      Returns:
      a List of WorldCoords which have passed the biome requirements.
    • filterOutByBiome

      public static List<WorldCoord> filterOutByBiome(org.bukkit.entity.Player player, List<WorldCoord> selection, Predicate<WorldCoord> biomeThresholdTest, String errorMsg)
    • getAreaSelectPivot

      public static int getAreaSelectPivot(String[] args)
    • isOnEdgeOfOwnership

      public static boolean isOnEdgeOfOwnership(TownBlockOwner owner, WorldCoord worldCoord)