* Used by Skript to import old settings into the updated config. The return value is used to not modify the config if no new options were added.
- *
+ *
* @param other
* @return Whether the configs' keys differ, i.e. false == configs only differ in values, not keys.
*/
@@ -203,7 +197,7 @@ public File getFile() {
if (file != null) {
try {
return file.toFile();
- } catch(Exception e) {
+ } catch (Exception e) {
return null; // ZipPath, for example, throws undocumented exception
}
}
@@ -235,7 +229,7 @@ public String getSaveSeparator() {
/**
* Splits the given path at the dot character and passes the result to {@link #get(String...)}.
- *
+ *
* @param path
* @return get(path.split("\\."))
*/
@@ -247,7 +241,7 @@ public String getByPath(final String path) {
/**
* Gets an entry node's value at the designated path
- *
+ *
* @param path
* @return The entry node's value at the location defined by path or null if it either doesn't exist or is not an entry.
*/
@@ -284,22 +278,19 @@ public boolean validate(final SectionValidator validator) {
return validator.validate(getMainNode());
}
- private void load(final Class> c, final @Nullable Object o, final String path) {
- for (final Field f : c.getDeclaredFields()) {
- f.setAccessible(true);
- if (o != null || Modifier.isStatic(f.getModifiers())) {
+ private void load(final Class> cls, final @Nullable Object object, final String path) {
+ for (final Field field : cls.getDeclaredFields()) {
+ field.setAccessible(true);
+ if (object != null || Modifier.isStatic(field.getModifiers())) {
try {
- if (OptionSection.class.isAssignableFrom(f.getType())) {
- final Object p = f.get(o);
- @NonNull
- final Class> pc = p.getClass();
- load(pc, p, path + ((OptionSection) p).key + ".");
- } else if (Option.class.isAssignableFrom(f.getType())) {
- ((Option>) f.get(o)).set(this, path);
+ if (OptionSection.class.isAssignableFrom(field.getType())) {
+ final OptionSection section = (OptionSection) field.get(object);
+ @NonNull final Class> pc = section.getClass();
+ load(pc, section, path + section.key + ".");
+ } else if (Option.class.isAssignableFrom(field.getType())) {
+ ((Option>) field.get(object)).set(this, path);
}
- } catch (final IllegalArgumentException e) {
- assert false;
- } catch (final IllegalAccessException e) {
+ } catch (final IllegalArgumentException | IllegalAccessException e) {
assert false;
}
}
diff --git a/src/main/java/ch/njol/skript/doc/Documentation.java b/src/main/java/ch/njol/skript/doc/Documentation.java
index 5da07aefb09..c7b9ebebbb1 100644
--- a/src/main/java/ch/njol/skript/doc/Documentation.java
+++ b/src/main/java/ch/njol/skript/doc/Documentation.java
@@ -60,7 +60,7 @@ public class Documentation {
private static final Pattern CP_EMPTY_PARSE_MARKS_PATTERN = Pattern.compile("\\(\\)");
private static final Pattern CP_PARSE_TAGS_PATTERN = Pattern.compile("(?<=[(|\\[ ])[-a-zA-Z0-9!$#%^&*_+~=\"'<>?,.]*?:");
private static final Pattern CP_EXTRA_OPTIONAL_PATTERN = Pattern.compile("\\[\\(((\\w+? ?)+)\\)]");
- private static final File DOCS_TEMPLATE_DIRECTORY = new File(Skript.getInstance().getDataFolder(), "doc-templates");
+ private static final File DOCS_TEMPLATE_DIRECTORY = new File(Skript.getInstance().getDataFolder(), "docs/templates");
private static final File DOCS_OUTPUT_DIRECTORY = new File(Skript.getInstance().getDataFolder(), "docs");
/**
diff --git a/src/main/java/ch/njol/skript/effects/EffKeepInventory.java b/src/main/java/ch/njol/skript/effects/EffKeepInventory.java
index 4c86bac1bcf..34cf29e85c6 100644
--- a/src/main/java/ch/njol/skript/effects/EffKeepInventory.java
+++ b/src/main/java/ch/njol/skript/effects/EffKeepInventory.java
@@ -19,6 +19,7 @@
package ch.njol.skript.effects;
import org.bukkit.event.Event;
+import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.eclipse.jdt.annotation.Nullable;
@@ -35,17 +36,19 @@
@Name("Keep Inventory / Experience")
@Description("Keeps the inventory or/and experiences of the dead player in a death event.")
-@Examples({"on death of a player:",
+@Examples({
+ "on death of a player:",
"\tif the victim is an op:",
- "\t\tkeep the inventory and experiences"})
+ "\t\tkeep the inventory and experiences"
+})
@Since("2.4")
@Events("death")
public class EffKeepInventory extends Effect {
static {
Skript.registerEffect(EffKeepInventory.class,
- "keep [the] (inventory|items) [(1¦and [e]xp[erience][s] [point[s]])]",
- "keep [the] [e]xp[erience][s] [point[s]] [(1¦and (inventory|items))]");
+ "keep [the] (inventory|items) [(1:and [e]xp[erience][s] [point[s]])]",
+ "keep [the] [e]xp[erience][s] [point[s]] [(1:and (inventory|items))]");
}
private boolean keepItems, keepExp;
@@ -54,7 +57,7 @@ public class EffKeepInventory extends Effect {
public boolean init(Expression>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
keepItems = matchedPattern == 0 || parseResult.mark == 1;
keepExp = matchedPattern == 1 || parseResult.mark == 1;
- if (!getParser().isCurrentEvent(PlayerDeathEvent.class)) {
+ if (!getParser().isCurrentEvent(EntityDeathEvent.class)) {
Skript.error("The keep inventory/experience effect can't be used outside of a death event");
return false;
}
@@ -66,18 +69,18 @@ public boolean init(Expression>[] exprs, int matchedPattern, Kleenean isDelaye
}
@Override
- protected void execute(Event e) {
- if (e instanceof PlayerDeathEvent) {
- PlayerDeathEvent event = (PlayerDeathEvent) e;
+ protected void execute(Event event) {
+ if (event instanceof PlayerDeathEvent) {
+ PlayerDeathEvent deathEvent = (PlayerDeathEvent) event;
if (keepItems)
- event.setKeepInventory(true);
+ deathEvent.setKeepInventory(true);
if (keepExp)
- event.setKeepLevel(true);
+ deathEvent.setKeepLevel(true);
}
}
@Override
- public String toString(@Nullable Event e, boolean debug) {
+ public String toString(@Nullable Event event, boolean debug) {
if (keepItems && !keepExp)
return "keep the inventory";
else
diff --git a/src/main/java/ch/njol/skript/effects/EffPotion.java b/src/main/java/ch/njol/skript/effects/EffPotion.java
index 64b07bb0be4..4ebc19e8d9f 100644
--- a/src/main/java/ch/njol/skript/effects/EffPotion.java
+++ b/src/main/java/ch/njol/skript/effects/EffPotion.java
@@ -52,7 +52,7 @@
@Since(
"2.0, 2.2-dev27 (ambient and particle-less potion effects), " +
"2.5 (replacing existing effect), 2.5.2 (potion effects), " +
- "INSERT VERSION (icon and infinite)"
+ "2.7 (icon and infinite)"
)
public class EffPotion extends Effect {
@@ -101,7 +101,7 @@ public boolean init(Expression>[] exprs, int matchedPattern, Kleenean isDelaye
potions = (Expression
+ * Bukkit's own {@link org.bukkit.util.Consumer} is deprecated.
+ * Use {@link #spawn(Location, Consumer)}
+ *
+ * @param location The {@link Location} to spawn the entity at.
+ * @param consumer A {@link Consumer} to apply the entity changes to.
+ * @return The Entity object that is spawned.
+ */
+ @Nullable
+ @Deprecated
+ @SuppressWarnings("deprecation")
+ public E spawn(Location location, org.bukkit.util.@Nullable Consumer