diff --git a/src/main/java/de/butzlabben/world/command/CommandRegistry.java b/src/main/java/de/butzlabben/world/command/CommandRegistry.java index 2a9b3e2..afadd97 100644 --- a/src/main/java/de/butzlabben/world/command/CommandRegistry.java +++ b/src/main/java/de/butzlabben/world/command/CommandRegistry.java @@ -43,6 +43,17 @@ public class CommandRegistry implements CommandExecutor { case "tp": return ws.tpCommand(sender, command, label, args); //Admin Command + case "day": + return admin.setTime(sender,0); + case "night": + return admin.setTime(sender,14000); + case "time": + return admin.setTime(sender, args[1]); + case "rain": + case "storm": + return admin.setStorm(sender,true); + case "sun": + return admin.setStorm(sender, false); case "delmember": return admin.delMemberCommand(sender, command, label, args); case "delete": @@ -66,6 +77,7 @@ public class CommandRegistry implements CommandExecutor { return settings.resetCommand(sender, command, label, args); case "sethome": sender.sendMessage("Disabled For Major Error and Rework"); + return false; /* if (sender.hasPermission("ws.sethome")) { return settings.setHomeCommand(sender, command, label, args); diff --git a/src/main/java/de/butzlabben/world/command/commands/WorldAdministrateCommand.java b/src/main/java/de/butzlabben/world/command/commands/WorldAdministrateCommand.java index 79c23ba..9363b41 100644 --- a/src/main/java/de/butzlabben/world/command/commands/WorldAdministrateCommand.java +++ b/src/main/java/de/butzlabben/world/command/commands/WorldAdministrateCommand.java @@ -25,6 +25,71 @@ import java.io.IOException; public class WorldAdministrateCommand { + public boolean setTime(CommandSender sender, String ticks) { + switch (ticks) { + case "day": + return setTime(sender, 0); + case "night": + return setTime(sender, 14000); + case "dawn": + return setTime(sender, 23000); + default: + try { + return setTime(sender, Long.parseLong(ticks)); + } catch (NumberFormatException e) { + sender.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws time [day/night/dawn/0-24000]")); + return false; + } + + } + } + + public boolean setStorm(CommandSender sender, boolean storm) { + if (!(sender instanceof Player)) { + sender.sendMessage("Command has to be executed as a player!"); + return false; + } + + Player p = (Player) sender; + DependenceConfig dc = new DependenceConfig(p); + if (!dc.hasWorld()) { + p.sendMessage(MessageConfig.getNoWorldOwn()); + return false; + } + + if (dc.getWorldname().equals(p.getWorld().getName())) { + p.getWorld().setStorm(storm); + return true; + } + + + p.sendMessage(MessageConfig.getNoMemberOwn()); + return false; + } + + public boolean setTime(CommandSender sender, long ticks) { + if (!(sender instanceof Player)) { + sender.sendMessage("Command has to be executed as a player!"); + return false; + } + + Player p = (Player) sender; + DependenceConfig dc = new DependenceConfig(p); + if (!dc.hasWorld()) { + p.sendMessage(MessageConfig.getNoWorldOwn()); + return false; + } + + if (dc.getWorldname().equals(p.getWorld().getName())) { + p.getWorld().setTime(ticks); + return true; + } + + + p.sendMessage(MessageConfig.getNoMemberOwn()); + return false; + } + public boolean delMemberCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof Player) { Player p = (Player) sender;