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

Fix CCE for ExprItemWithLore #2431

Closed
wants to merge 2 commits into from
Closed
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
18 changes: 9 additions & 9 deletions src/main/java/ch/njol/skript/expressions/ExprItemWithLore.java
Original file line number Diff line number Diff line change
@@ -25,11 +25,11 @@
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.Event;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.eclipse.jdt.annotation.Nullable;

import ch.njol.skript.Skript;
import ch.njol.skript.aliases.ItemType;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Examples;
import ch.njol.skript.doc.Name;
@@ -42,16 +42,16 @@
import ch.njol.util.StringUtils;

@Name("Item with Lore")
@Description({"Returns the given item type with the specified lore added to it.",
@Description({"Returns the given item stack with the specified lore added to it.",
"If multiple strings are passed, each of them will be a separate line in the lore."})
@Examples({"set {_test} to stone with lore \"line 1\" and \"line 2\"",
"give {_test} to player"})
@Since("2.3")
public class ExprItemWithLore extends PropertyExpression<ItemType, ItemType> {
public class ExprItemWithLore extends PropertyExpression<ItemStack, ItemStack> {

static {
Skript.registerExpression(ExprItemWithLore.class, ItemType.class, ExpressionType.PROPERTY,
"%itemtype% with [(a|the)] lore %strings%");
Skript.registerExpression(ExprItemWithLore.class, ItemStack.class, ExpressionType.PROPERTY,
"%itemstack% with [(a|the)] lore %strings%");
}

@SuppressWarnings("null")
@@ -60,13 +60,13 @@ public class ExprItemWithLore extends PropertyExpression<ItemType, ItemType> {
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean kleenean, ParseResult parseResult) {
setExpr((Expression<ItemType>) exprs[0]);
setExpr((Expression<ItemStack>) exprs[0]);
lore = (Expression<String>) exprs[1];
return true;
}

@Override
protected ItemType[] get(Event e, ItemType[] source) {
protected ItemStack[] get(Event e, ItemStack[] source) {
String[] lore = this.lore.getArray(e);
return get(source, item -> {
ItemMeta meta = item.getItemMeta();
@@ -78,8 +78,8 @@ protected ItemType[] get(Event e, ItemType[] source) {


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

@Override