-
-
Notifications
You must be signed in to change notification settings - Fork 379
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
1 parent
c26b1e1
commit 1cf58cd
Showing
6 changed files
with
120 additions
and
38 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/java/ch/njol/skript/conditions/CondIsDashing.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,36 @@ | ||
package ch.njol.skript.conditions; | ||
|
||
import ch.njol.skript.conditions.base.PropertyCondition; | ||
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 org.bukkit.entity.Camel; | ||
import org.bukkit.entity.LivingEntity; | ||
|
||
@Name("Camel Is Dashing") | ||
@Description("Checks whether a camel is sprinting.") | ||
@Examples({ | ||
"if last spawned camel is not dashing:", | ||
"\tmake last spawned camel start dashing" | ||
}) | ||
@Since("INSERT VERSION") | ||
public class CondIsDashing extends PropertyCondition<LivingEntity> { | ||
|
||
static { | ||
register(CondIsDashing.class, "dashing", "livingentities"); | ||
} | ||
|
||
@Override | ||
public boolean check(LivingEntity entity) { | ||
if (entity instanceof Camel camel) | ||
return camel.isDashing(); | ||
return false; | ||
} | ||
|
||
@Override | ||
protected String getPropertyName() { | ||
return "dashing"; | ||
} | ||
|
||
} |
22 changes: 7 additions & 15 deletions
22
src/main/java/ch/njol/skript/conditions/CondIsSprinting.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
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,59 @@ | ||
package ch.njol.skript.effects; | ||
|
||
import ch.njol.skript.Skript; | ||
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.lang.Effect; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.SkriptParser.ParseResult; | ||
import ch.njol.util.Kleenean; | ||
import org.bukkit.entity.Camel; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.event.Event; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@Name("Camel Dashing") | ||
@Description({ | ||
"Make a camel start or stop dashing.", | ||
"Dashing is a temporary speed burst, a dash lasts for 0.35 seconds." | ||
}) | ||
@Examples({ | ||
"make last spawned camel start dashing", | ||
"make last spawned camel stop dashing", | ||
}) | ||
@Since("INSERT VERSION") | ||
public class EffDashing extends Effect { | ||
|
||
static { | ||
Skript.registerEffect(EffDashing.class, | ||
"make %livingentities% (start dashing|dash)", | ||
"make %livingentities% stop dashing"); | ||
} | ||
|
||
private Expression<LivingEntity> entities; | ||
private boolean dash; | ||
|
||
@Override | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
//noinspection unchecked | ||
entities = (Expression<LivingEntity>) exprs[0]; | ||
dash = matchedPattern == 0; | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void execute(Event event) { | ||
for (LivingEntity entity : entities.getArray(event)) { | ||
if (entity instanceof Camel camel) | ||
camel.setDashing(dash); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString(@Nullable Event event, boolean debug) { | ||
return "make " + entities.toString(event, debug) + (dash ? " start" : " stop") + " dashing"; | ||
} | ||
|
||
} |
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,9 @@ | ||
test "camel dashing" when running minecraft "1.20": | ||
# Test fails on 1.19.4, effect does work. | ||
spawn a camel at test-location: | ||
set {_entity} to entity | ||
make {_entity} start dashing | ||
assert {_entity} is dashing with "Camel should be dashing" | ||
make {_entity} stop dashing | ||
assert {_entity} is not dashing with "Camel should not be dashing" | ||
clear entity within {_entity} |
This file was deleted.
Oops, something went wrong.