Class RegionFlag<T>

java.lang.Object
org.empirewar.orbis.flag.RegionFlag<T>
Type Parameters:
T - the type this flag has
All Implemented Interfaces:
net.kyori.adventure.key.Keyed
Direct Known Subclasses:
MutableRegionFlag, RegistryRegionFlag

public sealed class RegionFlag<T> extends Object implements net.kyori.adventure.key.Keyed permits MutableRegionFlag<T>, RegistryRegionFlag<T>
Represents the flag of a Region.

All flags are Keyed and thus have a Key to identify them.

To add a region flag, you should use the RegistryRegionFlag.builder() and register it to OrbisRegistries.FLAGS.

Note that all flags must provide a Codec of RegionFlag. This allows for deserialization and serialization and is also used in command parsing.

You may need to add Mojang's DataFixerUpper to your dependencies.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final com.mojang.serialization.Codec<T>
     
    protected final net.kyori.adventure.key.Key
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    RegionFlag(net.kyori.adventure.key.Key key, com.mojang.serialization.Codec<T> codec)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    com.mojang.serialization.MapCodec<? extends RegionFlag<T>>
    Gets the codec for this flag.
    int
     
    @NotNull net.kyori.adventure.key.Key
    key()
     
    com.mojang.serialization.Codec<T>
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • key

      protected final net.kyori.adventure.key.Key key
    • codec

      protected final com.mojang.serialization.Codec<T> codec
  • Constructor Details

    • RegionFlag

      protected RegionFlag(net.kyori.adventure.key.Key key, com.mojang.serialization.Codec<T> codec)
  • Method Details

    • typeCodec

      public com.mojang.serialization.Codec<T> typeCodec()
    • getCodec

      public com.mojang.serialization.MapCodec<? extends RegionFlag<T>> getCodec(RegistryRegionFlag<?> registry)
      Gets the codec for this flag.

      The parameter provided is the instance of this flag type in the OrbisRegistries.FLAGS registry. This allows for transformation within the codec to occur.

      Parameters:
      registry - the registry value of this flag
      Returns:
      the codec
    • key

      @NotNull public @NotNull net.kyori.adventure.key.Key key()
      Specified by:
      key in interface net.kyori.adventure.key.Keyed
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object