Java Code Examples for org.bukkit.command.PluginCommand#setPermissionMessage()
The following examples show how to use
org.bukkit.command.PluginCommand#setPermissionMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginHelper.java From PlayerSQL with GNU General Public License v2.0 | 8 votes |
@SneakyThrows public static void addExecutor(Plugin plugin, Command command) { Field f = SimplePluginManager.class.getDeclaredField("commandMap"); f.setAccessible(true); CommandMap map = (CommandMap) f.get(plugin.getServer().getPluginManager()); Constructor<PluginCommand> init = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class); init.setAccessible(true); PluginCommand inject = init.newInstance(command.getName(), plugin); inject.setExecutor((who, __, label, input) -> command.execute(who, label, input)); inject.setAliases(command.getAliases()); inject.setDescription(command.getDescription()); inject.setLabel(command.getLabel()); inject.setName(command.getName()); inject.setPermission(command.getPermission()); inject.setPermissionMessage(command.getPermissionMessage()); inject.setUsage(command.getUsage()); map.register(plugin.getName().toLowerCase(), inject); }
Example 2
Source File: ScriptCommand.java From Skript with GNU General Public License v3.0 | 6 votes |
private PluginCommand setupBukkitCommand() { try { final Constructor<PluginCommand> c = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class); c.setAccessible(true); final PluginCommand bukkitCommand = c.newInstance(name, Skript.getInstance()); bukkitCommand.setAliases(aliases); bukkitCommand.setDescription(description); bukkitCommand.setLabel(label); bukkitCommand.setPermission(permission); // We can only set the message if it's simple (doesn't contains expressions) if (permissionMessage.isSimple()) bukkitCommand.setPermissionMessage(permissionMessage.toString(null)); bukkitCommand.setUsage(usage); bukkitCommand.setExecutor(this); return bukkitCommand; } catch (final Exception e) { Skript.outdatedError(e); throw new EmptyStacktraceException(); } }
Example 3
Source File: Hawk.java From Hawk with GNU General Public License v3.0 | 5 votes |
private void registerCommand() { if(plugin == null) return; PluginCommand cmd = plugin.getCommand("hawk"); cmd.setExecutor(new HawkCommand(this)); cmd.setPermission(Hawk.BASE_PERMISSION + ".cmd"); if (messages.isSet("unknownCommandMsg")) cmd.setPermissionMessage(ChatColor.translateAlternateColorCodes('&', messages.getString("unknownCommandMsg"))); else { messages.set("unknownCommandMsg", "Unknown command. Type \"/help\" for help."); cmd.setPermissionMessage(ChatColor.translateAlternateColorCodes('&', messages.getString("unknownCommandMsg"))); } }
Example 4
Source File: CommandMapUtil.java From helper with MIT License | 5 votes |
/** * Registers a CommandExecutor with the server * * @param plugin the plugin instance * @param command the command instance * @param permission the command permission * @param permissionMessage the message sent when the sender doesn't the required permission * @param description the command description * @param aliases the command aliases * @param <T> the command executor class type * @return the command executor */ @Nonnull public static <T extends CommandExecutor> T registerCommand(@Nonnull Plugin plugin, @Nonnull T command, String permission, String permissionMessage, String description, @Nonnull String... aliases) { Preconditions.checkArgument(aliases.length != 0, "No aliases"); for (String alias : aliases) { try { PluginCommand cmd = COMMAND_CONSTRUCTOR.newInstance(alias, plugin); getCommandMap().register(plugin.getDescription().getName(), cmd); getKnownCommandMap().put(plugin.getDescription().getName().toLowerCase() + ":" + alias.toLowerCase(), cmd); getKnownCommandMap().put(alias.toLowerCase(), cmd); cmd.setLabel(alias.toLowerCase()); if (permission != null) { cmd.setPermission(permission); if (permissionMessage != null) { cmd.setPermissionMessage(permissionMessage); } } if (description != null) { cmd.setDescription(description); } cmd.setExecutor(command); if (command instanceof TabCompleter) { cmd.setTabCompleter((TabCompleter) command); } } catch (Exception e) { e.printStackTrace(); } } return command; }