From 9e4cf977510a19a8aa77db4d955f07640c22117c Mon Sep 17 00:00:00 2001 From: czQery Date: Sun, 12 Feb 2023 14:35:01 +0100 Subject: [PATCH] wc & clear command added --- src/main/java/cz/qery/toolkit/Main.java | 2 ++ .../cz/qery/toolkit/commands/Aliases.java | 22 ++++++++++++++----- src/main/resources/plugin.yml | 14 +++++++++++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/main/java/cz/qery/toolkit/Main.java b/src/main/java/cz/qery/toolkit/Main.java index 888d4f0..85c9342 100644 --- a/src/main/java/cz/qery/toolkit/Main.java +++ b/src/main/java/cz/qery/toolkit/Main.java @@ -53,6 +53,8 @@ public void onEnable() { Objects.requireNonNull(getCommand("gmsp")).setExecutor(new Aliases()); Objects.requireNonNull(getCommand("spawn")).setExecutor(new Aliases()); Objects.requireNonNull(getCommand("fly")).setExecutor(new Aliases()); + Objects.requireNonNull(getCommand("wc")).setExecutor(new Aliases()); + Objects.requireNonNull(getCommand("clear")).setExecutor(new Aliases()); new Interact(this); new Join(this); diff --git a/src/main/java/cz/qery/toolkit/commands/Aliases.java b/src/main/java/cz/qery/toolkit/commands/Aliases.java index e711bbe..b3a3231 100644 --- a/src/main/java/cz/qery/toolkit/commands/Aliases.java +++ b/src/main/java/cz/qery/toolkit/commands/Aliases.java @@ -10,6 +10,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; @@ -28,21 +29,21 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N if (!(sender instanceof Player p)) { if (args.length > 0) { target = Bukkit.getServer().getPlayer(args[0]); - if(target == null){ - sender.sendMessage(Tools.chat(b+"["+n+"SERVER"+b+"]"+t+" Player "+h+args[0]+t+" is not online!")); + if (target == null) { + sender.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Player " + h + args[0] + t + " is not online!")); return false; } } else { - sender.sendMessage(Tools.chat(b+"["+n+"SERVER"+b+"]"+t+" Please use "+h+"/"+cmd.getName().toLowerCase()+" ")); + sender.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Please use " + h + "/" + cmd.getName().toLowerCase() + " ")); return false; } } else { - if (!p.hasPermission("toolkit."+cmd.getName().toLowerCase())) { + if (!p.hasPermission("toolkit." + cmd.getName().toLowerCase())) { p.sendMessage(Tools.chat(plugin.getConfig().getString("commandblock.message"))); return false; } else { if (args.length > 0) { - if (!p.hasPermission("toolkit."+cmd.getName().toLowerCase()+".other")) { + if (!p.hasPermission("toolkit." + cmd.getName().toLowerCase() + ".other")) { p.sendMessage(Tools.chat(plugin.getConfig().getString("commandblock.message"))); return false; } else { @@ -94,6 +95,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N sender.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Fly mode has been turned &aON" + t + "!")); } } + case "wc" -> { + target.getWorld().setStorm(false); + target.getWorld().setThundering(false); + target.getWorld().setClearWeatherDuration(300); + target.getWorld().setTime(1000); + sender.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Weather cleared!")); + } + case "clear" -> { + target.getInventory().setContents(new ItemStack[]{}); + sender.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Inventory cleared!")); + } } return false; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 087427d..7c73170 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -42,6 +42,10 @@ commands: description: Teleport to spawn fly: description: Allows the player to fly + wc: + description: Clear weather + clear: + description: Clear inventory permissions: toolkit.crash: @@ -100,4 +104,12 @@ permissions: toolkit.fly: description: Fly command toolkit.fly.other: - description: Fly command \ No newline at end of file + description: Fly command + toolkit.wc: + description: Wc command + toolkit.wc.other: + description: Wc command + toolkit.clear: + description: Clear command + toolkit.clear.other: + description: CLear command \ No newline at end of file