org.bukkit.plugin.ServicePriority Java Examples

The following examples show how to use org.bukkit.plugin.ServicePriority. 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: VaultHookManager.java    From LuckPerms with MIT License 6 votes vote down vote up
/**
 * Registers the LuckPerms implementation of {@link Permission} and {@link Chat} with
 * the service manager.
 */
public void hook() {
    try {
        if (this.permission == null) {
            this.permission = new LuckPermsVaultPermission(this.plugin);
        }

        if (this.chat == null) {
            this.chat = new LuckPermsVaultChat(this.plugin, this.permission);
        }

        final ServicesManager sm = this.plugin.getBootstrap().getServer().getServicesManager();
        sm.register(Permission.class, this.permission, this.plugin.getBootstrap(), ServicePriority.High);
        sm.register(Chat.class, this.chat, this.plugin.getBootstrap(), ServicePriority.High);

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #2
Source File: VaultInvoker.java    From CloudNet with Apache License 2.0 5 votes vote down vote up
public static void invoke() {
    ServicesManager servicesManager = BukkitBootstrap.getPlugin(BukkitBootstrap.class).getServer().getServicesManager();

    Permission permission = new VaultPermissionImpl();

    servicesManager.register(Permission.class, permission, BukkitBootstrap.getPlugin(BukkitBootstrap.class), ServicePriority.Highest);
    servicesManager.register(Chat.class,
                             new VaultChatImpl(permission),
                             BukkitBootstrap.getPlugin(BukkitBootstrap.class),
                             ServicePriority.Highest);
}
 
Example #3
Source File: TServiceLoader.java    From TabooLib with MIT License 5 votes vote down vote up
@Override
public void preLoad(Plugin plugin, Class pluginClass) {
    if (pluginClass.isAnnotationPresent(TService.class)) {
        TService service = (TService) pluginClass.getAnnotation(TService.class);
        try {
            Bukkit.getServicesManager().register(pluginClass, service.value().newInstance(), plugin, ServicePriority.Normal);
            TabooLibAPI.debug("Service " + pluginClass.getSimpleName() + " registered. (" + plugin.getName() + ")");
        } catch (Exception e) {
            TLogger.getGlobalLogger().warn("TService load Failed: " + pluginClass.getName());
            e.printStackTrace();
        }
    }
}
 
Example #4
Source File: ExtendedJavaPlugin.java    From helper with MIT License 4 votes vote down vote up
@Nonnull
@Override
public <T> T provideService(@Nonnull Class<T> clazz, @Nonnull T instance, @Nonnull ServicePriority priority) {
    return Services.provide(clazz, instance, this, priority);
}
 
Example #5
Source File: ExtendedJavaPlugin.java    From helper with MIT License 4 votes vote down vote up
@Nonnull
@Override
public <T> T provideService(@Nonnull Class<T> clazz, @Nonnull T instance) {
    return provideService(clazz, instance, ServicePriority.Normal);
}
 
Example #6
Source File: LPBukkitPlugin.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
protected void registerApiOnPlatform(LuckPerms api) {
    this.bootstrap.getServer().getServicesManager().register(LuckPerms.class, api, this.bootstrap, ServicePriority.Normal);
}
 
Example #7
Source File: VaultHook.java    From SaneEconomy with GNU General Public License v3.0 4 votes vote down vote up
public void hook() {
    Bukkit.getServicesManager().register(Economy.class, this.provider, this.plugin, ServicePriority.Normal);
}
 
Example #8
Source File: CauldronPluginInterface.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public void install() {
    Cauldron.setInterface(this);
    Bukkit.getServicesManager().register(CauldronApi.class, this, null, ServicePriority.Highest);
}
 
Example #9
Source File: VaultBridge.java    From BungeePerms with GNU General Public License v3.0 4 votes vote down vote up
public void inject(Plugin plugin)
    {
        BungeePerms.getLogger().info("Injection of Bungeeperms into Vault");
        try
        {
            Vault v = (Vault) plugin;

            if (!v.isEnabled())
            {
                return;
            }

            //inject BungeePerms permissions
//            Method m = v.getClass().getDeclaredMethod("hookPermission", String.class, Class.class, ServicePriority.class, String[].class);
//            m.setAccessible(true);
//            m.invoke(v, "BungeePerms", Permission_BungeePerms.class, ServicePriority.Normal, new String[]
//             {
//                 "net.alpenblock.bungeeperms.platform.bukkit.BukkitPlugin"
//            });
//            
//            Field f = v.getClass().getDeclaredField("perms");
//            f.setAccessible(true);
//            f.set(v, Bukkit.getServicesManager().getRegistration(Permission.class).getProvider());
            
            Bukkit.getServer().getServicesManager().register(Permission.class, new Permission_BungeePerms(v), BukkitPlugin.getInstance(), ServicePriority.Highest);

            //inject BungeePerms chat
//            m = v.getClass().getDeclaredMethod("hookChat", String.class, Class.class, ServicePriority.class, String[].class);
//            m.setAccessible(true);
//            m.invoke(v, "BungeePerms", Chat_BungeePerms.class, ServicePriority.Normal, new String[]
//             {
//                 "net.alpenblock.bungeeperms.platform.bukkit.BukkitPlugin"
//            });
            
            Bukkit.getServer().getServicesManager().register(Chat.class, new Chat_BungeePerms(v, new Permission_BungeePerms(v)), BukkitPlugin.getInstance(), ServicePriority.Highest);
        }
        catch (Exception ex)
        {
            BungeePerms.getInstance().getDebug().log(ex);
        }
    }
 
Example #10
Source File: Services.java    From helper with MIT License 3 votes vote down vote up
/**
 * Provides a service.
 *
 * @param clazz the service class
 * @param instance the service instance
 * @param plugin the plugin to register the service to
 * @param priority the priority to register the service instance at
 * @param <T> the service class type
 * @return the same service instance
 */
@Nonnull
public static <T> T provide(@Nonnull Class<T> clazz, @Nonnull T instance, @Nonnull Plugin plugin, @Nonnull ServicePriority priority) {
    Objects.requireNonNull(clazz, "clazz");
    Objects.requireNonNull(instance, "instance");
    Objects.requireNonNull(plugin, "plugin");
    Objects.requireNonNull(priority, "priority");
    Bukkit.getServicesManager().register(clazz, instance, plugin, priority);
    return instance;
}
 
Example #11
Source File: HelperPlugin.java    From helper with MIT License 2 votes vote down vote up
/**
 * Provides a service to the ServiceManager, bound to this plugin
 *
 * @param clazz the service class
 * @param instance the instance
 * @param priority the priority to register the service at
 * @param <T> the service class type
 * @return the instance
 */
@Nonnull
<T> T provideService(@Nonnull Class<T> clazz, @Nonnull T instance, @Nonnull ServicePriority priority);
 
Example #12
Source File: Services.java    From helper with MIT License 2 votes vote down vote up
/**
 * Provides a service.
 *
 * @param clazz the service class
 * @param instance the service instance
 * @param priority the priority to register the service instance at
 * @param <T> the service class type
 * @return the same service instance
 */
@Nonnull
public static <T> T provide(@Nonnull Class<T> clazz, @Nonnull T instance, @Nonnull ServicePriority priority) {
    return provide(clazz, instance, LoaderUtils.getPlugin(), priority);
}
 
Example #13
Source File: Services.java    From helper with MIT License 2 votes vote down vote up
/**
 * Provides a service.
 *
 * @param clazz the service class
 * @param instance the service instance
 * @param <T> the service class type
 * @return the same service instance
 */
@Nonnull
public static <T> T provide(@Nonnull Class<T> clazz, @Nonnull T instance) {
    return provide(clazz, instance, ServicePriority.Normal);
}