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 06168c0..02a0795 100644 Binary files a/target/SilkTouch.jar and b/target/SilkTouch.jar differ