/** * @see Server#getLogger() */ public static Logger getLogger() { return server.getLogger(); }
/** * Loads a list of Permissions from a map of data, usually used from * retrieval from a yaml file. * <p> * The data may contain a list of name:data, where the data contains the * following keys: * <ul> * <li>default: Boolean true or false. If not specified, false. * <li>children: Map<String, Boolean> of child permissions. If not * specified, empty list. * <li>description: Short string containing a very small description of * this description. If not specified, empty string. * </ul> * * @param data Map of permissions * @param error An error message to show if a permission is invalid. * @param def Default permission value to use if missing * @return Permission object */ public static List<Permission> loadPermissions(Map<?, ?> data, String error, PermissionDefault def) { List<Permission> result = new ArrayList<Permission>(); for (Map.Entry<?, ?> entry : data.entrySet()) { try { result.add(Permission.loadPermission(entry.getKey().toString(), (Map<?, ?>) entry.getValue(), def, result)); } catch (Throwable ex) { Bukkit.getServer().getLogger().log(Level.SEVERE, String.format(error, entry.getKey()), ex); } } return result; }
/** * Attempts to set the {@link Server} singleton. * <p> * This cannot be done if the Server is already set. * * @param server Server instance */ public static void setServer(Server server) { if (Bukkit.server != null) { throw new UnsupportedOperationException("Cannot redefine singleton Server"); } Bukkit.server = server; server.getLogger().info("This server is running " + getName() + " version " + getVersion() + " (Implementing API version " + getBukkitVersion() + ")"); }
/** * 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); }
Bukkit.getServer().getLogger().severe("Could not load command " + entry.getKey() + " for plugin " + plugin.getName() + ": Illegal Characters"); continue; for (Object o : (List<?>) aliases) { if (o.toString().contains(":")) { Bukkit.getServer().getLogger().severe("Could not load alias " + o.toString() + " for plugin " + plugin.getName() + ": Illegal Characters"); continue; Bukkit.getServer().getLogger().severe("Could not load alias " + aliases.toString() + " for plugin " + plugin.getName() + ": Illegal Characters"); } else { aliasList.add(aliases.toString());
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"); continue; } else if (description.rawName.indexOf(' ') != -1) { server.getLogger().warning(String.format( "Plugin `%s' uses the space-character (0x20) in its name `%s' - this is discouraged", description.getFullName(), server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "'", ex); continue; server.getLogger().severe(String.format( "Ambiguous plugin name `%s' for files `%s' and `%s' in `%s'", description.getName(), server.getLogger().log( Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "'", continue; } catch (InvalidPluginException ex) { server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "'", ex); break; } catch (InvalidPluginException ex) { server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "'", ex); File file = failedPluginIterator.next();
server.getLogger().warning(String.format( "While loading %s (%s) found old-data folder: `%s' next to the new one `%s'", description.getFullName(), throw new InvalidPluginException("Unable to rename old data folder: `" + oldDataFolder + "' to: `" + dataFolder + "'"); server.getLogger().log(Level.INFO, String.format( "While loading %s (%s) renamed data folder: `%s' to `%s'", description.getFullName(),
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); } } }
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 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 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)); } }
private void fireEvent(Event event) { HandlerList handlers = event.getHandlers(); RegisteredListener[] listeners = handlers.getRegisteredListeners(); for (RegisteredListener registration : listeners) { if (!registration.getPlugin().isEnabled()) { continue; } try { registration.callEvent(event); } catch (AuthorNagException ex) { Plugin plugin = registration.getPlugin(); if (plugin.isNaggable()) { plugin.setNaggable(false); server.getLogger().log(Level.SEVERE, String.format( "Nag author(s): '%s' of '%s' about the following: %s", plugin.getDescription().getAuthors(), plugin.getDescription().getFullName(), ex.getMessage() )); } } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Could not pass event " + event.getEventName() + " to " + registration.getPlugin().getDescription().getFullName(), ex); } } }
jPlugin.setEnabled(false); } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
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; }
/** * @see Server#getLogger() */ public static Logger getLogger() { return server.getLogger(); }
/** * Attempts to set the {@link Server} singleton. * <p> * This cannot be done if the Server is already set. * * @param server Server instance */ public static void setServer(Server server) { if (Bukkit.server != null) { throw new UnsupportedOperationException("Cannot redefine singleton Server"); } Bukkit.server = server; server.getLogger().info("This server is running " + getName() + " version " + getVersion() + " (Implementing API version " + getBukkitVersion() + ")"); }
/** * 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); }
@Override public void log(Level level, String msg) { int debugLevel = this.getCore().getMVConfig().getGlobalDebug(); if ((level == Level.FINE && debugLevel >= 1) || (level == Level.FINER && debugLevel >= 2) || (level == Level.FINEST && debugLevel >= 3)) { debugLog.log(level, msg); } else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) { String message = new StringBuilder(getLogTag()).append(msg).toString(); this.getServer().getLogger().log(level, message); debugLog.log(level, message); } }
@Override public void load() { TotalFreedomMod.pluginName = plugin.getDescription().getName(); TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion(); FLog.setPluginLogger(plugin.getLogger()); FLog.setServerLogger(server.getLogger()); build.load(plugin); }