From 0ee954fecc75db2edab30ad5b1a33e088d0feebe Mon Sep 17 00:00:00 2001 From: lbenav8095 Date: Wed, 28 Sep 2022 11:48:27 -0600 Subject: [PATCH] 1.4.29 --- .../bloblib/utilities/BukkitUtil.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/us/mytheria/bloblib/utilities/BukkitUtil.java b/src/main/java/us/mytheria/bloblib/utilities/BukkitUtil.java index bb78d7d4..712927a4 100644 --- a/src/main/java/us/mytheria/bloblib/utilities/BukkitUtil.java +++ b/src/main/java/us/mytheria/bloblib/utilities/BukkitUtil.java @@ -3,6 +3,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.Block; +import org.bukkit.util.BlockVector; import org.bukkit.util.Vector; import java.util.ArrayList; @@ -64,7 +65,7 @@ public static Set deserializeBlockSet(List serialized) { public static List serializeVectorSet(Set vectors) { List serialized = new ArrayList<>(); for (Vector vector : vectors) { - serialized.add(vector.getBlockX() + "%" + vector.getBlockY() + "%" + vector.getBlockZ()); + serialized.add(vector.getX() + "%" + vector.getY() + "%" + vector.getZ()); } return serialized; } @@ -73,7 +74,24 @@ public static Set deserializeVectorSet(List serialized) { Set vectors = new HashSet<>(); for (String string : serialized) { String[] split = string.split("%"); - vectors.add(new Vector(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]))); + vectors.add(new Vector(Double.parseDouble(split[0]), Double.parseDouble(split[1]), Double.parseDouble(split[2]))); + } + return vectors; + } + + public static List serializeBlockVectorSet(Set vectors) { + List serialized = new ArrayList<>(); + for (BlockVector vector : vectors) { + serialized.add(vector.getX() + "%" + vector.getY() + "%" + vector.getZ()); + } + return serialized; + } + + public static Set deserializeBlockVectorSet(List serialized) { + Set vectors = new HashSet<>(); + for (String string : serialized) { + String[] split = string.split("%"); + vectors.add(new BlockVector(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]))); } return vectors; }