Search in sources :

Example 91 with PluginManager

use of org.bukkit.plugin.PluginManager in project LuckPerms by lucko.

the class InjectorPermissionMap method inject.

private LPPermissionMap inject() throws Exception {
    Objects.requireNonNull(PERMISSIONS_FIELD, "PERMISSIONS_FIELD");
    PluginManager pluginManager = this.plugin.getBootstrap().getServer().getPluginManager();
    if (!(pluginManager instanceof SimplePluginManager)) {
        this.plugin.getLogger().severe("PluginManager instance is not a 'SimplePluginManager', instead: " + pluginManager.getClass());
        this.plugin.getLogger().severe("Unable to inject LuckPerms Permission map.");
        return null;
    }
    Object map = PERMISSIONS_FIELD.get(pluginManager);
    if (map instanceof LPPermissionMap && ((LPPermissionMap) map).plugin == this.plugin) {
        return null;
    }
    // noinspection unchecked
    Map<String, Permission> castedMap = (Map<String, Permission>) map;
    // make a new map & inject it
    LPPermissionMap newMap = new LPPermissionMap(this.plugin, castedMap);
    PERMISSIONS_FIELD.set(pluginManager, newMap);
    return newMap;
}
Also used : SimplePluginManager(org.bukkit.plugin.SimplePluginManager) PluginManager(org.bukkit.plugin.PluginManager) Permission(org.bukkit.permissions.Permission) SimplePluginManager(org.bukkit.plugin.SimplePluginManager) Map(java.util.Map) HashMap(java.util.HashMap)

Example 92 with PluginManager

use of org.bukkit.plugin.PluginManager in project MagicPlugin by elBukkit.

the class MagicController method finalizeIntegrationPreSpells.

protected void finalizeIntegrationPreSpells() {
    final PluginManager pluginManager = plugin.getServer().getPluginManager();
    // Check for SkillAPI
    Plugin skillAPIPlugin = pluginManager.getPlugin("SkillAPI");
    if (skillAPIPlugin != null && skillAPIEnabled) {
        skillAPIManager = new SkillAPIManager(this, skillAPIPlugin);
        if (skillAPIManager.initialize()) {
            getLogger().info("SkillAPI found, attributes can be used in spell parameters. Classes and skills can be used in requirements.");
            if (useSkillAPIMana) {
                getLogger().info("SkillAPI mana will be used by spells and wands");
            }
        } else {
            skillAPIManager = null;
            getLogger().warning("SkillAPI integration failed");
        }
    } else if (!skillAPIEnabled) {
        skillAPIManager = null;
        getLogger().info("SkillAPI integration disabled");
    }
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) SkillAPIManager(com.elmakers.mine.bukkit.integration.SkillAPIManager) Plugin(org.bukkit.plugin.Plugin)

Example 93 with PluginManager

use of org.bukkit.plugin.PluginManager in project VotingPlugin by Ben12345rocks.

the class Main method registerEvents.

/**
 * Register events.
 */
private void registerEvents() {
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new PlayerJoinEvent(this), this);
    pm.registerEvents(new VotiferEvent(this), this);
    pm.registerEvents(new SignChange(this), this);
    pm.registerEvents(new BlockBreak(this), this);
    pm.registerEvents(new PlayerInteract(this), this);
    pm.registerEvents(new VotingPluginUpdateEvent(this), this);
    plugin.debug("Loaded Events");
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) PlayerJoinEvent(com.Ben12345rocks.VotingPlugin.Events.PlayerJoinEvent) BlockBreak(com.Ben12345rocks.VotingPlugin.Events.BlockBreak) VotingPluginUpdateEvent(com.Ben12345rocks.VotingPlugin.Events.VotingPluginUpdateEvent) VotiferEvent(com.Ben12345rocks.VotingPlugin.Events.VotiferEvent) PlayerInteract(com.Ben12345rocks.VotingPlugin.Events.PlayerInteract) SignChange(com.Ben12345rocks.VotingPlugin.Events.SignChange)

Example 94 with PluginManager

use of org.bukkit.plugin.PluginManager in project VotingPlugin by Ben12345rocks.

the class VotingPluginMain method registerEvents.

/**
 * Register events.
 */
