Class PluginMetadata

java.lang.Object
eu.hexagonmc.spigot.annotation.meta.PluginMetadata
All Implemented Interfaces:
Consumer<PluginMetadata>

public class PluginMetadata extends Object implements Consumer<PluginMetadata>
Reresents the parsed metadata of an plugin loaded from file, gradle or annotation.

This metadata is used for Spigot and BungeeCord plugins. Each field represents a value in the yaml file.
See Also:
  • Field Details

    • NAME_PATTERN

      public static final Pattern NAME_PATTERN
      The pattern plugin names must match.
      See Also:
  • Constructor Details

    • PluginMetadata

      public PluginMetadata(String name)
      Creates a new metadata for a plugin with the given name.
      Parameters:
      name - The name of the plugin
  • Method Details

    • from

      public static PluginMetadata from(String main, Plugin annotation)
      Creates metadata from a plugins main-class name and an annotation. Parses the data tored in the annotation.
      Parameters:
      main - The main-class name of the plugin
      annotation - The annotation to parse for data
      Returns:
      The new metadata
      See Also:
    • addAuthor

      public void addAuthor(String author)
      Adds an author the the list of authors of this plugin.
      Parameters:
      author - The author to add
    • getAuthors

      public Collection<String> getAuthors()
      Gets the list of authors for this plugin.
      Returns:
      The list of authors
      See Also:
    • removeAuthor

      public boolean removeAuthor(String author)
      Removes an author from the list of authors of this plugin.
      Parameters:
      author - The author to remove
      Returns:
      True if an author was removed false if not found
    • addDependency

      public void addDependency(PluginDependency dependency)
      Adds a dependency to this plugin.
      Parameters:
      dependency - The dependency to add
      See Also:
    • getDependencies

      public Collection<PluginDependency> getDependencies()
      Gets all dependencies of this plugin.
      Returns:
      The dependencies
      See Also:
    • replaceDependency

      public PluginDependency replaceDependency(PluginDependency dependency)
      Replaces or inserts a dependency of this plugin.
      Parameters:
      dependency - The dependency to replace or add
      Returns:
      The old dependency if replaced or null
      See Also:
    • removeDependency

      public boolean removeDependency(PluginDependency dependency)
      Removes a dependency from this pugin.
      Parameters:
      dependency - The dependency to remove
      Returns:
      true if the dependency was removed false if it did not exist
      See Also:
    • addCommand

      public void addCommand(PluginCommand command)
      Adds a command to this plugin.
      Parameters:
      command - The command to add
      See Also:
    • getCommands

      public Collection<PluginCommand> getCommands()
      Gets all commands of this plugin.
      Returns:
      The command
      See Also:
    • replaceCommand

      public PluginCommand replaceCommand(PluginCommand command)
      Replaces or inserts a command of this plugin.
      Parameters:
      command - The command to replace or add
      Returns:
      The old command if replaced or null
      See Also:
    • removeCommand

      public boolean removeCommand(PluginCommand command)
      Removes a command from this pugin.
      Parameters:
      command - The command to remove
      Returns:
      true if the command was removed false if it did not exist
      See Also:
    • addPermission

      public void addPermission(PluginPermission permission)
      Adds a permission to this plugin.
      Parameters:
      permission - The permission to add
      See Also:
    • getPermissions

      public Collection<PluginPermission> getPermissions()
      Gets all permissions of this plugin.
      Returns:
      The permissions
      See Also:
    • replacePermission

      public PluginPermission replacePermission(PluginPermission permission)
      Replaces or inserts a permission of this plugin.
      Parameters:
      permission - The permission to replace or add
      Returns:
      The old permission if replaced or null
      See Also:
    • removePermission

      public boolean removePermission(PluginPermission permission)
      Removes a permission from this pugin.
      Parameters:
      permission - The permission to remove
      Returns:
      true if the permission was removed false if it did not exist
      See Also:
    • accept

      public void accept(PluginMetadata other)
      Merges another metadata into this one.
      Specified by:
      accept in interface Consumer<PluginMetadata>
    • setName

      public void setName(String name)
      Sets the name of this plugin.
      Parameters:
      name - The name to set
    • getName

      public String getName()
      Gets the name of this plugin.
      Returns:
      The name
    • setVersion

      public void setVersion(String version)
      Sets the version of this plugin.
      Parameters:
      version - The version to set
    • getVersion

      public String getVersion()
      Gets the version of this plugin.
      Returns:
      The version
    • setDescription

      public void setDescription(String description)
      Sets the description of this plugin.
      Parameters:
      description - The description to set
    • getDescription

      public String getDescription()
      Gets the description of this plugin.
      Returns:
      The description
    • setLoadOn

      public void setLoadOn(LoadOn loadOn)
      Sets the load time of this plugin.
      Parameters:
      loadOn - The load time to set
      See Also:
    • getLoadOn

      public LoadOn getLoadOn()
      Gets the load time of this plugin.
      Returns:
      The load time
      See Also:
    • setWebsite

      public void setWebsite(String website)
      Sets the website of this plugin.
      Parameters:
      website - The website to set
    • getWebsite

      public String getWebsite()
      Gets the website of this plugin.
      Returns:
      The website
    • setMain

      public void setMain(String main)
      Sets the main-class name of this plugin.
      Parameters:
      main - The main-class name to set
    • getMain

      public String getMain()
      Gets the main-class name of this plugin.
      Returns:
      The main-class name
    • setDatabase

      public void setDatabase(Boolean database)
      Sets if the plugin should use plugin-databases.
      Parameters:
      database - True if it should be used false othewise
    • getDatabase

      public Boolean getDatabase()
      Gets if the plugin should use plugin-databases.
      Returns:
      True if it should be used false othewise
    • setPrefix

      public void setPrefix(String prefix)
      Sets the log prefix of this plugin.
      Parameters:
      prefix - The log prefix to set
    • getPrefix

      public String getPrefix()
      Gets the log prefix of this plugin.
      Returns:
      The log prefix
    • setBungee

      public void setBungee(boolean b)
    • isBungee

      public boolean isBungee()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object