Implemented messages.yml file in code

This commit is contained in:
stijnb1234 2020-02-27 14:13:49 +01:00
parent 58dd349140
commit a6302f8418
7 changed files with 217 additions and 201 deletions

View file

@ -2,6 +2,7 @@ package nl.SBDeveloper.V10Lift.API.Runnables;
import nl.SBDeveloper.V10Lift.API.Objects.*; import nl.SBDeveloper.V10Lift.API.Objects.*;
import nl.SBDeveloper.V10Lift.Managers.DataManager; import nl.SBDeveloper.V10Lift.Managers.DataManager;
import nl.SBDeveloper.V10Lift.Utils.ConfigUtil;
import nl.SBDeveloper.V10Lift.Utils.DirectionUtil; import nl.SBDeveloper.V10Lift.Utils.DirectionUtil;
import nl.SBDeveloper.V10Lift.Utils.XMaterial; import nl.SBDeveloper.V10Lift.Utils.XMaterial;
import nl.SBDeveloper.V10Lift.Utils.XSound; import nl.SBDeveloper.V10Lift.Utils.XSound;
@ -283,7 +284,7 @@ public class MoveLift implements Runnable {
} }
sign = (Sign) bs; sign = (Sign) bs;
if (ls.getType() == 0) { if (ls.getType() == 0) {
sign.setLine(3, ChatColor.GREEN + "up"); sign.setLine(3, ConfigUtil.getConfigText("UpText"));
} else { } else {
sign.setLine(3, ChatColor.GRAY + ChatColor.stripColor(sign.getLine(3))); sign.setLine(3, ChatColor.GRAY + ChatColor.stripColor(sign.getLine(3)));
} }
@ -397,7 +398,7 @@ public class MoveLift implements Runnable {
} }
sign = (Sign) bs; sign = (Sign) bs;
if (ls.getType() == 0) { if (ls.getType() == 0) {
sign.setLine(3, ChatColor.GREEN + "down"); sign.setLine(3, ConfigUtil.getConfigText("DownText"));
} else { } else {
sign.setLine(3, ChatColor.GRAY + ChatColor.stripColor(sign.getLine(3))); sign.setLine(3, ChatColor.GRAY + ChatColor.stripColor(sign.getLine(3)));
} }

View file

