From 10bcf6580228c978c1dd254d46d5b0ffe33d86d1 Mon Sep 17 00:00:00 2001 From: celsisus Date: Sat, 29 May 2021 18:15:22 -0400 Subject: [PATCH] Added /checksilktouch command to check if player has silk touch --- plugin.yml | 4 ++ .../silktouchhands/CheckSilkTouchCommand.java | 39 ++++++++++++++++++ .../ejs/silktouchhands/SilkTouchHands.java | 1 + target/SilkTouch.jar | Bin 5396 -> 6895 bytes 4 files changed, 44 insertions(+) create mode 100644 src/net/ejs/silktouchhands/CheckSilkTouchCommand.java diff --git a/plugin.yml b/plugin.yml index 799344f..93e791b 100644 --- a/plugin.yml +++ b/plugin.yml @@ -10,4 +10,8 @@ commands: unsilktouch: description: removes the ability for the player to have silk touch when they destroy blocks with their hand usage: /unsilktouch + permission: silktouchhands.silktouch + checksilktouch: + description: checks if the player has the ability to have silk touch when they destroy blocks with their hand + usage: /checksilktouch permission: silktouchhands.silktouch \ No newline at end of file diff --git a/src/net/ejs/silktouchhands/CheckSilkTouchCommand.java b/src/net/ejs/silktouchhands/CheckSilkTouchCommand.java new file mode 100644 index 0000000..d3a65bf --- /dev/null +++ b/src/net/ejs/silktouchhands/CheckSilkTouchCommand.java @@ -0,0 +1,39 @@ +package net.ejs.silktouchhands; + +import java.util.Arrays; + +import org.bukkit.NamespacedKey; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; + +import net.md_5.bungee.api.ChatColor; + +public class CheckSilkTouchCommand implements CommandExecutor{ + @Override + public boolean onCommand(CommandSender sender, Command arg1, String arg2, String[] arguments) { + if (sender instanceof Player) { + Player player = (Player) sender; + if (arguments.length == 1) { + player = sender.getServer().getPlayerExact(arguments[0]); + } + if (player == null) { + sender.sendMessage(ChatColor.AQUA + arguments[0] + " is offline"); + } + else if (arguments.length > 1) { + player.sendMessage(ChatColor.RED + Arrays.toString(arguments) + " is not valid input, only list 0-1 players"); + } else { + PersistentDataContainer data = player.getPersistentDataContainer(); + if(data.get(new NamespacedKey(SilkTouchHands.getPlugin(), "cansilktouch"), PersistentDataType.STRING).equals("silktouch")) { + player.sendMessage(ChatColor.GOLD + player.getName()+" has silk touch hands"); + } else { + player.sendMessage(ChatColor.GOLD + player.getName()+" does not have silk touch hands"); + } + } + } + return true; + } +} diff --git a/src/net/ejs/silktouchhands/SilkTouchHands.java b/src/net/ejs/silktouchhands/SilkTouchHands.java index 3a5ff60..9a1ee4c 100644 --- a/src/net/ejs/silktouchhands/SilkTouchHands.java +++ b/src/net/ejs/silktouchhands/SilkTouchHands.java @@ -19,6 +19,7 @@ public class SilkTouchHands extends JavaPlugin implements Listener { public void onEnable() { this.getCommand("silktouch").setExecutor(new SilkTouchCommand()); this.getCommand("unsilktouch").setExecutor(new UnsilkTouchCommand()); + this.getCommand("checksilktouch").setExecutor(new CheckSilkTouchCommand()); Bukkit.getPluginManager().registerEvents(this, this); plugin = this; } diff --git a/target/SilkTouch.jar b/target/SilkTouch.jar index 06168c086144f5a7380cd70734c1088e4cdace89..02a0795904a7d9a4847f6a5397c8bf25a545a2ca 100644 GIT binary patch delta 3503 zcmZvfc{CL4+sB8ojv>s**w-+Vv1U(}v6C&vGNH*f$RHDi3}emCP$c^@Docu*DAi*N zWzW8jZ6t+9DZ))L4B0sznW z47fyYgz^#d(6d2MN9gfv*ozT-QbQFR=Ap=7FJ2F(&*ROL5a^e^$vSI~OunfT*{ZYo z<%5bU#>Hq`YMZ$5krl$bl$sAku)mXqKp@AQ9=Db9xtCt525t`H{hm$ggbwJg&CDMb zg?=rVKRW!y6EnWuOkzoN$NX%`|4tZaT8*Myg%VR|`XeK%<fA@ye=-9nl7Cc)8O-BJW0v}O7908~Ij7p=V zmzIse={U!-(gLjMSW~B2)j8x0`-MRE#G7NvRJ9(rOa1radEVe6z)8|d3jL#qzhkx7%U|se+Xwj0RJ!ex672YWV?M<)GFC^6odGd+<}hRlA&PL5 zbKW$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