org.bukkit.event.server.PluginEnableEvent Java Examples

The following examples show how to use org.bukkit.event.server.PluginEnableEvent. 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: PlaceholderApiBridge.java    From BungeePerms with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onPluginEnable(final PluginEnableEvent e)
{
    if (!e.getPlugin().getName().equalsIgnoreCase("PlaceholderAPI"))
    {
        return;
    }
    Runnable r = new Runnable()
    {
        @Override
        public void run()
        {
            provider = new PlaceholderProvider();
            provider.register();
        }
    };
    Bukkit.getScheduler().runTask(BukkitPlugin.getInstance(), r);
}
 
Example #2
Source File: ServerListener.java    From AuthMeReloaded with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onPluginEnable(PluginEnableEvent event) {
    final String pluginName = event.getPlugin().getName();

    // Call the onPluginEnable method in the permissions manager
    permissionsManager.onPluginEnable(pluginName);

    if ("Essentials".equalsIgnoreCase(pluginName)) {
        pluginHookService.tryHookToEssentials();
    } else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) {
        pluginHookService.tryHookToMultiverse();
    } else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) {
        spawnLoader.loadEssentialsSpawn();
    } else if ("CMI".equalsIgnoreCase(pluginName)) {
        pluginHookService.tryHookToCmi();
        spawnLoader.loadCmiSpawn();
    } else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
        protocolLibService.setup();
    }
}
 
Example #3
Source File: EssentialsBridge.java    From BungeePerms with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onPluginEnable(final PluginEnableEvent e)
{
    if (!e.getPlugin().getName().equalsIgnoreCase("Essentials"))
    {
        return;
    }
    Runnable r = new Runnable()
    {
        @Override
        public void run()
        {
            inject(e.getPlugin());
        }
    };
    Bukkit.getScheduler().runTask(BukkitPlugin.getInstance(), r);
}
 
Example #4
Source File: CivilianListener.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onPluginEnable(PluginEnableEvent event) {
    if ("dynmap".equalsIgnoreCase(event.getPlugin().getName())) {
        DynmapHook.dynmapCommonAPI = (DynmapCommonAPI) event.getPlugin();
        DynmapHook.initMarkerSet();
        return;
    }
    if (Constants.PLACEHOLDER_API.equals(event.getPlugin().getName()) &&
            Bukkit.getPluginManager().isPluginEnabled(Constants.PLACEHOLDER_API)) {
        new PlaceHook().register();
        Civs.placeholderAPI = (PlaceholderAPIPlugin) event.getPlugin();
        return;
    }
    if ("MMOItems".equals(event.getPlugin().getName()) &&
            Bukkit.getPluginManager().isPluginEnabled("MMOItems")) {
        Civs.mmoItems = MMOItems.plugin;
        return;
    }
    if ("DiscordSRV".equals(event.getPlugin().getName()) &&
            Bukkit.getPluginManager().isPluginEnabled("DiscordSRV")) {
        Civs.discordSRV = DiscordSRV.getPlugin();
        return;
    }
}
 
Example #5
Source File: BridgeManager.java    From BungeePerms with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onPluginEnable(PluginEnableEvent e)
{
    for (Map.Entry<Class<? extends Bridge>, String> entry : bridgesmap.entrySet())
    {
        try
        {
            Class.forName(entry.getValue());
            for (Bridge b : bridges)
            {
                if (b.getClass().getName().equals(entry.getKey().getName()))
                {
                    throw new Exception();
                }
            }
            createBridge(entry.getKey(), entry.getValue()).enable();
        }
        catch (Exception ex)
        {
        }
    }
}
 
Example #6
Source File: WorldEditBridge.java    From BungeePerms with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onPluginEnable(PluginEnableEvent e)
{
    if (!e.getPlugin().getName().equalsIgnoreCase("worldedit"))
    {
        return;
    }
    inject(e.getPlugin());
}
 
Example #7
Source File: EssentialsBridge.java    From BungeePerms with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void disable()
{
    Plugin plugin = Bukkit.getPluginManager().getPlugin("Essentials");
    if (plugin != null)
    {
        uninject(plugin);
    }

    PluginEnableEvent.getHandlerList().unregister(this);
    PluginDisableEvent.getHandlerList().unregister(this);
}
 
