public CommandMap getCommandMap() { CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap"); if (commandMap == null) { if (fallbackCommands != null) { commandMap = fallbackCommands; } else { Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() + ": Could not retrieve server CommandMap, using fallback instead!"); fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer()); Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin); } } return commandMap; }
sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")"); } else { StringBuilder name = new StringBuilder(); Plugin exactPlugin = Bukkit.getPluginManager().getPlugin(pluginName); if (exactPlugin != null) { describeToSender(exactPlugin, sender); for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { if (plugin.getName().toLowerCase().contains(pluginName)) { describeToSender(plugin, sender); found = true;
public void enablePlugin(final Plugin plugin) { Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader"); if (!plugin.isEnabled()) { plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName()); JavaPlugin jPlugin = (JavaPlugin) plugin; String pluginName = jPlugin.getDescription().getName(); if (!loaders.containsKey(pluginName)) { loaders.put(pluginName, (PluginClassLoader) jPlugin.getClassLoader()); } try { jPlugin.setEnabled(true); } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); } // Perhaps abort here, rather than continue going, but as it stands, // an abort is not possible the way it's currently written server.getPluginManager().callEvent(new PluginEnableEvent(plugin)); } }
public PermissionAttachment(Plugin plugin, Permissible Permissible) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } else if (!plugin.isEnabled()) { throw new IllegalArgumentException("Plugin " + plugin.getDescription().getFullName() + " is disabled"); } this.permissible = Permissible; this.plugin = plugin; }
private String getPluginList() { StringBuilder pluginList = new StringBuilder(); Plugin[] plugins = Bukkit.getPluginManager().getPlugins(); for (Plugin plugin : plugins) { if (pluginList.length() > 0) { pluginList.append(ChatColor.WHITE); pluginList.append(", "); } pluginList.append(plugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED); pluginList.append(plugin.getDescription().getName()); } return "(" + plugins.length + "): " + pluginList.toString(); } }
/** * Creates a new PluginLogger that extracts the name from a plugin. * * @param context A reference to the plugin */ public PluginLogger(Plugin context) { super(context.getClass().getCanonicalName(), null); String prefix = context.getDescription().getPrefix(); pluginName = prefix != null ? new StringBuilder().append("[").append(prefix).append("] ").toString() : "[" + context.getDescription().getName() + "] "; setParent(context.getServer().getLogger()); setLevel(Level.ALL); }
public Permission_KPerms(Plugin plugin) { super(); this.vault = plugin; Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), vault); if (kperms == null) { Plugin perms = plugin.getServer().getPluginManager().getPlugin("KPerms"); if (perms != null && perms.isEnabled()) { this.kperms = (KPermsPlugin) perms; plugin.getLogger().info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), "KPerms")); } } }
public static NijikokunPermissions create(Server server, String name) { Plugin permissionsPlugin = server.getPluginManager().getPlugin("Permissions"); if (permissionsPlugin == null) return null; server.getPluginManager().enablePlugin(permissionsPlugin); if(permissionsPlugin.isEnabled() == false) return null; Log.info("Using Permissions " + permissionsPlugin.getDescription().getVersion() + " for access control"); return new NijikokunPermissions(permissionsPlugin, name); }
@EventHandler(priority = EventPriority.MONITOR) public void onPluginEnable(PluginEnableEvent event) { if (chat.overPerms == null) { Plugin chat = plugin.getServer().getPluginManager().getPlugin("OverPermissions"); if (chat != null) { this.chat.overPerms = (OverPermissions) chat; plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", new Object[] {plugin.getDescription().getName(), getName()})); } } }
@Override public void enablePlugin(Plugin plugin) { plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName()); LukkitPluginEnableEvent event = new LukkitPluginEnableEvent((LukkitPlugin) plugin); Bukkit.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { plugin.onEnable(); } else { if (plugin.isEnabled()) Bukkit.getPluginManager().disablePlugin(plugin); } }
public Chat_TotalPermissions(Plugin plugin, Permission perms) { super(perms); this.plugin = plugin; Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin); if (totalPermissions == null) { Plugin chat = plugin.getServer().getPluginManager().getPlugin("TotalPermissions"); if (chat != null) { if (chat.isEnabled()) { totalPermissions = (TotalPermissions) chat; plugin.getLogger().info(String.format("[Chat] %s hooked.", name)); } } } }
public PermissionAttachment addAttachment(Plugin plugin, int ticks) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } else if (!plugin.isEnabled()) { throw new IllegalArgumentException("Plugin " + plugin.getDescription().getFullName() + " is disabled"); } PermissionAttachment result = addAttachment(plugin); if (Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RemoveAttachmentRunnable(result), ticks) == -1) { Bukkit.getServer().getLogger().log(Level.WARNING, "Could not add PermissionAttachment to " + parent + " for plugin " + plugin.getDescription().getFullName() + ": Scheduler returned -1"); result.remove(); return null; } else { return result; } }
public static ArrayList<String> getPlugins() { ArrayList<String> pluginList = new ArrayList<String>(); Plugin[] plugins = BedwarsRel.getInstance().getServer().getPluginManager().getPlugins(); for (Plugin plugin : plugins) { pluginList.add(plugin.getName() + " (" + plugin.getDescription().getVersion() + ")"); } return pluginList; }
output = Bukkit.getConsoleSender(); String[] split = name.split(":", 2); String id = (split.length > 1) ? split[1] : null; Plugin plugin = Bukkit.getPluginManager().getPlugin(split[0]); } else if (!plugin.isEnabled()) { output.sendMessage("Could not set generator for world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled"); } else { result = plugin.getDefaultWorldGenerator(world, id);
@SuppressWarnings("SuspiciousMethodCalls") @Override public void disablePlugin(Plugin plugin) { plugin.getLogger().info("Disabling " + plugin.getDescription().getFullName()); LukkitPluginDisableEvent event = new LukkitPluginDisableEvent((LukkitPlugin) plugin); Bukkit.getServer().getPluginManager().callEvent(event); HandlerList.unregisterAll(plugin); plugin.onDisable(); this.loadedPlugins.remove(plugin); }
/** * Returns a List of plugin names. * * @return list of plugin names */ public static List<String> getPluginNames(boolean fullName) { List<String> plugins = new ArrayList<>(); for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { plugins.add(fullName ? plugin.getDescription().getFullName() : plugin.getName()); } return plugins; }
@Override public List<String> tabComplete(CommandSender sender, String alias, String[] args) { Validate.notNull(sender, "Sender cannot be null"); Validate.notNull(args, "Arguments cannot be null"); Validate.notNull(alias, "Alias cannot be null"); if (args.length == 1) { List<String> completions = new ArrayList<String>(); String toComplete = args[0].toLowerCase(); for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { if (StringUtil.startsWithIgnoreCase(plugin.getName(), toComplete)) { completions.add(plugin.getName()); } } return completions; } return ImmutableList.of(); } }
public void disablePlugin(final Plugin plugin) { if (plugin.isEnabled()) { try { plugin.getPluginLoader().disablePlugin(plugin); } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); } try { server.getScheduler().cancelTasks(plugin); } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while cancelling tasks for " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); } try { server.getServicesManager().unregisterAll(plugin); } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while unregistering services for " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); } try { HandlerList.unregisterAll(plugin); } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while unregistering events for " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); } try { server.getMessenger().unregisterIncomingPluginChannel(plugin); server.getMessenger().unregisterOutgoingPluginChannel(plugin); } catch(Throwable ex) { server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while unregistering plugin channels for " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); } } }
return false; if (!sender.getServer().getPluginManager().useTimings()) { sender.sendMessage("Please enable timings by setting \"settings.plugin-profiling\" to true in bukkit.yml"); return true; fileNames = new PrintStream(names); for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { pluginIdx++; long totalTime = 0; if (separate) { fileNames.println(pluginIdx + " " + plugin.getDescription().getFullName()); fileTimings.println("Plugin " + pluginIdx); else fileTimings.println(plugin.getDescription().getFullName()); for (RegisteredListener listener : HandlerList.getRegisteredListeners(plugin)) { if (listener instanceof TimedRegisteredListener) {
void register(Plugin plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); } }