@ -37,209 +37,209 @@ public class V10LiftCommand implements CommandExecutor {
} else if (args[0].equalsIgnoreCase("create") && (args.length == 1 || args.length == 2)) { } else if (args[0].equalsIgnoreCase("create") && (args.length == 1 || args.length == 2)) {
//v10lift create || v10lift create <Name> //v10lift create || v10lift create <Name>
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return createCommand(sender, args); return createCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("delete") && args.length == 2) { } else if (args[0].equalsIgnoreCase("delete") && args.length == 2) {
//v10lift delete <Name> //v10lift delete <Name>
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return deleteCommand(sender, args); return deleteCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("edit") && (args.length == 1 || args.length == 2)) { } else if (args[0].equalsIgnoreCase("edit") && (args.length == 1 || args.length == 2)) {
//v10lift edit <Name> //v10lift edit <Name>
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return editCommand(sender, args); return editCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("floor") && (args.length == 3 || args.length == 4)) { } else if (args[0].equalsIgnoreCase("floor") && (args.length == 3 || args.length == 4)) {
//v10lift floor add <Name> || v10lift floor del <Name> || v10lift floor rename <Old> <New> //v10lift floor add <Name> || v10lift floor del <Name> || v10lift floor rename <Old> <New>
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return floorCommand(sender, args); return floorCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("input") && (args.length == 2 || args.length == 3)) { } else if (args[0].equalsIgnoreCase("input") && (args.length == 2 || args.length == 3)) {
//v10lift input add <Floor name> || v10lift input del //v10lift input add <Floor name> || v10lift input del
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return inputCommand(sender, args); return inputCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("offline") && args.length == 2) { } else if (args[0].equalsIgnoreCase("offline") && args.length == 2) {
//v10lift offline add || v10lift offline del //v10lift offline add || v10lift offline del
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return offlineCommand(sender, args); return offlineCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("rename") && args.length == 2) { } else if (args[0].equalsIgnoreCase("rename") && args.length == 2) {
//v10lift rename <New name> //v10lift rename <New name>
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return renameCommand(sender, args); return renameCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("build") && args.length == 1) { } else if (args[0].equalsIgnoreCase("build") && args.length == 1) {
//v10lift build //v10lift build
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return buildCommand(sender); return buildCommand(sender);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("rope") && args.length == 2) { } else if (args[0].equalsIgnoreCase("rope") && args.length == 2) {
//v10lift rope add || v10lift rope del //v10lift rope add || v10lift rope del
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return ropeCommand(sender, args); return ropeCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("door") && (args.length == 1 || args.length == 2)) { } else if (args[0].equalsIgnoreCase("door") && (args.length == 1 || args.length == 2)) {
//v10lift door <Name> || v10lift door //v10lift door <Name> || v10lift door
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return doorCommand(sender, args); return doorCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("whitelist") && (args.length == 3 || args.length == 4)) { } else if (args[0].equalsIgnoreCase("whitelist") && (args.length == 3 || args.length == 4)) {
//v10lift whitelist add <Player> <Floor> || v10lift whitelist del <Player> <Floor> //v10lift whitelist add <Player> <Floor> || v10lift whitelist del <Player> <Floor>
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return whitelistCommand(sender, args); return whitelistCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("whois") && (args.length == 1 || args.length == 2)) { } else if (args[0].equalsIgnoreCase("whois") && (args.length == 1 || args.length == 2)) {
//v10lift whois || v10lift whois <Name> //v10lift whois || v10lift whois <Name>
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return whoisCommand(sender, args); return whoisCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("speed") && args.length == 2) { } else if (args[0].equalsIgnoreCase("speed") && args.length == 2) {
//v10lift speed <Speed> //v10lift speed <Speed>
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return speedCommand(sender, args); return speedCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("sound") && args.length == 1) { } else if (args[0].equalsIgnoreCase("sound") && args.length == 1) {
//v10lift sound //v10lift sound
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return soundCommand(sender); return soundCommand(sender);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("realistic") && args.length == 1) { } else if (args[0].equalsIgnoreCase("realistic") && args.length == 1) {
//v10lift realistic //v10lift realistic
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return realisticCommand(sender); return realisticCommand(sender);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("abort") && args.length == 1) { } else if (args[0].equalsIgnoreCase("abort") && args.length == 1) {
//v10lift abort //v10lift abort
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You have to be a player to do this."); ConfigUtil.sendMessage(sender, "General.PlayerOnly");
return true; return true;
} }
if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
return abortCommand(sender); return abortCommand(sender);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("reload") && args.length == 1) { } else if (args[0].equalsIgnoreCase("reload") && args.length == 1) {
//v10lift reload //v10lift reload
if (sender.hasPermission("v10lift.reload") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.reload") || sender.hasPermission("v10lift.admin")) {
return reloadCommand(sender); return reloadCommand(sender);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("repair") && args.length == 2) { } else if (args[0].equalsIgnoreCase("repair") && args.length == 2) {
//v10lift repair <Name> //v10lift repair <Name>
if (sender.hasPermission("v10lift.repair") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.repair") || sender.hasPermission("v10lift.admin")) {
return repairCommand(sender, args); return repairCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("disable") && args.length == 2) { } else if (args[0].equalsIgnoreCase("disable") && args.length == 2) {
//v10lift disable <Name> //v10lift disable <Name>
if (sender.hasPermission("v10lift.disable") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.disable") || sender.hasPermission("v10lift.admin")) {
return disableCommand(sender, args); return disableCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("start")) { } else if (args[0].equalsIgnoreCase("start")) {
//v10lift start <Name> <Floor> //v10lift start <Name> <Floor>
if (sender.hasPermission("v10lift.start") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.start") || sender.hasPermission("v10lift.admin")) {
return startCommand(sender, args); return startCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else if (args[0].equalsIgnoreCase("stop")) { } else if (args[0].equalsIgnoreCase("stop")) {
//v10lift stop <Name> //v10lift stop <Name>
if (sender.hasPermission("v10lift.stop") || sender.hasPermission("v10lift.admin")) { if (sender.hasPermission("v10lift.stop") || sender.hasPermission("v10lift.admin")) {
return stopCommand(sender, args); return stopCommand(sender, args);
} else { } else {
sender.sendMessage(ChatColor.RED + "You don't have the permission to do this!"); ConfigUtil.sendMessage(sender, "General.NoPermission");
} }
} else { } else {
return helpCommand(sender); return helpCommand(sender);
@ -250,19 +250,19 @@ public class V10LiftCommand implements CommandExecutor {
private boolean disableCommand(CommandSender sender, @Nonnull String[] args) { private boolean disableCommand(CommandSender sender, @Nonnull String[] args) {
String liftName = args[1]; String liftName = args[1];
if (!DataManager.containsLift(liftName)) { if (!DataManager.containsLift(liftName)) {
sender.sendMessage(ChatColor.RED + "Lift " + args[1] + " doesn't exists!"); ConfigUtil.sendMessage(sender, "General.DoesntExists");
return true; return true;
} }
Lift lift = DataManager.getLift(liftName); Lift lift = DataManager.getLift(liftName);
if (lift.isDefective()) { if (lift.isDefective()) {
sender.sendMessage(ChatColor.RED + "This lift is already defective!"); ConfigUtil.sendMessage(sender, "Disable.AlreadyDefective");
return true; return true;
} }
V10LiftPlugin.getAPI().setDefective(liftName, true); V10LiftPlugin.getAPI().setDefective(liftName, true);
sender.sendMessage(ChatColor.GREEN + "Lift disabled!"); ConfigUtil.sendMessage(sender, "Disable.Disabled");
return true; return true;
} }
@ -273,14 +273,14 @@ public class V10LiftCommand implements CommandExecutor {
Player p = (Player) sender; Player p = (Player) sender;
liftName = V10LiftPlugin.getAPI().getLiftByLocation(p.getLocation()); liftName = V10LiftPlugin.getAPI().getLiftByLocation(p.getLocation());
} else if (args.length == 1) { } else if (args.length == 1) {
sender.sendMessage(ChatColor.RED + "Please give a name as non-player!"); ConfigUtil.sendMessage(sender, "Stop.NonPlayer");
return true; return true;
} else { } else {
liftName = args[1]; liftName = args[1];
} }
if (liftName == null || !DataManager.containsLift(liftName)) { if (liftName == null || !DataManager.containsLift(liftName)) {
sender.sendMessage(ChatColor.RED + "Lift doesn't exists!"); ConfigUtil.sendMessage(sender, "General.DoesntExists");
return true; return true;
} }
@ -288,13 +288,13 @@ public class V10LiftCommand implements CommandExecutor {
if (!lift.getQueue().isEmpty()) lift.getQueue().clear(); if (!lift.getQueue().isEmpty()) lift.getQueue().clear();
if (!DataManager.containsMovingTask(liftName)) { if (!DataManager.containsMovingTask(liftName)) {
sender.sendMessage(ChatColor.RED + "Lift " + liftName + " doesn't contain any movingtasks!"); ConfigUtil.sendMessage(sender, "Stop.NoMovingTasks", Collections.singletonMap("%Name%", liftName));
return true; return true;
} }
Bukkit.getScheduler().cancelTask(DataManager.getMovingTask(liftName)); Bukkit.getScheduler().cancelTask(DataManager.getMovingTask(liftName));
DataManager.removeMovingTask(liftName); DataManager.removeMovingTask(liftName);
sender.sendMessage(ChatColor.GREEN + "Lift " + liftName + " stopped!"); ConfigUtil.sendMessage(sender, "Stop.Stopped", Collections.singletonMap("%Name%", liftName));
return true; return true;
} }
@ -305,14 +305,14 @@ public class V10LiftCommand implements CommandExecutor {
Player p = (Player) sender; Player p = (Player) sender;
liftName = V10LiftPlugin.getAPI().getLiftByLocation(p.getLocation()); liftName = V10LiftPlugin.getAPI().getLiftByLocation(p.getLocation());
} else if (args.length == 1) { } else if (args.length == 1) {
sender.sendMessage(ChatColor.RED + "Please give a name as non-player!"); ConfigUtil.sendMessage(sender, "Start.NonPlayer");
return true; return true;
} else { } else {
liftName = args[1]; liftName = args[1];
} }
if (liftName == null || !DataManager.containsLift(liftName)) { if (liftName == null || !DataManager.containsLift(liftName)) {
sender.sendMessage(ChatColor.RED + "Lift doesn't exists!"); ConfigUtil.sendMessage(sender, "General.DoesntExists");
return true; return true;
} }
@ -335,13 +335,14 @@ public class V10LiftCommand implements CommandExecutor {
} }
if (floorName == null || !lift.getFloors().containsKey(floorName)) { if (floorName == null || !lift.getFloors().containsKey(floorName)) {
sender.sendMessage(ChatColor.RED + "Lift " + liftName + " doesn't contain this floor!"); if (floorName == null) floorName = "null";
ConfigUtil.sendMessage(sender, "Start.FloorDoesntExists", Collections.singletonMap("%Name%", floorName));
return true; return true;
} }
Floor f = lift.getFloors().get(floorName); Floor f = lift.getFloors().get(floorName);
V10LiftPlugin.getAPI().addToQueue(liftName, f, floorName); V10LiftPlugin.getAPI().addToQueue(liftName, f, floorName);
sender.sendMessage(ChatColor.GREEN + "Lift " + liftName + " started!"); ConfigUtil.sendMessage(sender, "Start.Started", Collections.singletonMap("%Name%", liftName));
return true; return true;
} }
@ -365,7 +366,7 @@ public class V10LiftCommand implements CommandExecutor {
e.printStackTrace(); e.printStackTrace();
} }
sender.sendMessage(ChatColor.YELLOW + "Plugin reloaded successfully!"); ConfigUtil.sendMessage(sender, "Reload.Reloaded");
return true; return true;
} }
@ -425,9 +426,9 @@ public class V10LiftCommand implements CommandExecutor {
} }
if (abort) { if (abort) {
p.sendMessage(ChatColor.GOLD + "Cancelled."); ConfigUtil.sendMessage(sender, "Abort.Cancelled");
} else { } else {
p.sendMessage(ChatColor.RED + "Oops! You can't cancel anything."); ConfigUtil.sendMessage(sender, "Abort.NothingToCancel");
} }
return true; return true;
} }
@ -435,14 +436,14 @@ public class V10LiftCommand implements CommandExecutor {
private boolean repairCommand(CommandSender sender, @Nonnull String[] args) { private boolean repairCommand(CommandSender sender, @Nonnull String[] args) {
String liftName = args[1]; String liftName = args[1];
if (!DataManager.containsLift(liftName)) { if (!DataManager.containsLift(liftName)) {
sender.sendMessage(ChatColor.RED + "Lift " + args[1] + " doesn't exists!"); ConfigUtil.sendMessage(sender, "General.DoesntExists");
return true; return true;
} }
Lift lift = DataManager.getLift(liftName); Lift lift = DataManager.getLift(liftName);
if (!lift.isDefective()) { if (!lift.isDefective()) {
sender.sendMessage(ChatColor.RED + "This lift isn't defective!"); ConfigUtil.sendMessage(sender, "Repair.NotDefective");
return true; return true;
} }
@ -462,7 +463,10 @@ public class V10LiftCommand implements CommandExecutor {
} }
if (p.getGameMode() != GameMode.CREATIVE && masterAmount > 0) { if (p.getGameMode() != GameMode.CREATIVE && masterAmount > 0) {
if (!p.getInventory().contains(masterItem)) { if (!p.getInventory().contains(masterItem)) {
sender.sendMessage(ChatColor.RED + "You need " + masterAmount + "x " + masterItem.toString().toLowerCase() + "!"); Map<String, String> replacements = new HashMap<>();
replacements.put("%Amount%", String.valueOf(masterAmount));
replacements.put("%ItemName%", masterItem.toString().toLowerCase());
ConfigUtil.sendMessage(sender, "Repair.ItemsNeeded", replacements);
return true; return true;
} }
p.getInventory().remove(new ItemStack(masterItem, masterAmount)); p.getInventory().remove(new ItemStack(masterItem, masterAmount));
@ -470,40 +474,48 @@ public class V10LiftCommand implements CommandExecutor {
} }
} }
V10LiftPlugin.getAPI().setDefective(liftName, false); V10LiftPlugin.getAPI().setDefective(liftName, false);
sender.sendMessage(ChatColor.GREEN + "Lift repaired!"); ConfigUtil.sendMessage(sender, "Repair.Repaired");
return true; return true;
} }
private boolean realisticCommand(CommandSender sender) { private boolean realisticCommand(CommandSender sender) {
Player p = (Player) sender; Player p = (Player) sender;
if (!DataManager.containsEditPlayer(p.getUniqueId())) { if (!DataManager.containsEditPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "First switch on the editor mode!"); ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
return true; return true;
} }
Lift lift = DataManager.getLift(DataManager.getEditPlayer(p.getUniqueId())); Lift lift = DataManager.getLift(DataManager.getEditPlayer(p.getUniqueId()));
lift.setRealistic(!lift.isRealistic()); lift.setRealistic(!lift.isRealistic());
sender.sendMessage(ChatColor.GREEN + "Realistic mode turned " + (lift.isSound() ? "on" : "off") + "!"); if (lift.isRealistic()) {
ConfigUtil.sendMessage(sender, "Realistic.TurnedOn");
} else {
ConfigUtil.sendMessage(sender, "Realistic.TurnedOff");
}
return true; return true;
} }
private boolean soundCommand(CommandSender sender) { private boolean soundCommand(CommandSender sender) {
Player p = (Player) sender; Player p = (Player) sender;
if (!DataManager.containsEditPlayer(p.getUniqueId())) { if (!DataManager.containsEditPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "First switch on the editor mode!"); ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
return true; return true;
} }
Lift lift = DataManager.getLift(DataManager.getEditPlayer(p.getUniqueId())); Lift lift = DataManager.getLift(DataManager.getEditPlayer(p.getUniqueId()));
lift.setSound(!lift.isSound()); lift.setSound(!lift.isSound());
sender.sendMessage(ChatColor.GREEN + "Sound mode turned " + (lift.isSound() ? "on" : "off") + "!"); if (lift.isSound()) {
ConfigUtil.sendMessage(sender, "Sound.TurnedOn");
} else {
ConfigUtil.sendMessage(sender, "Sound.TurnedOff");
}
return true; return true;
} }
private boolean speedCommand(CommandSender sender, String[] args) { private boolean speedCommand(CommandSender sender, String[] args) {
Player p = (Player) sender; Player p = (Player) sender;
if (!DataManager.containsEditPlayer(p.getUniqueId())) { if (!DataManager.containsEditPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "First switch on the editor mode!"); ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
return true; return true;
} }
@ -512,9 +524,9 @@ public class V10LiftCommand implements CommandExecutor {
int speed = Integer.parseInt(args[1]); int speed = Integer.parseInt(args[1]);
lift.setSpeed(speed); lift.setSpeed(speed);
if (lift.getSpeed() < 1) lift.setSpeed(1); if (lift.getSpeed() < 1) lift.setSpeed(1);
sender.sendMessage(ChatColor.GREEN + "Lift speed changed!"); ConfigUtil.sendMessage(sender, "Speed.Changed");
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "Wrong speed: " + args[1]); ConfigUtil.sendMessage(sender, "Speed.WrongSpeed", Collections.singletonMap("%Speed%", args[1]));
} }
return true; return true;
} }
@ -522,18 +534,18 @@ public class V10LiftCommand implements CommandExecutor {
private boolean whoisCommand(CommandSender sender, @Nonnull String[] args) { private boolean whoisCommand(CommandSender sender, @Nonnull String[] args) {
if (args.length < 2) { if (args.length < 2) {
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You need to be a player to use this command without name."); ConfigUtil.sendMessage(sender, "Whois.UseWithoutName");
return true; return true;
} }
//Without name //Without name
Player p = (Player) sender; Player p = (Player) sender;
DataManager.addWhoisREQPlayer(p.getUniqueId()); DataManager.addWhoisREQPlayer(p.getUniqueId());
sender.sendMessage(ChatColor.GREEN + "Now right-click on the block you want to check."); ConfigUtil.sendMessage(sender, "Whois.WithoutName");
} else { } else {
String liftName = args[1]; String liftName = args[1];
if (!DataManager.containsLift(liftName)) { if (!DataManager.containsLift(liftName)) {
sender.sendMessage(ChatColor.RED + "Lift " + liftName + " not found!"); ConfigUtil.sendMessage(sender, "Whois.DoesntExists");
} else { } else {
V10LiftPlugin.getAPI().sendLiftInfo(sender, liftName); V10LiftPlugin.getAPI().sendLiftInfo(sender, liftName);
} }
@ -544,7 +556,7 @@ public class V10LiftCommand implements CommandExecutor {
private boolean whitelistCommand(CommandSender sender, @Nonnull String[] args) { private boolean whitelistCommand(CommandSender sender, @Nonnull String[] args) {
Player p = (Player) sender; Player p = (Player) sender;
if (!DataManager.containsEditPlayer(p.getUniqueId())) { if (!DataManager.containsEditPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "First switch on the editor mode!"); ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
return true; return true;
} }
@ -554,20 +566,20 @@ public class V10LiftCommand implements CommandExecutor {
UUID wpu = null; UUID wpu = null;
if (args[2].startsWith("g:")) { if (args[2].startsWith("g:")) {
if (!V10LiftPlugin.isVaultEnabled()) { if (!V10LiftPlugin.isVaultEnabled()) {
sender.sendMessage(ChatColor.RED + "You can't add a group when Vault is not found."); ConfigUtil.sendMessage(sender, "Whitelist.Group.VaultNotFound");
return true; return true;
} }
isGroup = true; isGroup = true;
wgn = args[2].replace("g:", ""); wgn = args[2].replace("g:", "");
if (!VaultManager.isGroup(wgn)) { if (!VaultManager.isGroup(wgn)) {
sender.sendMessage(ChatColor.RED + "Group " + wgn + " not found!"); ConfigUtil.sendMessage(sender, "Whitelist.Group.NotFound", Collections.singletonMap("%Name%", wgn));
return true; return true;
} }
} else { } else {
OfflinePlayer wp = Bukkit.getOfflinePlayer(args[2]); OfflinePlayer wp = Bukkit.getOfflinePlayer(args[2]);
wpu = wp.getUniqueId(); wpu = wp.getUniqueId();
if (!wp.hasPlayedBefore()) { if (!wp.hasPlayedBefore()) {
sender.sendMessage(ChatColor.RED + "Player " + args[2] + " not found!"); ConfigUtil.sendMessage(sender, "Whitelist.Player.NotFound", Collections.singletonMap("%Name%", args[2]));
return true; return true;
} }
} }
@ -577,7 +589,7 @@ public class V10LiftCommand implements CommandExecutor {
Block b = p.getLocation().getBlock(); Block b = p.getLocation().getBlock();
Floor f = new Floor(b.getY() - 1, Objects.requireNonNull(b.getWorld(), "World was null at whitelistCommand").getName()); Floor f = new Floor(b.getY() - 1, Objects.requireNonNull(b.getWorld(), "World was null at whitelistCommand").getName());
if (!lift.getFloors().containsValue(f)) { if (!lift.getFloors().containsValue(f)) {
sender.sendMessage(ChatColor.RED + "Automatic floor detection failed!"); ConfigUtil.sendMessage(sender, "General.DetectionFailed");
return true; return true;
} }
for (Map.Entry<String, Floor> e : lift.getFloors().entrySet()) { for (Map.Entry<String, Floor> e : lift.getFloors().entrySet()) {
@ -590,7 +602,7 @@ public class V10LiftCommand implements CommandExecutor {
} else { } else {
floor = args[3]; floor = args[3];
if (!lift.getFloors().containsKey(floor)) { if (!lift.getFloors().containsKey(floor)) {
sender.sendMessage(ChatColor.RED + "Floor " + args[3] + " not found!"); ConfigUtil.sendMessage(sender, "General.FloorDoesntExists", Collections.singletonMap("%Name%", args[3]));
return true; return true;
} }
} }
@ -599,33 +611,33 @@ public class V10LiftCommand implements CommandExecutor {
if (args[1].equalsIgnoreCase("add")) { if (args[1].equalsIgnoreCase("add")) {
if (isGroup) { if (isGroup) {
if (f.getGroupWhitelist().contains(wgn)) { if (f.getGroupWhitelist().contains(wgn)) {
sender.sendMessage(ChatColor.RED + "Whitelist already contains this group!"); ConfigUtil.sendMessage(sender, "Whitelist.Group.AlreadyContains");
} else { } else {
f.getGroupWhitelist().add(wgn); f.getGroupWhitelist().add(wgn);
sender.sendMessage(ChatColor.GREEN + "Group added to whitelist!"); ConfigUtil.sendMessage(sender, "Whitelist.Player.Added");
} }
} else { } else {
if (f.getUserWhitelist().contains(wpu)) { if (f.getUserWhitelist().contains(wpu)) {
sender.sendMessage(ChatColor.RED + "Whitelist already contains this user!"); ConfigUtil.sendMessage(sender, "Whitelist.Group.AlreadyContains");
} else { } else {
f.getUserWhitelist().add(wpu); f.getUserWhitelist().add(wpu);
sender.sendMessage(ChatColor.GREEN + "User added to whitelist!"); ConfigUtil.sendMessage(sender, "Whitelist.Player.Added");
} }
} }
} else if (args[1].equalsIgnoreCase("del")) { } else if (args[1].equalsIgnoreCase("del")) {
if (isGroup) { if (isGroup) {
if (!f.getGroupWhitelist().contains(wgn)) { if (!f.getGroupWhitelist().contains(wgn)) {
sender.sendMessage(ChatColor.RED + "Whitelist doesn't contain this group!"); ConfigUtil.sendMessage(sender, "Whitelist.Group.DoesntContains");
} else { } else {
f.getGroupWhitelist().remove(wgn); f.getGroupWhitelist().remove(wgn);
sender.sendMessage(ChatColor.GREEN + "Group removed from whitelist!"); ConfigUtil.sendMessage(sender, "Whitelist.Group.Removed");
} }
} else { } else {
if (!f.getUserWhitelist().contains(wpu)) { if (!f.getUserWhitelist().contains(wpu)) {
sender.sendMessage(ChatColor.RED + "Whitelist doesn't contain this user!"); ConfigUtil.sendMessage(sender, "Whitelist.Player.DoesntContains");
} else { } else {
f.getUserWhitelist().remove(wpu); f.getUserWhitelist().remove(wpu);
sender.sendMessage(ChatColor.GREEN + "User removed from whitelist!"); ConfigUtil.sendMessage(sender, "Whitelist.User.Removed");
} }
} }
} else { } else {
@ -637,13 +649,13 @@ public class V10LiftCommand implements CommandExecutor {
private boolean doorCommand(CommandSender sender, String[] args) { private boolean doorCommand(CommandSender sender, String[] args) {
Player p = (Player) sender; Player p = (Player) sender;
if (!DataManager.containsEditPlayer(p.getUniqueId())) { if (!DataManager.containsEditPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "First switch on the editor mode!"); ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
return true; return true;
} }
if (DataManager.containsDoorEditPlayer(p.getUniqueId())) { if (DataManager.containsDoorEditPlayer(p.getUniqueId())) {
DataManager.removeDoorEditPlayer(p.getUniqueId()); DataManager.removeDoorEditPlayer(p.getUniqueId());
sender.sendMessage(ChatColor.RED + "Door editor mode disabled!"); ConfigUtil.sendMessage(sender, "Door.Disabled");
return true; return true;
} }
@ -653,7 +665,7 @@ public class V10LiftCommand implements CommandExecutor {
Location loc = p.getLocation(); Location loc = p.getLocation();
Floor f = new Floor(loc.getBlockY() - 1, Objects.requireNonNull(loc.getWorld(), "World was null at doorCommand").getName()); Floor f = new Floor(loc.getBlockY() - 1, Objects.requireNonNull(loc.getWorld(), "World was null at doorCommand").getName());
if (!lift.getFloors().containsValue(f)) { if (!lift.getFloors().containsValue(f)) {
sender.sendMessage(ChatColor.RED + "Automatic floor detection failed!"); ConfigUtil.sendMessage(sender, "General.DetectionFailed");
return true; return true;
} }
for (Map.Entry<String, Floor> e : lift.getFloors().entrySet()) { for (Map.Entry<String, Floor> e : lift.getFloors().entrySet()) {
@ -666,37 +678,36 @@ public class V10LiftCommand implements CommandExecutor {
} else { } else {
floor = args[2]; floor = args[2];
if (!lift.getFloors().containsKey(floor)) { if (!lift.getFloors().containsKey(floor)) {
sender.sendMessage(ChatColor.RED + "The floor " + args[2] + " doesn't exists!"); ConfigUtil.sendMessage(sender, "General.FloorDoesntExists", Collections.singletonMap("%Name", args[2]));
return true; return true;
} }
} }
DataManager.addDoorEditPlayer(p.getUniqueId(), floor); DataManager.addDoorEditPlayer(p.getUniqueId(), floor);
sender.sendMessage(ChatColor.GREEN + "Now right-click on the door blocks! (If it are real doors/gates, click on the bottom block)"); ConfigUtil.sendMessage(sender, "Door.Enabled");
sender.sendMessage(ChatColor.GREEN + "Then do /v10lift door to save it.");
return true; return true;
} }
private boolean ropeCommand(CommandSender sender, String[] args) { private boolean ropeCommand(CommandSender sender, String[] args) {
Player p = (Player) sender; Player p = (Player) sender;
if (!DataManager.containsEditPlayer(p.getUniqueId())) { if (!DataManager.containsEditPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "First switch on the editor mode!"); ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
return true; return true;
} }
if (args[1].equalsIgnoreCase("add")) { if (args[1].equalsIgnoreCase("add")) {
if (DataManager.containsRopeEditPlayer(p.getUniqueId()) || DataManager.containsRopeRemovesPlayer(p.getUniqueId())) { if (DataManager.containsRopeEditPlayer(p.getUniqueId()) || DataManager.containsRopeRemovesPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "You're still adjusting the emergency stairs."); ConfigUtil.sendMessage(sender, "Rope.StillAdjusting");
return true; return true;
} }
DataManager.addRopeEditPlayer(p.getUniqueId(), null); DataManager.addRopeEditPlayer(p.getUniqueId(), null);
sender.sendMessage(ChatColor.GREEN + "Now right-click on the beginning and the end of the emergency stairs."); ConfigUtil.sendMessage(sender, "Rope.Add");
} else if (args[1].equalsIgnoreCase("del")) { } else if (args[1].equalsIgnoreCase("del")) {
if (DataManager.containsRopeEditPlayer(p.getUniqueId()) || DataManager.containsRopeRemovesPlayer(p.getUniqueId())) { if (DataManager.containsRopeEditPlayer(p.getUniqueId()) || DataManager.containsRopeRemovesPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "You're still adjusting the emergency stairs."); ConfigUtil.sendMessage(sender, "Rope.StillAdjusting");
return true; return true;
} }
DataManager.addRopeRemovesPlayer(p.getUniqueId()); DataManager.addRopeRemovesPlayer(p.getUniqueId());
sender.sendMessage(ChatColor.GREEN + "Now right-click on the the emergency stairs."); ConfigUtil.sendMessage(sender, "Rope.Delete");
} }
return true; return true;
} }
@ -704,18 +715,17 @@ public class V10LiftCommand implements CommandExecutor {
private boolean buildCommand(CommandSender sender) { private boolean buildCommand(CommandSender sender) {
Player p = (Player) sender; Player p = (Player) sender;
if (!DataManager.containsEditPlayer(p.getUniqueId())) { if (!DataManager.containsEditPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "First switch on the editor mode!"); ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
return true; return true;
} }
if (DataManager.containsBuilderPlayer(p.getUniqueId())) { if (DataManager.containsBuilderPlayer(p.getUniqueId())) {
DataManager.removeBuilderPlayer(p.getUniqueId()); DataManager.removeBuilderPlayer(p.getUniqueId());
V10LiftPlugin.getAPI().sortLiftBlocks(DataManager.getEditPlayer(p.getUniqueId())); V10LiftPlugin.getAPI().sortLiftBlocks(DataManager.getEditPlayer(p.getUniqueId()));
sender.sendMessage(ChatColor.GREEN + "Construction mode disabled!"); ConfigUtil.sendMessage(sender, "Build.Disabled");
} else { } else {
DataManager.addBuilderPlayer(p.getUniqueId()); DataManager.addBuilderPlayer(p.getUniqueId());
sender.sendMessage(ChatColor.GREEN + "Now right-click on the elevator blocks!"); ConfigUtil.sendMessage(sender, "Build.Enabled");
sender.sendMessage(ChatColor.GREEN + "Then do /v10lift build to save it!");
} }
return true; return true;
} }
@ -723,13 +733,13 @@ public class V10LiftCommand implements CommandExecutor {
private boolean renameCommand(CommandSender sender, String[] args) { private boolean renameCommand(CommandSender sender, String[] args) {
Player p = (Player) sender; Player p = (Player) sender;
if (!DataManager.containsEditPlayer(p.getUniqueId())) { if (!DataManager.containsEditPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "First switch on the editor mode!"); ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
return true; return true;
} }
String liftName = DataManager.getEditPlayer(p.getUniqueId()); String liftName = DataManager.getEditPlayer(p.getUniqueId());
if (!DataManager.containsLift(liftName)) { if (!DataManager.containsLift(liftName)) {
sender.sendMessage(ChatColor.RED + "That lift doesn't exists."); ConfigUtil.sendMessage(sender, "General.DoesntExists");
return true; return true;
} }
@ -737,45 +747,45 @@ public class V10LiftCommand implements CommandExecutor {
V10LiftPlugin.getAPI().renameLift(liftName, args[1]); V10LiftPlugin.getAPI().renameLift(liftName, args[1]);
Bukkit.dispatchCommand(sender, "v10lift edit " + args[1]); Bukkit.dispatchCommand(sender, "v10lift edit " + args[1]);
sender.sendMessage(ChatColor.GREEN + "Lift successfully renamed!"); ConfigUtil.sendMessage(sender, "Rename.Renamed");
return true; return true;
} }
private boolean offlineCommand(CommandSender sender, String[] args) { private boolean offlineCommand(CommandSender sender, String[] args) {
Player p = (Player) sender; Player p = (Player) sender;
if (!DataManager.containsEditPlayer(p.getUniqueId())) { if (!DataManager.containsEditPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "First switch on the editor mode!"); ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
return true; return true;
} }
String liftName = DataManager.getEditPlayer(p.getUniqueId()); String liftName = DataManager.getEditPlayer(p.getUniqueId());
if (!DataManager.containsLift(liftName)) { if (!DataManager.containsLift(liftName)) {
sender.sendMessage(ChatColor.RED + "That lift doesn't exists."); ConfigUtil.sendMessage(sender, "General.DoesntExists");
return true; return true;
} }
Lift lift = DataManager.getLift(liftName); Lift lift = DataManager.getLift(liftName);
if (args[1].equalsIgnoreCase("add")) { if (args[1].equalsIgnoreCase("add")) {
if (DataManager.containsOfflineEditsPlayer(p.getUniqueId()) || DataManager.containsOfflineRemovesPlayer(p.getUniqueId())) { if (DataManager.containsOfflineEditsPlayer(p.getUniqueId()) || DataManager.containsOfflineRemovesPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "You are still adjusting an input!"); ConfigUtil.sendMessage(sender, "OfflineInput.StillAdjusting");
return true; return true;
} }
DataManager.addOfflineEditsPlayer(p.getUniqueId()); DataManager.addOfflineEditsPlayer(p.getUniqueId());
sender.sendMessage(ChatColor.GREEN + "Now right click on the offline input block!"); ConfigUtil.sendMessage(sender, "OfflineInput.RightClick");
} else if (args[1].equalsIgnoreCase("del")) { } else if (args[1].equalsIgnoreCase("del")) {
if (lift.getOfflineInputs().isEmpty()) { if (lift.getOfflineInputs().isEmpty()) {
sender.sendMessage(ChatColor.RED + "There is no input to remove!"); ConfigUtil.sendMessage(sender, "OfflineInput.NothingToRemove");
return true; return true;
} }
if (DataManager.containsOfflineEditsPlayer(p.getUniqueId()) || DataManager.containsOfflineRemovesPlayer(p.getUniqueId())) { if (DataManager.containsOfflineEditsPlayer(p.getUniqueId()) || DataManager.containsOfflineRemovesPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "You are still adjusting an input!"); ConfigUtil.sendMessage(sender, "OfflineInput.StillAdjusting");
return true; return true;
} }
DataManager.addOfflineRemovesPlayer(p.getUniqueId()); DataManager.addOfflineRemovesPlayer(p.getUniqueId());
sender.sendMessage(ChatColor.GREEN + "Now right click on the offline input block!"); ConfigUtil.sendMessage(sender, "OfflineInput.RightClick");
} else { } else {
return helpCommand(sender); return helpCommand(sender);
} }
@ -785,13 +795,13 @@ public class V10LiftCommand implements CommandExecutor {
private boolean inputCommand(CommandSender sender, String[] args) { private boolean inputCommand(CommandSender sender, String[] args) {
Player p = (Player) sender; Player p = (Player) sender;
if (!DataManager.containsEditPlayer(p.getUniqueId())) { if (!DataManager.containsEditPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "First switch on the editor mode!"); ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
return true; return true;
} }
String liftName = DataManager.getEditPlayer(p.getUniqueId()); String liftName = DataManager.getEditPlayer(p.getUniqueId());
if (!DataManager.containsLift(liftName)) { if (!DataManager.containsLift(liftName)) {
sender.sendMessage(ChatColor.RED + "That lift doesn't exists."); ConfigUtil.sendMessage(sender, "General.DoesntExists");
return true; return true;
} }
@ -802,7 +812,7 @@ public class V10LiftCommand implements CommandExecutor {
Block b = p.getLocation().getBlock(); Block b = p.getLocation().getBlock();
Floor f = new Floor(b.getY() - 1, b.getWorld().getName()); Floor f = new Floor(b.getY() - 1, b.getWorld().getName());
if (!lift.getFloors().containsValue(f)) { if (!lift.getFloors().containsValue(f)) {
sender.sendMessage(ChatColor.RED + "Automatic floor detection failed!"); ConfigUtil.sendMessage(sender, "General.DetectionFailed");
return true; return true;
} }
@ -817,25 +827,25 @@ public class V10LiftCommand implements CommandExecutor {
} }
if (DataManager.containsInputEditsPlayer(p.getUniqueId()) || DataManager.containsInputRemovesPlayer(p.getUniqueId())) { if (DataManager.containsInputEditsPlayer(p.getUniqueId()) || DataManager.containsInputRemovesPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "You are still adjusting an input!"); ConfigUtil.sendMessage(sender, "Input.StillAdjusting");
return true; return true;
} }
DataManager.addInputEditsPlayer(p.getUniqueId(), Objects.requireNonNull(floor, "Floor is null at input add command")); 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!"); ConfigUtil.sendMessage(sender, "Input.RightClick");
} else if (args[1].equalsIgnoreCase("del")) { } else if (args[1].equalsIgnoreCase("del")) {
if (lift.getInputs().isEmpty()) { if (lift.getInputs().isEmpty()) {
sender.sendMessage(ChatColor.RED + "There is no input to remove!"); ConfigUtil.sendMessage(sender, "Input.NothingToRemove");
return true; return true;
} }
if (DataManager.containsInputEditsPlayer(p.getUniqueId()) || DataManager.containsInputRemovesPlayer(p.getUniqueId())) { if (DataManager.containsInputEditsPlayer(p.getUniqueId()) || DataManager.containsInputRemovesPlayer(p.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "You are still adjusting an input!"); ConfigUtil.sendMessage(sender, "Input.StillAdjusting");
return true; return true;
} }
DataManager.addInputRemovesPlayer(p.getUniqueId()); DataManager.addInputRemovesPlayer(p.getUniqueId());
sender.sendMessage(ChatColor.GREEN + "Now right click on the input block!"); ConfigUtil.sendMessage(sender, "Input.RightClick");
} else { } else {
return helpCommand(sender); return helpCommand(sender);
} }
@ -845,13 +855,13 @@ public class V10LiftCommand implements CommandExecutor {
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())) {
sender.sendMessage(ChatColor.RED + "First switch on the editor mode!"); ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
return true; return true;
} }
String liftName = DataManager.getEditPlayer(p.getUniqueId()); String liftName = DataManager.getEditPlayer(p.getUniqueId());
if (!DataManager.containsLift(liftName)) { if (!DataManager.containsLift(liftName)) {
sender.sendMessage(ChatColor.RED + "That lift doesn't exists."); ConfigUtil.sendMessage(sender, "General.DoesntExists");
return true; return true;
} }
if (args[1].equalsIgnoreCase("add")) { if (args[1].equalsIgnoreCase("add")) {
@ -860,28 +870,28 @@ public class V10LiftCommand implements CommandExecutor {
int response = V10LiftPlugin.getAPI().addFloor(liftName, floorName, new Floor(b.getY() - 1, b.getWorld().getName())); int response = V10LiftPlugin.getAPI().addFloor(liftName, floorName, new Floor(b.getY() - 1, b.getWorld().getName()));
switch (response) { switch (response) {
case 0: case 0:
sender.sendMessage(ChatColor.GREEN + "Floor successfully added!"); ConfigUtil.sendMessage(sender, "Floor.Added");
break; break;
case -2: case -2:
sender.sendMessage(ChatColor.RED + "That floor is too high!"); ConfigUtil.sendMessage(sender, "Floor.ToHigh");
break; break;
case -3: case -3:
sender.sendMessage(ChatColor.RED + "That floor already exists!"); ConfigUtil.sendMessage(sender, "Floor.AlreadyExists");
break; break;
default: default:
sender.sendMessage(ChatColor.RED + "Internal error!"); ConfigUtil.sendMessage(sender, "General.InternalError");
break; break;
} }
} else if (args[1].equalsIgnoreCase("del")) { } else if (args[1].equalsIgnoreCase("del")) {
String floorName = args[2]; String floorName = args[2];
if (!V10LiftPlugin.getAPI().removeFloor(liftName, floorName)) { if (!V10LiftPlugin.getAPI().removeFloor(liftName, floorName)) {
sender.sendMessage(ChatColor.RED + "Internal error!"); ConfigUtil.sendMessage(sender, "General.InternalError");
} else { } else {
sender.sendMessage(ChatColor.GREEN + "Floor successfully removed!"); ConfigUtil.sendMessage(sender, "Floor.Removed");
} }
} else if (args[1].equalsIgnoreCase("rename")) { } else if (args[1].equalsIgnoreCase("rename")) {
if (args.length < 4) { if (args.length < 4) {
sender.sendMessage(ChatColor.RED + "Please use: /v10lift floor rename <Old name> <New name>"); ConfigUtil.sendMessage(sender, "General.IncorrectUsage", Collections.singletonMap("%Command%", "/v10lift floor rename <Old name> <New name>"));
return true; return true;
} }
@ -890,16 +900,16 @@ public class V10LiftCommand implements CommandExecutor {
int response = V10LiftPlugin.getAPI().renameFloor(liftName, floorName, newFloorName); int response = V10LiftPlugin.getAPI().renameFloor(liftName, floorName, newFloorName);
switch (response) { switch (response) {
case 0: case 0:
sender.sendMessage(ChatColor.GREEN + "Floor successfully renamed!"); ConfigUtil.sendMessage(sender, "Floor.Renamed");
break; break;
case -2: case -2:
sender.sendMessage(ChatColor.RED + "That floor doesn't exists!"); ConfigUtil.sendMessage(sender, "Floor.DoesntExists");
break; break;
case -3: case -3:
sender.sendMessage(ChatColor.RED + "That floor already exists!"); ConfigUtil.sendMessage(sender, "Floor.AlreadyExists");
break; break;
default: default:
sender.sendMessage(ChatColor.RED + "Internal error!"); ConfigUtil.sendMessage(sender, "General.InternalError");
break; break;
} }
} else { } else {
@ -916,7 +926,7 @@ public class V10LiftCommand implements CommandExecutor {
if (args.length < 2) { if (args.length < 2) {
String liftName = DataManager.getEditPlayer(p.getUniqueId()); String liftName = DataManager.getEditPlayer(p.getUniqueId());
if (!DataManager.containsLift(liftName)) { if (!DataManager.containsLift(liftName)) {
sender.sendMessage(ChatColor.RED + "That lift doesn't exists."); ConfigUtil.sendMessage(sender, "General.DoesntExists");
return true; return true;
} }
@ -961,26 +971,27 @@ public class V10LiftCommand implements CommandExecutor {
sign.update(); sign.update();
ls.setOldText(null); ls.setOldText(null);
} }
sender.sendMessage(ChatColor.GREEN + "Editor turned off!"); ConfigUtil.sendMessage(sender, "Edit.TurnedOff");
} else { } else {
sender.sendMessage(ChatColor.RED + "You are still in editor mode."); ConfigUtil.sendMessage(sender, "Edit.StillInEditMode");
return true; return true;
} }
} else { } else {
//TURN ON //TURN ON
if (args.length < 2) { if (args.length < 2) {
sender.sendMessage(ChatColor.RED + "Please use /v10lift edit <Name>"); ConfigUtil.sendMessage(sender, "General.IncorrectUsage", Collections.singletonMap("%Command%", "/v10lift edit <Name>"));
return true; return true;
} }
if (!DataManager.containsLift(args[1])) { if (!DataManager.containsLift(args[1])) {
sender.sendMessage(ChatColor.RED + "That lift doesn't exists."); ConfigUtil.sendMessage(sender, "General.DoesntExists");
return true; return true;
} }
Lift lift = DataManager.getLift(args[1]); Lift lift = DataManager.getLift(args[1]);
if (!lift.getOwners().contains(p.getUniqueId()) && !p.hasPermission("v10lift.admin")) { if (!lift.getOwners().contains(p.getUniqueId()) && !p.hasPermission("v10lift.admin")) {
sender.sendMessage(ChatColor.RED + "You don't have the permission to remove that lift."); ConfigUtil.sendMessage(sender, "General.NoPermission");
return true;
} }
DataManager.addEditPlayer(p.getUniqueId(), args[1]); DataManager.addEditPlayer(p.getUniqueId(), args[1]);
@ -991,7 +1002,7 @@ public class V10LiftCommand implements CommandExecutor {
if (!(bs instanceof Sign)) continue; if (!(bs instanceof Sign)) continue;
sign = (Sign) bs; sign = (Sign) bs;
if (!sign.getLine(0).equalsIgnoreCase(ConfigUtil.getConfigText("SignText"))) continue; if (!sign.getLine(0).equalsIgnoreCase(ConfigUtil.getConfigText("SignText"))) continue;
sign.setLine(3, ChatColor.RED + "Maintenance"); sign.setLine(3, ConfigUtil.getConfigText("MaintenanceText"));
sign.update(); sign.update();
} }
@ -1009,7 +1020,7 @@ public class V10LiftCommand implements CommandExecutor {
sign.setLine(3, ConfigUtil.getConfigText("MaintenanceText")); sign.setLine(3, ConfigUtil.getConfigText("MaintenanceText"));
sign.update(); sign.update();
} }
sender.sendMessage(ChatColor.GREEN + "Editor turned on!"); ConfigUtil.sendMessage(sender, "Edit.TurnedOn");
} }
return true; return true;
} }
@ -1017,21 +1028,22 @@ public class V10LiftCommand implements CommandExecutor {
private boolean deleteCommand(@Nonnull CommandSender sender, @Nonnull String[] args) { private boolean deleteCommand(@Nonnull CommandSender sender, @Nonnull String[] args) {
Player p = (Player) sender; Player p = (Player) sender;
if (!DataManager.containsLift(args[1])) { if (!DataManager.containsLift(args[1])) {
sender.sendMessage(ChatColor.RED + "That lift doesn't exists."); ConfigUtil.sendMessage(sender, "General.DoesntExists");
return true; return true;
} }
Lift lift = DataManager.getLift(args[1]); Lift lift = DataManager.getLift(args[1]);
if (!lift.getOwners().contains(p.getUniqueId()) && !p.hasPermission("v10lift.admin")) { if (!lift.getOwners().contains(p.getUniqueId()) && !p.hasPermission("v10lift.admin")) {
sender.sendMessage(ChatColor.RED + "You don't have the permission to remove that lift."); ConfigUtil.sendMessage(sender, "General.NoPermission");
}
if (!V10LiftPlugin.getAPI().removeLift(args[1])) {
sender.sendMessage(ChatColor.RED + "The lift " + args[1] + " couldn't be removed!");
return true; return true;
} }
sender.sendMessage(ChatColor.GREEN + "The lift " + args[1] + " is removed successfully!"); if (!V10LiftPlugin.getAPI().removeLift(args[1])) {
ConfigUtil.sendMessage(sender, "Delete.NotRemoved", Collections.singletonMap("%Name%", args[1]));
return true;
}
ConfigUtil.sendMessage(sender, "Delete.Removed", Collections.singletonMap("%Name%", args[1]));
return true; return true;
} }
@ -1040,18 +1052,19 @@ public class V10LiftCommand implements CommandExecutor {
if (DataManager.containsPlayer(p.getUniqueId())) { if (DataManager.containsPlayer(p.getUniqueId())) {
//Already building!! //Already building!!
if (args.length < 2) { if (args.length < 2) {
sender.sendMessage(ChatColor.RED + "Please use /v10lift create <Name>"); ConfigUtil.sendMessage(sender, "General.IncorrectUsage", Collections.singletonMap("%Command%", "/v10lift create <Name>"));
return true; return true;
} }
TreeSet<LiftBlock> blocks = DataManager.getPlayer(p.getUniqueId()); TreeSet<LiftBlock> blocks = DataManager.getPlayer(p.getUniqueId());
if (blocks.isEmpty()) { if (blocks.isEmpty()) {
sender.sendMessage(ChatColor.RED + "Add blocks first!"); ConfigUtil.sendMessage(sender, "Create.NoBlocks");
return true; return true;
} }
if (!V10LiftPlugin.getAPI().createLift(p, args[1])) { if (!V10LiftPlugin.getAPI().createLift(p, args[1])) {
sender.sendMessage(ChatColor.RED + "A lift with that name already exists."); ConfigUtil.sendMessage(sender, "General.AlreadyExists");
return true;
} }
TreeSet<LiftBlock> blcks = DataManager.getLift(args[1]).getBlocks(); TreeSet<LiftBlock> blcks = DataManager.getLift(args[1]).getBlocks();
@ -1059,13 +1072,12 @@ public class V10LiftCommand implements CommandExecutor {
blocks.forEach(block -> V10LiftPlugin.getAPI().addBlockToLift(blcks, block)); blocks.forEach(block -> V10LiftPlugin.getAPI().addBlockToLift(blcks, block));
V10LiftPlugin.getAPI().sortLiftBlocks(args[1]); V10LiftPlugin.getAPI().sortLiftBlocks(args[1]);
DataManager.removePlayer(p.getUniqueId()); DataManager.removePlayer(p.getUniqueId());
sender.sendMessage(ChatColor.GREEN + "The lift " + args[1] + " is created successfully!"); ConfigUtil.sendMessage(p, "Create.Created", Collections.singletonMap("%Name%", args[1]));
p.performCommand("v10lift edit " + args[1]); p.performCommand("v10lift edit " + args[1]);
} else { } else {
//Not building yet!! //Not building yet!!
DataManager.addPlayer(p.getUniqueId()); DataManager.addPlayer(p.getUniqueId());
sender.sendMessage(ChatColor.GREEN + "Okay, now add all the blocks from the cab by right-clicking on the blocks."); ConfigUtil.sendMessage(p, "Create.AddBlocks");
sender.sendMessage(ChatColor.GREEN + "Then type: /v10lift create <Name>");
} }
return true; return true;
} }

View file

@ -4,9 +4,9 @@ import nl.SBDeveloper.V10Lift.API.Objects.Floor;
import nl.SBDeveloper.V10Lift.API.Objects.Lift; import nl.SBDeveloper.V10Lift.API.Objects.Lift;
import nl.SBDeveloper.V10Lift.API.Objects.LiftBlock; import nl.SBDeveloper.V10Lift.API.Objects.LiftBlock;
import nl.SBDeveloper.V10Lift.Managers.DataManager; import nl.SBDeveloper.V10Lift.Managers.DataManager;
import nl.SBDeveloper.V10Lift.Utils.ConfigUtil;
import nl.SBDeveloper.V10Lift.Utils.DoorUtil; import nl.SBDeveloper.V10Lift.Utils.DoorUtil;
import nl.SBDeveloper.V10Lift.V10LiftPlugin; import nl.SBDeveloper.V10Lift.V10LiftPlugin;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
@ -23,7 +23,7 @@ public class BlockBreakListener implements Listener {
public void onBlockBreak(BlockBreakEvent e) { public void onBlockBreak(BlockBreakEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (V10LiftPlugin.getAPI().isRope(b)) { if (V10LiftPlugin.getAPI().isRope(b)) {
e.getPlayer().sendMessage(ChatColor.RED + "You can't do this! Remove the rope first."); ConfigUtil.sendMessage(e.getPlayer(), "General.RemoveRopeFirst");
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
@ -32,14 +32,14 @@ public class BlockBreakListener implements Listener {
for (Map.Entry<String, Lift> entry : DataManager.getLifts().entrySet()) { for (Map.Entry<String, Lift> entry : DataManager.getLifts().entrySet()) {
Lift lift = entry.getValue(); Lift lift = entry.getValue();
if (lift.getBlocks().contains(tlb)) { if (lift.getBlocks().contains(tlb)) {
e.getPlayer().sendMessage(ChatColor.RED + "You can't do this! Remove the lift first."); ConfigUtil.sendMessage(e.getPlayer(), "General.RemoveLiftFirst");
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
for (Floor f : lift.getFloors().values()) { for (Floor f : lift.getFloors().values()) {
if (f.getDoorBlocks().contains(tlb)) { if (f.getDoorBlocks().contains(tlb)) {
e.getPlayer().sendMessage(ChatColor.RED + "You can't do this! Remove the door first."); ConfigUtil.sendMessage(e.getPlayer(), "General.RemoveDoorFirst");
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
@ -50,7 +50,7 @@ public class BlockBreakListener implements Listener {
&& lb.getX() == loc.getBlockX() && lb.getX() == loc.getBlockX()
&& lb.getY() == loc.getBlockY() && lb.getY() == loc.getBlockY()
&& lb.getZ() == loc.getBlockZ()) { && lb.getZ() == loc.getBlockZ()) {
e.getPlayer().sendMessage(ChatColor.RED + "You can't do this! Remove the door first."); ConfigUtil.sendMessage(e.getPlayer(), "General.RemoveDoorFirst");
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
@ -62,11 +62,11 @@ public class BlockBreakListener implements Listener {
if (!lift.getSigns().contains(tlb)) continue; if (!lift.getSigns().contains(tlb)) continue;
if (!lift.getOwners().contains(e.getPlayer().getUniqueId()) && !e.getPlayer().hasPermission("v10lift.admin")) { if (!lift.getOwners().contains(e.getPlayer().getUniqueId()) && !e.getPlayer().hasPermission("v10lift.admin")) {
e.getPlayer().sendMessage(ChatColor.RED + "You can't do this!"); ConfigUtil.sendMessage(e.getPlayer(), "General.NoPermission");
e.setCancelled(true); e.setCancelled(true);
} else { } else {
lift.getSigns().remove(tlb); lift.getSigns().remove(tlb);
e.getPlayer().sendMessage(ChatColor.YELLOW + "Lift sign removed!"); ConfigUtil.sendMessage(e.getPlayer(), "LiftSign.Removed");
} }
} }
} }

View file

@ -110,19 +110,19 @@ public class PlayerInteractListener implements Listener {
String f = ChatColor.stripColor(sign.getLine(3)); String f = ChatColor.stripColor(sign.getLine(3));
if (!lift.getFloors().containsKey(f)) { if (!lift.getFloors().containsKey(f)) {
p.sendMessage(ChatColor.RED + "Floor not found!"); ConfigUtil.sendMessage(e.getPlayer(), "General.FloorDoesntExists");
return; return;
} }
Floor floor = lift.getFloors().get(f); Floor floor = lift.getFloors().get(f);
if (!floor.getUserWhitelist().isEmpty() && !floor.getUserWhitelist().contains(p.getUniqueId()) && !p.hasPermission("v10lift.admin")) { if (!floor.getUserWhitelist().isEmpty() && !floor.getUserWhitelist().contains(p.getUniqueId()) && !p.hasPermission("v10lift.admin")) {
p.sendMessage(ChatColor.RED + "You can't go to that floor!"); ConfigUtil.sendMessage(e.getPlayer(), "General.NoWhitelistPermission");
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
if (!floor.getGroupWhitelist().isEmpty() && !VaultManager.userHasAnyGroup(p, floor.getGroupWhitelist()) && !p.hasPermission("v10lift.admin")) { if (!floor.getGroupWhitelist().isEmpty() && !VaultManager.userHasAnyGroup(p, floor.getGroupWhitelist()) && !p.hasPermission("v10lift.admin")) {
p.sendMessage(ChatColor.RED + "You can't go to that floor!"); ConfigUtil.sendMessage(e.getPlayer(), "General.NoWhitelistPermission");
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
@ -143,16 +143,16 @@ public class PlayerInteractListener implements Listener {
int res = V10LiftPlugin.getAPI().switchBlockAtLift(DataManager.getPlayer(p.getUniqueId()), e.getClickedBlock()); int res = V10LiftPlugin.getAPI().switchBlockAtLift(DataManager.getPlayer(p.getUniqueId()), e.getClickedBlock());
switch (res) { switch (res) {
case 0: case 0:
p.sendMessage(ChatColor.GREEN + "Block added to the elevator."); ConfigUtil.sendMessage(e.getPlayer(), "Build.BlockAdded");
break; break;
case 1: case 1:
p.sendMessage(ChatColor.GOLD + "Block removed from the elevator."); ConfigUtil.sendMessage(e.getPlayer(), "Build.BlockRemoved");
break; break;
case -2: case -2:
p.sendMessage(ChatColor.RED + "The material " + e.getClickedBlock().getType().toString() + " cannot be used!"); ConfigUtil.sendMessage(e.getPlayer(), "Build.BlacklistedMaterial", Collections.singletonMap("%Name%", e.getClickedBlock().getType().toString().toLowerCase()));
break; break;
default: default:
p.sendMessage(ChatColor.RED + "Internal error."); ConfigUtil.sendMessage(e.getPlayer(), "General.InternalError");
break; break;
} }
} else if (DataManager.containsInputEditsPlayer(p.getUniqueId())) { } else if (DataManager.containsInputEditsPlayer(p.getUniqueId())) {
@ -162,12 +162,12 @@ public class PlayerInteractListener implements Listener {
Lift lift = DataManager.getLift(DataManager.getEditPlayer(p.getUniqueId())); Lift lift = DataManager.getLift(DataManager.getEditPlayer(p.getUniqueId()));
e.setCancelled(true); e.setCancelled(true);
if (lift.getInputs().contains(tlb)) { if (lift.getInputs().contains(tlb)) {
p.sendMessage(ChatColor.RED + "This block has already been chosen as an input. Choose another block!"); ConfigUtil.sendMessage(e.getPlayer(), "Input.AlreadyAdded");
return; return;
} }
lift.getInputs().add(tlb); lift.getInputs().add(tlb);
DataManager.removeInputEditsPlayer(p.getUniqueId()); DataManager.removeInputEditsPlayer(p.getUniqueId());
p.sendMessage(ChatColor.GREEN + "Input created!"); ConfigUtil.sendMessage(e.getPlayer(), "Input.Created");
} else if (DataManager.containsOfflineEditsPlayer(p.getUniqueId())) { } else if (DataManager.containsOfflineEditsPlayer(p.getUniqueId())) {
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
Block block = e.getClickedBlock(); Block block = e.getClickedBlock();
@ -175,12 +175,12 @@ public class PlayerInteractListener implements Listener {
Lift lift = DataManager.getLift(DataManager.getEditPlayer(p.getUniqueId())); Lift lift = DataManager.getLift(DataManager.getEditPlayer(p.getUniqueId()));
e.setCancelled(true); e.setCancelled(true);
if (lift.getOfflineInputs().contains(tlb)) { if (lift.getOfflineInputs().contains(tlb)) {
p.sendMessage(ChatColor.RED + "This block has already been chosen as an input. Choose another block!"); ConfigUtil.sendMessage(e.getPlayer(), "OfflineInput.AlreadyAdded");
return; return;
} }
lift.getOfflineInputs().add(tlb); lift.getOfflineInputs().add(tlb);
DataManager.removeOfflineEditsPlayer(p.getUniqueId()); DataManager.removeOfflineEditsPlayer(p.getUniqueId());
p.sendMessage(ChatColor.GREEN + "Offline input created!"); ConfigUtil.sendMessage(e.getPlayer(), "OfflineInput.Created");
} else if (DataManager.containsInputRemovesPlayer(p.getUniqueId())) { } else if (DataManager.containsInputRemovesPlayer(p.getUniqueId())) {
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
Block block = e.getClickedBlock(); Block block = e.getClickedBlock();
@ -190,10 +190,10 @@ public class PlayerInteractListener implements Listener {
if (lift.getInputs().contains(tlb)) { if (lift.getInputs().contains(tlb)) {
lift.getInputs().remove(tlb); lift.getInputs().remove(tlb);
DataManager.removeInputRemovesPlayer(p.getUniqueId()); DataManager.removeInputRemovesPlayer(p.getUniqueId());
p.sendMessage(ChatColor.GREEN + "Input removed!"); ConfigUtil.sendMessage(e.getPlayer(), "Input.Removed");
return; return;
} }
p.sendMessage(ChatColor.RED + "This block is not an input. Choose another block!"); ConfigUtil.sendMessage(e.getPlayer(), "Input.NoInput");
} else if (DataManager.containsOfflineRemovesPlayer(p.getUniqueId())) { } else if (DataManager.containsOfflineRemovesPlayer(p.getUniqueId())) {
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
Block block = e.getClickedBlock(); Block block = e.getClickedBlock();
@ -203,26 +203,26 @@ public class PlayerInteractListener implements Listener {
if (lift.getOfflineInputs().contains(tlb)) { if (lift.getOfflineInputs().contains(tlb)) {
lift.getOfflineInputs().remove(tlb); lift.getOfflineInputs().remove(tlb);
DataManager.removeOfflineRemovesPlayer(p.getUniqueId()); DataManager.removeOfflineRemovesPlayer(p.getUniqueId());
p.sendMessage(ChatColor.GREEN + "Offline input removed!"); ConfigUtil.sendMessage(e.getPlayer(), "OfflineInput.Removed");
return; return;
} }
p.sendMessage(ChatColor.RED + "This block is not an offline input. Choose another block!"); ConfigUtil.sendMessage(e.getPlayer(), "OfflineInput.NoInput");
} else if (DataManager.containsBuilderPlayer(p.getUniqueId())) { } else if (DataManager.containsBuilderPlayer(p.getUniqueId())) {
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
e.setCancelled(true); e.setCancelled(true);
int res = V10LiftPlugin.getAPI().switchBlockAtLift(DataManager.getEditPlayer(p.getUniqueId()), e.getClickedBlock()); int res = V10LiftPlugin.getAPI().switchBlockAtLift(DataManager.getEditPlayer(p.getUniqueId()), e.getClickedBlock());
switch (res) { switch (res) {
case 0: case 0:
p.sendMessage(ChatColor.GREEN + "Block added to the elevator."); ConfigUtil.sendMessage(e.getPlayer(), "Build.BlockAdded");
break; break;
case 1: case 1:
p.sendMessage(ChatColor.GOLD + "Block removed from the elevator."); ConfigUtil.sendMessage(e.getPlayer(), "Build.BlockRemoved");
break; break;
case -2: case -2:
p.sendMessage(ChatColor.RED + "The material " + e.getClickedBlock().getType().toString() + " cannot be used!"); ConfigUtil.sendMessage(e.getPlayer(), "Build.BlacklistedMaterial", Collections.singletonMap("%Name%", e.getClickedBlock().getType().toString().toLowerCase()));
break; break;
default: default:
p.sendMessage(ChatColor.RED + "Internal error."); ConfigUtil.sendMessage(e.getPlayer(), "General.InternalError");
break; break;
} }
} else if (DataManager.containsRopeEditPlayer(p.getUniqueId())) { } else if (DataManager.containsRopeEditPlayer(p.getUniqueId())) {
@ -231,33 +231,32 @@ public class PlayerInteractListener implements Listener {
LiftBlock start = DataManager.getRopeEditPlayer(p.getUniqueId()); LiftBlock start = DataManager.getRopeEditPlayer(p.getUniqueId());
Block now = e.getClickedBlock(); Block now = e.getClickedBlock();
if (start == null) { if (start == null) {
p.sendMessage(ChatColor.GOLD + "Now right-click on the end of the rope!"); ConfigUtil.sendMessage(e.getPlayer(), "Rope.Delete");
DataManager.addRopeEditPlayer(p.getUniqueId(), new LiftBlock(now.getWorld().getName(), now.getX(), now.getY(), now.getZ(), (String) null)); DataManager.addRopeEditPlayer(p.getUniqueId(), new LiftBlock(now.getWorld().getName(), now.getX(), now.getY(), now.getZ(), (String) null));
} else if (start.equals(new LiftBlock(now.getWorld().getName(), now.getX(), now.getY(), now.getZ(), (String) null))) { } else if (start.equals(new LiftBlock(now.getWorld().getName(), now.getX(), now.getY(), now.getZ(), (String) null))) {
DataManager.addRopeEditPlayer(p.getUniqueId(), null); DataManager.addRopeEditPlayer(p.getUniqueId(), null);
p.sendMessage(ChatColor.GOLD + "Start removed!"); ConfigUtil.sendMessage(e.getPlayer(), "Rope.PartRemoved");
p.sendMessage(ChatColor.GOLD + "Now right-click on the end of the rope!");
} else { } else {
if (start.getX() != now.getX() || start.getZ() != now.getZ()) { if (start.getX() != now.getX() || start.getZ() != now.getZ()) {
p.sendMessage(ChatColor.RED + "A rope can only go up!"); ConfigUtil.sendMessage(e.getPlayer(), "Rope.OnlyUp");
return; return;
} }
int res = V10LiftPlugin.getAPI().addRope(DataManager.getEditPlayer(p.getUniqueId()), now.getWorld(), start.getX(), now.getY(), start.getY(), start.getZ()); int res = V10LiftPlugin.getAPI().addRope(DataManager.getEditPlayer(p.getUniqueId()), now.getWorld(), start.getX(), now.getY(), start.getY(), start.getZ());
switch (res) { switch (res) {
case 0: case 0:
p.sendMessage(ChatColor.GREEN + "Rope created."); ConfigUtil.sendMessage(e.getPlayer(), "Rope.Created");
break; break;
case -2: case -2:
p.sendMessage(ChatColor.RED + "The rope must be of the same material!"); ConfigUtil.sendMessage(e.getPlayer(), "Rope.OnlyOneMaterial");
break; break;
case -3: case -3:
p.sendMessage(ChatColor.RED + "Part of the rope is already part of another rope!"); ConfigUtil.sendMessage(e.getPlayer(), "Rope.AlreadyARope");
break; break;
case -4: case -4:
p.sendMessage(ChatColor.RED + "The rope is build of blacklisted blocks!"); ConfigUtil.sendMessage(e.getPlayer(), "Rope.BlacklistedMaterial");
break; break;
default: default:
p.sendMessage(ChatColor.RED + "Internal error."); ConfigUtil.sendMessage(e.getPlayer(), "General.InternalError");
break; break;
} }
DataManager.removeRopeEditPlayer(p.getUniqueId()); DataManager.removeRopeEditPlayer(p.getUniqueId());
@ -268,18 +267,18 @@ public class PlayerInteractListener implements Listener {
Block block = e.getClickedBlock(); Block block = e.getClickedBlock();
String liftName = DataManager.getEditPlayer(p.getUniqueId()); String liftName = DataManager.getEditPlayer(p.getUniqueId());
if (!V10LiftPlugin.getAPI().containsRope(liftName, block)) { if (!V10LiftPlugin.getAPI().containsRope(liftName, block)) {
p.sendMessage(ChatColor.RED + "This block is not part of the rope."); ConfigUtil.sendMessage(e.getPlayer(), "Rope.NotARope");
return; return;
} }
V10LiftPlugin.getAPI().removeRope(liftName, block); V10LiftPlugin.getAPI().removeRope(liftName, block);
DataManager.removeRopeRemovesPlayer(p.getUniqueId()); DataManager.removeRopeRemovesPlayer(p.getUniqueId());
p.sendMessage(ChatColor.GREEN + "Rope removed."); ConfigUtil.sendMessage(e.getPlayer(), "Rope.Removed");
} else if (DataManager.containsDoorEditPlayer(p.getUniqueId())) { } else if (DataManager.containsDoorEditPlayer(p.getUniqueId())) {
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
e.setCancelled(true); e.setCancelled(true);
Block block = e.getClickedBlock(); Block block = e.getClickedBlock();
if (V10LiftPlugin.getAPI().getFBM().isForbidden(block.getType())) { if (V10LiftPlugin.getAPI().getFBM().isForbidden(block.getType())) {
p.sendMessage(ChatColor.RED + "The material " + e.getClickedBlock().getType().toString() + " is currently not supported!"); ConfigUtil.sendMessage(e.getPlayer(), "Door.BlacklistedMaterial", Collections.singletonMap("%Name%", e.getClickedBlock().getType().toString().toLowerCase()));
return; return;
} }
LiftBlock lb; LiftBlock lb;
@ -293,19 +292,19 @@ public class PlayerInteractListener implements Listener {
if (DoorUtil.isOpenable(block)) { if (DoorUtil.isOpenable(block)) {
if (floor.getRealDoorBlocks().contains(lb)) { if (floor.getRealDoorBlocks().contains(lb)) {
floor.getRealDoorBlocks().remove(lb); floor.getRealDoorBlocks().remove(lb);
p.sendMessage(ChatColor.GOLD + "Door removed."); ConfigUtil.sendMessage(e.getPlayer(), "Door.Removed");
return; return;
} }
floor.getRealDoorBlocks().add(lb); floor.getRealDoorBlocks().add(lb);
} else { } else {
if (floor.getDoorBlocks().contains(lb)) { if (floor.getDoorBlocks().contains(lb)) {
floor.getDoorBlocks().remove(lb); floor.getDoorBlocks().remove(lb);
p.sendMessage(ChatColor.GOLD + "Door removed."); ConfigUtil.sendMessage(e.getPlayer(), "Door.Removed");
return; return;
} }
floor.getDoorBlocks().add(lb); floor.getDoorBlocks().add(lb);
} }
p.sendMessage(ChatColor.GREEN + "Door created."); ConfigUtil.sendMessage(e.getPlayer(), "Door.Created");
} else if (DataManager.containsWhoisREQPlayer(p.getUniqueId())) { } else if (DataManager.containsWhoisREQPlayer(p.getUniqueId())) {
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
e.setCancelled(true); e.setCancelled(true);
@ -319,7 +318,7 @@ public class PlayerInteractListener implements Listener {
return; return;
} }
} }
p.sendMessage(ChatColor.RED + "This block is not part of a lift."); ConfigUtil.sendMessage(e.getPlayer(), "Whois.NotALift");
} else { } else {
Action a = e.getAction(); Action a = e.getAction();
if (a != Action.RIGHT_CLICK_BLOCK && a != Action.LEFT_CLICK_BLOCK) return; if (a != Action.RIGHT_CLICK_BLOCK && a != Action.LEFT_CLICK_BLOCK) return;
@ -353,7 +352,10 @@ public class PlayerInteractListener implements Listener {
} }
if (p.getGameMode() != GameMode.CREATIVE && masterAmount > 0) { if (p.getGameMode() != GameMode.CREATIVE && masterAmount > 0) {
if (!p.getInventory().contains(masterItem)) { if (!p.getInventory().contains(masterItem)) {
p.sendMessage(ChatColor.RED + "You need " + masterAmount + "x " + masterItem.toString().toLowerCase() + "!"); Map<String, String> replacements = new HashMap<>();
replacements.put("%Amount%", String.valueOf(masterAmount));
replacements.put("%ItemName%", masterItem.toString().toLowerCase());
ConfigUtil.sendMessage(e.getPlayer(), "Repair.ItemsNeeded", replacements);
return; return;
} }
p.getInventory().remove(new ItemStack(masterItem, masterAmount)); p.getInventory().remove(new ItemStack(masterItem, masterAmount));
@ -373,7 +375,7 @@ public class PlayerInteractListener implements Listener {
Iterator<String> iter = lift.getFloors().keySet().iterator(); Iterator<String> iter = lift.getFloors().keySet().iterator();
if (!lift.getFloors().containsKey(f)) { if (!lift.getFloors().containsKey(f)) {
if (!iter.hasNext()) { if (!iter.hasNext()) {
p.sendMessage(ChatColor.RED + "This elevator has no floors!"); ConfigUtil.sendMessage(e.getPlayer(), "General.NoFloors");
return; return;
} }
f = iter.next(); f = iter.next();
@ -397,19 +399,19 @@ public class PlayerInteractListener implements Listener {
sign.update(); sign.update();
} else { } else {
if (!lift.getFloors().containsKey(f)) { if (!lift.getFloors().containsKey(f)) {
p.sendMessage(ChatColor.RED + "Floor not found!"); ConfigUtil.sendMessage(e.getPlayer(), "General.FloorDoesntExists");
return; return;
} }
Floor floor = lift.getFloors().get(f); Floor floor = lift.getFloors().get(f);
if (!floor.getUserWhitelist().isEmpty() && !floor.getUserWhitelist().contains(p.getUniqueId()) && !p.hasPermission("v10lift.admin")) { if (!floor.getUserWhitelist().isEmpty() && !floor.getUserWhitelist().contains(p.getUniqueId()) && !p.hasPermission("v10lift.admin")) {
p.sendMessage(ChatColor.RED + "You can't go to that floor!"); ConfigUtil.sendMessage(e.getPlayer(), "General.NoWhitelistPermission");
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
if (!floor.getGroupWhitelist().isEmpty() && !VaultManager.userHasAnyGroup(p, floor.getGroupWhitelist()) && !p.hasPermission("v10lift.admin")) { if (!floor.getGroupWhitelist().isEmpty() && !VaultManager.userHasAnyGroup(p, floor.getGroupWhitelist()) && !p.hasPermission("v10lift.admin")) {
p.sendMessage(ChatColor.RED + "You can't go to that floor!"); ConfigUtil.sendMessage(e.getPlayer(), "General.NoWhitelistPermission");
e.setCancelled(true); e.setCancelled(true);
return; return;
} }

View file

@ -3,6 +3,7 @@ package nl.SBDeveloper.V10Lift.Listeners;
import nl.SBDeveloper.V10Lift.API.Objects.Lift; import nl.SBDeveloper.V10Lift.API.Objects.Lift;
import nl.SBDeveloper.V10Lift.API.Objects.LiftSign; import nl.SBDeveloper.V10Lift.API.Objects.LiftSign;
import nl.SBDeveloper.V10Lift.Managers.DataManager; import nl.SBDeveloper.V10Lift.Managers.DataManager;
import nl.SBDeveloper.V10Lift.Utils.ConfigUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -20,18 +21,18 @@ public class SignChangeListener implements Listener {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (lines[1].isEmpty()) { if (lines[1].isEmpty()) {
p.sendMessage(ChatColor.RED + "No lift name given!"); ConfigUtil.sendMessage(e.getPlayer(), "LiftSign.NoName");
return; return;
} }
if (!DataManager.containsLift(lines[1])) { if (!DataManager.containsLift(lines[1])) {
p.sendMessage(ChatColor.RED + "Lift " + lines[1] + " doesn't exists!"); ConfigUtil.sendMessage(e.getPlayer(), "General.DoesntExists");
return; return;
} }
Lift lift = DataManager.getLift(lines[1]); Lift lift = DataManager.getLift(lines[1]);
if (!lift.getOwners().contains(p.getUniqueId()) && !p.hasPermission("v10lift.admin")) { if (!lift.getOwners().contains(p.getUniqueId()) && !p.hasPermission("v10lift.admin")) {
p.sendMessage(ChatColor.RED + "You can't do this!"); ConfigUtil.sendMessage(e.getPlayer(), "General.NoPermission");
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
@ -47,7 +48,7 @@ public class SignChangeListener implements Listener {
Block b = e.getBlock(); Block b = e.getBlock();
lift.getSigns().add(new LiftSign(b.getWorld().getName(), b.getX(), b.getY(), b.getZ(), type, (byte) 0)); lift.getSigns().add(new LiftSign(b.getWorld().getName(), b.getX(), b.getY(), b.getZ(), type, (byte) 0));
p.sendMessage(ChatColor.GREEN + "Lift sign created!"); ConfigUtil.sendMessage(e.getPlayer(), "LiftSign.Created");
} }
} }

View file

@ -5,7 +5,7 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.HashMap; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -48,9 +48,8 @@ public class ConfigUtil {
* @param p The commandsender to send it to * @param p The commandsender to send it to
* @param path The path to look for * @param path The path to look for
* @param replacement The replacements -> key: %Name% = value: TheName * @param replacement The replacements -> key: %Name% = value: TheName
* @return The message with replacements
*/ */
public static void sendMessage(CommandSender p, @Nonnull String path, HashMap<String, String> replacement) { public static void sendMessage(CommandSender p, @Nonnull String path, Map<String, String> replacement) {
String fileMessage = V10LiftPlugin.getMessages().getFile().getString(path); String fileMessage = V10LiftPlugin.getMessages().getFile().getString(path);
if (fileMessage == null) { if (fileMessage == null) {
throw new NullPointerException("Message " + path + " not found in messages.yml!"); throw new NullPointerException("Message " + path + " not found in messages.yml!");

View file

@ -108,6 +108,7 @@ Whitelist:
Removed: "&aUser removed from whitelist!" Removed: "&aUser removed from whitelist!"
Whois: Whois:
UseWithoutName: "&cYou need to be a player to use this command without name."
NotALift: "&cThis block is not part of a lift." NotALift: "&cThis block is not part of a lift."
WithoutName: "&aNow right-click on the block you want to check." WithoutName: "&aNow right-click on the block you want to check."