Class InjectionFactory

java.lang.Object
com.comphenix.protocol.injector.netty.channel.InjectionFactory

public class InjectionFactory extends Object
Represents an injector factory.

Note that the factory will return EmptyInjector when the factory is closed.

  • Constructor Details

    • InjectionFactory

      public InjectionFactory(org.bukkit.plugin.Plugin plugin, ErrorReporter errorReporter, ListenerManager listenerManager)
  • Method Details

    • getPlugin

      public org.bukkit.plugin.Plugin getPlugin()
      Retrieve the main plugin associated with this injection factory.
      Returns:
      The main plugin.
    • fromPlayer

      @Nonnull public Injector fromPlayer(org.bukkit.entity.Player player)
      Construct or retrieve a channel injector from an existing Bukkit player.
      Parameters:
      player - - the existing Bukkit player.
      Returns:
      A new injector, an existing injector associated with this player, or a closed injector.
    • fromName

      public Injector fromName(String name, org.bukkit.entity.Player player)
      Retrieve a cached injector from a name.

      The injector may be NULL if the plugin has been reloaded during a player login.

      Parameters:
      name - - the name.
      player - - the player.
      Returns:
      The cached injector, or a closed injector if it could not be found.
    • fromChannel

      @Nonnull public Injector fromChannel(io.netty.channel.Channel channel)
      Construct a new channel injector for the given channel.
      Parameters:
      channel - - the channel.
      Returns:
      The channel injector, or a closed injector.
    • invalidate

      public Injector invalidate(org.bukkit.entity.Player player, String name)
      Invalidate a cached injector.
      Parameters:
      player - - the associated player.
      Returns:
      The cached injector, or NULL if nothing was cached.
    • cacheInjector

      public Injector cacheInjector(org.bukkit.entity.Player player, Injector injector)
      Cache an injector by player.
      Parameters:
      player - - the player.
      injector - - the injector to cache.
      Returns:
      The previously cached injector.
    • cacheInjector

      public Injector cacheInjector(String name, Injector injector)
      Cache an injector by name alone.
      Parameters:
      name - - the name to lookup.
      injector - - the injector.
      Returns:
      The cached injector.
    • isClosed

      public boolean isClosed()
      Determine if the factory is closed.

      If it is, all new injectors will be closed by default.

      Returns:
      TRUE if it is closed, FALSE otherwise.
    • close

      public void close()
      Close all injectors created by this factory, and cease the creation of new injections.