Class BukkitConverters

java.lang.Object
com.comphenix.protocol.wrappers.BukkitConverters

public class BukkitConverters extends Object
Contains several useful equivalent converters for normal Bukkit types.
  • Constructor Details

    • BukkitConverters

      public BukkitConverters()
  • Method Details

    • getMapConverter

      public static <K, V> EquivalentConverter<Map<K,V>> getMapConverter(EquivalentConverter<K> keyConverter, EquivalentConverter<V> valConverter)
    • getListConverter

      public static <T> EquivalentConverter<List<T>> getListConverter(Class<?> listClass, EquivalentConverter<T> itemConverter)
    • getListConverter

      public static <T> EquivalentConverter<List<T>> getListConverter(EquivalentConverter<T> itemConverter)
      Retrieve an equivalent converter for a list of generic items.
      Type Parameters:
      T - Type
      Parameters:
      itemConverter - - an equivalent converter for the generic type.
      Returns:
      An equivalent converter.
    • getPairConverter

      public static <A, B> EquivalentConverter<Pair<A,B>> getPairConverter(EquivalentConverter<A> firstConverter, EquivalentConverter<B> secondConverter)
    • getEitherConverter

      public static <A, B> EquivalentConverter<Either<A,B>> getEitherConverter(EquivalentConverter<A> leftConverter, EquivalentConverter<B> rightConverter)
      Type Parameters:
      A - converted left type
      B - converted right type
      Parameters:
      leftConverter - convert the left value if available
      rightConverter - convert the right value if available
      Returns:
      converter for Mojang either class
    • getSetConverter

      public static <T> EquivalentConverter<Set<T>> getSetConverter(EquivalentConverter<T> itemConverter)
      Retrieve an equivalent converter for a set of generic items.
      Type Parameters:
      T - Element type
      Parameters:
      itemConverter - - an equivalent converter for the generic type.
      Returns:
      An equivalent converter.
    • getArrayConverter

      public static <T> EquivalentConverter<Iterable<? extends T>> getArrayConverter(Class<?> genericItemType, EquivalentConverter<T> itemConverter)
      Retrieve an equivalent converter for an array of generic items.
      Type Parameters:
      T - Type

      The array is wrapped in a list.

      Parameters:
      genericItemType - - the generic item type.
      itemConverter - - an equivalent converter for the generic type.
      Returns:
      An equivalent converter.
    • getWrappedGameProfileConverter

      public static EquivalentConverter<WrappedGameProfile> getWrappedGameProfileConverter()
      Retrieve a converter for wrapped game profiles.
      Returns:
      Wrapped game profile converter.
    • getWrappedChatComponentConverter

      public static EquivalentConverter<WrappedChatComponent> getWrappedChatComponentConverter()
      Retrieve a converter for wrapped chat components.
      Returns:
      Wrapped chat component.
    • getWrappedBlockDataConverter

      public static EquivalentConverter<WrappedBlockData> getWrappedBlockDataConverter()
      Retrieve a converter for wrapped block data.
      Returns:
      Wrapped block data.
    • getWrappedRegistrable

      public static EquivalentConverter<WrappedRegistrable> getWrappedRegistrable(@NotNull @NotNull Class<?> registrableClass)
      Retrieve a converter for wrapped block entity type.
      Returns:
      Wrapped block entity type.
    • getWrappedAttributeConverter

      public static EquivalentConverter<WrappedAttribute> getWrappedAttributeConverter()
      Retrieve a converter for wrapped attribute snapshots.
      Returns:
      Wrapped attribute snapshot converter.
    • getWrappedProfilePublicKeyConverter

      public static EquivalentConverter<WrappedProfilePublicKey> getWrappedProfilePublicKeyConverter()
    • getWrappedPublicKeyDataConverter

      public static EquivalentConverter<WrappedProfilePublicKey.WrappedProfileKeyData> getWrappedPublicKeyDataConverter()
    • getWrappedRemoteChatSessionDataConverter

      public static EquivalentConverter<WrappedRemoteChatSessionData> getWrappedRemoteChatSessionDataConverter()
    • getWrappedSignatureConverter

      public static EquivalentConverter<WrappedSaltedSignature> getWrappedSignatureConverter()
      Returns:
      converter for cryptographic signature data that are used in login and chat packets
    • getWrappedMessageSignatureConverter

      public static EquivalentConverter<WrappedMessageSignature> getWrappedMessageSignatureConverter()
      Returns:
      converter for an encoded cryptographic message signature
    • getWrappedChunkDataConverter

      public static EquivalentConverter<WrappedLevelChunkData.ChunkData> getWrappedChunkDataConverter()
    • getWrappedLightDataConverter

      public static EquivalentConverter<WrappedLevelChunkData.LightData> getWrappedLightDataConverter()
    • getWrappedTeamParametersConverter

      public static EquivalentConverter<WrappedTeamParameters> getWrappedTeamParametersConverter()
    • getWrappedNumberFormatConverter

      public static EquivalentConverter<WrappedNumberFormat> getWrappedNumberFormatConverter()
    • getPacketContainerConverter

      public static EquivalentConverter<PacketContainer> getPacketContainerConverter()
    • getWatchableObjectConverter

      public static EquivalentConverter<WrappedWatchableObject> getWatchableObjectConverter()
      Retrieve a converter for watchable objects and the respective wrapper.
      Returns:
      A watchable object converter.
    • getDataValueConverter

      public static EquivalentConverter<WrappedDataValue> getDataValueConverter()
      Retrieve a converter for data values in 1.19.3+.
      Returns:
      A data value converter.
    • getDataWatcherConverter

      public static EquivalentConverter<WrappedDataWatcher> getDataWatcherConverter()
      Retrieve a converter for the NMS DataWatcher class and our wrapper.
      Returns:
      A DataWatcher converter.
    • getWorldTypeConverter

      public static EquivalentConverter<org.bukkit.WorldType> getWorldTypeConverter()
      Retrieve a converter for Bukkit's world type enum and the NMS equivalent.
      Returns:
      A world type enum converter.
    • getNbtConverter

      public static EquivalentConverter<NbtBase<?>> getNbtConverter()
      Retrieve an equivalent converter for net.minecraft.server NBT classes and their wrappers.
      Returns:
      An equivalent converter for NBT.
    • getEntityConverter

      public static EquivalentConverter<org.bukkit.entity.Entity> getEntityConverter(org.bukkit.World world)
      Retrieve a converter for NMS entities and Bukkit entities.
      Parameters:
      world - - the current world.
      Returns:
      A converter between the underlying NMS entity and Bukkit's wrapper.
    • getEntityTypeConverter

      public static EquivalentConverter<org.bukkit.entity.EntityType> getEntityTypeConverter()
    • getItemStackConverter

      public static EquivalentConverter<org.bukkit.inventory.ItemStack> getItemStackConverter()
      Retrieve the converter used to convert NMS ItemStacks to Bukkit's ItemStack.
      Returns:
      Item stack converter.
    • getWrappedServerPingConverter

      public static EquivalentConverter<WrappedServerPing> getWrappedServerPingConverter()
      Retrieve the converter for the ServerPing packet in PacketType.Status.Server.SERVER_INFO.
      Returns:
      Server ping converter.
    • getWrappedStatisticConverter

      public static EquivalentConverter<WrappedStatistic> getWrappedStatisticConverter()
      Retrieve the converter for a statistic.
      Returns:
      Statistic converter.
    • getBlockConverter

      public static EquivalentConverter<org.bukkit.Material> getBlockConverter()
      Retrieve a converter for block instances.
      Returns:
      A converter for block instances.
    • getWorldConverter

      public static EquivalentConverter<org.bukkit.World> getWorldConverter()
      Retrieve the converter used to convert between a NMS World and a Bukkit world.
      Returns:
      The world converter.
    • getPotionEffectConverter

      public static EquivalentConverter<org.bukkit.potion.PotionEffect> getPotionEffectConverter()
      Retrieve the converter used to convert between a PotionEffect and the equivalent NMS Mobeffect.
      Returns:
      The potion effect converter.
    • getVectorConverter

      public static EquivalentConverter<org.bukkit.util.Vector> getVectorConverter()
      Retrieve the converter used to convert between a Vector and the equivalent NMS Vec3d.
      Returns:
      The Vector converter.
    • getSoundConverter

      public static EquivalentConverter<org.bukkit.Sound> getSoundConverter()
    • getParticleConverter

      public static EquivalentConverter<WrappedParticle> getParticleConverter()
    • getAdvancementConverter

      public static EquivalentConverter<org.bukkit.advancement.Advancement> getAdvancementConverter()
    • asUnwrapper

      public static PacketConstructor.Unwrapper asUnwrapper(Class<?> nativeType, EquivalentConverter<Object> converter)
      Retrieve an equivalent unwrapper for the converter.
      Parameters:
      nativeType - - the native NMS type the converter produces.
      converter - - the converter.
      Returns:
      The equivalent unwrapper.
    • getConvertersForGeneric

      public static Map<Class<?>,EquivalentConverter<Object>> getConvertersForGeneric()
      Retrieve every converter that is associated with a generic class.
      Returns:
      Every converter with a unique generic class.
    • getUnwrappers

      public static List<PacketConstructor.Unwrapper> getUnwrappers()
      Retrieve every NMS to/from Bukkit converter as unwrappers.
      Returns:
      Every unwrapper.
    • getEffectTypeConverter

      public static EquivalentConverter<org.bukkit.potion.PotionEffectType> getEffectTypeConverter()
    • getWorldKeyConverter

      public static EquivalentConverter<org.bukkit.World> getWorldKeyConverter()
    • getDimensionConverter

      public static EquivalentConverter<org.bukkit.World> getDimensionConverter()
    • getDimensionIDConverter

      public static EquivalentConverter<Integer> getDimensionIDConverter()
    • getMerchantRecipeListConverter

      public static EquivalentConverter<List<org.bukkit.inventory.MerchantRecipe>> getMerchantRecipeListConverter()
      Creates a converter from a MerchantRecipeList (which is just an ArrayList of MerchantRecipe wrapper) to a List of MerchantRecipe. Primarily for the packet OPEN_WINDOW_MERCHANT which is present in 1.13+.
      Returns:
      The MerchantRecipeList converter.
    • getSectionPositionConverter

      public static EquivalentConverter<BlockPosition> getSectionPositionConverter()
    • getGameStateConverter

      public static EquivalentConverter<Integer> getGameStateConverter()