diff --git a/pom.xml b/pom.xml index 8c80b0b5488..877cee77f55 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 ch.njol skript - 2.2-dev13b + 2.2-dev13c Skript A plugin for the Minecraft server API Bukkit that allows to create scripts in natural language. http://njol.ch/projects/skript/ diff --git a/src/main/java/ch/njol/skript/SkriptConfig.java b/src/main/java/ch/njol/skript/SkriptConfig.java index a23aea4caae..5f3c86a403b 100644 --- a/src/main/java/ch/njol/skript/SkriptConfig.java +++ b/src/main/java/ch/njol/skript/SkriptConfig.java @@ -163,6 +163,9 @@ public EventPriority convert(final String s) { public final static Option keepConfigsLoaded = new Option("keep configs loaded", false) .optional(true); + public final static Option addonSafetyChecks = new Option("addon safety checks", false) + .optional(true); + /** * This should only be used in special cases */ diff --git a/src/main/java/ch/njol/skript/registrations/Classes.java b/src/main/java/ch/njol/skript/registrations/Classes.java index d89b320618d..7bacc03b053 100644 --- a/src/main/java/ch/njol/skript/registrations/Classes.java +++ b/src/main/java/ch/njol/skript/registrations/Classes.java @@ -33,6 +33,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.regex.Pattern; @@ -44,6 +45,7 @@ import ch.njol.skript.Skript; import ch.njol.skript.SkriptAPIException; +import ch.njol.skript.SkriptConfig; import ch.njol.skript.classes.ClassInfo; import ch.njol.skript.classes.Converter; import ch.njol.skript.classes.Converter.ConverterInfo; @@ -126,6 +128,9 @@ public final static void onRegistrationsStop() { private final static void sortClassInfos() { assert classInfos == null; + if (!Skript.testing() && SkriptConfig.addonSafetyChecks.value()) + removeNullElements(); + // merge before, after & sub/supertypes in after for (final ClassInfo ci : tempClassInfos) { final Set before = ci.before(); @@ -215,6 +220,16 @@ private final static void sortClassInfos() { } + @SuppressWarnings({"null", "unused"}) + private final static void removeNullElements() { + Iterator> it = tempClassInfos.iterator(); + while (it.hasNext()) { + ClassInfo ci = it.next(); + if (ci.getC() == null) + it.remove(); + } + } + private final static void checkAllowClassInfoInteraction() { if (Skript.isAcceptRegistrations()) throw new IllegalStateException("Cannot use classinfos until registration is over");