diff --git a/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java index a0034cdacc..e505c26f8e 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +++ b/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java @@ -24,6 +24,7 @@ public final class PluginDescriptionFile { private ArrayList authors = new ArrayList(); 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); diff --git a/paper-api/src/main/java/org/bukkit/plugin/PluginLoadOrder.java b/paper-api/src/main/java/org/bukkit/plugin/PluginLoadOrder.java new file mode 100644 index 0000000000..c1ae4be4f2 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/plugin/PluginLoadOrder.java @@ -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 +}