Class Plugin<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<G,​A,​R>>

  • All Implemented Interfaces:
    java.lang.Iterable<PluginParameter<G,​A,​R,​?>>

    public class Plugin<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<G,​A,​R>>
    extends java.lang.Object
    implements java.lang.Iterable<PluginParameter<G,​A,​R,​?>>
    Model for plugins.
    • Constructor Summary

      Constructors 
      Constructor Description
      Plugin​(@NotNull java.lang.String name, @NotNull PluginParameterFactory<G,​A,​R> pluginParameterFactory)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addParameter​(@NotNull PluginParameter<G,​A,​R,​?> pluginParameter)
      Adds a plugin parameter to this plugin.
      void addPluginListener​(@NotNull PluginListener listener)
      Adds a PluginListener to be notified about changes.
      @NotNull Plugin<G,​A,​R> clonePlugin()
      Returns a clone copy of this plugin.
      void convertType​(@NotNull PluginParameter<G,​A,​R,​?> pluginParameter, @NotNull java.lang.String newType)
      Changes the type of a plugin parameter.
      @NotNull java.lang.String getCode()
      Returns the executable code of this plugin.
      @Nullable java.io.File getFile()
      Returns the location to save this plugin to.
      @NotNull java.lang.String getName()
      Returns the name of this plugin.
      PluginParameter<G,​A,​R,​?> getParameter​(int index)
      Returns the PluginParameter at a given index.
      int getParameter​(@NotNull java.lang.String parameterName)
      Returns the index for a plugin parameter name.
      @Nullable Filter<?,​?> getPluginAsFilter​(@NotNull PluginParameters pluginParameters)  
      boolean hasParameters()
      Returns whether this plugin has at least one parameter.
      boolean isAutoBoot()
      Returns whether this plugin is run whenever the editor starts.
      boolean isFilter()
      Returns whether this plugin is a filter.
      boolean isModified()
      Returns whether the plugin contents have been modified since last save.
      boolean isScript()
      Returns whether this plugin is a stand-alone plugin.
      @NotNull java.util.Iterator<PluginParameter<G,​A,​R,​?>> iterator()  
      void newParameter()
      Creates a new plugin parameter.
      void removeParameter​(int index)
      Removes a plugin parameter.
      void removePluginListener​(@NotNull PluginListener listener)
      Removes a PluginListener to be notified about changes.
      void resetModified()
      Marks the plugin as unmodified since last save.
      void runPlugin​(@NotNull PluginParameters pluginParameters)  
      void setAutoBoot​(boolean autoBoot)
      Sets whether this plugin is run whenever the editor starts.
      void setCode​(@NotNull java.lang.String code)
      Sets the executable code of this plugin.
      void setFile​(@Nullable java.io.File file)
      Sets the location to save this plugin to.
      void setFilter​(boolean filter)
      Sets whether this plugin is a filter.
      void setScript​(boolean script)
      Sets whether this plugin is a stand-alone plugin.
      @NotNull java.lang.String toString()  
      @NotNull nu.xom.Node toXML​(@NotNull PluginParameter<G,​A,​R,​?> pluginParameter)
      Returns XML representation for a PluginParameter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • Plugin

        public Plugin​(@NotNull
                      @NotNull java.lang.String name,
                      @NotNull
                      @NotNull PluginParameterFactory<G,​A,​R> pluginParameterFactory)
        Creates a new instance.
        Parameters:
        name - the plugin name
        pluginParameterFactory - the plugin parameter factory for creating plugin parameters
    • Method Detail

      • getName

        @NotNull
        public @NotNull java.lang.String getName()
        Returns the name of this plugin.
        Returns:
        the name of this plugin
      • getCode

        @NotNull
        public @NotNull java.lang.String getCode()
        Returns the executable code of this plugin.
        Returns:
        the executable code of this plugin
      • setCode

        public void setCode​(@NotNull
                            @NotNull java.lang.String code)
        Sets the executable code of this plugin.
        Parameters:
        code - the executable code of this plugin
      • hasParameters

        public boolean hasParameters()
        Returns whether this plugin has at least one parameter.
        Returns:
        whether this plugin has at least one parameter
      • getParameter

        public int getParameter​(@NotNull
                                @NotNull java.lang.String parameterName)
        Returns the index for a plugin parameter name.
        Parameters:
        parameterName - the plugin parameter name
        Returns:
        the index or -1 if the parameter name does not exist
      • toString

        @NotNull
        public @NotNull java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • newParameter

        public void newParameter()
        Creates a new plugin parameter.
      • removeParameter

        public void removeParameter​(int index)
        Removes a plugin parameter.
        Parameters:
        index - the plugin parameter's index
      • addPluginListener

        public void addPluginListener​(@NotNull
                                      @NotNull PluginListener listener)
        Adds a PluginListener to be notified about changes.
        Parameters:
        listener - the change listener
      • removePluginListener

        public void removePluginListener​(@NotNull
                                         @NotNull PluginListener listener)
        Removes a PluginListener to be notified about changes.
        Parameters:
        listener - the change listener
      • clonePlugin

        @NotNull
        public @NotNull Plugin<G,​A,​R> clonePlugin()
        Returns a clone copy of this plugin. The copy include name, executable code, type and a clone of each parameter. The change listeners are not copied.
        Returns:
        a clone of this plugin
      • addParameter

        public void addParameter​(@NotNull
                                 @NotNull PluginParameter<G,​A,​R,​?> pluginParameter)
        Adds a plugin parameter to this plugin.
        Parameters:
        pluginParameter - the plugin parameter to add
      • isAutoBoot

        public boolean isAutoBoot()
        Returns whether this plugin is run whenever the editor starts.
        Returns:
        whether this plugin is run whenever the editor starts
      • isScript

        public boolean isScript()
        Returns whether this plugin is a stand-alone plugin.
        Returns:
        whether this plugin is a stand-alone plugin
      • isFilter

        public boolean isFilter()
        Returns whether this plugin is a filter.
        Returns:
        whether this plugin is a filter
      • setAutoBoot

        public void setAutoBoot​(boolean autoBoot)
        Sets whether this plugin is run whenever the editor starts.
        Parameters:
        autoBoot - whether this plugin is run whenever the editor starts
      • setScript

        public void setScript​(boolean script)
        Sets whether this plugin is a stand-alone plugin.
        Parameters:
        script - whether this plugin is a stand-alone plugin
      • setFilter

        public void setFilter​(boolean filter)
        Sets whether this plugin is a filter.
        Parameters:
        filter - whether this plugin is a filter
      • convertType

        public void convertType​(@NotNull
                                @NotNull PluginParameter<G,​A,​R,​?> pluginParameter,
                                @NotNull
                                @NotNull java.lang.String newType)
                         throws NoSuchParameterException
        Changes the type of a plugin parameter.
        Parameters:
        pluginParameter - the plugin parameter
        newType - the new type
        Throws:
        NoSuchParameterException - if the index is invalid
      • isModified

        public boolean isModified()
        Returns whether the plugin contents have been modified since last save.
        Returns:
        whether the plugin contents have been modified since last save
      • resetModified

        public void resetModified()
        Marks the plugin as unmodified since last save.
      • getFile

        @Nullable
        public @Nullable java.io.File getFile()
        Returns the location to save this plugin to.
        Returns:
        the location to save to, or null if the plugin has no associated location
      • setFile

        public void setFile​(@Nullable
                            @Nullable java.io.File file)
        Sets the location to save this plugin to.
        Parameters:
        file - the save location or null
      • iterator

        @NotNull
        public @NotNull java.util.Iterator<PluginParameter<G,​A,​R,​?>> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<G extends GameObject<G,​A,​R>>
      • runPlugin

        public void runPlugin​(@NotNull
                              @NotNull PluginParameters pluginParameters)
      • getPluginAsFilter

        @Nullable
        public @Nullable Filter<?,​?> getPluginAsFilter​(@NotNull
                                                             @NotNull PluginParameters pluginParameters)
      • toXML

        @NotNull
        public @NotNull nu.xom.Node toXML​(@NotNull
                                          @NotNull PluginParameter<G,​A,​R,​?> pluginParameter)
        Returns XML representation for a PluginParameter.
        Parameters:
        pluginParameter - the plugin parameter
        Returns:
        the plugin parameter in XML representation