Skip to content

Commit 5d890f6

Browse files
committed
And some bugs fixed
1 parent d88a84a commit 5d890f6

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/main/java/ch/njol/skript/ScriptLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ static ScriptInfo loadScripts() {
212212
Skript.info(m_scripts_loaded.toString(i.files, i.triggers, i.commands, start.difference(new Date())));
213213

214214
SkriptEventHandler.registerBukkitEvents();
215+
Functions.postCheck(); // Check that all functions which are called exist.
215216

216217
return i;
217218
}

src/main/java/ch/njol/skript/events/EvtItem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ public class EvtItem extends SkriptEvent {
6767
.since("");
6868
if (hasPrepareCraftEvent) {
6969
Skript.registerEvent("Prepare Craft", EvtItem.class, PrepareItemCraftEvent.class, "[player] (preparing|beginning) craft[ing] [[of] %itemtypes%]")
70-
.description("Called just before displaying crafting result to player. You can set the result, but not cancel the event")
70+
.description("Called just before displaying crafting result to player. Note that setting the result item might or might not work due to Bukkit bugs.")
7171
.examples("")
7272
.since("2.2-Fixes-V10");
7373
}
7474
Skript.registerEvent("Pick Up", EvtItem.class, PlayerPickupItemEvent.class, "[player] (pick[ ]up|picking up) [[of] %itemtypes%]")
75-
.description("Called when a player picks up an item. Note that setting the result item might or might not work due to Bukkit bugs.")
75+
.description("Called when a player picks up an item. Please note that the item is still on the ground when this event is called.")
7676
.examples("")
7777
.since("");
7878
// TODO brew event

src/main/java/ch/njol/skript/expressions/ExprPotionItem.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ public class ExprPotionItem extends SimpleExpression<ItemType> {
5353
}
5454
}
5555

56-
@SuppressWarnings("null")
56+
@Nullable
5757
private Expression<PotionEffectType> type;
5858
private int mod = 0; // 1=upgraded, 2=extended
5959
private int usage = 0; // 0=normal, 1=splash, 2=exploding
6060
private boolean water = false;
6161
private boolean matchAll = false;
6262

63-
@SuppressWarnings({"unchecked", "null"})
63+
@SuppressWarnings({"unchecked"})
6464
@Override
6565
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
6666
if (matchedPattern == 2) {
@@ -121,7 +121,8 @@ public Class<? extends ItemType> getReturnType() {
121121

122122
@Override
123123
public String toString(final @Nullable Event e, final boolean debug) {
124-
if (e == null) return "bottle of water";
124+
if (e == null || type == null) return "bottle of water";
125+
assert type != null;
125126
return PotionEffectUtils.getPotionName(type.getSingle(e), mod == 2, mod == 1);
126127
}
127128
}

src/main/java/ch/njol/skript/lang/SkriptParser.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,13 @@ public final <T> FunctionReference<T> parseFunction(final @Nullable Class<? exte
752752
// }
753753
// @SuppressWarnings("null")
754754
final FunctionReference<T> e = new FunctionReference<T>(functionName, SkriptLogger.getNode(), ScriptLoader.currentScript != null ? ScriptLoader.currentScript.getFile() : null, types, params);//.toArray(new Expression[params.size()]));
755-
if (!SkriptConfig.allowFunctionsBeforeDefs.value() && !e.validateFunction(true)) {
756-
log.printError();
757-
return null;
755+
if (SkriptConfig.allowFunctionsBeforeDefs.value()) {
756+
Functions.addPostCheck(e); // Query function for post-checking
757+
} else {
758+
if (!e.validateFunction(true)) {
759+
log.printError();
760+
return null;
761+
}
758762
}
759763
log.printLog();
760764
return e;

0 commit comments

Comments
 (0)