diff options
| author | fatpigsarefat <fatpigsarefat@outlook.com> | 2018-07-25 19:22:53 +0100 |
|---|---|---|
| committer | fatpigsarefat <fatpigsarefat@outlook.com> | 2018-07-25 19:40:41 +0100 |
| commit | 7a21e621ddebdccc80234ea4828a36509aa3f6c1 (patch) | |
| tree | 6999d87036e53f319f6121bad4c51dd6d444fdf6 /src/main/java/me/fatpigsarefat/quests/obj/misc | |
| parent | e662a173daa763ebf6b511d535e5e3822f681711 (diff) | |
Added quest cancel gui
- config.yml was updated with new items
- QMenuCancel.java and EventInventory.java added for the gui
- pom.xml version changed to 2.0.11
Diffstat (limited to 'src/main/java/me/fatpigsarefat/quests/obj/misc')
| -rw-r--r-- | src/main/java/me/fatpigsarefat/quests/obj/misc/QMenuCancel.java | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/main/java/me/fatpigsarefat/quests/obj/misc/QMenuCancel.java b/src/main/java/me/fatpigsarefat/quests/obj/misc/QMenuCancel.java new file mode 100644 index 00000000..6021fd9d --- /dev/null +++ b/src/main/java/me/fatpigsarefat/quests/obj/misc/QMenuCancel.java @@ -0,0 +1,100 @@ +package me.fatpigsarefat.quests.obj.misc; + +import me.fatpigsarefat.quests.obj.Items; +import me.fatpigsarefat.quests.obj.Options; +import me.fatpigsarefat.quests.player.QPlayer; +import me.fatpigsarefat.quests.player.questprogressfile.QuestProgress; +import me.fatpigsarefat.quests.quests.Quest; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class QMenuCancel implements QMenu { + + private HashMap<Integer, String> slotsToQuestIds = new HashMap<>(); + private QMenuQuest superMenu; + private QPlayer owner; + private Quest quest; + + public QMenuCancel(QPlayer owner, QMenuQuest superMenu, Quest quest) { + this.owner = owner; + this.superMenu = superMenu; + this.quest = quest; + } + + public void populate(List<Quest> quests) { + /* ignored */ + } + + @Override + public HashMap<Integer, String> getSlotsToMenu() { + return slotsToQuestIds; + } + + public Quest getQuest() { + return quest; + } + + @Override + public QPlayer getOwner() { + return owner; + } + + public Inventory toInventory() { + String title = Options.GUITITLE_QUEST_CANCEL.getStringValue(); + + ItemStack yes = Items.QUEST_CANCEL_YES.getItem(); + ItemStack no = Items.QUEST_CANCEL_NO.getItem(); + + ItemStack is = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7); + ItemMeta ism = is.getItemMeta(); + ism.setDisplayName(" "); + is.setItemMeta(ism); + + Inventory inventory = Bukkit.createInventory(null, 27, title); + + for (int i = 0; i < inventory.getSize(); i++) { + inventory.setItem(i, is); + } + + inventory.setItem(10, no); + inventory.setItem(11, no); + inventory.setItem(12, no); + inventory.setItem(13, quest.getDisplayItem().toItemStack(owner.getQuestProgressFile().getQuestProgress(quest))); + inventory.setItem(14, yes); + inventory.setItem(15, yes); + inventory.setItem(16, yes); + + return inventory; + } + + public QMenuQuest getSuperMenu() { + return superMenu; + } + + public ItemStack replaceItemStack(ItemStack is, Map<String, String> placeholders) { + ItemStack newItemStack = is.clone(); + List<String> lore = newItemStack.getItemMeta().getLore(); + List<String> newLore = new ArrayList<>(); + ItemMeta ism = newItemStack.getItemMeta(); + if (lore != null) { + for (String s : lore) { + for (Map.Entry<String, String> entry : placeholders.entrySet()) { + s = s.replace(entry.getKey(), entry.getValue()); + ism.setDisplayName(ism.getDisplayName().replace(entry.getKey(), entry.getValue())); + } + newLore.add(s); + } + } + ism.setLore(newLore); + newItemStack.setItemMeta(ism); + return newItemStack; + } +} |
