Skip to content

Commit

Permalink
Fixed serialization for enchantments
Browse files Browse the repository at this point in the history
  • Loading branch information
BrainStone committed Apr 22, 2017
1 parent 6ec1635 commit db7af74
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/java/world/jnc/invsync/util/InventorySerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import lombok.Cleanup;
import lombok.experimental.UtilityClass;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.gson.GsonConfigurationLoader;
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
import world.jnc.invsync.InventorySync;

@UtilityClass
Expand Down Expand Up @@ -95,8 +95,8 @@ public static void deserializeInventory(byte[] data, Inventory inventory)
private static Optional<String> serializeItemStack(ItemStack item) {
try {
StringWriter sink = new StringWriter();
GsonConfigurationLoader loader = GsonConfigurationLoader.builder().setSink(() -> new BufferedWriter(sink))
.setIndent(0).build();
HoconConfigurationLoader loader = HoconConfigurationLoader.builder().setSink(() -> new BufferedWriter(sink))
.build();
ConfigurationNode node = CONFIGURATION_NODE.translate(item.toContainer());
loader.save(node);
return Optional.of(sink.toString());
Expand All @@ -109,10 +109,9 @@ private static Optional<String> serializeItemStack(ItemStack item) {
private static Optional<ItemStack> deserializeItemStack(String json) {
try {
StringReader source = new StringReader(json);
GsonConfigurationLoader loader = GsonConfigurationLoader.builder()
HoconConfigurationLoader loader = HoconConfigurationLoader.builder()
.setSource(() -> new BufferedReader(source)).build();
ConfigurationNode node = loader.load();
// TODO Fix Enchantments and stuff!
return Optional.of(ItemStack.builder().fromContainer(CONFIGURATION_NODE.translate(node)).build());
} catch (Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit db7af74

Please sign in to comment.