Skip to content

Commit

Permalink
Set a new region(BoundingBox) for the elevator & you can change the a…
Browse files Browse the repository at this point in the history
…tDoor location for the elevator.
  • Loading branch information
andrew121410 committed Sep 11, 2024
1 parent b196fcb commit 7888dd0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
}

// Check the volume of the region to make sure it's not bigger than maxSizeOfElevator
int maxSizeOfElevator = this.plugin.getMaxSizeOfElevator();
if (region.getVolume() > maxSizeOfElevator) {
player.sendMessage(Translate.miniMessage("<red>The region you selected is too big. The max size is: <white>" + maxSizeOfElevator));
player.sendMessage(Translate.miniMessage("<red>The region you selected size is: <white>" + region.getVolume()));
if (isRegionToBig(region, player)) {
return true;
}

Expand Down Expand Up @@ -958,7 +955,7 @@ public void run() {
} else {
player.sendMessage(Translate.chat("&6/elevator realign &e<Controller> &9<Elevator>"));
}
} else if (args[0].equalsIgnoreCase("boundingbox")) { // elevator boundingbox <controller> <elevator> <show/shift> <y>
} else if (args[0].equalsIgnoreCase("boundingbox")) { // elevator boundingbox <controller> <elevator> <setting>
if (!player.hasPermission("world16elevators.boundingbox")) {
player.sendMessage(Translate.color("&bYou don't have permission to use this command."));
return true;
Expand Down Expand Up @@ -1033,6 +1030,34 @@ public void run() {
elevator.showLocationOfElevator(blockMap, copyAtDoor, copyBoundingBox, copyExpandedBoundingBox);
p1.sendMessage(Translate.miniMessage("<green>The original blocks have been restored."));
})));
} else if (setting.equalsIgnoreCase("fix-with-worldedit")) { // /elevator boundingbox <controller> <elevator> fix-with-worldedit
BoundingBox boundingBox = this.plugin.getOtherPlugins().getWorld16Utils().getClassWrappers().getWorldEdit().getRegion(player);

if (boundingBox == null) {
player.sendMessage(Translate.miniMessage("<red>You need to select a region with WorldEdit."));
return true;
}

// Check the volume of the region to make sure it's not bigger than maxSizeOfElevator
if (isRegionToBig(boundingBox, player)) return true;

// Current elevator movement stuff.
Location atDoor = elevator.getElevatorMovement().getAtDoor();
Integer floor = elevator.getElevatorMovement().getFloor();

ElevatorMovement elevatorMovement = new ElevatorMovement(floor, atDoor, boundingBox);
elevator.setElevatorMovement(elevatorMovement);
player.sendMessage(Translate.miniMessage("<green>The bounding box has been updated."));
} else if (setting.equalsIgnoreCase("atdoor")) {
Block block = PlayerUtils.getBlockPlayerIsLookingAt(player);

if (block == null) {
player.sendMessage(Translate.miniMessage("<red>You need to look at a block."));
return true;
}

elevator.getElevatorMovement().setAtDoor(block.getLocation());
player.sendMessage(Translate.miniMessage("<green>The door atDoor location in elevator movement has been updated."));
}
return true;
} else {
Expand All @@ -1057,6 +1082,17 @@ public void run() {
return true;
}

private boolean isRegionToBig(BoundingBox boundingBox, Player player) {
// Check the volume of the region to make sure it's not bigger than maxSizeOfElevator
int maxSizeOfElevator = this.plugin.getMaxSizeOfElevator();
if (boundingBox.getVolume() > maxSizeOfElevator) {
player.sendMessage(Translate.miniMessage("<red>The region you selected is too big. The max size is: <white>" + maxSizeOfElevator));
player.sendMessage(Translate.miniMessage("<red>The region you selected size is: <white>" + boundingBox.getVolume()));
return true;
}
return false;
}

private ElevatorArguments getElevatorArguments(String[] args, int start) {
ElevatorArguments elevatorArguments = new ElevatorArguments();
String[] newStringArray = Arrays.copyOfRange(args, start - 1, args.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public List<String> onTabComplete(CommandSender sender, Command cmd, String aile
} else if (args.length == 3) {
return this.elevatorControllerMap.containsKey(args[1]) ? new ArrayList<>(this.elevatorControllerMap.get(args[1]).getElevatorsMap().keySet()) : null;
} else if (args.length == 4) {
return getContainsString(args[3], Arrays.asList("show", "shift"));
return getContainsString(args[3], Arrays.asList("show", "shift", "fix-with-worldedit", "atdoor"));
}
return null;
}
Expand Down

0 comments on commit 7888dd0

Please sign in to comment.