Example #8
Source File: Permission_BungeePerms.java    From BungeePerms with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event)
{
    if (perms == null)
    {
        Plugin p = event.getPlugin();
        if (p.getDescription().getName().equals("BungeePerms"))
        {
            perms = BungeePerms.getInstance();
            log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
        }
    }
}
 
Example #9
Source File: VaultBridge.java    From BungeePerms with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void disable()
{
    Plugin plugin = Bukkit.getPluginManager().getPlugin("Vault");
    if (plugin != null)
    {
        uninject(plugin);
    }

    PluginEnableEvent.getHandlerList().unregister(this);
    PluginDisableEvent.getHandlerList().unregister(this);
}
 
Example #10
Source File: VaultBridge.java    From BungeePerms with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onPluginEnable(PluginEnableEvent e)
{
    if (!e.getPlugin().getName().equalsIgnoreCase("vault"))
    {
        return;
    }
    inject(e.getPlugin());
}
 
Example #11
Source File: Chat_BungeePerms.java    From BungeePerms with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event)
{
    if (perms == null)
    {
        Plugin p = event.getPlugin();
        if (p.getDescription().getName().equals("BungeePerms"))
        {
            perms = BungeePerms.getInstance();
            log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
        }
    }
}
 
Example #12
Source File: WorldEditBridge.java    From BungeePerms with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void disable()
{
    Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldEdit");
    if (plugin != null)
    {
        uninject(plugin);
    }

    PluginEnableEvent.getHandlerList().unregister(this);
    PluginDisableEvent.getHandlerList().unregister(this);
}
 
Example #13
Source File: PlaceholderApiBridge.java    From BungeePerms with GNU General Public License v3.0 5 votes vote down vote up
@Override
   public void disable()
   {
       Plugin plugin = Bukkit.getPluginManager().getPlugin("PlaceholderAPI");
       if (plugin != null)
       {
//           provider.unregister();
       }

       PluginEnableEvent.getHandlerList().unregister(this);
       PluginDisableEvent.getHandlerList().unregister(this);
   }
 
Example #14
Source File: BridgeManager.java    From BungeePerms with GNU General Public License v3.0 5 votes vote down vote up
public void disable()
{
    PluginEnableEvent.getHandlerList().unregister((Listener) this);
    for (Bridge b : bridges)
    {
        b.disable();
    }
}
 
Example #15
Source File: BridgeManager.java    From BungeePerms with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onPluginEnable2(PluginEnableEvent e)
{
    if (e.getPlugin().getName().equalsIgnoreCase("BungeePermsBukkitBridge"))
    {
        Bukkit.getConsoleSender().sendMessage(Color.RED + "WARNING: Please remove BungeePermsBukkitBridge!!! It's now integrated in BungeePerms.");
    }
}
 
Example #16
Source File: ServerListenerTest.java    From AuthMeReloaded with GNU General Public License v3.0 5 votes vote down vote up
private void checkEnableHandling(String pluginName, Runnable verifier) {
    PluginEnableEvent event = mockEventWithPluginName(PluginEnableEvent.class, pluginName);
    serverListener.onPluginEnable(event);
    verifier.run();
    verify(permissionsManager).onPluginEnable(pluginName);
    verifyNoMoreInteractionsAndReset();
}
 
Example #17
Source File: PluginListener.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
void onPluginEnable(PluginEnableEvent event) {
	String pluginName = event.getPlugin().getName();
	if (pluginName.equals(CitizensHandler.PLUGIN_NAME)) {
		CitizensHandler.enable();
	}
}
 
Example #18
Source File: RuntimePluginLoader.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean togglePlugin(Plugin plugin, boolean on) {
  if (plugin.isEnabled() == on) return true;

  try {
    final Field enabled = JavaPlugin.class.getDeclaredField("isEnabled");
    enabled.setAccessible(true);

    if (on) {
      enabled.setBoolean(plugin, true);
      plugin.onEnable();
    } else {
      plugin.onDisable();
      enabled.setBoolean(plugin, false);
    }

    final PluginEvent event = on ? new PluginEnableEvent(plugin) : new PluginDisableEvent(plugin);
    server.getPluginManager().callEvent(event);

    return true;
  } catch (NoSuchFieldException | IllegalAccessException e) {
    server.getLogger().log(Level.SEVERE, "Could not toggle plugin state", e);
  } catch (Throwable t) {
    server
        .getLogger()
        .log(
            Level.WARNING,
            "Could not " + (on ? "load" : "unload") + " plugin " + plugin.getName(),
            t);
  }

  return false;
}
 
