summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2021-12-25 22:46:22 -0600
committerTyler Murphy <tylermurphy534@gmail.com>2021-12-25 22:46:22 -0600
commit6e09da9150bb8b178a168f463136759d95a2f8d4 (patch)
tree9cdb12f385607eac33da25d2edb3d79bf28ef158 /src/main/java/net/tylermurphy/hideAndSeek/util/Util.java
parentfix @NotNull (diff)
downloadkenshinshideandseek-6e09da9150bb8b178a168f463136759d95a2f8d4.tar.gz
kenshinshideandseek-6e09da9150bb8b178a168f463136759d95a2f8d4.tar.bz2
kenshinshideandseek-6e09da9150bb8b178a168f463136759d95a2f8d4.zip
1.3.3 beta 2
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/util/Util.java')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/util/Util.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java
index 513ac16..8112f74 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java
@@ -3,10 +3,13 @@ package net.tylermurphy.hideAndSeek.util;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import java.io.*;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.UUID;
+import com.google.common.io.ByteStreams;
import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.configuration.Items;
import net.tylermurphy.hideAndSeek.configuration.LocalizationString;
@@ -92,4 +95,22 @@ public class Util {
for(ItemStack i : player.getInventory().getContents())
if(hi.isSimilar(i)) player.getInventory().remove(i);
}
+
+ public static InputStream convertUniqueId(UUID uuid) {
+ byte[] bytes = new byte[16];
+ ByteBuffer.wrap(bytes)
+ .putLong(uuid.getMostSignificantBits())
+ .putLong(uuid.getLeastSignificantBits());
+ return new ByteArrayInputStream(bytes);
+ }
+
+ public static UUID convertBinaryStream(InputStream stream) {
+ ByteBuffer buffer = ByteBuffer.allocate(16);
+ try {
+ buffer.put(ByteStreams.toByteArray(stream));
+ buffer.flip();
+ return new UUID(buffer.getLong(), buffer.getLong());
+ } catch (IOException e) {}
+ return null;
+ }
} \ No newline at end of file