Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error when spawn section used on 1.9.4 #4753

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/java/ch/njol/skript/sections/EffSecSpawn.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public Entity get(SpawnEvent spawnEvent) {
}, 0);
}

private static final boolean BUKKIT_CONSUMER_EXISTS = Skript.classExists("org.bukkit.util.Consumer");

@Nullable
public static Entity lastSpawned = null;

Expand All @@ -113,8 +115,14 @@ public boolean init(Expression<?>[] exprs,
types = (Expression<EntityType>) exprs[matchedPattern];
locations = Direction.combine((Expression<? extends Direction>) exprs[1 + matchedPattern], (Expression<? extends Location>) exprs[2 + matchedPattern]);

if (sectionNode != null)
if (sectionNode != null) {
if (!BUKKIT_CONSUMER_EXISTS) {
Skript.error("The spawn section isn't available on your Minecraft version, use a spawn effect instead");
return false;
}

trigger = loadCode(sectionNode, "spawn", SpawnEvent.class);
}

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/skript/tests/syntaxes/sections/EffSecSpawn.sk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test "event-value-converting":
test "spawn section" when minecraft version is not "1.9.4":
spawn a pig at spawn of "world":
assert event-entity is a pig with "entity not a pig"
set {_test} to event-entity
Expand Down