Skip to content

Commit

Permalink
Fix some slot setting issues (#1822)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensku committed Jan 19, 2019
1 parent 5e3fa5f commit c2f1048
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/aliases/ItemData.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public ItemData aliasCopy() {
* @param meta Item meta.
*/
public void applyMeta(ItemMeta meta) {
ItemMeta our = stack.getItemMeta();
ItemMeta our = getItemMeta();
if (meta.hasLore())
our.setLore(meta.getLore());
if (meta.hasDisplayName())
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/ch/njol/skript/expressions/ExprNamed.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.bukkit.event.Event;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.eclipse.jdt.annotation.Nullable;

Expand Down Expand Up @@ -78,6 +79,16 @@ protected Object[] get(final Event e, final Object[] source) {
public Object get(Object obj) {
if (obj instanceof InventoryType)
return Bukkit.createInventory(null, (InventoryType) obj, name);
if (obj instanceof ItemStack) {
ItemStack stack = (ItemStack) obj;
stack = stack.clone();
ItemMeta meta = stack.getItemMeta();
if (meta != null) {
meta.setDisplayName(name);
stack.setItemMeta(meta);
}
return new ItemType(stack);
}
ItemType item = (ItemType) obj;
item = item.clone();
ItemMeta meta = item.getItemMeta();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/util/slot/InventorySlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class InventorySlot extends SlotWithIndex {

public InventorySlot(final Inventory invi, final int index) {
assert invi != null;
assert index > 0;
assert index >= 0;
this.invi = invi;
this.index = index;
}
Expand Down

0 comments on commit c2f1048

Please sign in to comment.