-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...it/jakegblp/lusk/elements/minecraft/blocks/spawner/expressions/ExprSpawnerEntityType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package it.jakegblp.lusk.elements.minecraft.blocks.spawner.expressions; | ||
|
||
import ch.njol.skript.doc.Description; | ||
import ch.njol.skript.doc.Examples; | ||
import ch.njol.skript.doc.Name; | ||
import ch.njol.skript.doc.Since; | ||
import ch.njol.skript.entity.EntityData; | ||
import it.jakegblp.lusk.api.BlockWrapper; | ||
import it.jakegblp.lusk.api.skript.SimplerPropertyExpression; | ||
import org.bukkit.entity.EntityType; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@Name("Spawner/Trial Spawner - Entity Type") | ||
@Description("Gets the spawner entity type of the provided spawners or trial spawners (1.21+).\n**Works with items.**\nCan be set and reset (sets it to pig).") | ||
@Examples("set spawner entity type of {_block} to zombie") | ||
@Since("1.3.4-beta1") | ||
public class ExprSpawnerEntityType extends SimplerPropertyExpression<Object, EntityData> { | ||
|
||
static { | ||
register(ExprSpawnerEntityType.class, EntityData.class, "spawner (entity|creature) type", "itemtypes/blocks/blockstates"); | ||
} | ||
|
||
@Override | ||
public @Nullable EntityData convert(Object from) { | ||
return new BlockWrapper(from).getSpawnerEntityType(); | ||
} | ||
|
||
@Override | ||
public boolean allowSet() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean allowReset() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void set(Object from, EntityData to) { | ||
new BlockWrapper(from).setSpawnerEntityType(to); | ||
} | ||
|
||
@Override | ||
public void reset(Object from) { | ||
new BlockWrapper(from).setSpawnerEntityType(EntityType.PIG); | ||
} | ||
|
||
@Override | ||
protected String getPropertyName() { | ||
return "spawner entity type"; | ||
} | ||
|
||
@Override | ||
public Class<? extends EntityData> getReturnType() { | ||
return EntityData.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
test "ExprSpawnerEntityType": | ||
set {_location} to location(10, 11, 10) | ||
set block at {_location} to spawner | ||
set {_spawner} to block at {_location} | ||
assert spawner entity type of {_spawner} is pig with "spawner entity type of spawner at location %{_location}% is not pig (default)" | ||
set spawner entity type of {_spawner} to zombie | ||
assert spawner entity type of {_spawner} is zombie with "spawner entity type of spawner at location %{_location}% is not zombie" | ||
|
||
server version >= 1.21.0 | ||
|
||
set block at {_location} to trial spawner | ||
set {_spawner} to block at {_location} | ||
set spawner entity type of {_spawner} to skeleton | ||
assert spawner entity type of {_spawner} is zombie with "spawner entity type of spawner at location %{_location}% is not skeleton" |