From 9da6fe3b4df7fb388350c6d039bddc27610e5cf8 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Sun, 10 Oct 2021 03:29:35 -0400 Subject: [PATCH] Adjust module name and items --- .../me/blackvein/quests/CustomObjective.java | 23 +++++++++------- .../blackvein/quests/CustomRequirement.java | 26 ++++++++++++------- .../me/blackvein/quests/CustomReward.java | 26 ++++++++++++------- 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/CustomObjective.java b/main/src/main/java/me/blackvein/quests/CustomObjective.java index 7c849fee6..86b9203f2 100644 --- a/main/src/main/java/me/blackvein/quests/CustomObjective.java +++ b/main/src/main/java/me/blackvein/quests/CustomObjective.java @@ -33,7 +33,7 @@ public abstract class CustomObjective implements Listener { private String name = null; private String author = null; private String display = "Progress: %count%"; - private final Map items = new HashMap<>(); + private Entry item = new AbstractMap.SimpleEntry<>("BOOK", (short) 0); private final LinkedList> data = new LinkedList<>(); private final Map descriptions = new HashMap<>(); private String countPrompt = "Enter number"; @@ -45,10 +45,8 @@ public abstract class CustomObjective implements Listener { .replace(".jar", ""); } - public Map getModuleItem() { - final Map moduleItems = new HashMap<>(); - moduleItems.put("IRON_INGOT", (short) 0); - return moduleItems; + public Entry getModuleItem() { + return new AbstractMap.SimpleEntry<>("IRON_INGOT", (short) 0); } public String getName() { @@ -75,12 +73,19 @@ public abstract class CustomObjective implements Listener { this.display = display; } - public Map getItems() { - return items; + public Entry getItem() { + return item; } - + + /** + * @deprecated Use {@link #setItem(String, short)} + */ public void addItem(final String type, final short durability) { - this.items.put(type, durability); + setItem(type, durability); + } + + public void setItem(final String type, final short durability) { + this.item = new AbstractMap.SimpleEntry<>(type, durability); } public LinkedList> getData() { diff --git a/main/src/main/java/me/blackvein/quests/CustomRequirement.java b/main/src/main/java/me/blackvein/quests/CustomRequirement.java index b64793cb6..dc0014b1e 100644 --- a/main/src/main/java/me/blackvein/quests/CustomRequirement.java +++ b/main/src/main/java/me/blackvein/quests/CustomRequirement.java @@ -15,6 +15,7 @@ package me.blackvein.quests; import org.bukkit.entity.Player; import java.io.File; +import java.util.AbstractMap; import java.util.HashMap; import java.util.Map; @@ -23,7 +24,7 @@ public abstract class CustomRequirement { private String name = null; private String author = null; private String display = null; - private final Map items = new HashMap<>(); + private Map.Entry item = new AbstractMap.SimpleEntry<>("BOOK", (short) 0); private final Map data = new HashMap<>(); private final Map descriptions = new HashMap<>(); @@ -34,10 +35,8 @@ public abstract class CustomRequirement { .replace(".jar", ""); } - public Map getModuleItem() { - final Map moduleItems = new HashMap<>(); - moduleItems.put("IRON_INGOT", (short) 0); - return moduleItems; + public Map.Entry getModuleItem() { + return new AbstractMap.SimpleEntry<>("IRON_INGOT", (short) 0); } public String getName() { @@ -63,13 +62,20 @@ public abstract class CustomRequirement { public void setDisplay(final String display) { this.display = display; } - - public Map getItems() { - return items; + + public Map.Entry getItem() { + return item; } - + + /** + * @deprecated Use {@link #setItem(String, short)} + */ public void addItem(final String type, final short durability) { - this.items.put(type, durability); + setItem(type, durability); + } + + public void setItem(final String type, final short durability) { + this.item = new AbstractMap.SimpleEntry<>(type, durability); } public Map getData() { diff --git a/main/src/main/java/me/blackvein/quests/CustomReward.java b/main/src/main/java/me/blackvein/quests/CustomReward.java index b61f76872..e54be845f 100644 --- a/main/src/main/java/me/blackvein/quests/CustomReward.java +++ b/main/src/main/java/me/blackvein/quests/CustomReward.java @@ -15,6 +15,7 @@ package me.blackvein.quests; import org.bukkit.entity.Player; import java.io.File; +import java.util.AbstractMap; import java.util.HashMap; import java.util.Map; @@ -23,7 +24,7 @@ public abstract class CustomReward { private String name = null; private String author = null; private String display = null; - private final Map items = new HashMap<>(); + private Map.Entry item = new AbstractMap.SimpleEntry<>("BOOK", (short) 0); private final Map data = new HashMap<>(); private final Map descriptions = new HashMap<>(); @@ -34,10 +35,8 @@ public abstract class CustomReward { .replace(".jar", ""); } - public Map getModuleItem() { - final Map moduleItems = new HashMap<>(); - moduleItems.put("IRON_INGOT", (short) 0); - return moduleItems; + public Map.Entry getModuleItem() { + return new AbstractMap.SimpleEntry<>("IRON_INGOT", (short) 0); } public String getName() { @@ -63,13 +62,20 @@ public abstract class CustomReward { public void setDisplay(final String display) { this.display = display; } - - public Map getItems() { - return items; + + public Map.Entry getItem() { + return item; } - + + /** + * @deprecated Use {@link #setItem(String, short)} + */ public void addItem(final String type, final short durability) { - this.items.put(type, durability); + setItem(type, durability); + } + + public void setItem(final String type, final short durability) { + this.item = new AbstractMap.SimpleEntry<>(type, durability); } /**