The org.bukkit.command.CommandSender hasPermission method allows you to check if a sender (which can be either a player or console) has a certain permission node. This is a useful feature for plugin developers who want to restrict certain commands or actions to players with certain permissions.
Here are examples of how to use hasPermission:
// Assuming the CommandSender is a player: if (sender.hasPermission("myplugin.use")) { // Player has permission to use the MyPlugin command // Execute code for the command here } else { // Player does not have permission to use the MyPlugin command // Send error message here }
// Assuming the CommandSender is the console: if (sender.hasPermission("myplugin.admin")) { // Console has permission to use the MyPlugin admin command // Execute code for the command here } else { // Console does not have permission to use the MyPlugin admin command // Send error message here }
The package library for org.bukkit.command is Bukkit API, which is the plugin API for Minecraft servers running on the Bukkit platform.
Java CommandSender.hasPermission - 30 examples found. These are the top rated real world Java examples of org.bukkit.command.CommandSender.hasPermission extracted from open source projects. You can rate examples to help us improve the quality of examples.