From 7a241af596410e78ef64c0381b481f9d1e661528 Mon Sep 17 00:00:00 2001 From: Brianna Date: Thu, 11 Jun 2020 17:14:07 -0500 Subject: [PATCH] Use the CompatibleMaterial class correctly. --- .../challenge/challenge/ChallengeCategory.java | 5 +---- .../skyblock/challenge/challenge/ItemChallenge.java | 10 ++++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java index 709e3c2a..ddc31195 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java @@ -57,10 +57,7 @@ public class ChallengeCategory { CompatibleMaterial compatibleMaterial = CompatibleMaterial.getMaterial(strItem); if (compatibleMaterial == null) throw new IllegalArgumentException("Item " + strItem + " isn't a correct material"); - Material item = compatibleMaterial.getMaterial(); - if (item == null) - throw new IllegalArgumentException("Item " + strItem + " isn't a correct material"); - ItemChallenge ic = new ItemChallenge(show, row, col, item, amount, lore); + ItemChallenge ic = new ItemChallenge(show, row, col, compatibleMaterial, amount, lore); Challenge c = new Challenge(this, id, name, maxTimes, showInChat, require, reward, ic); challenges.put(id, c); } catch (IllegalArgumentException ex) { diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java b/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java index 61bb7812..8f000cdc 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.List; import java.util.UUID; +import com.songoda.core.compatibility.CompatibleMaterial; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; @@ -18,13 +19,13 @@ public class ItemChallenge { private boolean show; private int row; private int col; - private Material type; + private CompatibleMaterial type; private int amount; private List lore; private String itemTitle; - public ItemChallenge(boolean show, int row, int col, Material type, int amount, List lore) { + public ItemChallenge(boolean show, int row, int col, CompatibleMaterial type, int amount, List lore) { this.show = show; this.row = row; this.col = col; @@ -39,7 +40,8 @@ public class ItemChallenge { } public ItemStack createItem(UUID player, int amount) { - ItemStack is = new ItemStack(type, this.amount); + ItemStack is = type.getItem(); + is.setAmount(this.amount); // Air ItemMeta im = is.getItemMeta(); if (im != null) { @@ -73,7 +75,7 @@ public class ItemChallenge { return col; } - public Material getType() { + public CompatibleMaterial getType() { return type; }