Java Code Examples for cn.nukkit.plugin.Plugin#isEnabled()

The following examples show how to use cn.nukkit.plugin.Plugin#isEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PermissibleBase.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, Boolean value) {
    if (plugin == null) {
        throw new PluginException("Plugin cannot be null");
    } else if (!plugin.isEnabled()) {
        throw new PluginException("Plugin " + plugin.getDescription().getName() + " is disabled");
    }

    PermissionAttachment result = new PermissionAttachment(plugin, this.parent != null ? this.parent : this);
    this.attachments.add(result);
    if (name != null && value != null) {
        result.setPermission(name, value);
    }
    this.recalculatePermissions();

    return result;
}
 
Example 2
Source File: StandardMessenger.java    From SynapseAPI with GNU General Public License v3.0 6 votes vote down vote up
public static void validatePluginMessage(Messenger messenger, Plugin source, String channel, byte[] message) {
    if (messenger == null) {
        throw new IllegalArgumentException("Messenger cannot be null");
    }
    if (source == null) {
        throw new IllegalArgumentException("Plugin source cannot be null");
    }
    if (!source.isEnabled()) {
        throw new IllegalArgumentException("Plugin must be enabled to send messages");
    }
    if (message == null) {
        throw new IllegalArgumentException("Message cannot be null");
    }
    if (!messenger.isOutgoingChannelRegistered(source, channel)) {
        throw new ChannelNotRegisteredException(channel);
    }
    if (message.length > 32766) {
        throw new MessageTooLargeException(message);
    }
    StandardMessenger.validateChannel(channel);
}
 
Example 3
Source File: PermissionAttachment.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
public PermissionAttachment(Plugin plugin, Permissible permissible) {
    if (!plugin.isEnabled()) {
        throw new PluginException("Plugin " + plugin.getDescription().getName() + " is disabled");
    }
    this.permissible = permissible;
    this.plugin = plugin;
}
 
Example 4
Source File: Server.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
public void enablePlugins(PluginLoadOrder type) {
    for (Plugin plugin : new ArrayList<>(this.pluginManager.getPlugins().values())) {
        if (!plugin.isEnabled() && type == plugin.getDescription().getOrder()) {
            this.enablePlugin(plugin);
        }
    }

    if (type == PluginLoadOrder.POSTWORLD) {
        this.commandMap.registerServerAliases();
        DefaultPermissions.registerCorePermissions();
    }
}
 
Example 5
Source File: PluginsCommand.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
private void sendPluginList(CommandSender sender) {
    String list = "";
    Map<String, Plugin> plugins = sender.getServer().getPluginManager().getPlugins();
    for (Plugin plugin : plugins.values()) {
        if (list.length() > 0) {
            list += TextFormat.WHITE + ", ";
        }
        list += plugin.isEnabled() ? TextFormat.GREEN : TextFormat.RED;
        list += plugin.getDescription().getFullName();
    }

    sender.sendMessage(new TranslationContainer("nukkit.command.plugins.success", new String[]{String.valueOf(plugins.size()), list}));
}
 
Example 6
Source File: PermissionAttachment.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public PermissionAttachment(Plugin plugin, Permissible permissible) {
    if (!plugin.isEnabled()) {
        throw new PluginException("Plugin " + plugin.getDescription().getName() + " is disabled");
    }
    this.permissible = permissible;
    this.plugin = plugin;
}
 
Example 7
Source File: PermissibleBase.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, Boolean value) {
    if (!plugin.isEnabled()) {
        throw new PluginException("Plugin " + plugin.getDescription().getName() + " is disabled");
    }

    PermissionAttachment result = new PermissionAttachment(plugin, this.parent != null ? this.parent : this);
    this.attachments.add(result);
    if (name != null && value != null) {
        result.setPermission(name, value);
    }
    this.recalculatePermissions();

    return result;
}
 
Example 8
Source File: Server.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void enablePlugins(PluginLoadOrder type) {
    for (Plugin plugin : new ArrayList<>(this.pluginManager.getPlugins().values())) {
        if (!plugin.isEnabled() && type == plugin.getDescription().getOrder()) {
            this.enablePlugin(plugin);
        }
    }

    if (type == PluginLoadOrder.POSTWORLD) {
        this.commandMap.registerServerAliases();
        DefaultPermissions.registerCorePermissions();
    }
}
 
Example 9
Source File: PluginsCommand.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private void sendPluginList(CommandSender sender) {
    String list = "";
    Map<String, Plugin> plugins = sender.getServer().getPluginManager().getPlugins();
    for (Plugin plugin : plugins.values()) {
        if (list.length() > 0) {
            list += TextFormat.WHITE + ", ";
        }
        list += plugin.isEnabled() ? TextFormat.GREEN : TextFormat.RED;
        list += plugin.getDescription().getFullName();
    }

    sender.sendMessage(new TranslationContainer("nukkit.command.plugins.success", String.valueOf(plugins.size()), list));
}
 
Example 10
Source File: PermissionAttachment.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public PermissionAttachment(Plugin plugin, Permissible permissible) {
    if (!plugin.isEnabled()) {
        throw new PluginException("Plugin " + plugin.getDescription().getName() + " is disabled");
    }
    this.permissible = permissible;
    this.plugin = plugin;
}
 
Example 11
Source File: PermissibleBase.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, Boolean value) {
    if (!plugin.isEnabled()) {
        throw new PluginException("Plugin " + plugin.getDescription().getName() + " is disabled");
    }

    PermissionAttachment result = new PermissionAttachment(plugin, this.parent != null ? this.parent : this);
    this.attachments.add(result);
    if (name != null && value != null) {
        result.setPermission(name, value);
    }
    this.recalculatePermissions();

    return result;
}
 
Example 12
Source File: Server.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void enablePlugins(PluginLoadOrder type) {
    for (Plugin plugin : new ArrayList<>(this.pluginManager.getPlugins().values())) {
        if (!plugin.isEnabled() && type == plugin.getDescription().getOrder()) {
            this.enablePlugin(plugin);
        }
    }

    if (type == PluginLoadOrder.POSTWORLD) {
        this.commandMap.registerServerAliases();
        DefaultPermissions.registerCorePermissions();
    }
}
 
Example 13
Source File: PluginsCommand.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private void sendPluginList(CommandSender sender) {
    String list = "";
    Map<String, Plugin> plugins = sender.getServer().getPluginManager().getPlugins();
    for (Plugin plugin : plugins.values()) {
        if (list.length() > 0) {
            list += TextFormat.WHITE + ", ";
        }
        list += plugin.isEnabled() ? TextFormat.GREEN : TextFormat.RED;
        list += plugin.getDescription().getFullName();
    }

    sender.sendMessage(new TranslationContainer("nukkit.command.plugins.success", new String[]{String.valueOf(plugins.size()), list}));
}