private String replaceDatabaseString(String input) { input = input.replaceAll("\\{DIR\\}", dataFolder.getPath().replaceAll("\\\\", "/") + "/"); input = input.replaceAll("\\{NAME\\}", description.getName().replaceAll("[^\\w_-]", "")); return input; }
public PluginNameConversationPrefix(Plugin plugin, String separator, ChatColor prefixColor) { this.separator = separator; this.prefixColor = prefixColor; this.plugin = plugin; cachedPrefix = prefixColor + plugin.getDescription().getName() + separator + ChatColor.WHITE; }
public final String getName() { return getDescription().getName(); } }
@Override public String getDetectionMessage() { return "Using plugin '" + this.plugin.getDescription().getName() + "' for permissions."; }
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(); } }
@EventHandler public void onPluginEnable(PluginEnableEvent event) { Plugin plugin = event.getPlugin(); String name = plugin.getDescription().getName(); if (plugin instanceof PermissionsProvider) { setPluginPermissionsResolver(plugin); } else if ("permissions".equalsIgnoreCase(name) || "permissionsex".equalsIgnoreCase(name) || "bpermissions".equalsIgnoreCase(name) || "groupmanager".equalsIgnoreCase(name) || "vault".equalsIgnoreCase(name)) { load(); } }
@EventHandler public void onPluginDisable(PluginDisableEvent event) { String name = event.getPlugin().getDescription().getName(); if (event.getPlugin() instanceof PermissionsProvider || "permissions".equalsIgnoreCase(name) || "permissionsex".equalsIgnoreCase(name) || "bpermissions".equalsIgnoreCase(name) || "groupmanager".equalsIgnoreCase(name) || "vault".equalsIgnoreCase(name)) { load(); } }
/** * 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); }
lookupNames.put(result.getDescription().getName(), result);
try { description = loader.getPluginDescription(file); String name = description.getName(); if (name.equalsIgnoreCase("bukkit") || name.equalsIgnoreCase("minecraft") || name.equalsIgnoreCase("mojang")) { server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "': Restricted Name"); File replacedFile = plugins.put(description.getName(), file); if (replacedFile != null) { server.getLogger().severe(String.format( "Ambiguous plugin name `%s' for files `%s' and `%s' in `%s'", description.getName(), file.getPath(), replacedFile.getPath(), if (softDependencies.containsKey(description.getName())) { softDependencies.get(description.getName()).addAll(softDependencySet); } else { softDependencies.put(description.getName(), new LinkedList<String>(softDependencySet)); dependencies.put(description.getName(), new LinkedList<String>(dependencySet)); for (String loadBeforeTarget : loadBeforeSet) { if (softDependencies.containsKey(loadBeforeTarget)) { softDependencies.get(loadBeforeTarget).add(description.getName()); } else { shortSoftDependency.add(description.getName()); softDependencies.put(loadBeforeTarget, shortSoftDependency);
/** * Gets the command with the given name, specific to this plugin. Commands * need to be registered in the {@link PluginDescriptionFile#getCommands() * PluginDescriptionFile} to exist at runtime. * * @param name name or alias of the command * @return the plugin command if found, otherwise null */ public PluginCommand getCommand(String name) { String alias = name.toLowerCase(); PluginCommand command = getServer().getPluginCommand(alias); if (command == null || command.getPlugin() != this) { command = getServer().getPluginCommand(description.getName().toLowerCase() + ":" + alias); } if (command != null && command.getPlugin() == this) { return command; } else { return null; } }
final void init(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) { this.loader = loader; this.server = server; this.file = file; this.description = description; this.dataFolder = dataFolder; this.classLoader = classLoader; this.configFile = new File(dataFolder, "config.yml"); this.logger = new PluginLogger(this); if (description.isDatabaseEnabled()) { ServerConfig db = new ServerConfig(); db.setDefaultServer(false); db.setRegister(false); db.setClasses(getDatabaseClasses()); db.setName(description.getName()); server.configureDbConfig(db); DataSourceConfig ds = db.getDataSourceConfig(); ds.setUrl(replaceDatabaseString(ds.getUrl())); dataFolder.mkdirs(); ClassLoader previous = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(classLoader); ebean = EbeanServerFactory.create(db); Thread.currentThread().setContextClassLoader(previous); } }
public void enablePlugin(final Plugin plugin) { if (!plugin.isEnabled()) { List<Command> pluginCommands = PluginCommandYamlParser.parse(plugin); if (!pluginCommands.isEmpty()) { commandMap.registerAll(plugin.getDescription().getName(), pluginCommands); } try { plugin.getPluginLoader().enablePlugin(plugin); } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); } HandlerList.bakeAll(); } }
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)); } }
loaders.remove(jPlugin.getDescription().getName());
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; }
private void describeToSender(Plugin plugin, CommandSender sender) { PluginDescriptionFile desc = plugin.getDescription(); sender.sendMessage(ChatColor.GREEN + desc.getName() + ChatColor.WHITE + " version " + ChatColor.GREEN + desc.getVersion()); if (desc.getDescription() != null) { sender.sendMessage(desc.getDescription()); } if (desc.getWebsite() != null) { sender.sendMessage("Website: " + ChatColor.GREEN + desc.getWebsite()); } if (!desc.getAuthors().isEmpty()) { if (desc.getAuthors().size() == 1) { sender.sendMessage("Author: " + getAuthors(desc)); } else { sender.sendMessage("Authors: " + getAuthors(desc)); } } }
public boolean register(List<CommandInfo> registered) { CommandMap commandMap = getCommandMap(); if (registered == null || commandMap == null) { return false; } for (CommandInfo command : registered) { DynamicPluginCommand cmd = new DynamicPluginCommand(command.getAliases(), command.getDesc(), "/" + command.getAliases()[0] + " " + command.getUsage(), executor, command.getRegisteredWith(), plugin); cmd.setPermissions(command.getPermissions()); commandMap.register(plugin.getDescription().getName(), cmd); } return true; }
@Override public void assertPlayerVisibility(Player player, boolean is_visible, Plugin plugin) { core.assertPlayerVisibility(player.getName(), is_visible, plugin.getDescription().getName()); } @Override