Skip to content

Commit

Permalink
Reverted debugging
Browse files Browse the repository at this point in the history
(Did not intend to include this in the original commit)
  • Loading branch information
BrainStone committed May 7, 2017
1 parent 1e164d9 commit 65c06db
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions src/main/java/world/jnc/invsync/util/InventorySerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.zip.Deflater;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
Expand Down Expand Up @@ -80,10 +79,7 @@ public static byte[] serializePlayer(Player player) throws IOException {
container.set(SATURATION, player.get(KEY_SATURATION).get());
}
if (Config.Values.Synchronize.getEnablePotionEffects()) {
List<DataView> potions = player.get(KEY_POTION_EFFECTS).orElse(Collections.emptyList()).stream()
.map(potion -> potion.toContainer()).collect(Collectors.toList());

container.set(POTION_EFFECTS, potions);
container.set(POTION_EFFECTS, player.get(KEY_POTION_EFFECTS).orElse(Collections.emptyList()));
}

if (Config.Values.Global.getDebug()) {
Expand Down Expand Up @@ -125,7 +121,7 @@ public static void deserializePlayer(Player player, byte[] data) throws IOExcept
Optional<Double> health = container.getDouble(HEALTH);
Optional<Integer> foodLevel = container.getInt(FOOD_LEVEL);
Optional<Double> saturation = container.getDouble(SATURATION);
Optional<List<DataView>> potionEffects = container.getViewList(POTION_EFFECTS);
Optional<List<PotionEffect>> potionEffects = container.getSerializableList(POTION_EFFECTS, PotionEffect.class);

if (inventory.isPresent() && Config.Values.Synchronize.getEnableInventory()) {
deserializeInventory(inventory.get(), player.getInventory());
Expand All @@ -147,25 +143,12 @@ public static void deserializePlayer(Player player, byte[] data) throws IOExcept
player.offer(KEY_SATURATION, saturation.get());
}
if (potionEffects.isPresent() && Config.Values.Synchronize.getEnablePotionEffects()) {
List<PotionEffect> effects = potionEffects.get().stream()
.map(potion -> PotionEffect.builder().build(potion)).filter(potion -> potion.isPresent())
.map(potion -> potion.get()).collect(Collectors.toList());

player.offer(KEY_POTION_EFFECTS, effects);
player.offer(KEY_POTION_EFFECTS, potionEffects.get());
}

if (Config.Values.Global.getDebug()) {
try {
InventorySync.getLogger().info("" + potionEffects.isPresent());
InventorySync.getLogger().info("" + container.get(POTION_EFFECTS).get().getClass());
InventorySync.getLogger().info("" + (container.get(POTION_EFFECTS).get() instanceof List<?>));
InventorySync.getLogger().info("" + container.getList(POTION_EFFECTS).get().getClass());
InventorySync.getLogger().info("" + container.getList(POTION_EFFECTS).get().get(0).getClass());
InventorySync.getLogger()
.info("" + container.getObjectList(POTION_EFFECTS, PotionEffect.class).get().getClass());
} catch (Exception e) {
e.printStackTrace();
}
InventorySync.getLogger().info("" + potionEffects.isPresent());
InventorySync.getLogger().info("" + container.get(POTION_EFFECTS).get().getClass());

@Cleanup
ByteArrayOutputStream debug = new ByteArrayOutputStream();
Expand Down

0 comments on commit 65c06db

Please sign in to comment.