Interface PacketHandler

All Superinterfaces:
AbstractBiomeRenderer

@NullMarked @AsOf("2.1.0") public interface PacketHandler extends AbstractBiomeRenderer
An interface for handling packet manipulation related to biome injection. It is recommended to use the BiomeUpdater for updating chunks after appending a biome for immediate changes to a player.

An external packet handling library (either ProtocolLib or PacketEvents) is required for this interface.

Since:
0.0.6
  • Field Details

    • WIRE

      @Internal static final WireProvider<PacketHandler.Factory> WIRE
      The wire-resolved factory that constructs concrete PacketHandler instances. The implementation lives in the commons module; this points to its canonical class name.
  • Method Details

    • of

      @AsOf("2.1.0") static PacketHandler of(Plugin provider)
      Creates a PacketHandler using ProtocolLib as the underlying packet manipulation library. The packet listener priority defaults to NORMAL.
      Parameters:
      provider - The plugin providing this PacketHandler
      Returns:
      A new PacketHandler instance
      Throws:
      MissingPacketManipulatorLibraryException - if ProtocolLib is not installed
      Since:
      0.0.6
    • of

      @AsOf("2.1.0") static PacketHandler of(Plugin provider, PacketHandler.Injector injector)
      Creates a PacketHandler using the specified packet manipulation library. The packet listener priority defaults to NORMAL.
      Parameters:
      provider - The plugin providing this PacketHandler
      injector - The packet manipulation library to use
      Returns:
      A new PacketHandler instance
      Throws:
      MissingPacketManipulatorLibraryException - if the specified manipulator library is not installed
      Since:
      2.1.0
    • of

      @AsOf("0.0.19") @Deprecated(since="2.1.0", forRemoval=true) static PacketHandler of(Plugin provider, PacketHandler.Manipulator manipulator)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a PacketHandler using the specified packet manipulation library. The packet listener priority defaults to NORMAL.
      Parameters:
      provider - The plugin providing this PacketHandler
      manipulator - The packet manipulation library to use
      Returns:
      A new PacketHandler instance
      Throws:
      MissingPacketManipulatorLibraryException - if the specified manipulator library is not installed
      Since:
      0.0.19
    • of

      @AsOf("2.1.0") static PacketHandler of(Plugin provider, PacketHandler.Injector injector, PacketHandler.Priority priority)
      Creates a PacketHandler using the specified packet manipulation library.
      Parameters:
      provider - The plugin providing this PacketHandler
      injector - The packet manipulation library to use
      priority - The priority of the packet listener
      Returns:
      A new PacketHandler instance
      Throws:
      MissingPacketManipulatorLibraryException - if the specified injector library is not installed
      Since:
      2.1.0
    • of

      @AsOf("0.0.19") static PacketHandler of(Plugin provider, PacketHandler.Manipulator manipulator, PacketHandler.Priority priority)
      Creates a PacketHandler using the specified packet manipulation library.
      Parameters:
      provider - The plugin providing this PacketHandler
      manipulator - The packet manipulation library to use
      priority - The priority of the packet listener
      Returns:
      A new PacketHandler instance
      Throws:
      MissingPacketManipulatorLibraryException - if the specified injector library is not installed
      Since:
      0.0.19
    • register

      @AsOf("0.0.6") PacketHandler register()
      Registers the necessary packet listeners to handle biome injection. Calling this in your plugin's onLoad/onEnable is recommended assuming your plugin soft-depends on PacketEvents and/or ProtocolLib.
      Returns:
      the registered PacketHandler instance
    • unregister

      @AsOf("0.0.6") PacketHandler unregister()
      Unregisters the packet listeners handling biome injection. Calling this in your plugin's onDisable is recommended.
      Returns:
      the unregistered PacketHandler instance
    • appendBiome

      @AsOf("0.0.6") PacketHandler appendBiome(VirtualBiome biome)
      Appends a custom biome to the packet handler's list of biomes to inject.
      Parameters:
      biome - The phony custom biome to append
      Returns:
      the PacketHandler instance for chaining
    • appendBiome

      @AsOf("0.0.6") default PacketHandler appendBiome(VirtualBiome... biomes)
      Appends multiple custom biomes to the packet handler's list of biomes to inject.
      Parameters:
      biomes - The phony custom biomes to append
      Returns:
      the PacketHandler instance for chaining
    • removeBiome

      @AsOf("0.0.6") boolean removeBiome(VirtualBiome biome)
      Removes a custom biome from the packet handler's list of biomes to inject.
      Parameters:
      biome - The phony custom biome to remove
      Returns:
      true if the biome was removed, false if it was not found
    • dismissBiome

      @AsOf("2.1.0") default PacketHandler dismissBiome(VirtualBiome biome)
      Removes a custom biome from the packet handler's list of biomes to inject.
      Parameters:
      biome - The phony custom biome to remove
      Returns:
      the PacketHandler instance for chaining
    • removeBiome

      @AsOf("0.0.6") boolean removeBiome(ResourceKey biomeKey)
      Removes a custom biome from the packet handler's list of biomes to inject by its ResourceKey.
      Parameters:
      biomeKey - The ResourceKey of the biome to remove
      Returns:
      true if the biome was removed, false if it was not found
    • dismissBiome

      @AsOf("2.1.0") default PacketHandler dismissBiome(ResourceKey biomeKey)
      Removes a custom biome from the packet handler's list of biomes to inject by its ResourceKey.
      Parameters:
      biomeKey - The ResourceKey of the biome to remove
      Returns:
      the PacketHandler instance for chaining
    • hasBiome

      @AsOf("0.0.10") boolean hasBiome(VirtualBiome biome)
      Checks if a custom biome is in the packet handler's list of biomes to inject.
      Parameters:
      biome - The phony custom biome to check
      Returns:
      true if the biome is present, false otherwise
    • hasBiome

      @AsOf("0.0.10") boolean hasBiome(ResourceKey biomeKey)
      Checks if a custom biome is in the packet handler's list of biomes to inject by its ResourceKey.
      Parameters:
      biomeKey - The ResourceKey of the biome to check
      Returns:
      true if the biome is present, false otherwise
    • clearBiomes

      @AsOf("0.0.6") PacketHandler clearBiomes()
      Clears all phony custom biomes from the packet handler's list of biomes to inject.
      Returns:
      the PacketHandler instance for chaining