本文整理了Java中org.bukkit.plugin.Plugin.isEnabled()
方法的一些代码示例,展示了Plugin.isEnabled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Plugin.isEnabled()
方法的具体详情如下:
包路径:org.bukkit.plugin.Plugin
类名称:Plugin
方法名:isEnabled
[英]Returns a value indicating whether or not this plugin is currently enabled
[中]返回一个值,该值指示此插件当前是否已启用
代码示例来源:origin: Bukkit/Bukkit
/**
* Checks if the given plugin is enabled or not
*
* @param plugin Plugin to check
* @return true if the plugin is enabled, otherwise false
*/
public boolean isPluginEnabled(Plugin plugin) {
if ((plugin != null) && (plugins.contains(plugin))) {
return plugin.isEnabled();
} else {
return false;
}
}
代码示例来源: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
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: 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 registerEvents(Listener listener, Plugin plugin) {
if (!plugin.isEnabled()) {
throw new IllegalPluginAccessException("Plugin attempted to register " + listener + " while not enabled");
}
for (Map.Entry<Class<? extends Event>, Set<RegisteredListener>> entry : plugin.getPluginLoader().createRegisteredListeners(listener, plugin).entrySet()) {
getEventListeners(getRegistrationClass(entry.getKey())).registerAll(entry.getValue());
}
}
代码示例来源:origin: Bukkit/Bukkit
throw new IllegalArgumentException("Plugin source cannot be null");
if (!source.isEnabled()) {
throw new IllegalArgumentException("Plugin must be enabled to send messages");
代码示例来源:origin: Bukkit/Bukkit
/**
* Registers the given event to the specified listener using a directly
* passed EventExecutor
*
* @param event Event class to register
* @param listener PlayerListener to register
* @param priority Priority of this event
* @param executor EventExecutor to register
* @param plugin Plugin to register
* @param ignoreCancelled Do not call executor if event was already
* cancelled
*/
public void registerEvent(Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin, boolean ignoreCancelled) {
Validate.notNull(listener, "Listener cannot be null");
Validate.notNull(priority, "Priority cannot be null");
Validate.notNull(executor, "Executor cannot be null");
Validate.notNull(plugin, "Plugin cannot be null");
if (!plugin.isEnabled()) {
throw new IllegalPluginAccessException("Plugin attempted to register " + event + " while not enabled");
}
if (useTimings) {
getEventListeners(event).register(new TimedRegisteredListener(listener, executor, priority, plugin, ignoreCancelled));
} else {
getEventListeners(event).register(new RegisteredListener(listener, executor, priority, plugin, ignoreCancelled));
}
}
代码示例来源: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) {
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
} else if (!plugin.isEnabled()) {
output.sendMessage("Could not set generator for world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled");
} else {
代码示例来源:origin: Bukkit/Bukkit
public void disablePlugin(Plugin plugin) {
Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
if (plugin.isEnabled()) {
String message = String.format("Disabling %s", plugin.getDescription().getFullName());
plugin.getLogger().info(message);
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Registers a custom entity type.
*
* @param descriptor the entity type to register; all fields except
* {@link CustomEntityDescriptor#getStorage()} must be non-null
*/
public static void registerCustomEntity(
CustomEntityDescriptor<? extends GlowEntity> descriptor) {
if (descriptor == null || descriptor.getEntityClass() == null || descriptor.getId() == null
|| descriptor.getPlugin() == null) {
return;
}
if (descriptor.getPlugin().isEnabled()) {
ConsoleMessages.Warn.Entity.LOAD_TOO_LATE.log(
descriptor.getId(), descriptor.getPlugin());
return;
}
if (CUSTOM_ENTITIES.containsKey(descriptor.getId().toLowerCase())) {
return;
}
CUSTOM_ENTITIES.put(descriptor.getId(), descriptor);
if (descriptor.getStorage() != null) {
EntityStorage.bind(descriptor.getStorage());
}
}
代码示例来源: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
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: GlowstoneMC/Glowstone
if (!plugin.isEnabled() && plugin.getDescription().getLoad() == type) {
List<Permission> perms = plugin.getDescription().getPermissions();
for (Permission perm : perms) {
代码示例来源:origin: webbukkit/dynmap
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);
}
内容来源于网络,如有侵权,请联系作者删除!