diff --git a/src/main/java/com/andrew121410/mc/world16elevators/commands/ElevatorCMD.java b/src/main/java/com/andrew121410/mc/world16elevators/commands/ElevatorCMD.java index 696cc11..ced71ee 100644 --- a/src/main/java/com/andrew121410/mc/world16elevators/commands/ElevatorCMD.java +++ b/src/main/java/com/andrew121410/mc/world16elevators/commands/ElevatorCMD.java @@ -607,7 +607,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String elevator.getElevatorSettings().setSignFinderSystem(bool); p.sendMessage(Translate.chat("The signFinderSystem has been set to: " + bool)); return true; - }else if (setting.equalsIgnoreCase("teleportElevatorOnEmpty")) { + } else if (setting.equalsIgnoreCase("teleportElevatorOnEmpty")) { boolean bool = Utils.asBooleanOrElse(eleArgs.getOtherArgumentsAt(1), false); elevator.getElevatorSettings().setTeleportElevatorOnEmpty(bool); p.sendMessage(Translate.chat("The teleportElevatorOnEmpty has been set to: " + bool)); @@ -745,6 +745,31 @@ public void run() { } else { p.sendMessage(Translate.chat("&6/elevator copysettingsfrom &e &9 &e &9")); } + } else if (args[0].equalsIgnoreCase("teleport")) { // /elevator teleport + if (!p.hasPermission("world16elevators.teleport")) { + p.sendMessage(Translate.color("&bYou don't have permission to use this command.")); + return true; + } + if (args.length == 3) { + ElevatorArguments elevatorArguments = getElevatorArguments(args, 2); + ElevatorController elevatorController = elevatorArguments.getElevatorController(); + if (elevatorController == null) { + p.sendMessage("Elevator controller was not found."); + return true; + } + Elevator elevator = elevatorArguments.getElevator(); + if (elevator == null) { + p.sendMessage("Elevator was not found."); + return true; + } + + Location location = elevator.getElevatorMovement().getAtDoor(); + p.teleport(location); + p.sendMessage(Translate.miniMessage("You have been teleported to the elevator.")); + return true; + } else { + p.sendMessage(Translate.chat("&6/elevator teleport &e &9")); + } } return true; } diff --git a/src/main/java/com/andrew121410/mc/world16elevators/commands/tabcomplete/ElevatorTab.java b/src/main/java/com/andrew121410/mc/world16elevators/commands/tabcomplete/ElevatorTab.java index 3a1f152..fd1089f 100644 --- a/src/main/java/com/andrew121410/mc/world16elevators/commands/tabcomplete/ElevatorTab.java +++ b/src/main/java/com/andrew121410/mc/world16elevators/commands/tabcomplete/ElevatorTab.java @@ -1,7 +1,7 @@ package com.andrew121410.mc.world16elevators.commands.tabcomplete; -import com.andrew121410.mc.world16elevators.ElevatorController; import com.andrew121410.mc.world16elevators.Elevator; +import com.andrew121410.mc.world16elevators.ElevatorController; import com.andrew121410.mc.world16elevators.ElevatorFloor; import com.andrew121410.mc.world16elevators.World16Elevators; import com.andrew121410.mc.world16elevators.enums.ElevatorCallButtonType; @@ -43,6 +43,7 @@ public ElevatorTab(World16Elevators plugin) { tabCompleteList.add("opendoor"); tabCompleteList.add("copysettingsfrom"); tabCompleteList.add("tostring"); + tabCompleteList.add("teleport"); this.elevatorControllerMap = this.plugin.getMemoryHolder().getElevatorControllerMap(); this.soundList = new ArrayList<>(); for (Sound value : Sound.values()) { @@ -181,6 +182,13 @@ public List onTabComplete(CommandSender sender, Command cmd, String aile return this.elevatorControllerMap.containsKey(args[1]) ? new ArrayList<>(this.elevatorControllerMap.get(args[1]).getElevatorsMap().keySet()) : null; } return null; + } else if (args[0].equalsIgnoreCase("teleport")) { + if (args.length == 2) { + return getContainsString(args[1], controllerList); + } else if (args.length == 3) { + return this.elevatorControllerMap.containsKey(args[1]) ? new ArrayList<>(this.elevatorControllerMap.get(args[1]).getElevatorsMap().keySet()) : null; + } + return null; } return null; }