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,?>>
Constructor and Description |
---|
Plugin(java.lang.String name,
PluginParameterFactory<G,A,R> pluginParameterFactory)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addParameter(PluginParameter<G,A,R,?> pluginParameter)
Adds a plugin parameter to this plugin.
|
void |
addPluginListener(PluginListener listener)
Adds a
PluginListener to be notified about changes. |
Plugin<G,A,R> |
clonePlugin()
Returns a clone copy of this plugin.
|
void |
convertType(PluginParameter<G,A,R,?> pluginParameter,
java.lang.String newType)
Changes the type of a plugin parameter.
|
java.lang.String |
getCode()
Returns the executable code of this plugin.
|
java.io.File |
getFile()
Returns the location to save this plugin to.
|
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(java.lang.String parameterName)
Returns the index for a plugin parameter name.
|
Filter<?,?> |
getPluginAsFilter(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.
|
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(PluginListener listener)
Removes a
PluginListener to be notified about changes. |
void |
resetModified()
Marks the plugin as unmodified since last save.
|
void |
runPlugin(PluginParameters pluginParameters) |
void |
setAutoBoot(boolean autoBoot)
Sets whether this plugin is run whenever the editor starts.
|
void |
setCode(java.lang.String code)
Sets the executable code of this plugin.
|
void |
setFile(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.
|
java.lang.String |
toString() |
nu.xom.Node |
toXML(PluginParameter<G,A,R,?> pluginParameter)
Returns XML representation for a
PluginParameter . |
public Plugin(@NotNull java.lang.String name, @NotNull PluginParameterFactory<G,A,R> pluginParameterFactory)
name
- the plugin namepluginParameterFactory
- the plugin parameter factory for creating
plugin parameters@NotNull public java.lang.String getName()
@NotNull public java.lang.String getCode()
public void setCode(@NotNull java.lang.String code)
code
- the executable code of this pluginpublic boolean hasParameters()
public int getParameter(@NotNull java.lang.String parameterName)
parameterName
- the plugin parameter name-1
if the parameter name does not exist@NotNull public java.lang.String toString()
toString
in class java.lang.Object
public void newParameter()
public void removeParameter(int index)
index
- the plugin parameter's indexpublic void addPluginListener(@NotNull PluginListener listener)
PluginListener
to be notified about changes.listener
- the change listenerpublic void removePluginListener(@NotNull PluginListener listener)
PluginListener
to be notified about changes.listener
- the change listener@NotNull public Plugin<G,A,R> clonePlugin()
public void addParameter(@NotNull PluginParameter<G,A,R,?> pluginParameter)
pluginParameter
- the plugin parameter to addpublic PluginParameter<G,A,R,?> getParameter(int index) throws NoSuchParameterException
PluginParameter
at a given index.index
- the index of parameter to return; must be between 0
and getParametersCount()
NoSuchParameterException
- if the index is invalidpublic boolean isAutoBoot()
public boolean isScript()
public boolean isFilter()
public void setAutoBoot(boolean autoBoot)
autoBoot
- whether this plugin is run whenever the editor startspublic void setScript(boolean script)
script
- whether this plugin is a stand-alone pluginpublic void setFilter(boolean filter)
filter
- whether this plugin is a filterpublic void convertType(@NotNull PluginParameter<G,A,R,?> pluginParameter, @NotNull java.lang.String newType) throws NoSuchParameterException
pluginParameter
- the plugin parameternewType
- the new typeNoSuchParameterException
- if the index is invalidpublic boolean isModified()
public void resetModified()
@Nullable public java.io.File getFile()
null
if the plugin has no
associated locationpublic void setFile(@Nullable java.io.File file)
file
- the save location or null
@NotNull public java.util.Iterator<PluginParameter<G,A,R,?>> iterator()
iterator
in interface java.lang.Iterable<PluginParameter<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,?>>
public void runPlugin(@NotNull PluginParameters pluginParameters)
@Nullable public Filter<?,?> getPluginAsFilter(@NotNull PluginParameters pluginParameters)
@NotNull public nu.xom.Node toXML(@NotNull PluginParameter<G,A,R,?> pluginParameter)
PluginParameter
.pluginParameter
- the plugin parameter