org.bukkit.event.server.ServiceRegisterEvent Java Examples

The following examples show how to use org.bukkit.event.server.ServiceRegisterEvent. 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: SimpleServicesManager.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Register a provider of a service.
 *
 * @param <T>      Provider
 * @param service  service class
 * @param provider provider to register
 * @param plugin   plugin with the provider
 * @param priority priority of the provider
 */
public <T> void register(Class<T> service, T provider, Plugin plugin, ServicePriority priority) {
    RegisteredServiceProvider<T> registeredProvider = null;
    synchronized (providers) {
        List<RegisteredServiceProvider<?>> registered = providers.get(service);
        if (registered == null) {
            registered = new ArrayList<RegisteredServiceProvider<?>>();
            providers.put(service, registered);
        }

        registeredProvider = new RegisteredServiceProvider<T>(service, provider, priority, plugin);

        // Insert the provider into the collection, much more efficient big O than sort
        int position = Collections.binarySearch(registered, registeredProvider);
        if (position < 0) {
            registered.add(-(position + 1), registeredProvider);
        } else {
            registered.add(position, registeredProvider);
        }

    }
    Bukkit.getServer().getPluginManager().callEvent(new ServiceRegisterEvent(registeredProvider));
}
 
Example #2
Source File: Economy_Vault.java    From QuickShop-Reremake with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onServiceRegister(ServiceRegisterEvent event) {
    if (!(event.getProvider() instanceof net.milkbowl.vault.economy.Economy)) {
        return;
    }
    setupEconomy();
}
 
Example #3
Source File: ServiceCallback.java    From helper with MIT License 5 votes vote down vote up
private ServiceCallback(Class<T> serviceClass) {
    this.serviceClass = serviceClass;
    refresh();

    // listen for service updates
    this.listener = Events.merge(ServiceEvent.class, ServiceRegisterEvent.class, ServiceUnregisterEvent.class)
            .filter(e -> e.getProvider() != null && e.getProvider().getService().equals(serviceClass))
            .handler(e -> refresh());
}
 
Example #4
Source File: VaultPermissions.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
@SuppressWarnings("unused")
public void onPermissionRegister(ServiceRegisterEvent event) {
    if (event.getProvider().getProvider() instanceof Permission) {
        setupPermission().ifPresent((permission) -> this.permission = permission);
    }
}
 
Example #5
Source File: VaultEconomy.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
@SuppressWarnings("unused")
public void onEconomyRegister(ServiceRegisterEvent event) {
    if (event.getProvider().getProvider() instanceof Economy) {
        setupEconomy().ifPresent((economy) -> this.economy = economy);
    }
}