Skip to content
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
41 changes: 41 additions & 0 deletions src/main/java/ch/njol/skript/conditions/CondIsEating.java
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 src/main/java/ch/njol/skript/conditions/CondPandaIsOnBack.java
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 src/main/java/ch/njol/skript/conditions/CondPandaIsRolling.java
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 src/main/java/ch/njol/skript/conditions/CondPandaIsScared.java
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";
}

}
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";
}

}
69 changes: 69 additions & 0 deletions src/main/java/ch/njol/skript/effects/EffEating.java
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();
}

}
66 changes: 66 additions & 0 deletions src/main/java/ch/njol/skript/effects/EffPandaOnBack.java
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();
}

}
66 changes: 66 additions & 0 deletions src/main/java/ch/njol/skript/effects/EffPandaRolling.java
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,
Comment thread
Absolutionism marked this conversation as resolved.
"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();
}

}
Loading