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
9 changes: 7 additions & 2 deletions src/main/java/ch/njol/skript/conditions/CondAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ public class CondAI extends PropertyCondition<LivingEntity> {
public boolean check(LivingEntity entity) {
return entity.hasAI();
}


@Override
protected PropertyType getPropertyType() {
return PropertyType.HAVE;
}

@Override
protected String getPropertyName() {
return "artificial intelligence";
}

}
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/conditions/CondCanFly.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
@Description("Whether a player is allowed to fly.")
@Examples("player can fly")
@Since("2.3")

public class CondCanFly extends PropertyCondition<Player> {

static {
Expand All @@ -33,4 +32,5 @@ protected PropertyType getPropertyType() {
protected String getPropertyName() {
return "fly";
}

}
5 changes: 5 additions & 0 deletions src/main/java/ch/njol/skript/conditions/CondChatColors.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public boolean check(Player player) {
return player.getClientOption(ClientOption.CHAT_COLORS_ENABLED);
}

@Override
protected PropertyType getPropertyType() {
return PropertyType.CAN;
}

@Override
protected String getPropertyName() {
return "see chat colors";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public boolean check(Player player) {
return player.getClientOption(ClientOption.TEXT_FILTERING_ENABLED);
}

@Override
protected PropertyType getPropertyType() {
return PropertyType.HAVE;
}

@Override
protected String getPropertyName() {
return "chat filtering enabled";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

@Name("Entity is in Liquid")
@Description("Checks whether an entity is in rain, lava, water or a bubble column.")
@Examples({"if player is in rain:",
"if player is in water:",
"player is in lava:",
"player is in bubble column"})
@RequiredPlugins("Minecraft 1.16+ (in water), Paper 1.16+ (in rain, lava and bubble column)")
@Examples({
"if player is in rain:",
"if player is in water:",
"player is in lava:",
"player is in bubble column"
})
@RequiredPlugins("Paper (in rain, lava and bubble column)")
@Since("2.6.1")
public class CondEntityIsInLiquid extends PropertyCondition<Entity> {

Expand All @@ -24,7 +26,7 @@ public class CondEntityIsInLiquid extends PropertyCondition<Entity> {
patterns.append("1¦water");
if (Skript.methodExists(Entity.class, "isInLava")) // Paper - All added at the same time + isInWater
patterns.append("|2¦lava|3¦[a] bubble[ ]column|4¦rain");
register(CondEntityIsInLiquid.class, PropertyType.BE, "in (" + patterns + ")", "entities");
register(CondEntityIsInLiquid.class, "in (" + patterns + ")", "entities");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CondEntityIsWet extends PropertyCondition<Entity> {

static {
if (Skript.methodExists(Entity.class, "isInWaterOrRainOrBubbleColumn"))
register(CondEntityIsWet.class, PropertyType.BE, "wet", "entities");
register(CondEntityIsWet.class, "wet", "entities");
}

@Override
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/ch/njol/skript/conditions/CondGlowingText.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public class CondGlowingText extends PropertyCondition<Object> {

@Override
public boolean check(Object obj) {
if (obj instanceof Block) {
BlockState state = ((Block) obj).getState();
return state instanceof Sign && ((Sign) state).isGlowingText();
} else if (obj instanceof ItemType) {
ItemMeta meta = ((ItemType) obj).getItemMeta();
if (meta instanceof BlockStateMeta) {
BlockState state = ((BlockStateMeta) meta).getBlockState();
return state instanceof Sign && ((Sign) state).isGlowingText();
if (obj instanceof Block block) {
BlockState state = block.getState();
return state instanceof Sign sign && sign.isGlowingText();
} else if (obj instanceof ItemType itemType) {
ItemMeta meta = itemType.getItemMeta();
if (meta instanceof BlockStateMeta blockStateMeta) {
BlockState state = blockStateMeta.getBlockState();
return state instanceof Sign sign && sign.isGlowingText();
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

@Name("Has Client Weather")
@Description("Checks whether the given players have a custom client weather")
@Examples({"if the player has custom weather:",
"\tmessage \"Your custom weather is %player's weather%\""})
@Examples({
"if the player has custom weather:",
"\tmessage \"Your custom weather is %player's weather%\""
})
@Since("2.3")

public class CondHasClientWeather extends PropertyCondition<Player> {

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public class CondHasCustomModelData extends PropertyCondition<ItemType> {
public boolean check(ItemType item) {
return item.getItemMeta().hasCustomModelData();
}


@Override
protected PropertyType getPropertyType() {
return PropertyType.HAVE;
}

@Override
protected String getPropertyName() {
return "custom model data";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

@Name("Ignition Process")
@Description("Checks if a creeper is going to explode.")
@Examples({"if the last spawned creeper is going to explode:",
"\tloop all players in radius 3 of the last spawned creeper",
"\t\tsend \"RUN!!!\" to the loop-player"})
@Examples({
"if the last spawned creeper is going to explode:",
"\tloop all players in radius 3 of the last spawned creeper",
"\t\tsend \"RUN!!!\" to the loop-player"
})
@Since("2.5")
@RequiredPlugins("Paper 1.13 or newer")
@RequiredPlugins("Paper")
public class CondIgnitionProcess extends PropertyCondition<LivingEntity> {

static {
Expand All @@ -32,7 +34,7 @@ public class CondIgnitionProcess extends PropertyCondition<LivingEntity> {
}
}

@SuppressWarnings({"unchecked", "null"})
@SuppressWarnings({"unchecked"})
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
setExpr((Expression<LivingEntity>) exprs[0]);
Expand All @@ -41,12 +43,13 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
}

@Override
public boolean check(LivingEntity e) {
return e instanceof Creeper && ((Creeper) e).isIgnited();
public boolean check(LivingEntity entity) {
return entity instanceof Creeper creeper && creeper.isIgnited();
}

@Override
protected String getPropertyName() {
return "going to explode";
}

}
6 changes: 4 additions & 2 deletions src/main/java/ch/njol/skript/conditions/CondIsAlive.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@

@Name("Is Alive")
@Description("Checks whether an entity is alive. Works for non-living entities too.")
@Examples({"if {villager-buddy::%player's uuid%} is not dead:",
@Examples({
"if {villager-buddy::%player's uuid%} is not dead:",
"",
"on shoot:",
"\twhile the projectile is alive:"})
"\twhile the projectile is alive:"
})
@Since("2.0, 2.4-alpha4 (non-living entity support)")
public class CondIsAlive extends PropertyCondition<Entity> {

Expand Down
35 changes: 16 additions & 19 deletions src/main/java/ch/njol/skript/conditions/CondIsBanned.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package ch.njol.skript.conditions;

import java.net.InetSocketAddress;

import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;

import ch.njol.skript.Skript;
import ch.njol.skript.conditions.base.PropertyCondition;
import ch.njol.skript.doc.Description;
Expand All @@ -15,15 +9,19 @@
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;

import java.net.InetSocketAddress;

/**
* @author Peter Güttinger
*/
@Name("Is Banned")
@Description("Checks whether a player or IP is banned.")
@Examples({"player is banned",
"victim is not IP-banned",
"\"127.0.0.1\" is banned"})
@Examples({
"player is banned",
"victim is not IP-banned",
"\"127.0.0.1\" is banned"
})
@Since("1.4")
public class CondIsBanned extends PropertyCondition<Object> {

Expand All @@ -36,8 +34,7 @@ public class CondIsBanned extends PropertyCondition<Object> {
}

private boolean ipBanned;

@SuppressWarnings("null")

@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
setExpr(exprs[0]);
Expand All @@ -48,17 +45,17 @@ public boolean init(final Expression<?>[] exprs, final int matchedPattern, final

@Override
public boolean check(Object obj) {
if (obj instanceof Player) {
if (obj instanceof Player player) {
if (ipBanned) {
InetSocketAddress sockAddr = ((Player) obj).getAddress();
InetSocketAddress sockAddr = player.getAddress();
if (sockAddr == null)
return false; // Assume not banned, they've never played here
return Bukkit.getIPBans().contains(sockAddr.getAddress().getHostAddress());
} else {
return ((Player) obj).isBanned();
return player.isBanned();
}
} else if (obj instanceof OfflinePlayer) {
return ((OfflinePlayer) obj).isBanned();
} else if (obj instanceof OfflinePlayer offlinePlayer) {
return offlinePlayer.isBanned();
} else if (obj instanceof String) {
return Bukkit.getIPBans().contains(obj) ||
!ipBanned && Bukkit.getBannedPlayers().stream()
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/ch/njol/skript/conditions/CondIsBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

@Name("Is Block")
@Description("Checks whether an item is a block.")
@Examples({"player's held item is a block", "{list::*} are blocks"})
@Examples({
"player's held item is a block",
"{list::*} are blocks"
})
@Since("2.4")
public class CondIsBlock extends PropertyCondition<ItemType> {

Expand All @@ -18,8 +21,8 @@ public class CondIsBlock extends PropertyCondition<ItemType> {
}

@Override
public boolean check(ItemType i) {
return i.getMaterial().isBlock();
public boolean check(ItemType itemType) {
return itemType.getMaterial().isBlock();
}

@Override
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/ch/njol/skript/conditions/CondIsBlocking.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;

/**
* @author Peter Güttinger
*/
@Name("Is Blocking")
@Description("Checks whether a player is blocking with their shield.")
@Examples({"on damage of player:",
" victim is blocking",
" damage attacker by 0.5 hearts"})
@Examples({
"on damage of player:",
"\tvictim is blocking",
"\tdamage attacker by 0.5 hearts"
})
@Since("<i>unknown</i> (before 2.1)")
public class CondIsBlocking extends PropertyCondition<Player> {

Expand All @@ -24,8 +23,8 @@ public class CondIsBlocking extends PropertyCondition<Player> {
}

@Override
public boolean check(final Player p) {
return p.isBlocking();
public boolean check(Player player) {
return player.isBlocking();
}

@Override
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/ch/njol/skript/conditions/CondIsBurning.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;

/**
* @author Peter Güttinger
*/
@Name("Is Burning")
@Description("Checks whether an entity is on fire, e.g. a zombie due to being in sunlight, or any entity after falling into lava.")
@Examples({"# increased attack against burning targets",
"victim is burning:",
" increase damage by 2"})
@Examples({
"# increased attack against burning targets",
"victim is burning:",
"\tincrease damage by 2"
})
@Since("1.4.4")
public class CondIsBurning extends PropertyCondition<Entity> {

Expand All @@ -24,8 +23,8 @@ public class CondIsBurning extends PropertyCondition<Entity> {
}

@Override
public boolean check(final Entity e) {
return e.getFireTicks() > 0;
public boolean check(Entity entity) {
return entity.getFireTicks() > 0;
}

@Override
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/ch/njol/skript/conditions/CondIsCharged.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

@Name("Is Charged")
@Description("Checks if a creeper, wither, or wither skull is charged (powered).")
@Examples({"if the last spawned creeper is charged:",
"\tbroadcast \"A charged creeper is at %location of last spawned creeper%\""})
@Examples({
"if the last spawned creeper is charged:",
"\tbroadcast \"A charged creeper is at %location of last spawned creeper%\""
})
@Since("2.5, 2.10 (withers, wither skulls)")
public class CondIsCharged extends PropertyCondition<Entity> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import org.bukkit.block.data.type.CommandBlock;

@Name("Is Conditional")
@Description(
"Checks whether a command block is conditional or not."
)
@Description("Checks whether a command block is conditional or not.")
@Examples({
"if {_block} is conditional:",
"\tmake {_block} unconditional"
Expand Down
Loading