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