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