Record Class CommandSourceConverter<S>

java.lang.Object
java.lang.Record
org.geysermc.geyser.command.CommandSourceConverter<S>
Type Parameters:
S - server command sender type
Record Components:
senderType - class of the server command sender type
playerLookup - function for looking up a player command sender by UUID
consoleProvider - supplier of the console command sender
commandSourceLookup - supplier of the platform implementation of the GeyserCommandSource
All Implemented Interfaces:
org.incendo.cloud.SenderMapper<S,GeyserCommandSource>

public record CommandSourceConverter<S>(Class<S> senderType, Function<UUID,S> playerLookup, Supplier<S> consoleProvider, Function<S,GeyserCommandSource> commandSourceLookup) extends Record implements org.incendo.cloud.SenderMapper<S,GeyserCommandSource>
Converts GeyserCommandSources to the server's command sender type (and back) in a lenient manner.
  • Constructor Details

  • Method Details

    • layered

      public static <P, S> CommandSourceConverter<S> layered(Class<S> senderType, Function<UUID,P> playerLookup, Function<P,S> senderLookup, Supplier<S> consoleProvider, Function<S,GeyserCommandSource> commandSourceLookup)
      Creates a new CommandSourceConverter for a server platform in which the player type is not a command sender type, and must be mapped.
      Type Parameters:
      P - server player type
      S - server command sender type
      Parameters:
      senderType - class of the command sender type
      playerLookup - function for looking up a player by UUID
      senderLookup - function for converting a player to a command sender
      consoleProvider - supplier of the console command sender
      commandSourceLookup - supplier of the platform implementation of GeyserCommandSource
      Returns:
      a new CommandSourceConverter
    • map

      public @NonNull GeyserCommandSource map(@NonNull S base)
      Specified by:
      map in interface org.incendo.cloud.SenderMapper<S,GeyserCommandSource>
    • reverse

      public @NonNull S reverse(GeyserCommandSource source) throws IllegalArgumentException
      Specified by:
      reverse in interface org.incendo.cloud.SenderMapper<S,GeyserCommandSource>
      Throws:
      IllegalArgumentException
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • senderType

      public Class<S> senderType()
      Returns the value of the senderType record component.
      Returns:
      the value of the senderType record component
    • playerLookup

      public Function<UUID,S> playerLookup()
      Returns the value of the playerLookup record component.
      Returns:
      the value of the playerLookup record component
    • consoleProvider

      public Supplier<S> consoleProvider()
      Returns the value of the consoleProvider record component.
      Returns:
      the value of the consoleProvider record component
    • commandSourceLookup

      public Function<S,GeyserCommandSource> commandSourceLookup()
      Returns the value of the commandSourceLookup record component.
      Returns:
      the value of the commandSourceLookup record component