Skip to content
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

Armor Expression #4813

Closed
wants to merge 10 commits into from
54 changes: 54 additions & 0 deletions src/main/java/ch/njol/skript/expressions/ExprGetAllArmor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* 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 <http://www.gnu.org/licenses/>.
*
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
package ch.njol.skript.expressions;

import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import org.eclipse.jdt.annotation.Nullable;

import ch.njol.skript.Skript;
import ch.njol.skript.expressions.base.SimplePropertyExpression;
import ch.njol.skript.lang.ExpressionType;

frackz marked this conversation as resolved.
Show resolved Hide resolved
@Name("Entities's Armor")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Name("Entities's Armor")
@Name("Entity Armor")

@Description("Returns a list of entities armor.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Description("Returns a list of entities armor.")
@Description("Returns a list of entity's armor.")

@Examples("player's armor")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer adding couple more examples or providing a useful little example

@Since("INSERT VERSION")
public class ExprArmor extends SimplePropertyExpression<LivingEntity, ItemStack> {

static {
Skript.registerExpression(ExprGetAllArmor.class, ItemStack.class, ExpressionType.COMBINED, "%livingentities%'s armor");
}

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

@Override
public Class<? extends ItemStack> getReturnType() {
return ItemStack.class;
}

@Override
@Nullable
public ItemStack convert(LivingEntity entity) {
return entity.getEquipment().getArmorContents();
}
}