Search in sources :

Example 16 with PluginManager

use of org.bukkit.plugin.PluginManager in project HawkEye by oliverwoodings.

the class HawkEye method onEnable.

/**
	 * Starts up HawkEye initiation process
	 */
@Override
public void onEnable() {
    //Set up config and permissions
    PluginManager pm = getServer().getPluginManager();
    server = getServer();
    name = this.getDescription().getName();
    version = this.getDescription().getVersion();
    Util.info("Starting HawkEye " + version + " initiation process...");
    //Load config and permissions
    config = new Config(this);
    new Permission(this);
    versionCheck();
    new SessionManager();
    //Initiate database connection
    try {
        new DataManager(this);
    } catch (Exception e) {
        Util.severe("Error initiating HawkEye database connection, disabling plugin");
        pm.disablePlugin(this);
        return;
    }
    checkDependencies(pm);
    containerManager = new ContainerAccessManager();
    registerListeners(pm);
    registerCommands();
    Util.info("Version " + version + " enabled!");
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) Config(uk.co.oliwali.HawkEye.util.Config) Permission(uk.co.oliwali.HawkEye.util.Permission) DataManager(uk.co.oliwali.HawkEye.database.DataManager)

Example 17 with PluginManager

use of org.bukkit.plugin.PluginManager in project Bukkit by Bukkit.

the class Permission method addParent.

/**
     * Adds this permission to the specified parent permission.
     * <p>
     * If the parent permission does not exist, it will be created and
     * registered.
     *
     * @param name Name of the parent permission
     * @param value The value to set this permission to
     * @return Parent permission it created or loaded
     */
public Permission addParent(String name, boolean value) {
    PluginManager pm = Bukkit.getServer().getPluginManager();
    String lname = name.toLowerCase();
    Permission perm = pm.getPermission(lname);
    if (perm == null) {
        perm = new Permission(lname);
        pm.addPermission(perm);
    }
    addParent(perm, value);
    return perm;
}
Also used : PluginManager(org.bukkit.plugin.PluginManager)

Example 18 with PluginManager

use of org.bukkit.plugin.PluginManager in project Towny by ElgarL.

the class Towny method registerEvents.

private void registerEvents() {
    final PluginManager pluginManager = getServer().getPluginManager();
    if (!isError()) {
        // Have War Events get launched before regular events.
        pluginManager.registerEvents(townyWarBlockListener, this);
        pluginManager.registerEvents(townyWarEntityListener, this);
        // Manage player deaths and death payments
        pluginManager.registerEvents(entityMonitorListener, this);
        pluginManager.registerEvents(vehicleListener, this);
        pluginManager.registerEvents(weatherListener, this);
        pluginManager.registerEvents(townyWarCustomListener, this);
        pluginManager.registerEvents(customListener, this);
        pluginManager.registerEvents(worldListener, this);
        // Only register a physics listener if we need to.
        if (TownySettings.getRegenDelay() > 0)
            pluginManager.registerEvents(physicsListener, this);
    }
    // Always register these events.
    pluginManager.registerEvents(playerListener, this);
    pluginManager.registerEvents(blockListener, this);
    pluginManager.registerEvents(entityListener, this);
}
Also used : PluginManager(org.bukkit.plugin.PluginManager)

Example 19 with PluginManager

use of org.bukkit.plugin.PluginManager in project AuthMeReloaded by AuthMe.

the class AuthMe method registerEventListeners.

/**
     * Registers all event listeners.
     *
     * @param injector the injector
     */
void registerEventListeners(Injector injector) {
    // Get the plugin manager instance
    PluginManager pluginManager = getServer().getPluginManager();
    // Register event listeners
    pluginManager.registerEvents(injector.getSingleton(PlayerListener.class), this);
    pluginManager.registerEvents(injector.getSingleton(BlockListener.class), this);
    pluginManager.registerEvents(injector.getSingleton(EntityListener.class), this);
    pluginManager.registerEvents(injector.getSingleton(ServerListener.class), this);
    // Try to register 1.6 player listeners
    if (isClassLoaded("org.bukkit.event.player.PlayerEditBookEvent")) {
        pluginManager.registerEvents(injector.getSingleton(PlayerListener16.class), this);
    }
    // Try to register 1.8 player listeners
    if (isClassLoaded("org.bukkit.event.player.PlayerInteractAtEntityEvent")) {
        pluginManager.registerEvents(injector.getSingleton(PlayerListener18.class), this);
    }
    // Try to register 1.9 player listeners
    if (isClassLoaded("org.bukkit.event.player.PlayerSwapHandItemsEvent")) {
        pluginManager.registerEvents(injector.getSingleton(PlayerListener19.class), this);
    }
    // Register listener for 1.11 events if available
    if (isClassLoaded("org.bukkit.event.entity.EntityAirChangeEvent")) {
        pluginManager.registerEvents(injector.getSingleton(PlayerListener111.class), this);
    }
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) EntityListener(fr.xephi.authme.listener.EntityListener) PlayerListener111(fr.xephi.authme.listener.PlayerListener111) PlayerListener16(fr.xephi.authme.listener.PlayerListener16) PlayerListener19(fr.xephi.authme.listener.PlayerListener19) PlayerListener18(fr.xephi.authme.listener.PlayerListener18) BlockListener(fr.xephi.authme.listener.BlockListener) PlayerListener(fr.xephi.authme.listener.PlayerListener) ServerListener(fr.xephi.authme.listener.ServerListener)

Example 20 with PluginManager

use of org.bukkit.plugin.PluginManager in project AuthMeReloaded by AuthMe.

the class PluginHookServiceTest method shouldReturnEssentialsDataFolder.

@Test
public void shouldReturnEssentialsDataFolder() {
    // given
    Essentials ess = mock(Essentials.class);
    File essDataFolder = new File("test/data-folder");
    // Need to set the data folder with reflections because getDataFolder() is declared final
    ReflectionTestUtils.setField(JavaPlugin.class, ess, "dataFolder", essDataFolder);
    PluginManager pluginManager = mock(PluginManager.class);
    setPluginAvailable(pluginManager, ESSENTIALS, ess);
    PluginHookService pluginHookService = new PluginHookService(pluginManager);
    // when
    File dataFolder = pluginHookService.getEssentialsDataFolder();
    // then
    assertThat(dataFolder, equalTo(essDataFolder));
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) Essentials(com.earth2me.essentials.Essentials) File(java.io.File) Test(org.junit.Test)

Aggregations

PluginManager (org.bukkit.plugin.PluginManager)30 Test (org.junit.Test)12 World (org.bukkit.World)5 Plugin (org.bukkit.plugin.Plugin)5 MultiverseWorld (com.onarandombox.MultiverseCore.api.MultiverseWorld)3 Location (org.bukkit.Location)3 Listener (org.bukkit.event.Listener)3 Essentials (com.earth2me.essentials.Essentials)2 MultiverseCore (com.onarandombox.MultiverseCore.MultiverseCore)2 MVWorldManager (com.onarandombox.MultiverseCore.api.MVWorldManager)2 File (java.io.File)2 Method (java.lang.reflect.Method)2 IEssentials (net.ess3.api.IEssentials)2 Player (org.bukkit.entity.Player)2 Event (org.bukkit.event.Event)2 EventException (org.bukkit.event.EventException)2 EventHandler (org.bukkit.event.EventHandler)2 PlayerJoinEvent (org.bukkit.event.player.PlayerJoinEvent)2 EventExecutor (org.bukkit.plugin.EventExecutor)2 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)2