mirror of
https://github.com/YouHaveTrouble/BlockEdit.git
synced 2026-06-29 21:46:19 +00:00
fixing selections and basic //set
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user