org.bukkit.Server.getLogger()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(12.3k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.bukkit.Server.getLogger()方法的一些代码示例,展示了Server.getLogger()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.getLogger()方法的具体详情如下:
包路径:org.bukkit.Server
类名称:Server
方法名:getLogger

Server.getLogger介绍

[英]Returns the primary logger associated with this server instance.
[中]返回与此服务器实例关联的主记录器。

代码示例

代码示例来源:origin: Bukkit/Bukkit

/**
 * @see Server#getLogger()
 */
public static Logger getLogger() {
  return server.getLogger();
}

代码示例来源:origin: Bukkit/Bukkit

/**
 * 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;
}

代码示例来源:origin: Bukkit/Bukkit

server.getLogger().warning("Could not register alias " + alias + " because it contains illegal characters");
continue;
server.getLogger().warning("Could not register alias " + alias + " because it contains commands that do not exist: " + bad);
continue;

代码示例来源:origin: Bukkit/Bukkit

/**
 * 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() + ")");
}

代码示例来源:origin: Bukkit/Bukkit

/**
 * 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);
}

代码示例来源:origin: Bukkit/Bukkit

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());

代码示例来源:origin: Bukkit/Bukkit

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();

代码示例来源:origin: Bukkit/Bukkit

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(),

代码示例来源:origin: Bukkit/Bukkit

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);
    }
  }
}

代码示例来源:origin: Bukkit/Bukkit

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();
  }
}

代码示例来源:origin: Bukkit/Bukkit

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;
  }
}

代码示例来源:origin: Bukkit/Bukkit

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));
  }
}

代码示例来源:origin: Bukkit/Bukkit

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);
    }
  }
}

代码示例来源:origin: Bukkit/Bukkit

jPlugin.setEnabled(false);
} catch (Throwable ex) {
  server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);

代码示例来源:origin: EngineHub/WorldEdit

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;
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * @see Server#getLogger()
 */
public static Logger getLogger() {
  return server.getLogger();
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * 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() + ")");
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * 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);
}

代码示例来源:origin: Multiverse/Multiverse-Core

@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);
  }
}

代码示例来源:origin: TotalFreedom/TotalFreedomMod

@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);
}

相关文章

微信公众号

最新文章

更多

Server类方法