diff --git a/src/main/java/ch/njol/skript/conditions/CondIsWearing.java b/src/main/java/ch/njol/skript/conditions/CondIsWearing.java
index 19e2f38fb9c..3b43620b6f6 100644
--- a/src/main/java/ch/njol/skript/conditions/CondIsWearing.java
+++ b/src/main/java/ch/njol/skript/conditions/CondIsWearing.java
@@ -1,29 +1,5 @@
-/**
- * This file is part of Skript.
- *
- * Skript is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Skript is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Skript. If not, see .
- *
- * Copyright Peter Güttinger, SkriptLang team and contributors
- */
package ch.njol.skript.conditions;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.event.Event;
-import org.bukkit.inventory.EntityEquipment;
-import org.bukkit.inventory.ItemStack;
-import org.eclipse.jdt.annotation.Nullable;
-
import ch.njol.skript.aliases.ItemType;
import ch.njol.skript.conditions.base.PropertyCondition;
import ch.njol.skript.conditions.base.PropertyCondition.PropertyType;
@@ -35,14 +11,22 @@
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.Event;
+import org.bukkit.inventory.EntityEquipment;
+import org.bukkit.inventory.ItemStack;
+import org.eclipse.jdt.annotation.Nullable;
/**
* @author Peter Güttinger
*/
@Name("Is Wearing")
-@Description("Checks whether a player is wearing some armour.")
-@Examples({"player is wearing an iron chestplate and iron leggings",
- "player is wearing all diamond armour"})
+@Description("Checks whether an entity is wearing some items (usually armor).")
+@Examples({
+ "player is wearing an iron chestplate and iron leggings",
+ "player is wearing all diamond armour",
+ "target is wearing wolf armor"
+})
@Since("1.0")
public class CondIsWearing extends Condition {
@@ -57,7 +41,7 @@ public class CondIsWearing extends Condition {
@SuppressWarnings({"unchecked", "null"})
@Override
- public boolean init(final Expression>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
+ public boolean init(Expression>[] vars, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
entities = (Expression) vars[0];
types = (Expression) vars[1];
setNegated(matchedPattern == 1);
@@ -65,24 +49,24 @@ public boolean init(final Expression>[] vars, final int matchedPattern, final
}
@Override
- public boolean check(final Event e) {
- return entities.check(e,
- en -> types.check(e,
- t -> {
- EntityEquipment equip = en.getEquipment();
+ public boolean check(Event event) {
+ return entities.check(event,
+ entity -> types.check(event,
+ type -> {
+ EntityEquipment equip = entity.getEquipment();
if (equip == null)
return false; // No equipment -> not wearing anything
- for (final ItemStack is : equip.getArmorContents()) {
- if (t.isOfType(is) ^ t.isAll())
- return !t.isAll();
+ for (ItemStack armorContent : equip.getArmorContents()) {
+ if (type.isOfType(armorContent) ^ type.isAll())
+ return !type.isAll();
}
- return t.isAll();
+ return type.isAll();
}),
isNegated());
}
@Override
- public String toString(final @Nullable Event e, final boolean debug) {
+ public String toString(@Nullable Event e, boolean debug) {
return PropertyCondition.toString(this, PropertyType.BE, e, debug, entities,
"wearing " + types.toString(e, debug));
}