Record Class BukkitEventApplication

java.lang.Object
java.lang.Record
kr.toxicity.model.api.bukkit.event.BukkitEventApplication
Record Components:
name - the name of the plugin
pluginRef - a weak reference to the plugin instance
All Implemented Interfaces:
kr.toxicity.model.api.event.ModelEventApplication

public record BukkitEventApplication(@NotNull String name, @NotNull WeakReference<org.bukkit.plugin.Plugin> pluginRef) extends Record implements kr.toxicity.model.api.event.ModelEventApplication
An implementation of ModelEventApplication for Bukkit plugins.

This record holds a weak reference to a Bukkit plugin to prevent memory leaks and checks if the plugin is enabled.

Since:
2.0.0
  • Constructor Details

    • BukkitEventApplication

      public BukkitEventApplication(@NotNull @NotNull String name, @NotNull @NotNull WeakReference<org.bukkit.plugin.Plugin> pluginRef)
      Creates an instance of a BukkitEventApplication record class.
      Parameters:
      name - the value for the name record component
      pluginRef - the value for the pluginRef record component
  • Method Details

    • of

      @NotNull public static @NotNull BukkitEventApplication of(@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
      Creates a new BukkitEventApplication for the given plugin.
      Parameters:
      plugin - the Bukkit plugin
      Returns:
      the event application wrapper
      Since:
      2.0.0
    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface kr.toxicity.model.api.event.ModelEventApplication
    • equals

      public 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.
    • hashCode

      public 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
    • 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
    • name

      @NotNull public @NotNull String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • pluginRef

      @NotNull public @NotNull WeakReference<org.bukkit.plugin.Plugin> pluginRef()
      Returns the value of the pluginRef record component.
      Returns:
      the value of the pluginRef record component