Added input command
This commit is contained in:
parent
46bd6676e3
commit
9ef7830c69
1 changed files with 72 additions and 2 deletions
|
@ -18,8 +18,10 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.xml.crypto.Data;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class V10LiftCommand implements CommandExecutor {
|
public class V10LiftCommand implements CommandExecutor {
|
||||||
|
@ -72,10 +74,80 @@ public class V10LiftCommand implements CommandExecutor {
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!");
|
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!");
|
||||||
}
|
}
|
||||||
|
} else if (args[0].equalsIgnoreCase("input") && (args.length == 2 || args.length == 3)) {
|
||||||
|
//v10lift input add <Floor name> || v10lift input del
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You have to be a player to do this.");
|
||||||
|
}
|
||||||
|
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
|
||||||
|
return inputCommand(sender, args);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean inputCommand(CommandSender sender, String[] args) {
|
||||||
|
Player p = (Player) sender;
|
||||||
|
if (!DataManager.containsEditPlayer(p.getUniqueId())) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "First switch on the editor mode!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String liftName = DataManager.getEditPlayer(p.getUniqueId());
|
||||||
|
if (!DataManager.containsLift(liftName)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "That lift doesn't exists.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Lift lift = DataManager.getLift(liftName);
|
||||||
|
if (args[1].equalsIgnoreCase("add")) {
|
||||||
|
String floor = null;
|
||||||
|
if (args.length < 3) {
|
||||||
|
Block b = p.getLocation().getBlock();
|
||||||
|
Floor f = new Floor(b.getY() - 1, b.getWorld().getName());
|
||||||
|
if (!lift.getFloors().containsValue(f)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Automatic floor detection failed!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<String, Floor> e : lift.getFloors().entrySet()) {
|
||||||
|
Floor fl = e.getValue();
|
||||||
|
if (fl.equals(f)) {
|
||||||
|
floor = e.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
floor = args[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DataManager.containsInputEditsPlayer(p.getUniqueId()) || DataManager.containsInputRemovesPlayer(p.getUniqueId())) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You are still adjusting an input!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataManager.addInputEditsPlayer(p.getUniqueId(), Objects.requireNonNull(floor, "Floor is null at input add command"));
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Now right click on the input block!");
|
||||||
|
} else if (args[1].equalsIgnoreCase("del")) {
|
||||||
|
if (lift.getInputs().isEmpty()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "There is no input to remove!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DataManager.containsInputEditsPlayer(p.getUniqueId()) || DataManager.containsInputRemovesPlayer(p.getUniqueId())) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You are still adjusting an input!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataManager.addInputRemovesPlayer(p.getUniqueId());
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Now right click on the input block!");
|
||||||
|
} else {
|
||||||
|
return helpCommand(sender);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean floorCommand(CommandSender sender, String[] args) {
|
private boolean floorCommand(CommandSender sender, String[] args) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (!DataManager.containsEditPlayer(p.getUniqueId())) {
|
if (!DataManager.containsEditPlayer(p.getUniqueId())) {
|
||||||
|
@ -88,8 +160,6 @@ public class V10LiftCommand implements CommandExecutor {
|
||||||
sender.sendMessage(ChatColor.RED + "That lift doesn't exists.");
|
sender.sendMessage(ChatColor.RED + "That lift doesn't exists.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Lift lift = DataManager.getLift(liftName);
|
|
||||||
if (args[1].equalsIgnoreCase("add")) {
|
if (args[1].equalsIgnoreCase("add")) {
|
||||||
Block b = p.getLocation().getBlock();
|
Block b = p.getLocation().getBlock();
|
||||||
String floorName = args[2];
|
String floorName = args[2];
|
||||||
|
|
Loading…
Reference in a new issue