Class ResidentModeHandler

java.lang.Object
com.palmergames.bukkit.towny.object.resident.mode.ResidentModeHandler

public class ResidentModeHandler extends Object
  • Constructor Details

    • ResidentModeHandler

      public ResidentModeHandler()
  • Method Details

    • initialize

      public static void initialize()
    • registerMode

      public static void registerMode(@NotNull @NotNull AbstractResidentMode mode) throws TownyException
      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

      public static boolean isValidMode(String name)
    • isValidMode

      public static boolean isValidMode(AbstractResidentMode mode)
    • getValidModeNames

      public static List<String> getValidModeNames()
    • getMode

      @Nullable public static @Nullable AbstractResidentMode getMode(String name)
    • getModes

      public static Set<AbstractResidentMode> getModes(org.bukkit.entity.Player player)
    • getModes

      public static Set<AbstractResidentMode> getModes(Resident resident)
    • hasMode

      public static boolean hasMode(Resident resident, String name)
    • hasMode

      public static boolean hasMode(Resident resident, AbstractResidentMode mode)
    • 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 the AbstractResidentMode 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

      public static void toggleMode(Resident resident, String name, boolean notify) throws TownyException
      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 the AbstractResidentMode 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

      public static void clearModes(Resident resident, boolean notify)
      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

      public 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.
      Parameters:
      resident - Resident to reset.
      notify - whether to notify the Resident of their modes after.
    • applyDefaultModes

      public static void applyDefaultModes(Resident resident, boolean notify)
    • addMode

      protected static void addMode(Resident resident, AbstractResidentMode mode)
    • removeMode

      protected static void removeMode(Resident resident, AbstractResidentMode mode)
    • getResidentModesNames

      public static List<String> getResidentModesNames(Resident resident)
    • getResidentModes

      protected static Set<AbstractResidentMode> getResidentModes(Resident resident)