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 Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    PlotFlag​(@NonNull T value, @NonNull Caption flagCategory, @NonNull Caption flagDescription)
    Construct a new flag instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    canEqual​(Object other)
     
    createFlagInstance​(@NonNull T value)
    Create a new instance of the flag using a provided (non-null) value.
    boolean
    equals​(Object o)
     
    protected abstract F
    flagOf​(@NonNull T value)
     
    abstract String
    An example of a string that would parse into a valid flag value.
    Get the category this flag belongs to.
    Get a simple caption that describes the flag usage.
    static <T,​ F extends PlotFlag<T,​ F>>
    String
    getFlagName​(Class<F> flagClass)
    Return the name of the flag.
    Get the flag name.
    Get the tab completable values associated with the flag type, or an empty collection if tab completion isn't supported.
    @NonNull T
    Get the flag value
    int
     
    boolean
    Get if the flag's permission should check for values.
    abstract F
    merge​(@NonNull T newValue)
    Merge this flag's value with another value and return an instance holding the merged value.
    abstract F
    parse​(@NonNull String input)
    Parse a string into a flag, and throw an exception in the case that the string does not represent a valid flag value.
    abstract String
    Returns a string representation of the flag instance, that when passed through parse(String) will result in an equivalent instance of the flag.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 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

      public Caption getFlagDescription()
      Get a simple caption that describes the flag usage.
      Returns:
      Flag description.
    • getFlagCategory

      public Caption 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
    • 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

      public Collection<String> 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
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object