-
-
Notifications
You must be signed in to change notification settings - Fork 446
Panda Support #7747
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
APickledWalrus
merged 4 commits into
SkriptLang:dev/feature
from
Absolutionism:dev/PandaSupport
Apr 1, 2025
Merged
Panda Support #7747
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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,41 @@ | ||
| 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.AbstractHorse; | ||
| import org.bukkit.entity.LivingEntity; | ||
| import org.bukkit.entity.Panda; | ||
|
|
||
| @Name("Is Eating") | ||
| @Description("Whether a panda or horse type (horse, camel, donkey, llama, mule) is eating.") | ||
| @Example(""" | ||
| if last spawned panda is eating: | ||
| force last spawned panda to stop eating | ||
| """) | ||
| @Since("INSERT VERSION") | ||
| @RequiredPlugins("Paper (horse type)") | ||
| public class CondIsEating extends PropertyCondition<LivingEntity> { | ||
|
|
||
| private static final boolean SUPPORTS_HORSES = Skript.methodExists(AbstractHorse.class, "isEating"); | ||
|
|
||
| static { | ||
| register(CondIsEating.class, "eating", "livingentities"); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean check(LivingEntity entity) { | ||
| if (entity instanceof Panda panda) { | ||
| return panda.isEating(); | ||
| } else if (SUPPORTS_HORSES && entity instanceof AbstractHorse horse) { | ||
| return horse.isEating(); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getPropertyName() { | ||
| return "eating"; | ||
| } | ||
|
|
||
| } |
34 changes: 34 additions & 0 deletions
34
src/main/java/ch/njol/skript/conditions/CondPandaIsOnBack.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,34 @@ | ||
| 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.LivingEntity; | ||
| import org.bukkit.entity.Panda; | ||
|
|
||
| @Name("Panda Is On Its Back") | ||
| @Description("Whether a panda is on its back.") | ||
| @Examples(""" | ||
| if last spawned panda is on its back: | ||
| make last spawned panda get off its back | ||
| """) | ||
| @Since("INSERT VERSION") | ||
| public class CondPandaIsOnBack extends PropertyCondition<LivingEntity> { | ||
|
|
||
| static { | ||
| register(CondPandaIsOnBack.class, "on (its|their) back[s]", "livingentities"); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean check(LivingEntity entity) { | ||
| return entity instanceof Panda panda && panda.isOnBack(); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getPropertyName() { | ||
| return "on their back"; | ||
| } | ||
|
|
||
| } |
34 changes: 34 additions & 0 deletions
34
src/main/java/ch/njol/skript/conditions/CondPandaIsRolling.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,34 @@ | ||
| package ch.njol.skript.conditions; | ||
|
|
||
| import ch.njol.skript.conditions.base.PropertyCondition; | ||
| import ch.njol.skript.doc.Description; | ||
| import ch.njol.skript.doc.Example; | ||
| import ch.njol.skript.doc.Name; | ||
| import ch.njol.skript.doc.Since; | ||
| import org.bukkit.entity.LivingEntity; | ||
| import org.bukkit.entity.Panda; | ||
|
|
||
| @Name("Panda Is Rolling") | ||
| @Description("Whether a panda is rolling.") | ||
| @Example(""" | ||
| if last spawned panda is rolling: | ||
| make last spawned panda stop rolling | ||
| """) | ||
| @Since("INSERT VERSION") | ||
| public class CondPandaIsRolling extends PropertyCondition<LivingEntity> { | ||
|
|
||
| static { | ||
| register(CondPandaIsRolling.class, "rolling", "livingentities"); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean check(LivingEntity entity) { | ||
| return entity instanceof Panda panda && panda.isRolling(); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getPropertyName() { | ||
| return "rolling"; | ||
| } | ||
|
|
||
| } |
31 changes: 31 additions & 0 deletions
31
src/main/java/ch/njol/skript/conditions/CondPandaIsScared.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,31 @@ | ||
| package ch.njol.skript.conditions; | ||
|
|
||
| import ch.njol.skript.conditions.base.PropertyCondition; | ||
| import ch.njol.skript.doc.Description; | ||
| import ch.njol.skript.doc.Example; | ||
| import ch.njol.skript.doc.Name; | ||
| import ch.njol.skript.doc.Since; | ||
| import org.bukkit.entity.LivingEntity; | ||
| import org.bukkit.entity.Panda; | ||
|
|
||
| @Name("Panda Is Scared") | ||
| @Description("Whether a panda is scared.") | ||
| @Example("if last spawned panda is scared:") | ||
| @Since("INSERT VERSION") | ||
| public class CondPandaIsScared extends PropertyCondition<LivingEntity> { | ||
|
|
||
| static { | ||
| register(CondPandaIsScared.class, "scared", "livingentities"); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean check(LivingEntity entity) { | ||
| return entity instanceof Panda panda && panda.isScared(); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getPropertyName() { | ||
| return "scared"; | ||
| } | ||
|
|
||
| } |
34 changes: 34 additions & 0 deletions
34
src/main/java/ch/njol/skript/conditions/CondPandaIsSneezing.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,34 @@ | ||
| package ch.njol.skript.conditions; | ||
|
|
||
| import ch.njol.skript.conditions.base.PropertyCondition; | ||
| import ch.njol.skript.doc.Description; | ||
| import ch.njol.skript.doc.Example; | ||
| import ch.njol.skript.doc.Name; | ||
| import ch.njol.skript.doc.Since; | ||
| import org.bukkit.entity.LivingEntity; | ||
| import org.bukkit.entity.Panda; | ||
|
|
||
| @Name("Panda Is Sneezing") | ||
| @Description("Whether a panda is sneezing.") | ||
| @Example(""" | ||
| if last spawned panda is sneezing: | ||
| make last spawned panda stop sneezing | ||
| """) | ||
| @Since("INSERT VERSION") | ||
| public class CondPandaIsSneezing extends PropertyCondition<LivingEntity> { | ||
|
|
||
| static { | ||
| register(CondPandaIsSneezing.class, "sneezing", "livingentities"); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean check(LivingEntity entity) { | ||
| return entity instanceof Panda panda && panda.isSneezing(); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getPropertyName() { | ||
| return "sneezing"; | ||
| } | ||
|
|
||
| } |
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,69 @@ | ||
| 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.skript.lang.SyntaxStringBuilder; | ||
| import ch.njol.util.Kleenean; | ||
| import org.bukkit.entity.AbstractHorse; | ||
| import org.bukkit.entity.LivingEntity; | ||
| import org.bukkit.entity.Panda; | ||
| import org.bukkit.event.Event; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| @Name("Force Eating") | ||
| @Description("Make a panda or horse type (horse, camel, donkey, llama, mule) start/stop eating.") | ||
| @Example(""" | ||
| if last spawned panda is eating: | ||
| make last spawned panda stop eating | ||
| """) | ||
| @Since("INSERT VERSION") | ||
| @RequiredPlugins("Paper (horse type)") | ||
| public class EffEating extends Effect { | ||
|
|
||
| private static final boolean SUPPORTS_HORSES = Skript.methodExists(AbstractHorse.class, "isEating"); | ||
|
|
||
| static { | ||
| Skript.registerEffect(EffEating.class, | ||
| "make %livingentities% (:start|stop) eating", | ||
| "force %livingentities% to (:start|stop) eating"); | ||
| } | ||
|
|
||
| private Expression<LivingEntity> entities; | ||
| private boolean start; | ||
|
|
||
| @Override | ||
| public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
| //noinspection unchecked | ||
| entities = (Expression<LivingEntity>) exprs[0]; | ||
| start = parseResult.hasTag("start"); | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected void execute(Event event) { | ||
| for (LivingEntity entity : entities.getArray(event)) { | ||
| if (entity instanceof Panda panda) { | ||
| panda.setEating(start); | ||
| } else if (SUPPORTS_HORSES && entity instanceof AbstractHorse horse) { | ||
| horse.setEating(start); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(@Nullable Event event, boolean debug) { | ||
| SyntaxStringBuilder builder = new SyntaxStringBuilder(event, debug); | ||
| builder.append("make", entities); | ||
| if (start) { | ||
| builder.append("start"); | ||
| } else { | ||
| builder.append("stop"); | ||
| } | ||
| builder.append("eating"); | ||
| 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,66 @@ | ||
| 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.LivingEntity; | ||
| import org.bukkit.entity.Panda; | ||
| import org.bukkit.event.Event; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| @Name("Force Panda On Back") | ||
| @Description("Make a panda get on/off its back.") | ||
| @Examples(""" | ||
| if last spawned panda is on its back: | ||
| make last spawned panda get off its back | ||
| """) | ||
| @Since("INSERT VERSION") | ||
| public class EffPandaOnBack extends Effect { | ||
|
|
||
| static { | ||
| Skript.registerEffect(EffPandaOnBack.class, | ||
| "make %livingentities% get (:on|off) (its|their) back[s]", | ||
| "force %livingentities% to get (:on|off) (its|their) back[s]"); | ||
| } | ||
|
|
||
| private Expression<LivingEntity> entities; | ||
| private boolean getOn; | ||
|
|
||
| @Override | ||
| public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
| //noinspection unchecked | ||
| entities = (Expression<LivingEntity>) exprs[0]; | ||
| getOn = parseResult.hasTag("on"); | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected void execute(Event event) { | ||
| for (LivingEntity entity : entities.getArray(event)) { | ||
| if (entity instanceof Panda panda) { | ||
| panda.setOnBack(getOn); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(@Nullable Event event, boolean debug) { | ||
| SyntaxStringBuilder builder = new SyntaxStringBuilder(event, debug); | ||
| builder.append("make", entities, "get"); | ||
| if (getOn) { | ||
| builder.append("on"); | ||
| } else { | ||
| builder.append("off"); | ||
| } | ||
| builder.append("their backs"); | ||
| 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,66 @@ | ||
| package ch.njol.skript.effects; | ||
|
|
||
| import ch.njol.skript.Skript; | ||
| import ch.njol.skript.doc.Description; | ||
| import ch.njol.skript.doc.Example; | ||
| 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.LivingEntity; | ||
| import org.bukkit.entity.Panda; | ||
| import org.bukkit.event.Event; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| @Name("Make Panda Roll") | ||
| @Description("Make a panda start/stop rolling.") | ||
| @Example(""" | ||
| if last spawned panda is not rolling: | ||
| make last spawned panda start rolling | ||
| """) | ||
| @Since("INSERT VERSION") | ||
| public class EffPandaRolling extends Effect { | ||
|
|
||
| static { | ||
| Skript.registerEffect(EffPandaRolling.class, | ||
| "make %livingentities% (start:(start rolling|roll)|stop rolling)", | ||
| "force %livingentities% to (:start|stop) rolling"); | ||
| } | ||
|
|
||
| private Expression<LivingEntity> entities; | ||
| private boolean start; | ||
|
|
||
| @Override | ||
| public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
| //noinspection unchecked | ||
| entities = (Expression<LivingEntity>) exprs[0]; | ||
| start = parseResult.hasTag("start"); | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected void execute(Event event) { | ||
| for (LivingEntity entity : entities.getArray(event)) { | ||
| if (entity instanceof Panda panda) { | ||
| panda.setRolling(start); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(@Nullable Event event, boolean debug) { | ||
| SyntaxStringBuilder builder = new SyntaxStringBuilder(event, debug); | ||
| builder.append("make", entities); | ||
| if (start) { | ||
| builder.append("start"); | ||
| } else { | ||
| builder.append("stop"); | ||
| } | ||
| builder.append("rolling"); | ||
| return builder.toString(); | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
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.