mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-23 16:56:31 +01:00
Added new plugin.yml option 'load', possible values are 'startup' and 'postworld' (default postworld)
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
e2779f623c
commit
ba32a78b3b
2 changed files with 32 additions and 0 deletions
|
@ -24,6 +24,7 @@ public final class PluginDescriptionFile {
|
|||
private ArrayList<String> authors = new ArrayList<String>();
|
||||
private String website = null;
|
||||
private boolean database = false;
|
||||
private PluginLoadOrder order = PluginLoadOrder.POSTWORLD;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public PluginDescriptionFile(final InputStream stream) throws InvalidDescriptionException {
|
||||
|
@ -108,6 +109,10 @@ public final class PluginDescriptionFile {
|
|||
return softDepend;
|
||||
}
|
||||
|
||||
public PluginLoadOrder getLoad() {
|
||||
return order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description of this plugin
|
||||
*
|
||||
|
@ -213,6 +218,16 @@ public final class PluginDescriptionFile {
|
|||
}
|
||||
}
|
||||
|
||||
if (map.containsKey("load")) {
|
||||
try {
|
||||
order = PluginLoadOrder.valueOf(((String)map.get("load")).toUpperCase().replaceAll("\\W", ""));
|
||||
} catch (ClassCastException ex) {
|
||||
throw new InvalidDescriptionException(ex, "load is of wrong type");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new InvalidDescriptionException(ex, "load is not a valid choice");
|
||||
}
|
||||
}
|
||||
|
||||
if (map.containsKey("author")) {
|
||||
try {
|
||||
String extra = (String) map.get("author");
|
||||
|
@ -241,6 +256,7 @@ public final class PluginDescriptionFile {
|
|||
map.put("main", main);
|
||||
map.put("version", version);
|
||||
map.put("database", database);
|
||||
map.put("order", order.toString());
|
||||
|
||||
if (commands != null) {
|
||||
map.put("command", commands);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
package org.bukkit.plugin;
|
||||
|
||||
/**
|
||||
* Represents the order in which a plugin should be initialized and enabled
|
||||
*/
|
||||
public enum PluginLoadOrder {
|
||||
/**
|
||||
* Indicates that the plugin will be loaded at startup
|
||||
*/
|
||||
STARTUP,
|
||||
/**
|
||||
* Indicates that the plugin will be loaded after the first/default world was created
|
||||
*/
|
||||
POSTWORLD
|
||||
}
|
Loading…
Add table
Reference in a new issue