fixing selections and basic //set

This commit is contained in:
YouHaveTrouble
2021-07-22 23:05:58 +02:00
parent 9dbcc6d7d0
commit 6ee58e3199
10 changed files with 219 additions and 34 deletions
@@ -1,6 +1,7 @@
package me.youhavetrouble.blockedit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.BoundingBox;
@@ -12,14 +13,30 @@ public class BEPlayer {
private static final HashMap<UUID, BEPlayer> playerHashMap = new HashMap<>();
private BoundingBox selection;
private Location selectionPoint1, selectionPoint2;
private World selectionWorld;
public BoundingBox getSelection() {
return selection;
}
private void updateSelection() {
if (selectionPoint1 == null || selectionPoint2 == null) return;
if (selectionPoint1 == null || selectionPoint2 == null) {
selection = null;
return;
}
if (selectionPoint1.getWorld() == null || selectionPoint2 == null) {
selection = null;
return;
}
if (!selectionPoint1.getWorld().equals(selectionPoint2.getWorld())) {
selection = null;
return;
}
selectionWorld = selectionPoint1.getWorld();
selection = BoundingBox.of(selectionPoint1, selectionPoint2);
// bounding boxes are dumb.
selection.expand(0.5, 0.5, 0.5);
selection.shift(0.5,0.5,0.5);
}
public void setSelectionPoint1(Location selectionPoint1) {
@@ -34,6 +51,13 @@ public class BEPlayer {
updateSelection();
}
/**
* @return World withinn which the selection is made.
*/
public World getSelectionWorld() {
return selectionWorld;
}
/**
* @return Clone of selectionPoint1
*/