Class PlotFlag<T,F extends PlotFlag<T,F>>

java.lang.Object
com.plotsquared.core.plot.flag.PlotFlag<T,F>
Type Parameters:
T - Value contained in the flag.
Direct Known Subclasses:
BooleanFlag, DenyTeleportFlag, FlyFlag, GamemodeFlag, GuestGamemodeFlag, KeepFlag, LiquidFlowFlag, ListFlag, MusicFlag, NumberFlag, PlotTitleFlag, StringFlag, TimedFlag, TitlesFlag, WeatherFlag

public abstract class PlotFlag<T,F extends PlotFlag<T,F>> extends Object
A plot flag is any property that can be assigned to a plot, that will alter its functionality in some way. These are user assignable in-game, or via configuration files.
  • Constructor Details

    • PlotFlag

      protected PlotFlag(@NonNull T value, @NonNull Caption flagCategory, @NonNull Caption flagDescription)
      Construct a new flag instance.
      Parameters:
      value - Flag value
      flagCategory - The flag category
      flagDescription - A caption describing the flag functionality
  • Method Details

    • getFlagName

      public static <T, F extends PlotFlag<T, F>> String getFlagName(Class<F> flagClass)
      Return the name of the flag.
      Type Parameters:
      T - Value type
      F - Flag type
      Parameters:
      flagClass - Flag class
      Returns:
      The name of the flag implemented by the given class
    • getValue

      public final @NonNull T getValue()
      Get the flag value
      Returns:
      Non-nullable flag value
    • parse

      public abstract F parse(@NonNull String input) throws FlagParseException
      Parse a string into a flag, and throw an exception in the case that the string does not represent a valid flag value. This instance won't change its state, but instead an instance holding the parsed flag value will be returned.
      Parameters:
      input - String to parse.
      Returns:
      Parsed value, if valid.
      Throws:
      FlagParseException - If the value could not be parsed.
    • merge

      public abstract F merge(@NonNull T newValue)
      Merge this flag's value with another value and return an instance holding the merged value.
      Parameters:
      newValue - New flag value.
      Returns:
      Flag containing parsed flag value.
    • toString

      public abstract String toString()
      Returns a string representation of the flag instance, that when passed through parse(String) will result in an equivalent instance of the flag.
      Overrides:
      toString in class Object
      Returns:
      String representation of the flag
    • getName

      public final String getName()
      Get the flag name.
      Returns:
      Flag name
    • getFlagDescription

      Get a simple caption that describes the flag usage.
      Returns:
      Flag description.
    • getFlagCategory

      Get the category this flag belongs to. Usually a caption from TranslatableCaption

      These categories are used to categorize the flags when outputting flag lists to players.

      Returns:
      Flag category
    • isValuedPermission

      public boolean isValuedPermission()
      Get if the flag's permission should check for values. E.g. plots.flag.set.music.VALUE
      Returns:
      if valued permission
      Since:
      6.0.10
    • getExample

      public abstract String getExample()
      An example of a string that would parse into a valid flag value.
      Returns:
      An example flag value.
    • flagOf

      protected abstract F flagOf(@NonNull T value)
    • createFlagInstance

      public final F createFlagInstance(@NonNull T value)
      Create a new instance of the flag using a provided (non-null) value.
      Parameters:
      value - The flag value
      Returns:
      The created flag instance
    • getTabCompletions

      Get the tab completable values associated with the flag type, or an empty collection if tab completion isn't supported.
      Returns:
      Collection containing tab completable flag values
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • canEqual

      @Deprecated(forRemoval=true, since="6.6.0") protected boolean canEqual(Object other)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method is not meant to be invoked or overridden, with no replacement.