-
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev/feature' into angle
- Loading branch information
Showing
41 changed files
with
2,128 additions
and
329 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
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
45 changes: 45 additions & 0 deletions
45
src/main/java/ch/njol/skript/conditions/CondFromMobSpawner.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,45 @@ | ||
package ch.njol.skript.conditions; | ||
|
||
import ch.njol.skript.Skript; | ||
import ch.njol.skript.conditions.base.PropertyCondition; | ||
import ch.njol.skript.doc.*; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.SkriptParser.ParseResult; | ||
import ch.njol.util.Kleenean; | ||
import org.bukkit.entity.Entity; | ||
|
||
@Name("Is From A Mob Spawner") | ||
@Description("Checks if an entity was spawned from a mob spawner.") | ||
@Examples("send whether target is from a mob spawner") | ||
@RequiredPlugins("PaperMC") | ||
@Since("INSERT VERSION") | ||
public class CondFromMobSpawner extends PropertyCondition<Entity> { | ||
|
||
static { | ||
if (Skript.methodExists(Entity.class, "fromMobSpawner")) | ||
Skript.registerCondition(CondFromMobSpawner.class, | ||
"%entities% (is|are) from a [mob] spawner", | ||
"%entities% (isn't|aren't|is not|are not) from a [mob] spawner", | ||
"%entities% (was|were) spawned (from|by) a [mob] spawner", | ||
"%entities% (wasn't|weren't|was not|were not) spawned (from|by) a [mob] spawner"); | ||
} | ||
|
||
@Override | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
setNegated(matchedPattern == 1 || matchedPattern == 3); | ||
setExpr((Expression<Entity>) exprs[0]); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean check(Entity entity) { | ||
return entity.fromMobSpawner(); | ||
} | ||
|
||
@Override | ||
protected String getPropertyName() { | ||
return "from a mob spawner"; | ||
} | ||
|
||
} | ||
|
46 changes: 46 additions & 0 deletions
46
src/main/java/ch/njol/skript/conditions/CondIsCustomNameVisible.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,46 @@ | ||
package ch.njol.skript.conditions; | ||
|
||
import ch.njol.skript.Skript; | ||
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 ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.SkriptParser.ParseResult; | ||
import ch.njol.util.Kleenean; | ||
import org.bukkit.entity.Entity; | ||
|
||
@Name("Is Custom Name Visible") | ||
@Description("Checks if an entity's custom name is visible.") | ||
@Examples("send true if target's custom name is visible") | ||
@Since("INSERT VERSION") | ||
public class CondIsCustomNameVisible extends PropertyCondition<Entity> { | ||
|
||
static { | ||
Skript.registerCondition(CondIsCustomNameVisible.class, | ||
"%entities%'[s] custom name[s] (is|are) visible", | ||
"%entities%'[s] custom name[s] (isn't|is not|are not|aren't) visible", | ||
"custom name of %entities% (is|are) visible", | ||
"custom name of %entities% (isn't|is not|are not|aren't) visible"); | ||
} | ||
|
||
@Override | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
setNegated(matchedPattern == 1 || matchedPattern == 3); | ||
setExpr((Expression<Entity>) exprs[0]); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean check(Entity entity) { | ||
return entity.isCustomNameVisible(); | ||
} | ||
|
||
@Override | ||
protected String getPropertyName() { | ||
return "custom name"; | ||
} | ||
|
||
} | ||
|
54 changes: 54 additions & 0 deletions
54
src/main/java/ch/njol/skript/conditions/CondIsSaddled.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,54 @@ | ||
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 ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.SkriptParser.ParseResult; | ||
import ch.njol.util.Kleenean; | ||
import org.bukkit.Material; | ||
import org.bukkit.entity.AbstractHorse; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.entity.Steerable; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
@Name("Is Saddled") | ||
@Description({ | ||
"Checks whether a given entity (horse or steerable) is saddled.", | ||
"If 'properly' is used, this will only return true if the entity is wearing specifically a saddle item." | ||
}) | ||
@Examples("send whether {_horse} is saddled") | ||
@Since("INSERT VERSION") | ||
public class CondIsSaddled extends PropertyCondition<LivingEntity> { | ||
|
||
static { | ||
register(CondIsSaddled.class, "[:properly] saddled", "livingentities"); | ||
} | ||
|
||
private boolean properly; | ||
|
||
@Override | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
properly = parseResult.hasTag("properly"); | ||
return super.init(exprs, matchedPattern, isDelayed, parseResult); | ||
} | ||
|
||
@Override | ||
public boolean check(LivingEntity entity) { | ||
if (entity instanceof Steerable steerable) { | ||
return steerable.hasSaddle(); | ||
} else if (entity instanceof AbstractHorse horse) { | ||
ItemStack saddle = horse.getInventory().getSaddle(); | ||
return properly ? (saddle != null && saddle.equals(new ItemStack(Material.SADDLE))) : (saddle != null); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
protected String getPropertyName() { | ||
return properly ? "properly saddled" : "saddled"; | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/ch/njol/skript/conditions/CondIsTicking.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,31 @@ | ||
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.Entity; | ||
|
||
@Name("Is Ticking") | ||
@Description("Checks if an entity is ticking.") | ||
@Examples("send true if target is ticking") | ||
@RequiredPlugins("PaperMC") | ||
@Since("INSERT VERSION") | ||
public class CondIsTicking extends PropertyCondition<Entity> { | ||
|
||
static { | ||
if (Skript.methodExists(Entity.class, "isTicking")) | ||
register(CondIsTicking.class, "ticking", "entities"); | ||
} | ||
|
||
@Override | ||
public boolean check(Entity entity) { | ||
return entity.isTicking(); | ||
} | ||
|
||
@Override | ||
protected String getPropertyName() { | ||
return "ticking"; | ||
} | ||
|
||
} | ||
|
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
Oops, something went wrong.