Class PaperComponents

java.lang.Object
io.papermc.paper.text.PaperComponents

@NullMarked public final class PaperComponents extends Object
Paper API-specific methods for working with Components and related.
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
    Deprecated, for removal: This API element is subject to removal in a future version.
    use GsonComponentSerializer.colorDownsamplingGson()
    static net.kyori.adventure.text.flattener.ComponentFlattener
    Return a component flattener that can use game data to resolve extra information about components.
    static net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
    Deprecated, for removal: This API element is subject to removal in a future version.
    use GsonComponentSerializer.gson()
    static net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
    Deprecated, for removal: This API element is subject to removal in a future version.
    use LegacyComponentSerializer.legacySection()
    static net.kyori.adventure.text.serializer.plain.PlainComponentSerializer
    Deprecated, for removal: This API element is subject to removal in a future version.
    will be removed in adventure 5.0.0, use PlainTextComponentSerializer.plainText()
    static net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer
    Deprecated, for removal: This API element is subject to removal in a future version.
    use PlainTextComponentSerializer.plainText()
    static net.kyori.adventure.text.Component
    resolveWithContext(net.kyori.adventure.text.Component input, @Nullable CommandSender context, @Nullable Entity scoreboardSubject)
    Resolves a component with a specific command sender and subject.
    static net.kyori.adventure.text.Component
    resolveWithContext(net.kyori.adventure.text.Component input, @Nullable CommandSender context, @Nullable Entity scoreboardSubject, boolean bypassPermissions)
    Resolves a component with a specific command sender and subject.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • resolveWithContext

      public static net.kyori.adventure.text.Component resolveWithContext(net.kyori.adventure.text.Component input, @Nullable CommandSender context, @Nullable Entity scoreboardSubject) throws IOException
      Resolves a component with a specific command sender and subject.

      Note that in Vanilla, elevated permissions are usually required to use '@' selectors in various component types, but this method should not check such permissions from the sender.

      A CommandSender argument is required to resolve:

      • NBTComponent
      • ScoreComponent
      • SelectorComponent
      A Entity argument is optional to help resolve:
      • ScoreComponent
      TranslatableComponents don't require any extra arguments.
      Parameters:
      input - the component to resolve
      context - the command sender to resolve with
      scoreboardSubject - the scoreboard subject to use (for use with ScoreComponents)
      Returns:
      the resolved component
      Throws:
      IOException - if a syntax error tripped during resolving
    • resolveWithContext

      public static net.kyori.adventure.text.Component resolveWithContext(net.kyori.adventure.text.Component input, @Nullable CommandSender context, @Nullable Entity scoreboardSubject, boolean bypassPermissions) throws IOException
      Resolves a component with a specific command sender and subject.

      Note that in Vanilla, elevated permissions are required to use '@' selectors in various component types. If the boolean bypassPermissions argument is false, the CommandSender argument will be used to query those permissions.

      A CommandSender argument is required to resolve:

      • NBTComponent
      • ScoreComponent
      • SelectorComponent
      A Entity argument is optional to help resolve:
      • ScoreComponent
      TranslatableComponents don't require any extra arguments.
      Parameters:
      input - the component to resolve
      context - the command sender to resolve with
      scoreboardSubject - the scoreboard subject to use (for use with ScoreComponents)
      bypassPermissions - true to bypass permissions checks for resolving components
      Returns:
      the resolved component
      Throws:
      IOException - if a syntax error tripped during resolving
    • flattener

      public static net.kyori.adventure.text.flattener.ComponentFlattener flattener()
      Return a component flattener that can use game data to resolve extra information about components.
      Returns:
      a component flattener
    • plainSerializer

      @Deprecated(forRemoval=true, since="1.18.1") public static net.kyori.adventure.text.serializer.plain.PlainComponentSerializer plainSerializer()
      Deprecated, for removal: This API element is subject to removal in a future version.
      will be removed in adventure 5.0.0, use PlainTextComponentSerializer.plainText()
      Get a serializer for Components that will convert components to a plain-text string.

      Implementations may provide a serializer capable of processing any information that requires access to implementation details.

      Returns:
      a serializer to plain text
    • plainTextSerializer

      @Deprecated(forRemoval=true, since="1.18.2") public static net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer plainTextSerializer()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use PlainTextComponentSerializer.plainText()
      Get a serializer for Components that will convert components to a plain-text string.

      Implementations may provide a serializer capable of processing any information that requires access to implementation details.

      Returns:
      a serializer to plain text
    • gsonSerializer

      @Deprecated(forRemoval=true, since="1.18.2") public static net.kyori.adventure.text.serializer.gson.GsonComponentSerializer gsonSerializer()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use GsonComponentSerializer.gson()
      Get a serializer for Components that will convert to and from the standard JSON serialization format using Gson.

      Implementations may provide a serializer capable of processing any information that requires implementation details, such as legacy (pre-1.16) hover events.

      Returns:
      a json component serializer
    • colorDownsamplingGsonSerializer

      @Deprecated(forRemoval=true, since="1.18.2") public static net.kyori.adventure.text.serializer.gson.GsonComponentSerializer colorDownsamplingGsonSerializer()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use GsonComponentSerializer.colorDownsamplingGson()
      Get a serializer for Components that will convert to and from the standard JSON serialization format using Gson, downsampling any RGB colors to their nearest NamedTextColor counterpart.

      Implementations may provide a serializer capable of processing any information that requires implementation details, such as legacy (pre-1.16) hover events.

      Returns:
      a json component serializer
    • legacySectionSerializer

      @Deprecated(forRemoval=true, since="1.18.2") public static net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacySectionSerializer()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use LegacyComponentSerializer.legacySection()
      Get a serializer for Components that will convert to and from the legacy component format used by Bukkit. This serializer uses the LegacyComponentSerializer.Builder.useUnusualXRepeatedCharacterHexFormat() option to match upstream behavior.

      This legacy serializer uses the standard section symbol to mark formatting characters.

      Implementations may provide a serializer capable of processing any information that requires access to implementation details.

      Returns:
      a section serializer