Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
Plugin.java
1 package org.bukkit.plugin;
2 
3 import java.io.File;
4 import java.io.InputStream;
5 import java.util.logging.Logger;
6 
7 import org.bukkit.Server;
11 
12 import com.avaje.ebean.EbeanServer;
13 
14 /**
15  * Represents a Plugin
16  * <p>
17  * The use of {@link PluginBase} is recommended for actual Implementation
18  */
19 public interface Plugin extends TabExecutor {
20  /**
21  * Returns the folder that the plugin data's files are located in. The
22  * folder may not yet exist.
23  *
24  * @return The folder
25  */
26  public File getDataFolder();
27 
28  /**
29  * Returns the plugin.yaml file containing the details for this plugin
30  *
31  * @return Contents of the plugin.yaml file
32  */
34 
35  /**
36  * Gets a {@link FileConfiguration} for this plugin, read through
37  * "config.yml"
38  * <p>
39  * If there is a default config.yml embedded in this plugin, it will be
40  * provided as a default for this Configuration.
41  *
42  * @return Plugin configuration
43  */
45 
46  /**
47  * Gets an embedded resource in this plugin
48  *
49  * @param filename Filename of the resource
50  * @return File if found, otherwise null
51  */
52  public InputStream getResource(String filename);
53 
54  /**
55  * Saves the {@link FileConfiguration} retrievable by {@link #getConfig()}.
56  */
57  public void saveConfig();
58 
59  /**
60  * Saves the raw contents of the default config.yml file to the location
61  * retrievable by {@link #getConfig()}. If there is no default config.yml
62  * embedded in the plugin, an empty config.yml file is saved. This should
63  * fail silently if the config.yml already exists.
64  */
65  public void saveDefaultConfig();
66 
67  /**
68  * Saves the raw contents of any resource embedded with a plugin's .jar
69  * file assuming it can be found using {@link #getResource(String)}.
70  * <p>
71  * The resource is saved into the plugin's data folder using the same
72  * hierarchy as the .jar file (subdirectories are preserved).
73  *
74  * @param resourcePath the embedded resource path to look for within the
75  * plugin's .jar file. (No preceding slash).
76  * @param replace if true, the embedded resource will overwrite the
77  * contents of an existing file.
78  * @throws IllegalArgumentException if the resource path is null, empty,
79  * or points to a nonexistent resource.
80  */
81  public void saveResource(String resourcePath, boolean replace);
82 
83  /**
84  * Discards any data in {@link #getConfig()} and reloads from disk.
85  */
86  public void reloadConfig();
87 
88  /**
89  * Gets the associated PluginLoader responsible for this plugin
90  *
91  * @return PluginLoader that controls this plugin
92  */
94 
95  /**
96  * Returns the Server instance currently running this plugin
97  *
98  * @return Server running this plugin
99  */
100  public Server getServer();
101 
102  /**
103  * Returns a value indicating whether or not this plugin is currently
104  * enabled
105  *
106  * @return true if this plugin is enabled, otherwise false
107  */
108  public boolean isEnabled();
109 
110  /**
111  * Called when this plugin is disabled
112  */
113  public void onDisable();
114 
115  /**
116  * Called after a plugin is loaded but before it has been enabled.
117  * <p>
118  * When mulitple plugins are loaded, the onLoad() for all plugins is
119  * called before any onEnable() is called.
120  */
121  public void onLoad();
122 
123  /**
124  * Called when this plugin is enabled
125  */
126  public void onEnable();
127 
128  /**
129  * Simple boolean if we can still nag to the logs about things
130  *
131  * @return boolean whether we can nag
132  */
133  public boolean isNaggable();
134 
135  /**
136  * Set naggable state
137  *
138  * @param canNag is this plugin still naggable?
139  */
140  public void setNaggable(boolean canNag);
141 
142  /**
143  * Gets the {@link EbeanServer} tied to this plugin. This will only be
144  * available if enabled in the {@link
145  * PluginDescriptionFile#isDatabaseEnabled()}
146  * <p>
147  * <i>For more information on the use of <a href="http://www.avaje.org/">
148  * Avaje Ebeans ORM</a>, see <a
149  * href="http://www.avaje.org/ebean/documentation.html">Avaje Ebeans
150  * Documentation</a></i>
151  * <p>
152  * <i>For an example using Ebeans ORM, see <a
153  * href="https://github.com/Bukkit/HomeBukkit">Bukkit's Homebukkit Plugin
154  * </a></i>
155  *
156  * @return ebean server instance or null if not enabled
157  */
158  public EbeanServer getDatabase();
159 
160  /**
161  * Gets a {@link ChunkGenerator} for use in a default world, as specified
162  * in the server configuration
163  *
164  * @param worldName Name of the world that this will be applied to
165  * @param id Unique ID, if any, that was specified to indicate which
166  * generator was requested
167  * @return ChunkGenerator for use in the default world generation
168  */
169  public ChunkGenerator getDefaultWorldGenerator(String worldName, String id);
170 
171  /**
172  * Returns the plugin logger associated with this server's logger. The
173  * returned logger automatically tags all log messages with the plugin's
174  * name.
175  *
176  * @return Logger associated with this plugin
177  */
178  public Logger getLogger();
179 
180  /**
181  * Returns the name of the plugin.
182  * <p>
183  * This should return the bare name of the plugin and should be used for
184  * comparison.
185  *
186  * @return name of the plugin
187  */
188  public String getName();
189 }
ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
PluginLoader getPluginLoader()
PluginDescriptionFile getDescription()
InputStream getResource(String filename)
EbeanServer getDatabase()
void setNaggable(boolean canNag)
FileConfiguration getConfig()
void saveResource(String resourcePath, boolean replace)