Class AbstractTokenFactory<I>

java.lang.Object
com.minecolonies.api.colony.requestsystem.token.AbstractTokenFactory<I>
All Implemented Interfaces:
IFactory<I,StandardToken>, ITokenFactory<I,StandardToken>
Direct Known Subclasses:
InitializedTokenFactory, RandomSeededTokenFactory, StandardTokenFactory

public abstract class AbstractTokenFactory<I> extends Object implements ITokenFactory<I,StandardToken>
An abstract implementation of the ITokenFactory interface that handles serialization etc.
  • Field Details

  • Constructor Details

    • AbstractTokenFactory

      public AbstractTokenFactory()
  • Method Details

    • getFactoryOutputType

      @NotNull public @NotNull com.google.common.reflect.TypeToken<StandardToken> getFactoryOutputType()
      Description copied from interface: IFactory
      Method to get the type this factory can produce.
      Specified by:
      getFactoryOutputType in interface IFactory<I,StandardToken>
      Returns:
      The type of request this factory can produce.
    • serialize

      @NotNull public @NotNull net.minecraft.nbt.CompoundTag serialize(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull IFactoryController controller, @NotNull @NotNull StandardToken request)
      Method to serialize a given constructable.
      Specified by:
      serialize in interface IFactory<I,StandardToken>
      Parameters:
      controller - The controller that can be used to serialize complicated types.
      request - The request to serialize.
      Returns:
      The serialized data of the given requets.
    • deserialize

      @NotNull public @NotNull StandardToken deserialize(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull IFactoryController controller, @NotNull @NotNull net.minecraft.nbt.CompoundTag nbt)
      Method to deserialize a given constructable.
      Specified by:
      deserialize in interface IFactory<I,StandardToken>
      Parameters:
      controller - The controller that can be used to deserialize complicated types.
      nbt - The data of the request that should be deserialized.
      Returns:
      The request that corresponds with the given data in the nbt
    • serialize

      public void serialize(IFactoryController controller, StandardToken input, net.minecraft.network.RegistryFriendlyByteBuf packetBuffer)
      Description copied from interface: IFactory
      Method to serialize a given constructable.
      Specified by:
      serialize in interface IFactory<I,StandardToken>
      Parameters:
      controller - The controller that can be used to serialize complicated types.
      input - The request to serialize.
      packetBuffer - The buffer to serialize into.
    • deserialize

      public StandardToken deserialize(IFactoryController controller, net.minecraft.network.RegistryFriendlyByteBuf buffer) throws Throwable
      Description copied from interface: IFactory
      Method to deserialize a given constructable.
      Specified by:
      deserialize in interface IFactory<I,StandardToken>
      Parameters:
      controller - The controller that can be used to deserialize complicated types.
      buffer - The data buffer of the request that should be deserialized.
      Returns:
      The request that corresponds with the given data in the nbt
      Throws:
      Throwable