Skip to content

Commit

Permalink
wc & clear command added
Browse files Browse the repository at this point in the history
  • Loading branch information
czQery committed Feb 12, 2023
1 parent 9a6753d commit 9e4cf97
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/java/cz/qery/toolkit/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 17 additions & 5 deletions src/main/java/cz/qery/toolkit/commands/Aliases.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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()+" <player>"));
sender.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Please use " + h + "/" + cmd.getName().toLowerCase() + " <player>"));
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 {
Expand Down Expand Up @@ -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;
}
Expand Down
14 changes: 13 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -100,4 +104,12 @@ permissions:
toolkit.fly:
description: Fly command
toolkit.fly.other:
description: Fly command
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

0 comments on commit 9e4cf97

Please sign in to comment.