Skip to content

Commit

Permalink
Don't force initialization for serialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Oct 21, 2019
1 parent 2a1c261 commit d0373f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@

<distributionManagement>
<repository>
<id>bintray-theneweconomy-java</id>
<name>theneweconomy-java</name>
<url>https://api.bintray.com/maven/theneweconomy/java/TheNewItemLibrary/;publish=1</url>
<id>github</id>
<name>GitHub TheNewEconomy Apache Maven Packages</name>
<url>https://maven.pkg.github.com/TheNewEconomy/TheNewItemLibrary</url>
</repository>
</distributionManagement>
</project>
6 changes: 3 additions & 3 deletions src/net/tnemc/item/ItemCalculations.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -100,7 +100,7 @@ public static void giveItems(JavaPlugin plugin, Collection<ItemStack> 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;
Expand Down
4 changes: 4 additions & 0 deletions src/net/tnemc/item/SerialItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit d0373f6

Please sign in to comment.