Class BaseCommand

java.lang.Object
com.palmergames.bukkit.towny.command.BaseCommand
All Implemented Interfaces:
org.bukkit.command.TabCompleter
Direct Known Subclasses:
InviteCommand, NationCommand, PlotCommand, ResidentCommand, TownCommand, TownyAdminCommand, TownyCommand, TownyWorldCommand

public class BaseCommand extends Object implements org.bukkit.command.TabCompleter
  • Field Details

    • setOnOffCompletes

      public static final List<String> setOnOffCompletes
    • numbers

      public static final List<String> numbers
  • Constructor Details

    • BaseCommand

      public BaseCommand()
  • Method Details

    • onTabComplete

      public List<String> onTabComplete(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String alias, String[] args)
      Specified by:
      onTabComplete in interface org.bukkit.command.TabCompleter
    • getTownyStartingWith

      public static List<String> getTownyStartingWith(String arg, String type)
      Returns a List<String> containing strings of resident, town, and/or nation names that match with arg. Can check for multiple types, for example "rt" would check for residents and towns but not nations or worlds.
      Parameters:
      arg - the string to match with the chosen type
      type - the type of Towny object to check for, can be r(esident), t(own), n(ation), w(orld), or any combination of those to check
      Returns:
      Matches for the arg with the chosen type
    • filterByStartOrGetTownyStartingWith

      public static List<String> filterByStartOrGetTownyStartingWith(List<String> filters, String arg, String type)
      Checks if arg starts with filters, if not returns matches from getTownyStartingWith(String, String). Add a "+" to the type to return both cases
      Parameters:
      filters - the strings to filter arg with
      arg - the string to check with filters and possibly match with Towny objects if no filters are found
      type - the type of check to use, see getTownyStartingWith(String, String) for possible types. Add "+" to check for both filters and getTownyStartingWith(String, String)
      Returns:
      Matches for the arg filtered by filters or checked with type
    • getNationResidentNamesOfPlayerStartingWith

      public static List<String> getNationResidentNamesOfPlayerStartingWith(org.bukkit.entity.Player player, String str)
      Returns the names a player's nation's residents that start with a string
      Parameters:
      player - the player to get the nation's residents of
      str - the string to check if the nation's residents start with
      Returns:
      the resident names that match str
    • getTownResidentNamesOfPlayerStartingWith

      public static List<String> getTownResidentNamesOfPlayerStartingWith(org.bukkit.entity.Player player, String str)
      Returns the names a player's town's residents that start with a string
      Parameters:
      player - the player to get the town's residents of
      str - the string to check if the town's residents start with
      Returns:
      the resident names that match str
    • getResidentsOfTownStartingWith

      public static List<String> getResidentsOfTownStartingWith(String townName, String str)
      Returns the names a town's residents that start with a string
      Parameters:
      townName - the town to get the residents of
      str - the string to check if the town's residents start with
      Returns:
      the resident names that match str
    • getResidentsWithoutTownStartingWith

      public static List<String> getResidentsWithoutTownStartingWith(String str)
      Returns a list of residents which are online and have no town.
      Parameters:
      str - the string to check if the resident's name starts with.
      Returns:
      the residents name or an empty list.
    • getVisibleResidentsForPlayerWithoutTownsStartingWith

      public List<String> getVisibleResidentsForPlayerWithoutTownsStartingWith(String arg, org.bukkit.command.CommandSender sender)
      Returns a list of residents which are online and have no town, and can be seen by the sender.
      Parameters:
      arg - the string to check if the resident's name starts with.
      Returns:
      the residents names or an empty list.
    • parseToggleChoice

      protected static Optional<Boolean> parseToggleChoice(String str)
      Parses the given string into a boolean choice.
      Parameters:
      str - The string to parse
      Returns:
      true for "ON", false for "OFF", or null if no match.
    • getTownFromPlayerOrThrow

      @NotNull protected static @NotNull Town getTownFromPlayerOrThrow(org.bukkit.entity.Player player) throws TownyException
      Throws:
      TownyException
    • getTownFromResidentOrThrow

      @NotNull protected static @NotNull Town getTownFromResidentOrThrow(@NotNull @NotNull Resident resident) throws TownyException
      Throws:
      TownyException
    • getResidentOrThrow

      @NotNull protected static @NotNull Resident getResidentOrThrow(UUID playerUUID) throws TownyException
      Throws:
      TownyException
    • getResidentOrThrow

      @NotNull @Contract("null -> fail") protected static @NotNull Resident getResidentOrThrow(@Nullable @Nullable org.bukkit.entity.Player player) throws TownyException
      Throws:
      TownyException
    • getResidentOrThrow

      @NotNull protected static @NotNull Resident getResidentOrThrow(String residentName) throws TownyException
      Throws:
      TownyException
    • getTownOrThrow

      @NotNull protected static @NotNull Town getTownOrThrow(String townName) throws TownyException
      Throws:
      TownyException
    • getNationOrThrow

      @NotNull protected static @NotNull Nation getNationOrThrow(String nationName) throws TownyException
      Throws:
      TownyException
    • getNationFromPlayerOrThrow

      @NotNull protected static @NotNull Nation getNationFromPlayerOrThrow(org.bukkit.entity.Player player) throws TownyException
      Throws:
      TownyException
    • getNationFromResidentOrThrow

      @NotNull protected static @NotNull Nation getNationFromResidentOrThrow(Resident resident) throws TownyException
      Throws:
      TownyException
    • getNationFromTownOrThrow

      @NotNull protected static @NotNull Nation getNationFromTownOrThrow(Town town) throws TownyException
      Throws:
      TownyException
    • catchPlayer

      public static void catchPlayer(org.bukkit.command.CommandSender sender) throws TownyException
      Throws:
      TownyException
    • catchConsole

      public static org.bukkit.entity.Player catchConsole(org.bukkit.command.CommandSender sender) throws TownyException
      Throws:
      TownyException
    • checkPermOrThrow

      public static void checkPermOrThrow(org.bukkit.permissions.Permissible permissible, String node) throws NoPermissionException
      Throws:
      NoPermissionException
    • checkPermOrThrowWithMessage

      public static void checkPermOrThrowWithMessage(org.bukkit.permissions.Permissible permissible, String node, Translatable errormsg) throws NoPermissionException
      Throws:
      NoPermissionException
    • catchNPCResident

      public static void catchNPCResident(Resident resident) throws ResidentNPCException
      Throws:
      ResidentNPCException
    • prettyMoney

      public static String prettyMoney(double cost)