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
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.entity.Player
catchConsole
(org.bukkit.command.CommandSender sender) static void
catchNPCResident
(Resident resident) static void
catchPlayer
(org.bukkit.command.CommandSender sender) static void
checkPermOrThrow
(org.bukkit.permissions.Permissible permissible, String node) static void
checkPermOrThrowWithMessage
(org.bukkit.permissions.Permissible permissible, String node, Translatable errormsg) filterByStartOrGetTownyStartingWith
(List<String> filters, String arg, String type) Checks if arg starts with filters, if not returns matches fromgetTownyStartingWith(String, String)
.protected static @NotNull Nation
getNationFromPlayerOrThrow
(org.bukkit.entity.Player player) protected static @NotNull Nation
getNationFromResidentOrThrow
(Resident resident) protected static @NotNull Nation
getNationFromTownOrThrow
(Town town) protected static @NotNull Nation
getNationOrThrow
(String nationName) getNationResidentNamesOfPlayerStartingWith
(org.bukkit.entity.Player player, String str) Returns the names a player's nation's residents that start with a stringprotected static @NotNull Resident
getResidentOrThrow
(String residentName) protected static @NotNull Resident
getResidentOrThrow
(UUID playerUUID) protected static @NotNull Resident
getResidentOrThrow
(@Nullable org.bukkit.entity.Player player) getResidentsOfTownStartingWith
(String townName, String str) Returns the names a town's residents that start with a stringReturns a list of residents which are online and have no town.protected static @NotNull Town
getTownFromPlayerOrThrow
(org.bukkit.entity.Player player) protected static @NotNull Town
getTownFromResidentOrThrow
(@NotNull Resident resident) protected static @NotNull Town
getTownOrThrow
(String townName) getTownResidentNamesOfPlayerStartingWith
(org.bukkit.entity.Player player, String str) Returns the names a player's town's residents that start with a stringgetTownyStartingWith
(String arg, String type) Returns a List<String> containing strings of resident, town, and/or nation names that match with arg.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.onTabComplete
(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String alias, String[] args) parseToggleChoice
(String str) Parses the given string into a boolean choice.static String
prettyMoney
(double cost)
-
Field Details
-
setOnOffCompletes
-
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 interfaceorg.bukkit.command.TabCompleter
-
getTownyStartingWith
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 typetype
- 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 fromgetTownyStartingWith(String, String)
. Add a "+" to the type to return both cases- Parameters:
filters
- the strings to filter arg witharg
- the string to check with filters and possibly match with Towny objects if no filters are foundtype
- the type of check to use, seegetTownyStartingWith(String, String)
for possible types. Add "+" to check for both filters andgetTownyStartingWith(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 ofstr
- 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 ofstr
- the string to check if the town's residents start with- Returns:
- the resident names that match str
-
getResidentsOfTownStartingWith
Returns the names a town's residents that start with a string- Parameters:
townName
- the town to get the residents ofstr
- the string to check if the town's residents start with- Returns:
- the resident names that match str
-
getResidentsWithoutTownStartingWith
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
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
- Throws:
TownyException
-
getNationOrThrow
- 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
- Throws:
TownyException
-
catchPlayer
- 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
- Throws:
ResidentNPCException
-
prettyMoney
-