From d0373f623b0b9de0b3269af1cec7de22b6278481 Mon Sep 17 00:00:00 2001 From: creatorfromhell Date: Mon, 21 Oct 2019 18:15:57 -0400 Subject: [PATCH] Don't force initialization for serialization. --- pom.xml | 6 +++--- src/net/tnemc/item/ItemCalculations.java | 6 +++--- src/net/tnemc/item/SerialItem.java | 4 ++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index fe0448b..5ce5bd7 100644 --- a/pom.xml +++ b/pom.xml @@ -81,9 +81,9 @@ - bintray-theneweconomy-java - theneweconomy-java - https://api.bintray.com/maven/theneweconomy/java/TheNewItemLibrary/;publish=1 + github + GitHub TheNewEconomy Apache Maven Packages + https://maven.pkg.github.com/TheNewEconomy/TheNewItemLibrary \ No newline at end of file diff --git a/src/net/tnemc/item/ItemCalculations.java b/src/net/tnemc/item/ItemCalculations.java index d244325..4763187 100644 --- a/src/net/tnemc/item/ItemCalculations.java +++ b/src/net/tnemc/item/ItemCalculations.java @@ -3,18 +3,18 @@ import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.ShulkerBox; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.HumanEntity; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.BlockStateMeta; -import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; +import java.util.Arrays; import java.util.Collection; import java.util.Map; +import java.util.Objects; /** * The New Economy Minecraft Server Plugin @@ -100,7 +100,7 @@ public static void giveItems(JavaPlugin plugin, Collection items, Inv * @return The remaining amount of items to remove. */ public static int removeItem(ItemStack stack, Inventory inventory) { - int left = stack.getAmount(); + int left = stack.clone().getAmount(); for(int i = 0; i < inventory.getStorageContents().length; i++) { if(left <= 0) break; diff --git a/src/net/tnemc/item/SerialItem.java b/src/net/tnemc/item/SerialItem.java index bb62100..e006c2b 100644 --- a/src/net/tnemc/item/SerialItem.java +++ b/src/net/tnemc/item/SerialItem.java @@ -275,6 +275,10 @@ public String serialize() { return toJSON().toJSONString(); } + public static String serialize(ItemStack stack) { + return new SerialItem(stack).serialize(); + } + public static SerialItem unserialize(String serialized) throws ParseException { return fromJSON((JSONObject)new JSONParser().parse(serialized)); }