/** * Registers the LuckPerms implementation of {@link Permission} and {@link Chat} with * the service manager. * * @param plugin the plugin */ public void hook(LPBukkitPlugin plugin) { try { if (this.permissionHook == null) { this.permissionHook = new VaultPermissionHook(plugin); } if (this.chatHook == null) { this.chatHook = new VaultChatHook(plugin, this.permissionHook); } final ServicesManager sm = plugin.getServer().getServicesManager(); sm.register(Permission.class, this.permissionHook, plugin, ServicePriority.High); sm.register(Chat.class, this.chatHook, plugin, ServicePriority.High); } catch (Exception e) { e.printStackTrace(); } }
@Override public void onLoad() { pool = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>()); manager = new Manager(this); getServer().getServicesManager().register( MyEconomy.class, manager, this, ServicePriority.Normal ); Plugin vault = getServer().getPluginManager().getPlugin("Vault"); if (vault != null) { getServer().getServicesManager().register( Economy.class, new VaultEconomy(this, manager), this, ServicePriority.Highest ); getLogger().info("Hook to vault!!!"); } }
@Override public void onEnable() { placeholderManager = new BukkitPlaceholderManager(); pluginListener = new PluginListener(this); Plugin vaultPlugin = getServer().getPluginManager().getPlugin("Vault"); Arrays.stream(VaultPlaceholder.values()).filter(placeholder -> placeholder.isRegisterable(getServer())).forEach(placeholder -> { // Register using Vault so that when it is disabled the placeholders are unregistered placeholderManager.registerMapping(vaultPlugin, placeholder); }); Arrays.stream(BukkitPlaceholder.values()).forEach(placeholder -> placeholderManager.registerMapping(this, placeholder)); getServer().getServicesManager().register(BukkitPlaceholderManager.class, placeholderManager, this, ServicePriority.Highest); getServer().getServicesManager().register(PlaceholderManager.class, placeholderManager, this, ServicePriority.Highest); getServer().getPluginManager().registerEvents(pluginListener, this); }
@Override public void onEnable() { super.onEnable(); ViewItPlugin.instance = this; if (!getDataFolder().exists()) { getDataFolder().mkdir(); } saveDefaultConfig(); reloadConfig(); replacers = new Replacers(); scoreboardService = new SimpleScoreboardService(this); Bukkit.getServicesManager().register(ScoreboardService.class, scoreboardService, this, ServicePriority.Normal); if (getConfig().getBoolean("track-players-on-join")) { Bukkit.getOnlinePlayers().forEach(scoreboardService::addPlayer); } configElements = new ConfigElements(this); commands = new CommandsManager(); }
@Override public void init(Plugin plugin) { ProtocolLibrary.getProtocolManager().addPacketListener( new PacketAdapter(PacketAdapter .params(plugin, PacketType.Play.Server.SET_SLOT, PacketType.Play.Server.WINDOW_ITEMS) .serverSide().listenerPriority(ListenerPriority.HIGH)) { @Override public void onPacketSending(PacketEvent event) { if (event.getPacketType().equals(PacketType.Play.Server.SET_SLOT)) { addGlow(new ItemStack[] { event.getPacket().getItemModifier().read(0) }); } else { addGlow(event.getPacket().getItemArrayModifier().read(0)); } } }); _signManager = new ProtocolLibSignGUI(plugin); Bukkit.getServicesManager().register(SignGUI.class, _signManager, plugin, ServicePriority.Highest); }
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); }
@Nonnull @Override public <T> T provideService(@Nonnull Class<T> clazz, @Nonnull T instance) { Preconditions.checkNotNull(clazz, "clazz"); Preconditions.checkNotNull(instance, "instance"); return provideService(clazz, instance, ServicePriority.Normal); }
@Override public void onEnable() { serviceManager = getServer().getServicesManager(); motdConfig = loadConfig(); motdService = new BukkitMotdService(new SimpleMotdProvider(motdConfig)); serviceManager.register(MotdService.class, motdService, this, ServicePriority.Normal); getServer().getPluginManager().registerEvents(new MotdListener(motdService), this); // todo configurable priority }
@Override public void onLoad() { Config config = loadConfig(); List<RemoteRepository> remoteRepositories = config.getRepositories(); LocalRepository localRepository = createLocalRepository(config); RepositorySystem repositorySystem = createRepositorySystem(); libraryManager = new BukkitLibraryManager(repositorySystem, localRepository, () -> remoteRepositories, getLogger()); Bukkit.getServicesManager().register(LibraryManager.class, libraryManager, this, ServicePriority.Normal); }
public ImmutableList<CombatTagPlugin> getCombatTagPlugins() { if (getServer().getServicesManager().getRegistrations(this).isEmpty()) { getServer().getServicesManager().register(CombatTagPlugin.class, new CombatTagLegacySupport(), this, ServicePriority.Low); getServer().getServicesManager().register(CombatTagPlugin.class, new PvPManagerSupport(), this, ServicePriority.Normal); getServer().getServicesManager().register(CombatTagPlugin.class, new CombatTagPlusSupport(), this, ServicePriority.Normal); } return getServer().getServicesManager().getRegistrations(CombatTagPlugin.class).stream() .map(RegisteredServiceProvider::getProvider) .filter(CombatTagPlugin::isInstalled) // Only return installed plugins :) .collect(Utils.immutableListCollector()); }
/** * {@inheritDoc} */ @Override public void onEnable () { super.onEnable (); Grid grid = new Grid (this); this.getServer ().getMessenger ().registerOutgoingPluginChannel (this, Grid.CHANNEL_NAME); this.getServer ().getMessenger ().registerIncomingPluginChannel (this, Grid.CHANNEL_NAME, grid); this.getServer ().getServicesManager ().register (IGrid.class, grid, this, ServicePriority.Normal); }
private void setupEconomy() { if (getServer().getPluginManager().getPlugin("Vault") != null) { final ServicesManager sm = getServer().getServicesManager(); sm.register(Economy.class, new UCEconomy(), this, ServicePriority.Highest); System.out.println("Universal Coins: Registered Vault interface."); } else { System.out.println("Universal Coins: Vault not detected. Initialization failed."); } }
/** * Register Gringotts as economy provider for vault. */ private void registerEconomy() { if (DEP.vault.exists()) { final ServicesManager sm = getServer().getServicesManager(); sm.register(Economy.class, new VaultConnector(), this, ServicePriority.Highest); log.info("Registered Vault interface."); } else { log.info("Vault not found. Other plugins may not be able to access Gringotts accounts."); } }
public void hook(PowerfulPerms plugin) { Plugin vault = Bukkit.getPluginManager().getPlugin("Vault"); PowerfulPerms_Vault_Permissions vaultPermsHook = new PowerfulPerms_Vault_Permissions(plugin); PowerfulPerms_Vault_Chat vaultChatHook = new PowerfulPerms_Vault_Chat(vaultPermsHook, plugin); Bukkit.getServicesManager().register(net.milkbowl.vault.permission.Permission.class, vaultPermsHook, vault, ServicePriority.High); Bukkit.getServicesManager().register(net.milkbowl.vault.chat.Chat.class, vaultChatHook, vault, ServicePriority.High); }
@Override public void onEnable() { instance = this; Database db = setupDatabase(); if (db == null) { logWarning("Could not connect to a database. Disabling."); for (Player player : Bukkit.getOnlinePlayers()) { player.kickPlayer("Error with Database. Kicking for safety."); } Bukkit.setWhitelist(true); Bukkit.reloadWhitelist(); return; } coreData = new CoreData(this, db); coreMethods = new CoreMethods(this); coreErrors = new CoreErrors(this); coreZones = (Zones) getServer().getPluginManager().getPlugin("Zones"); coreFactions = (Factions) getServer().getPluginManager().getPlugin("Factions"); //new WorldLogListeners(this,db); nerfListener = new Nerf(this); godListener = new God(this); Bukkit.getServicesManager().register(CoreFunctions.class, this, this, ServicePriority.High); }
public static void setEconomy(Object economy) { if(VaultAPI.hasVault()) { if(!(economy instanceof net.milkbowl.vault.economy.Economy)) { return; } VaultAPI.economy = economy; Bukkit.getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, (net.milkbowl.vault.economy.Economy) economy, Bukkit.getServer().getPluginManager().getPlugin(VaultAPI.manager.getImplementationName()), ServicePriority.Highest); ModuleManager.getLogger().info("Registered Vault economy \"" + ((net.milkbowl.vault.economy.Economy) economy).getName() + "\"."); } }
public static void setPermissions(Object perms) { if(VaultAPI.hasVault()) { if(!(perms instanceof net.milkbowl.vault.economy.Economy)) { return; } VaultAPI.perms = perms; Bukkit.getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, (net.milkbowl.vault.permission.Permission) perms, Bukkit.getServer().getPluginManager().getPlugin(VaultAPI.manager.getImplementationName()), ServicePriority.Highest); ModuleManager.getLogger().info("Registered Vault permissions \"" + ((net.milkbowl.vault.permission.Permission) perms).getName() + "\"."); } }
public static void setChat(Object chat) { if(VaultAPI.hasVault()) { if(!(chat instanceof net.milkbowl.vault.economy.Economy)) { return; } VaultAPI.chat = chat; Bukkit.getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, (net.milkbowl.vault.chat.Chat) chat, Bukkit.getServer().getPluginManager().getPlugin(VaultAPI.manager.getImplementationName()), ServicePriority.Highest); ModuleManager.getLogger().info("Registered Vault chat \"" + ((net.milkbowl.vault.chat.Chat) chat).getName() + "\"."); } }
@Override public void onLoad() { loadLibrary(this); saveDefaultConfig(); EbeanManager.url = getConfig().getString("dataSource.url", "jdbc:mysql://localhost/db"); EbeanManager.user = getConfig().getString("dataSource.user", "root"); EbeanManager.password = getConfig().getString("dataSource.password", "wowsuchpassword"); getServer().getServicesManager().register(EbeanManager.class, EbeanManager.DEFAULT, this, ServicePriority.Normal); }
@Override public void init(Plugin plugin) { _purelyReflectiveImplementation = Bukkit.getServicesManager().getRegistration(DefaultProtocolUtilityImplementation.class).getProvider(); PacketAPI.getInstance().addListener(this); try { _getEnchantmentLevel = ReflectionUtilities.Minecraft.getType("EnchantmentManager").getDeclaredMethod("getEnchantmentLevel", int.class, ReflectionUtilities.Minecraft.getType("ItemStack")); } catch (Exception e) { e.printStackTrace(); } _signListener = new PacketAPISignGUI(plugin); Bukkit.getServicesManager().register(SignGUI.class, _signListener, plugin, ServicePriority.Normal); }
@Override public void onEnable(){ this.getServer().getServicesManager().register(AutoSaverScheduler.class, new AutoSaverScheduler(this), this, ServicePriority.Normal); this.getServer().getServicesManager().register(TeleportationManager.class, new GBukkitTPManager(), this, ServicePriority.Normal); //XXX: Should the configuration-provided server-owner registered messages be at the highest priority, or the lowest priority? this.getServer().getServicesManager().register(MessageProvider.class, new DefaultMessageProvider(), this, ServicePriority.Highest); this.getServer().getServicesManager().register(ServerTransportManager.class, new ServerTransportManager(this), this, ServicePriority.High); // Register DefaultServerTeleportationManager AFTER registering ServerTransportManager this.getServer().getServicesManager().register(ServerTeleportationManager.class, new DefaultServerTeleportationManager(this), this, ServicePriority.Highest); ConfigurationSerialization.registerClass(SerializableLocation.class); Plugin protocol = getServer().getPluginManager().getPlugin("ProtocolLib"); if(protocol != null && protocol.isEnabled()){ getServer().getServicesManager().register(ProtocolUtilities.class, new ProtocolLibUtilImplementation(), this, ServicePriority.Highest); } Plugin packet = getServer().getPluginManager().getPlugin("PacketAPI"); if(packet != null && packet.isEnabled()){ getServer().getServicesManager().register(ProtocolUtilities.class, new PacketAPIUtilityImplementation(), this, ServicePriority.Normal); } DefaultProtocolUtilityImplementation reflectUtils = new DefaultProtocolUtilityImplementation(); getServer().getServicesManager().register(ProtocolUtilities.class, reflectUtils, this, ServicePriority.Lowest); // Purely reflective implementation getServer().getServicesManager().register(DefaultProtocolUtilityImplementation.class, reflectUtils, this, ServicePriority.Highest); // Purely reflective implementation for calling unwrapped methods Utilities.initialize(this); saveDefaultConfig(); // if(getConfig().getBoolean("autoupdate")){ // Bukkit.getScheduler().runTaskTimerAsynchronously(this, new Runnable(){ // // @Override // public void run() { // final Updater up = new Updater(GBukkitCorePlugin.this, /*<PLUGIN ID ON DEVBUKKIT>*/0, getFile(), true); // up.startThread(Updater.UpdateType.DEFAULT); // Updater.UpdateResult res = up.getResult(); // Bukkit.getLogger().log(Level.FINE, "Update check result was " + res.toString()); // } // // }, 0L, Constants.TICKS_PER_MINUTE * 5); // } }
@Override public void onEnable() { getLogger().info("Enabling Necessities..."); INSTANCE = this; if (!hookGoogle()) getLogger().warning("Could not hook into Google Analytics!"); Initialization init = new Initialization(); init.initiateFiles(); getServer().getPluginManager().registerEvents(new Listeners(), this); if (Bukkit.getPluginManager().getPlugin("Vault") != null) Bukkit.getServicesManager().register(net.milkbowl.vault.economy.Economy.class, new VaultEconomy(), Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal); getDevInfo(); getLogger().info("Necessities enabled."); GameProfile janetProfile = new GameProfile(UUID.randomUUID(), "Janet"); Property skin = getSkin(); if (skin != null) janetProfile.getProperties().put("textures", skin); MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer(); WorldServer world = server.getWorldServer(0); PlayerInteractManager manager = new PlayerInteractManager(world); EntityPlayer player = new EntityPlayer(server, world, janetProfile, manager); player.listName = formatMessage(ChatColor.translateAlternateColorCodes('&', rm.getRank(rm.getOrder().size() - 1).getTitle() + ' ') + "Janet"); this.janetInfo = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, player); }
public static void setupIntegration(SwornPermissions plugin) { SwornPermissionsVault perms = new SwornPermissionsVault(plugin); plugin.getServer().getServicesManager().register(Permission.class, perms, plugin, ServicePriority.Highest); SwornChatVault chat = new SwornChatVault(plugin, perms); plugin.getServer().getServicesManager().register(Chat.class, chat, plugin, ServicePriority.Highest); }
public static final void addToVault() { final Skyowallet skyowallet = SkyowalletAPI.getPlugin(); final Logger logger = skyowallet.getLogger(); logger.log(Level.INFO, "Initializing the Vault hook..."); final VaultHook hook = new VaultHook(skyowallet); logger.log(Level.INFO, "Registering the Vault hook..."); Bukkit.getServicesManager().register(Economy.class, hook, skyowallet, ServicePriority.Highest); logger.log(Level.INFO, "Finished ! Vault will now support Skyowallet !"); /*final Method hookEconomy = vault.getClass().getDeclaredMethod("hookEconomy", String.class, Class.class, ServicePriority.class, String[].class); hookEconomy.setAccessible(true); hookEconomy.invoke(vault, "Skyowallet", VaultHook.class, ServicePriority.Normal, new String[]{"fr.skyost.skyowallet.Skyowallet"});*/ }
/** * @author xize * @param this will be used in onEnable! */ public void hookEconomyInVault() { //I give credits to niccholaspage the developer of Fe economy since I didn't discovered the possibility to let my plugin hook in Vault //to allow economy support through vault, so this method and the VaultEcoHandler() may be smiliar but are modified. if(econ != null) { Bukkit.getServer().getServicesManager().unregister(econ); } Bukkit.getServer().getServicesManager().register(Economy.class, new VaultEcoHandler(pl), pl, ServicePriority.Highest); }
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()); //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" }); } catch (Exception ex) { BungeePerms.getInstance().getDebug().log(ex); } }
/** * Attempts to load Chat Addons */ private void loadChat() { // Try to load PermissionsEx hookChat("PermissionsEx", Chat_PermissionsEx.class, ServicePriority.Highest, "ru.tehkode.permissions.bukkit.PermissionsEx"); // Try to load mChatSuite hookChat("mChatSuite", Chat_mChatSuite.class, ServicePriority.Highest, "in.mDev.MiracleM4n.mChatSuite.mChatSuite"); // Try to load mChat hookChat("mChat", Chat_mChat.class, ServicePriority.Highest, "net.D3GN.MiracleM4n.mChat"); // Try to load bPermssions 2 hookChat("bPermssions2", Chat_bPermissions2.class, ServicePriority.Highest, "de.bananaco.bpermissions.api.ApiLayer"); // Try to load bPermissions 1 hookChat("bPermissions", Chat_bPermissions.class, ServicePriority.Normal, "de.bananaco.permissions.info.InfoReader"); // Try to load GroupManager hookChat("GroupManager", Chat_GroupManager.class, ServicePriority.Normal, "org.anjocaido.groupmanager.GroupManager"); // Try to load Permissions 3 (Yeti) hookChat("Permissions3", Chat_Permissions3.class, ServicePriority.Normal, "com.nijiko.permissions.ModularControl"); // Try to load iChat hookChat("iChat", Chat_iChat.class, ServicePriority.Low, "net.TheDgtl.iChat.iChat"); // Try to load zPermissions hookChat("zPermissions", Chat_zPermissions.class, ServicePriority.Normal, "org.tyrannyofheaven.bukkit.zPermissions.model.EntityMetadata"); // Try to load Privileges hookChat("Privileges", Chat_Privileges.class, ServicePriority.Normal, "net.krinsoft.privileges.Privileges"); }
private void hookChat (String name, Class<? extends Chat> hookClass, ServicePriority priority, String...packages) { try { if (packagesExists(packages)) { Chat chat = hookClass.getConstructor(Plugin.class, Permission.class).newInstance(this, perms); sm.register(Chat.class, chat, this, priority); log.info(String.format("[%s][Chat] %s found: %s", getDescription().getName(), name, chat.isEnabled() ? "Loaded" : "Waiting")); } } catch (Exception e) { log.severe(String.format("[%s][Chat] There was an error hooking %s - check to make sure you're using a compatible version!", getDescription().getName(), name)); } }
private void hookEconomy (String name, Class<? extends Economy> hookClass, ServicePriority priority, String...packages) { try { if (packagesExists(packages)) { Economy econ = hookClass.getConstructor(Plugin.class).newInstance(this); sm.register(Economy.class, econ, this, priority); log.info(String.format("[%s][Economy] %s found: %s", getDescription().getName(), name, econ.isEnabled() ? "Loaded" : "Waiting")); } } catch (Exception e) { log.severe(String.format("[%s][Economy] There was an error hooking %s - check to make sure you're using a compatible version!", getDescription().getName(), name)); } }
private void hookPermission (String name, Class<? extends Permission> hookClass, ServicePriority priority, String...packages) { try { if (packagesExists(packages)) { Permission perms = hookClass.getConstructor(Plugin.class).newInstance(this); sm.register(Permission.class, perms, this, priority); log.info(String.format("[%s][Permission] %s found: %s", getDescription().getName(), name, perms.isEnabled() ? "Loaded" : "Waiting")); } } catch (Exception e) { log.severe(String.format("[%s][Permission] There was an error hooking %s - check to make sure you're using a compatible version!", getDescription().getName(), name)); } }
public void install() { Cauldron.setInterface(this); Bukkit.getServicesManager().register(CauldronApi.class, this, null, ServicePriority.Highest); }
@Nonnull @Override public <T> T provideService(@Nonnull Class<T> clazz, @Nonnull T instance, @Nonnull ServicePriority priority) { getServer().getServicesManager().register(clazz, instance, this, priority); return instance; }
@Override public void onEnable() { plugin = this; getConfig().options().copyDefaults(true); saveDefaultConfig(); EbeanHandler db = EbeanManager.DEFAULT.getHandler(this); if (db.isNotInitialized()) { db.define(Nick.class); try { db.initialize(); } catch (Exception e) { throw new RuntimeException(e); } } db.install(); database = db.getServer(); coloured = getConfig().getBoolean("nick.coloured"); prefix = getConfig().getString("prefix", "#"); pattern = Pattern.compile(getConfig().getString("nick.allow", "[\\u4E00-\\u9FA5]+")); blockList = getConfig().getStringList("nick.block"); Plugin vault = getServer().getPluginManager().getPlugin("Vault"); if (!nil(vault)) { val provider = getServer().getServicesManager().getRegistration(Chat.class); if (!nil(provider)) VaultP.bind(provider.getProvider()); } Plugin tag = getServer().getPluginManager().getPlugin("TagAPI"); if (!nil(tag) && getConfig().getBoolean("modify.tag")) { getServer().getPluginManager().registerEvents(TagExecutor.inst(), this); } if (getConfig().getBoolean("set.buy")) { Plugin p = getServer().getPluginManager().getPlugin("PlayerPoints"); if (!nil(p)) { PlayerPointsAPI api = ((PlayerPoints) p).getAPI(); point = new IPoint.PP(api); getLogger().log(Level.INFO, "关联到点券插件"); } } getServer().getPluginManager().registerEvents(new Executor(this), this); getCommand("nick").setExecutor(new Commander(this)); getServer().getConsoleSender().sendMessage(new String[]{ ChatColor.GREEN + "梦梦家高性能服务器出租店", ChatColor.GREEN + "shop105595113.taobao.com" }); getServer().getServicesManager().register(NickManager.class, this, this, ServicePriority.Normal); new MLite(this).start(); }
public void hook() { Bukkit.getServicesManager().register(Economy.class, provider, plugin, ServicePriority.Normal); }