Class ResidentModeHandler
java.lang.Object
com.palmergames.bukkit.towny.object.resident.mode.ResidentModeHandler
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static void
addMode
(Resident resident, AbstractResidentMode mode) static void
applyDefaultModes
(Resident resident, boolean notify) static void
clearModes
(Resident resident, boolean notify) Removes all modes from a Resident.static void
clearModes
(org.bukkit.entity.Player player) Removes all modes from a Player.static @Nullable AbstractResidentMode
static Set
<AbstractResidentMode> static Set
<AbstractResidentMode> getModes
(org.bukkit.entity.Player player) protected static Set
<AbstractResidentMode> getResidentModes
(Resident resident) getResidentModesNames
(Resident resident) static boolean
hasMode
(Resident resident, AbstractResidentMode mode) static boolean
static void
static boolean
static boolean
isValidMode
(String name) static void
registerMode
(@NotNull AbstractResidentMode mode) Registers a new ResidentMode.protected static void
removeMode
(Resident resident, AbstractResidentMode mode) static void
resetModes
(Resident resident, boolean notify) Removes all modes from a Resident and then resets their modes to the Default Modes according to their permissions.static void
toggleMode
(Resident resident, AbstractResidentMode mode, boolean notify) Will attempt to toggle on or off, a AbstractResidentMode on a Resident.static void
toggleMode
(Resident resident, String name, boolean notify) Will attempt to toggle on or off, a named mode on a Resident.static void
toggleMode
(org.bukkit.entity.Player player, String name, boolean notify) Will attempt to toggle on or off, a named mode on a Player.static void
toggleModes
(Resident resident, String[] names, boolean notify, boolean clearModes) Will clear a Resident's modes and then apply all of the given named Modes.static void
toggleModes
(org.bukkit.entity.Player player, String[] names, boolean notify) Will clear a Player's modes and then apply all of the given named Modes.
-
Constructor Details
-
ResidentModeHandler
public ResidentModeHandler()
-
-
Method Details
-
initialize
public static void initialize() -
registerMode
Registers a new ResidentMode. Should not be used at all outside of the ResidentModesInitializeEvent.- Parameters:
mode
- The ResidentMode to add.- Throws:
TownyException
- if a mode with this name is already registered.
-
isValidMode
-
isValidMode
-
getValidModeNames
-
getMode
-
getModes
-
getModes
-
hasMode
-
hasMode
-
toggleModes
public static void toggleModes(org.bukkit.entity.Player player, String[] names, boolean notify) throws TownyException Will clear a Player's modes and then apply all of the given named Modes.- Parameters:
player
- Player to toggle modes on.names
- String[] of all modes to add to the Player.notify
- whether to notify the Player of their new modes.- Throws:
TownyException
-
toggleModes
public static void toggleModes(Resident resident, String[] names, boolean notify, boolean clearModes) Will clear a Resident's modes and then apply all of the given named Modes.- Parameters:
resident
- Resident to toggle modes on.names
- String[] of all modes to add to the Resident.notify
- whether to notify the Resident of their new modes.clearModes
- whether a resident's nodes are cleared before toggling happens.
-
toggleMode
public static void toggleMode(org.bukkit.entity.Player player, String name, boolean notify) throws TownyException Will attempt to toggle on or off, a named mode on a Player.- Parameters:
player
- Player to toggle a mode on.name
- the String name of theAbstractResidentMode
to toggle.notify
- whether to notify the Player of their mode changing.- Throws:
TownyException
- thrown when a mode doesn't exist, the Player does not have permisson, or when the ResidentToggleModeEvent is cancelled, or the Player isn't a registered Resident.
-
toggleMode
Will attempt to toggle on or off, a named mode on a Resident.- Parameters:
resident
- Resident to toggle a mode on.name
- the String name of theAbstractResidentMode
to toggle.notify
- whether to notify the Resident of their mode changing.- Throws:
TownyException
- thrown when a mode doesn't exist, the resident does not have permisson, or when the ResidentToggleModeEvent is cancelled.
-
toggleMode
public static void toggleMode(Resident resident, AbstractResidentMode mode, boolean notify) throws TownyException Will attempt to toggle on or off, a AbstractResidentMode on a Resident.- Parameters:
resident
- Resident to toggle a mode on.mode
-AbstractResidentMode
to toggle on or off.notify
- whether to notify the Resident of their mode changing.- Throws:
TownyException
- thrown when a mode doesn't exist, the resident does not have permisson, or when the ResidentToggleModeEvent is cancelled.
-
clearModes
public static void clearModes(org.bukkit.entity.Player player) Removes all modes from a Player.- Parameters:
player
- Player to remove the modes from.
-
clearModes
Removes all modes from a Resident.- Parameters:
resident
- Resident to remove the modes from.notify
- whether to notify the Resident of their modes being cleared.
-
resetModes
Removes all modes from a Resident and then resets their modes to the Default Modes according to their permissions.- Parameters:
resident
- Resident to reset.notify
- whether to notify the Resident of their modes after.
-
applyDefaultModes
-
addMode
-
removeMode
-
getResidentModesNames
-
getResidentModes
-