private String getCommandPluginName(Command command) { if (command instanceof VanillaCommandWrapper) { return "Minecraft"; } if (command instanceof BukkitCommand || command instanceof VanillaCommand) { return "Bukkit"; } if (command instanceof PluginIdentifiableCommand) { return ((PluginIdentifiableCommand)command).getPlugin().getName(); } return null; }
private boolean commandInIgnoredPlugin(Command command, Set<String> ignoredPlugins) { if ((command instanceof BukkitCommand || command instanceof VanillaCommand) && ignoredPlugins.contains("Bukkit")) { return true; } if (command instanceof PluginIdentifiableCommand && ignoredPlugins.contains(((PluginIdentifiableCommand)command).getPlugin().getName())) { return true; } return false; }
private void registerDynamicCommand(String command, BukkitCommand clazz) { try { final Class<?> subclazz = Class.forName("org.bukkit.craftbukkit.VERSION.CraftServer".replace("VERSION", BungeeCord.getServerVersion())); Object instance = subclazz.cast(Bukkit.getServer()); instance = BungeeCord.invokeMethodByObject(instance, "getCommandMap"); ReflectionLib.invokeMethodByObject(instance, "register", command, clazz); } catch (final Exception ex) { Bukkit.getLogger().log(Level.WARNING, "Cannot register dynamic command.", ex); } }
private String getCommandPluginName(Command command) { if (command.getClass().equals(VanillaCommandWrapper.class)) { return "Minecraft"; } if (command.getClass().equals(BukkitCommand.class) || command.getClass().equals(VanillaCommand.class)) { return "Bukkit"; } if (command instanceof PluginIdentifiableCommand) { return ((PluginIdentifiableCommand)command).getPlugin().getName(); } return null; }
private boolean commandInIgnoredPlugin(Command command, Set<String> ignoredPlugins) { if ((command.getClass().equals(BukkitCommand.class) || command.getClass().equals(VanillaCommand.class)) && ignoredPlugins.contains("Bukkit")) { return true; } if (command instanceof PluginIdentifiableCommand && ignoredPlugins.contains(((PluginIdentifiableCommand)command).getPlugin().getName())) { return true; } return false; }
private String getCommandPluginName(Command command) { if (command instanceof BukkitCommand || command instanceof VanillaCommand) { return "Bukkit"; } if (command instanceof PluginIdentifiableCommand) { return ((PluginIdentifiableCommand)command).getPlugin().getName(); } return null; }
public static void registerDynamicCommand(String command, BukkitCommand clazz) { Object obj = ReflectionLib.getClassFromName("org.bukkit.craftbukkit.VERSION.CraftServer").cast(Bukkit.getServer()); obj = ReflectionLib.invokeMethodByObject(obj, "getCommandMap"); ReflectionLib.invokeMethodByObject(obj, "register", command, clazz); }