本文整理了Java中org.bukkit.plugin.Plugin.getDescription()
方法的一些代码示例,展示了Plugin.getDescription()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Plugin.getDescription()
方法的具体详情如下:
包路径:org.bukkit.plugin.Plugin
类名称:Plugin
方法名:getDescription
[英]Returns the plugin.yaml file containing the details for this plugin
[中]返回插件。包含此插件详细信息的yaml文件
代码示例来源:origin: Bukkit/Bukkit
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;
}
代码示例来源:origin: EngineHub/WorldEdit
@Override
public String getDetectionMessage() {
return "Using plugin '" + this.plugin.getDescription().getName() + "' for permissions.";
}
代码示例来源:origin: Bukkit/Bukkit
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder(super.toString());
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
stringBuilder.append(", ").append(owningPlugin.getDescription().getFullName()).append(')');
return stringBuilder.toString();
}
}
代码示例来源:origin: Bukkit/Bukkit
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;
}
代码示例来源: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
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();
}
}
代码示例来源:origin: Bukkit/Bukkit
public PermissionAttachment addAttachment(Plugin plugin) {
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 = new PermissionAttachment(plugin, parent);
attachments.add(result);
recalculatePermissions();
return result;
}
代码示例来源:origin: EngineHub/WorldEdit
@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();
}
}
代码示例来源:origin: EngineHub/WorldEdit
@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();
}
}
代码示例来源:origin: Bukkit/Bukkit
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
if (name == null) {
throw new IllegalArgumentException("Permission name cannot be null");
} else 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, ticks);
if (result != null) {
result.setPermission(name, value);
}
return result;
}
代码示例来源:origin: Bukkit/Bukkit
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
if (name == null) {
throw new IllegalArgumentException("Permission name cannot be null");
} else 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);
result.setPermission(name, value);
recalculatePermissions();
return result;
}
代码示例来源: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
/**
* Executes the command, returning its success
*
* @param sender Source object which is executing this command
* @param commandLabel The alias of the command used
* @param args All arguments passed to the command, split via ' '
* @return true if the command was successful, otherwise false
*/
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
boolean success = false;
if (!owningPlugin.isEnabled()) {
return false;
}
if (!testPermission(sender)) {
return true;
}
try {
success = executor.onCommand(sender, this, commandLabel, args);
} catch (Throwable ex) {
throw new CommandException("Unhandled exception executing command '" + commandLabel + "' in plugin " + owningPlugin.getDescription().getFullName(), ex);
}
if (!success && usageMessage.length() > 0) {
for (String line : usageMessage.replace("<command>", commandLabel).split("\n")) {
sender.sendMessage(line);
}
}
return success;
}
代码示例来源: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
String message = String.format("Disabling %s", plugin.getDescription().getFullName());
plugin.getLogger().info(message);
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: Bukkit/Bukkit
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));
}
}
}
代码示例来源:origin: EngineHub/WorldEdit
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;
}
内容来源于网络,如有侵权,请联系作者删除!