-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added /checksilktouch command to check if player has silk touch
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.