Example #19
Source File: PluginHookMgr.java    From SuperVanish with Mozilla Public License 2.0 5 votes vote down vote up
public PluginHookMgr(SuperVanish plugin) {
    this.plugin = plugin;
    plugin.getServer().getPluginManager().registerEvents(this, plugin);
    for (Plugin alreadyEnabledPlugin : Bukkit.getPluginManager().getPlugins())
        if (alreadyEnabledPlugin.isEnabled())
            onPluginEnable(new PluginEnableEvent(alreadyEnabledPlugin));
}
 
Example #20
Source File: CitizensNpcFactory.java    From helper with MIT License 5 votes vote down vote up
public CitizensNpcFactory() {

        // create an enable hook for citizens
        Events.subscribe(PluginEnableEvent.class)
                .filter(e -> e.getPlugin().getName().equals("Citizens"))
                .expireAfter(1) // only call once
                .handler(e -> init());
    }
 
Example #21
Source File: PlayerAnalyticsHook.java    From AntiVPN with MIT License 5 votes vote down vote up
public static void create(Plugin plugin, Plugin plan) {
    if (!plan.isEnabled()) {
        BukkitEvents.subscribe(plugin, PluginEnableEvent.class, EventPriority.MONITOR)
                .expireIf(e -> e.getPlugin().getName().equals("Plan"))
                .filter(e -> e.getPlugin().getName().equals("Plan"))
                .handler(e -> ServiceLocator.register(new PlayerAnalyticsHook()));
        return;
    }
    ServiceLocator.register(new PlayerAnalyticsHook());
}
 
Example #22
Source File: JavaPluginLoader.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
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;

        PluginClassLoader pluginLoader = (PluginClassLoader) jPlugin.getClassLoader();

        if (!loaders.contains(pluginLoader)) {
            loaders.add(pluginLoader);
            server.getLogger().log(Level.WARNING, "Enabled plugin with unregistered PluginClassLoader " + plugin.getDescription().getFullName());
        }

        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);
            server.getPluginManager().disablePlugin(jPlugin, true); // Paper - close Classloader on disable - She's dead jim
            return;
            // Paper end
        }

        // 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));
    }
}
 
Example #23
Source File: BukkitBridge.java    From BungeeTabListPlus with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler
public void onPluginEnable(PluginEnableEvent event) {
    updateDataHooks();
}
 
Example #24
Source File: PluginListener.java    From PerWorldInventory with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onPluginEnable(PluginEnableEvent event) {
    final String name = event.getPlugin().getName();

    permissionManager.onPluginEnable(name);
}
 
Example #25
Source File: HookManager.java    From RandomTeleport with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler
public void onPluginEnable(PluginEnableEvent event) {
    registerHook(event.getPlugin());
}
 
Example #26
Source File: Compatibility.java    From BetonQuest with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPluginEnable(PluginEnableEvent event) {
    hook(event.getPlugin());
}
 
Example #27
Source File: ThreadSafetyListener.java    From LagMonitor with MIT License 4 votes vote down vote up
@EventHandler
public void onPluginEnable(PluginEnableEvent pluginEnableEvent) {
    checkSafety(pluginEnableEvent);
}
 
Example #28
Source File: EventListener.java    From iDisguise with Creative Commons Attribution Share Alike 4.0 International 4 votes vote down vote up
@EventHandler
public void onPluginEnable(PluginEnableEvent event) {
	if(plugin.getConfiguration().MODIFY_SCOREBOARD_PACKETS && StringUtil.equals(event.getPlugin().getName(), "NametagEdit", "ColoredTags")) ScoreboardHooks.setup();
}
 
Example #29
Source File: PluginListener.java    From PerWorldInventory with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onPluginEnable(PluginEnableEvent event) {
    final String name = event.getPlugin().getName();

    permissionManager.onPluginEnable(name);
}
 
Example #30
Source File: ThreadSafetyListener.java    From LagMonitor with MIT License 4 votes vote down vote up
@EventHandler
public void onPluginEnable(PluginEnableEvent pluginEnableEvent) {
    checkSafety(pluginEnableEvent);
}