-
-
Notifications
You must be signed in to change notification settings - Fork 451
Goat Support #7479
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
Merged
Efnilite
merged 18 commits into
SkriptLang:dev/feature
from
Absolutionism:dev/GoatSupport
Mar 30, 2025
Merged
Goat Support #7479
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
79c8243
Initial Commit
Absolutionism 1dd0ff5
Ram Note
Absolutionism 4b57955
Requested Changes
Absolutionism bd5de06
Docs Update
Absolutionism 3972deb
Merge branch 'dev/feature' into dev/GoatSupport
Absolutionism 0f0ed07
Semi-Update
Absolutionism 7058971
Merge branch 'dev/feature' into dev/GoatSupport
Absolutionism 42053ce
No Work
Absolutionism f0944e7
update junit tests
Efnilite 04a74c8
Void GoatHorns Test
Absolutionism 8c88b03
Merge branch 'dev/feature' into dev/GoatSupport
Absolutionism 5f52bb4
Requested Changes
Absolutionism 90d929a
Merge branch 'dev/GoatSupport' of https://github.com/TheAbsolutionism…
Absolutionism 023325d
Merge branch 'dev/feature' into dev/GoatSupport
Absolutionism bba77bf
Merge branch 'dev/feature' into dev/GoatSupport
Absolutionism d068f1b
Merge remote-tracking branch 'upstream/dev/feature' into dev/GoatSupport
Absolutionism 9681851
Example Annotation
Absolutionism 0d53934
Merge branch 'dev/feature' into dev/GoatSupport
Efnilite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
src/main/java/ch/njol/skript/conditions/CondGoatHorns.java
This file contains hidden or 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,86 @@ | ||
| package ch.njol.skript.conditions; | ||
|
|
||
| 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.effects.EffGoatHorns.GoatHorn; | ||
| import ch.njol.skript.lang.Condition; | ||
| import ch.njol.skript.lang.Expression; | ||
| import ch.njol.skript.lang.SkriptParser.ParseResult; | ||
| import ch.njol.skript.lang.SyntaxStringBuilder; | ||
| import ch.njol.util.Kleenean; | ||
| import org.bukkit.entity.Goat; | ||
| import org.bukkit.entity.LivingEntity; | ||
| import org.bukkit.event.Event; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| @Name("Goat Has Horns") | ||
| @Description("Checks to see if a goat has or does not have a left, right, or both horns.") | ||
| @Examples({ | ||
| "if last spawned goat does not have both horns:", | ||
| "\tmake last spawned goat have both horns", | ||
| "", | ||
| "if {_goat} has a right horn:", | ||
| "\tforce {_goat} to not have a right horn" | ||
| }) | ||
| @Since("INSERT VERSION") | ||
| public class CondGoatHorns extends Condition { | ||
|
|
||
| static { | ||
| Skript.registerCondition(CondGoatHorns.class, | ||
| "%livingentities% (has|[does] have) [a] left horn", | ||
| "%livingentities% (has|[does] have) [a] right horn", | ||
| "%livingentities% (has|[does] have) both horns", | ||
| "%livingentities% (does not|doesn't) have [a] left horn", | ||
| "%livingentities% (does not|doesn't) have [a] right horn", | ||
| "%livingentities% (does not|doesn't) have both horns"); | ||
|
Absolutionism marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| private Expression<LivingEntity> entities; | ||
| private GoatHorn goatHorn; | ||
|
|
||
| @Override | ||
| public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
| //noinspection unchecked | ||
| entities = (Expression<LivingEntity>) exprs[0]; | ||
| goatHorn = GoatHorn.values()[matchedPattern / 3]; | ||
| setNegated(matchedPattern >= 3); | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean check(Event event) { | ||
| return entities.check(event, entity -> { | ||
| if (!(entity instanceof Goat goat)) | ||
| return false; | ||
| boolean hasHorns = true; | ||
| if (goatHorn != GoatHorn.RIGHT) | ||
| hasHorns = goat.hasLeftHorn(); | ||
| if (goatHorn != GoatHorn.LEFT) | ||
| hasHorns &= goat.hasRightHorn(); | ||
| return hasHorns; | ||
| }, isNegated()); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(@Nullable Event event, boolean debug) { | ||
| SyntaxStringBuilder builder = new SyntaxStringBuilder(event, debug); | ||
| builder.append(entities); | ||
| if (isNegated()) { | ||
| builder.append("does not have"); | ||
| } else if (entities.isSingle()) { | ||
| builder.append("has"); | ||
| } else { | ||
| builder.append("have"); | ||
| } | ||
| builder.append(switch (goatHorn) { | ||
| case LEFT -> "left horn"; | ||
| case RIGHT -> "right horn"; | ||
| case BOTH -> "both horns"; | ||
| }); | ||
| return builder.toString(); | ||
| } | ||
|
|
||
| } | ||
44 changes: 44 additions & 0 deletions
44
src/main/java/ch/njol/skript/conditions/CondIsScreaming.java
This file contains hidden or 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,44 @@ | ||
| package ch.njol.skript.conditions; | ||
|
|
||
| import ch.njol.skript.Skript; | ||
| import ch.njol.skript.conditions.base.PropertyCondition; | ||
| import ch.njol.skript.doc.*; | ||
| import org.bukkit.entity.Enderman; | ||
| import org.bukkit.entity.Goat; | ||
| import org.bukkit.entity.LivingEntity; | ||
|
|
||
| @Name("Is Screaming") | ||
| @Description("Check if a goat or enderman (Paper) is or is not screaming.") | ||
|
Absolutionism marked this conversation as resolved.
Outdated
|
||
| @Examples({ | ||
| "if last spawned goat is not screaming:", | ||
| "\tmake last spawned goat scream", | ||
| "", | ||
| "if {_enderman} is screaming:", | ||
| "\tforce {_enderman} to stop screaming" | ||
| }) | ||
|
Absolutionism marked this conversation as resolved.
Outdated
|
||
| @RequiredPlugins("Paper (enderman)") | ||
|
Absolutionism marked this conversation as resolved.
Outdated
|
||
| @Since("INSERT VERSION") | ||
| public class CondIsScreaming extends PropertyCondition<LivingEntity> { | ||
|
|
||
| private static final boolean SUPPORTS_ENDERMAN = Skript.methodExists(Enderman.class, "isScreaming"); | ||
|
|
||
| static { | ||
| register(CondIsScreaming.class, "screaming", "livingentities"); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean check(LivingEntity entity) { | ||
| if (entity instanceof Goat goat) { | ||
| return goat.isScreaming(); | ||
| } else if (SUPPORTS_ENDERMAN && entity instanceof Enderman enderman) { | ||
| return enderman.isScreaming(); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getPropertyName() { | ||
| return "screaming"; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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,86 @@ | ||
| 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.skript.lang.SyntaxStringBuilder; | ||
| import ch.njol.util.Kleenean; | ||
| import org.bukkit.entity.Goat; | ||
| import org.bukkit.entity.LivingEntity; | ||
| import org.bukkit.event.Event; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| @Name("Make Goat Have Horns") | ||
| @Description("Make a goat have or not have a left, right, or both horns.") | ||
| @Examples({ | ||
| "make last spawned goat not have both horns", | ||
| "force {_goat} to have a left horn", | ||
| "make all goats have a right horn" | ||
| }) | ||
| @Since("INSERT VERSION") | ||
| public class EffGoatHorns extends Effect { | ||
|
Absolutionism marked this conversation as resolved.
|
||
|
|
||
| public enum GoatHorn { | ||
| LEFT, RIGHT, BOTH | ||
| } | ||
|
|
||
| static { | ||
| Skript.registerEffect(EffGoatHorns.class, | ||
| "make %livingentities% [:not] have [a] left horn", | ||
| "force %livingentities% to [:not] have [a] left horn", | ||
| "make %livingentities% [:not] have [a] right horn", | ||
| "force %livingentities% to [:not] have [a] right horn", | ||
| "make %livingentities% [:not] have both horns", | ||
| "force %livingentities% to [:not] have both horns"); | ||
|
Absolutionism marked this conversation as resolved.
Outdated
Absolutionism marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| private Expression<LivingEntity> entities; | ||
| private GoatHorn goatHorn = GoatHorn.LEFT; | ||
| private boolean have; | ||
|
|
||
| @Override | ||
| public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
| if (matchedPattern >= 4) { | ||
| goatHorn = GoatHorn.BOTH; | ||
| } else if (matchedPattern >= 2) { | ||
| goatHorn = GoatHorn.RIGHT; | ||
| } | ||
| //noinspection unchecked | ||
| entities = (Expression<LivingEntity>) exprs[0]; | ||
| have = !parseResult.hasTag("not"); | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected void execute(Event event) { | ||
| for (LivingEntity entity : entities.getArray(event)) { | ||
| if (entity instanceof Goat goat) { | ||
| if (goatHorn != GoatHorn.RIGHT) | ||
| goat.setLeftHorn(have); | ||
| if (goatHorn != GoatHorn.LEFT) | ||
| goat.setRightHorn(have); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(@Nullable Event event, boolean debug) { | ||
| SyntaxStringBuilder builder = new SyntaxStringBuilder(event, debug); | ||
| builder.append("make", entities); | ||
| if (!have) | ||
| builder.append("not"); | ||
| builder.append("have"); | ||
| builder.append(switch (goatHorn) { | ||
| case LEFT -> "left horn"; | ||
| case RIGHT -> "right horn"; | ||
| case BOTH -> "both horns"; | ||
| }); | ||
| return builder.toString(); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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,60 @@ | ||
| package ch.njol.skript.effects; | ||
|
|
||
| import ch.njol.skript.Skript; | ||
| import ch.njol.skript.doc.*; | ||
| 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.Goat; | ||
| import org.bukkit.entity.LivingEntity; | ||
| import org.bukkit.event.Event; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| @Name("Make Goat Ram") | ||
| @Description({ | ||
| "Make a goat ram an entity.", | ||
| "Ramming does have a cooldown and currently no way to change it." | ||
| }) | ||
| @Examples("make all goats ram player") | ||
| @RequiredPlugins("Paper") | ||
| @Since("INSERT VERSION") | ||
| public class EffGoatRam extends Effect { | ||
|
|
||
| static { | ||
| if (Skript.methodExists(Goat.class, "ram", LivingEntity.class)) | ||
| Skript.registerEffect(EffGoatRam.class, | ||
| "make %livingentities% ram %livingentity%", | ||
| "force %livingentities% to ram %livingentity%"); | ||
| } | ||
|
|
||
| private Expression<LivingEntity> entities; | ||
| private Expression<LivingEntity> target; | ||
|
|
||
| @Override | ||
| public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
| //noinspection unchecked | ||
| entities = (Expression<LivingEntity>) exprs[0]; | ||
| //noinspection unchecked | ||
| target = (Expression<LivingEntity>) exprs[1]; | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected void execute(Event event) { | ||
| LivingEntity target = this.target.getSingle(event); | ||
| if (target == null) | ||
| return; | ||
| for (LivingEntity entity : entities.getArray(event)) { | ||
| if (entity instanceof Goat goat) { | ||
| goat.ram(target); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(@Nullable Event event, boolean debug) { | ||
| return "make " + entities.toString(event, debug) + " ram " + target.toString(event, debug); | ||
| } | ||
|
|
||
| } |
This file contains hidden or 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,65 @@ | ||
| package ch.njol.skript.effects; | ||
|
|
||
| import ch.njol.skript.Skript; | ||
| import ch.njol.skript.doc.*; | ||
| 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.Enderman; | ||
| import org.bukkit.entity.Goat; | ||
| import org.bukkit.entity.LivingEntity; | ||
| import org.bukkit.event.Event; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| @Name("Make Entity Scream") | ||
| @Description("Make a goat or enderman (Paper) start or stop screaming.") | ||
|
Absolutionism marked this conversation as resolved.
Outdated
|
||
| @Examples({ | ||
| "make last spawned goat start screaming", | ||
| "force last spawned goat to not scream", | ||
| "", | ||
| "make {_enderman} scream", | ||
| "force {_enderman} to stop screaming" | ||
| }) | ||
| @RequiredPlugins("Paper (enderman)") | ||
|
Absolutionism marked this conversation as resolved.
Outdated
|
||
| @Since("INSERT VERSION") | ||
| public class EffScreaming extends Effect { | ||
|
|
||
| private static final boolean SUPPORTS_ENDERMAN = Skript.methodExists(Enderman.class, "setScreaming", boolean.class); | ||
|
|
||
| static { | ||
| Skript.registerEffect(EffScreaming.class, | ||
| "make %livingentities% (start screaming|scream)", | ||
| "force %livingentities% to (start screaming|scream)", | ||
| "make %livingentities% (stop screaming|not scream)", | ||
| "force %livingentities% to (stop screaming|not scream)"); | ||
|
Absolutionism marked this conversation as resolved.
Outdated
Absolutionism marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| private Expression<LivingEntity> entities; | ||
| private boolean scream; | ||
|
|
||
| @Override | ||
| public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
| //noinspection unchecked | ||
| entities = (Expression<LivingEntity>) exprs[0]; | ||
| scream = matchedPattern <= 1; | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected void execute(Event event) { | ||
| for (LivingEntity entity : entities.getArray(event)) { | ||
| if (entity instanceof Goat goat) { | ||
| goat.setScreaming(scream); | ||
| } else if (SUPPORTS_ENDERMAN && entity instanceof Enderman enderman) { | ||
| enderman.setScreaming(scream); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(@Nullable Event event, boolean debug) { | ||
| return "make " + entities.toString(event, debug) + (scream ? " start " : " stop ") + "screaming"; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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,17 @@ | ||
| test "goat scream": | ||
| spawn a goat at test-location: | ||
| set {_entity} to entity | ||
| make {_entity} scream | ||
| assert {_entity} is screaming with "Goat should be screaming" | ||
| make {_entity} not scream | ||
| assert {_entity} is not screaming with "Goat should not be screaming" | ||
| clear entity within {_entity} | ||
|
|
||
| test "enderman scream": | ||
| spawn an enderman at test-location: | ||
| set {_entity} to entity | ||
| make {_entity} scream | ||
| assert {_entity} is screaming with "Enderman should be screaming" | ||
| make {_entity} not scream | ||
| assert {_entity} is not screaming with "Enderman should not be screaming" | ||
| clear entity within {_entity} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.