Skip to content

Commit

Permalink
1.4.29
Browse files Browse the repository at this point in the history
  • Loading branch information
anjoismysign committed Sep 28, 2022
1 parent c50429e commit 0ee954f
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/main/java/us/mytheria/bloblib/utilities/BukkitUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -64,7 +65,7 @@ public static Set<Block> deserializeBlockSet(List<String> serialized) {
public static List<String> serializeVectorSet(Set<Vector> vectors) {
List<String> 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;
}
Expand All @@ -73,7 +74,24 @@ public static Set<Vector> deserializeVectorSet(List<String> serialized) {
Set<Vector> 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<String> serializeBlockVectorSet(Set<BlockVector> vectors) {
List<String> serialized = new ArrayList<>();
for (BlockVector vector : vectors) {
serialized.add(vector.getX() + "%" + vector.getY() + "%" + vector.getZ());
}
return serialized;
}

public static Set<BlockVector> deserializeBlockVectorSet(List<String> serialized) {
Set<BlockVector> 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;
}
Expand Down

0 comments on commit 0ee954f

Please sign in to comment.