private void registerEvents() {
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new PlayerJoinEvent(this), this);
    if (votifierLoaded) {
        pm.registerEvents(new VotiferEvent(this), this);
    }
    pm.registerEvents(new PlayerVoteListener(this), this);
    pm.registerEvents(new SignChange(this), this);
    pm.registerEvents(new BlockBreak(this), this);
    if (!plugin.getConfigFile().isDisableInteractEvent()) {
        pm.registerEvents(new PlayerInteract(this), this);
    }
    pm.registerEvents(new VotingPluginUpdateEvent(this), this);
    /*
		 * if (!NMSManager.getInstance().isVersion("1.12")) { pm.registerEvents(new
		 * PlayerCommandSendListener(this), this); }
		 */
    coolDownCheck = new CoolDownCheck(this);
    pm.registerEvents(coolDownCheck, this);
    plugin.debug("Loaded Events");
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) PlayerJoinEvent(com.bencodez.votingplugin.listeners.PlayerJoinEvent) BlockBreak(com.bencodez.votingplugin.listeners.BlockBreak) PlayerVoteListener(com.bencodez.votingplugin.listeners.PlayerVoteListener) VotingPluginUpdateEvent(com.bencodez.votingplugin.listeners.VotingPluginUpdateEvent) VotiferEvent(com.bencodez.votingplugin.listeners.VotiferEvent) PlayerInteract(com.bencodez.votingplugin.listeners.PlayerInteract) SignChange(com.bencodez.votingplugin.listeners.SignChange) CoolDownCheck(com.bencodez.votingplugin.cooldown.CoolDownCheck)

Example 95 with PluginManager

use of org.bukkit.plugin.PluginManager in project TotalFreedomMod by TotalFreedom.

the class Command_plugincontrol method run.

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
    if (args.length == 0 || args.length > 2) {
        return false;
    }
    final PluginManager pm = server.getPluginManager();
    if (args.length == 1) {
        if (args[0].equalsIgnoreCase("list")) {
            for (Plugin serverPlugin : pm.getPlugins()) {
                final String version = serverPlugin.getDescription().getVersion();
                msg(ChatColor.GRAY + "- " + (serverPlugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED) + serverPlugin.getName() + ChatColor.GOLD + (version != null && !version.isEmpty() ? " v" + version : "") + " by " + StringUtils.join(serverPlugin.getDescription().getAuthors(), ", "));
            }
            return true;
        }
        return false;
    }
    if ("enable".equals(args[0])) {
        final Plugin target = getPlugin(args[1]);
        if (target == null) {
            msg("Plugin not found!");
            return true;
        }
        if (target.isEnabled()) {
            msg("Plugin is already enabled.");
            return true;
        }
        pm.enablePlugin(target);
        if (!pm.isPluginEnabled(target)) {
            msg("Error enabling plugin " + target.getName());
            return true;
        }
        msg(target.getName() + " is now enabled.");
        return true;
    }
    if ("disable".equals(args[0])) {
        final Plugin target = getPlugin(args[1]);
        if (target == null) {
            msg("Plugin not found!");
            return true;
        }
        if (!target.isEnabled()) {
            msg("Plugin is already disabled.");
            return true;
        }
        if (target.getName().equals(plugin.getName())) {
            msg("You cannot disable " + plugin.getName());
            return true;
        }
        pm.disablePlugin(target);
        if (pm.isPluginEnabled(target)) {
            msg("Error disabling plugin " + target.getName());
            return true;
        }
        msg(target.getName() + " is now disabled.");
        return true;
    }
    if ("reload".equals(args[0])) {
        final Plugin target = getPlugin(args[1]);
        if (target == null) {
            msg("Plugin not found!");
            return true;
        }
        if (target.getName().equals(plugin.getName())) {
            msg("Use /tfm reload to reload instead.");
            return true;
        }
        pm.disablePlugin(target);
        pm.enablePlugin(target);
        msg(target.getName() + " reloaded.");
        return true;
    }
    return false;
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) Plugin(org.bukkit.plugin.Plugin)

Aggregations

PluginManager (org.bukkit.plugin.PluginManager)148 Plugin (org.bukkit.plugin.Plugin)33 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)20 Permission (org.bukkit.permissions.Permission)16 MetricsWrapper (com.earth2me.essentials.metrics.MetricsWrapper)14 Player (org.bukkit.entity.Player)14 Test (org.junit.Test)13 SimplePluginManager (org.bukkit.plugin.SimplePluginManager)12 Map (java.util.Map)11 File (java.io.File)9 IOException (java.io.IOException)9 World (org.bukkit.World)9 PluginCommand (org.bukkit.command.PluginCommand)9 Command (org.bukkit.command.Command)8 Listener (org.bukkit.event.Listener)8 PluginDescriptionFile (org.bukkit.plugin.PluginDescriptionFile)8 HashMap (java.util.HashMap)7 EventHandler (org.bukkit.event.EventHandler)7 ArrayList (java.util.ArrayList)6 Bukkit (org.bukkit.Bukkit)6