From 686a6c499f33af6cff58014377b2beb2829fae31 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 11 Jan 2017 07:53:53 +1100 Subject: [PATCH] Fixes #1502 --- .../com/plotsquared/bukkit/util/NbtFactory.java | 15 ++++++--------- .../plotsquared/bukkit/uuid/FileUUIDHandler.java | 8 ++++---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java index 8bad6ef4d..5124f9194 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java @@ -6,14 +6,9 @@ import com.google.common.collect.HashBiMap; import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; import com.google.common.io.ByteSink; -import com.google.common.io.ByteSource; import com.google.common.io.Closeables; +import com.google.common.io.InputSupplier; import com.google.common.primitives.Primitives; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Server; -import org.bukkit.inventory.ItemStack; - import java.io.BufferedInputStream; import java.io.DataInput; import java.io.DataInputStream; @@ -39,6 +34,10 @@ import java.util.Set; import java.util.concurrent.ConcurrentMap; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Server; +import org.bukkit.inventory.ItemStack; public class NbtFactory { @@ -164,13 +163,11 @@ public class NbtFactory { * @return The decoded NBT compound. * @throws IOException If anything went wrong. */ - public static NbtCompound fromStream(ByteSource stream, StreamOptions option) throws IOException { - InputStream input = null; + public static NbtCompound fromStream(InputStream input, StreamOptions option) throws IOException { DataInputStream data = null; boolean suppress = true; try { - input = stream.openStream(); if (option == StreamOptions.GZIP_COMPRESSION) { data = new DataInputStream(new BufferedInputStream(new GZIPInputStream(input))); } else { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java index fcf007ea7..1b1eb87bb 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java @@ -3,6 +3,7 @@ package com.plotsquared.bukkit.uuid; import com.google.common.collect.HashBiMap; import com.google.common.collect.Sets; import com.google.common.io.ByteSource; +import com.google.common.io.InputSupplier; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -17,6 +18,7 @@ import com.intellectualcrafters.plot.util.expiry.ExpireManager; import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.plotsquared.bukkit.util.NbtFactory; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -94,8 +96,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { UUID uuid = UUID.fromString(s); if (check || all.remove(uuid)) { File file = new File(playerDataFolder, current); - ByteSource is = com.google.common.io.Files.asByteSource(file); - NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION); + NbtFactory.NbtCompound compound = NbtFactory.fromStream(new FileInputStream(file), NbtFactory.StreamOptions.GZIP_COMPRESSION); if (!compound.containsKey("bukkit")) { PS.debug("ERROR: Player data (" + uuid.toString() + ".dat) does not contain the the key \"bukkit\""); } else { @@ -160,8 +161,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { if (!file.exists()) { continue; } - ByteSource is = com.google.common.io.Files.asByteSource(file); - NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION); + NbtFactory.NbtCompound compound = NbtFactory.fromStream(new FileInputStream(file), NbtFactory.StreamOptions.GZIP_COMPRESSION); if (!compound.containsKey("bukkit")) { PS.debug("ERROR: Player data (" + uuid.toString() + ".dat) does not contain the the key \"bukkit\""); } else {