From 7862cdb2996dfe6ca8ce27c055747f6c312f2502 Mon Sep 17 00:00:00 2001 From: Liam Ryde Date: Wed, 14 Jul 2021 16:51:51 -0400 Subject: [PATCH] Quality of life change, add lore/name --- .../itemslotmachine/util/ItemUtils.java | 27 +++++++++++++++++++ src/main/resources/template.yml | 4 +-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/darkblade12/itemslotmachine/util/ItemUtils.java b/src/main/java/com/darkblade12/itemslotmachine/util/ItemUtils.java index fc3502a..00694f9 100644 --- a/src/main/java/com/darkblade12/itemslotmachine/util/ItemUtils.java +++ b/src/main/java/com/darkblade12/itemslotmachine/util/ItemUtils.java @@ -9,6 +9,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; import java.util.Arrays; @@ -54,6 +55,32 @@ public static ItemStack fromString(String text, Map customIte } } + if (data.length >= 3) { + try { + String t_name = data[2]; + ItemMeta data_ = item.getItemMeta(); + data_.setDisplayName(t_name); + item.setItemMeta(data_); + } catch (NumberFormatException e) { + throw new IllegalArgumentException("Invalid name value."); + } + } + + if (data.length >= 4) { + try { + String lore = data[3]; + ItemMeta data_ = item.getItemMeta(); + List lores = new ArrayList(); + for(String s : lore.split("\n")) { + lores.add(s); + } + data_.setLore(lores); + item.setItemMeta(data_); + } catch (NumberFormatException e) { + throw new IllegalArgumentException("Invalid lore value."); + } + } + return item; } diff --git a/src/main/resources/template.yml b/src/main/resources/template.yml index d5c22c5..38ab109 100644 --- a/src/main/resources/template.yml +++ b/src/main/resources/template.yml @@ -78,12 +78,12 @@ item-pot: enabled: true # The default content of the item pot, which will be set after a player has won the pot - # Item format: [-] + # Item format: [-][-][-] # The item name 'coin' can be used for a coin item default: ['feather-5', 'diamond-1', 'iron_ingot-1'] # The items which are added to the pot by every spin - # Item format: [-] + # Item format: [-][-][-] # The item name 'coin' can be used for a coin item raise: ['glowstone_dust-2', 'lapis_lazuli-2']