Java Code Examples for org.bukkit.plugin.RegisteredServiceProvider#getProvider()

The following examples show how to use org.bukkit.plugin.RegisteredServiceProvider#getProvider() . 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: VaultHook.java    From FunnyGuilds with Apache License 2.0 6 votes vote down vote up
public static void initHooks() {
    RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
    RegisteredServiceProvider<Permission> permissionProvider = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);

    if (economyProvider != null) {
        economyHook = economyProvider.getProvider();
    }
    else {
        FunnyGuilds.getInstance().getPluginLogger().warning("No economy provider found, some features may not be available");
    }

    if (permissionProvider != null) {
        permissionHook = permissionProvider.getProvider();
    }
    else {
        FunnyGuilds.getInstance().getPluginLogger().warning("No permission provider found, some features may not be available");
    }
}
 
Example 2
Source File: Econ.java    From ClaimChunk with MIT License 6 votes vote down vote up
boolean setupEconomy(ClaimChunk instance) {
    this.instance = instance;

    // Check if Vault is present
    if (instance.getServer().getPluginManager().getPlugin("Vault") == null) return false;

    // Get the Vault service if it is present
    RegisteredServiceProvider<Economy> rsp = instance.getServer().getServicesManager().getRegistration(Economy.class);

    // Check if the service is valid
    if (rsp == null) return false;

    // Update current economy handler
    econ = rsp.getProvider();

    // Success
    return true;
}
 
Example 3
Source File: VaultIntegrator.java    From BetonQuest with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void hook() {
    RegisteredServiceProvider<Permission> permissionProvider = Bukkit.getServer().getServicesManager()
            .getRegistration(net.milkbowl.vault.permission.Permission.class);
    if (permissionProvider != null) {
        permission = permissionProvider.getProvider();
    }
    RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServer().getServicesManager()
            .getRegistration(net.milkbowl.vault.economy.Economy.class);
    if (economyProvider != null) {
        economy = economyProvider.getProvider();
    }
    if (economy != null) {
        plugin.registerEvents("money", MoneyEvent.class);
        plugin.registerConditions("money", MoneyCondition.class);
        plugin.registerVariable("money", MoneyVariable.class);
    } else {
        LogUtils.getLogger().log(Level.WARNING, "There is no economy plugin on the server!");
    }
    if (permission != null) {
        plugin.registerEvents("permission", PermissionEvent.class);
    } else {
        LogUtils.getLogger().log(Level.WARNING, "Could not get permission provider!");
    }
}
 
Example 4
Source File: TutorialEco.java    From ServerTutorial with MIT License 5 votes vote down vote up
/**
 * @return Economy returns Economy instance otherwise null if none found
 */
public Economy getEcon() {
    if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
        return null;
    }
    RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl
            .vault.economy.Economy.class);
    if (rsp != null) {
        return rsp.getProvider();
    }
    return null;
}
 
Example 5
Source File: PlayerInteractListener.java    From PetMaster with GNU General Public License v3.0 5 votes vote down vote up
public PlayerInteractListener(PetMaster petMaster) {
	this.plugin = petMaster;
	version = Integer.parseInt(PackageType.getServerVersion().split("_")[1]);
	// Try to retrieve an Economy instance from Vault.
	if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) {
		RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager()
				.getRegistration(Economy.class);
		if (rsp != null) {
			economy = rsp.getProvider();
		}
	}
}
 
Example 6
Source File: VaultHandler.java    From Parties with GNU Affero General Public License v3.0 5 votes vote down vote up
private boolean setupEconomy() {
	boolean ret = false;
	RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
	if (rsp != null) {
		economy = rsp.getProvider();
		ret = economy != null;
	}
	return ret;
}
 
Example 7
Source File: VaultProvider.java    From HoloAPI with GNU General Public License v3.0 5 votes vote down vote up
private boolean setupPermissions() {
    RegisteredServiceProvider<Permission> permissionProvider = this.getHandlingPlugin().getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
    if (permissionProvider != null) {
        permission = permissionProvider.getProvider();
    }
    return (permission != null);
}
 
Example 8
Source File: VaultEconomy.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
private Optional<Economy> setupEconomy() {
    RegisteredServiceProvider<Economy> rsp =
        plugin.getServer().getServicesManager().getRegistration(Economy.class);
    if (rsp != null) {
        economy = rsp.getProvider();
        return Optional.of(economy);
    }

    return Optional.empty();
}
 
Example 9
Source File: VaultPermissions.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
private Optional<Permission> setupPermission() {
    RegisteredServiceProvider<Permission> rsp =
        plugin.getServer().getServicesManager().getRegistration(Permission.class);
    if (rsp != null) {
        permission = rsp.getProvider();
        return Optional.of(permission);
    }

    return Optional.empty();
}
 
Example 10
Source File: Main.java    From BedWars with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean setupEconomy() {
    if (getServer().getPluginManager().getPlugin("Vault") == null) {
        return false;
    }
    RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
    if (rsp == null) {
        return false;
    }

    econ = rsp.getProvider();
    return true;
}
 
Example 11
Source File: VaultEconomyHook.java    From factions-top with MIT License 5 votes vote down vote up
@Override
public void initialize() {
    RegisteredServiceProvider<Economy> rsp = plugin.getServer().getServicesManager().getRegistration(Economy.class);

    if (rsp == null || (economy = rsp.getProvider()) == null) {
        plugin.getLogger().warning("No economy provider for Vault found!");
        plugin.getLogger().warning("Economy support by Vault is now disabled.");
        return;
    }

    plugin.getServer().getPluginManager().registerEvents(this, plugin);
    runTaskTimer(plugin, liquidUpdateTicks, liquidUpdateTicks);
    enabled = true;
}
 
Example 12
Source File: ServiceInjector.java    From QuickShop-Reremake with GNU General Public License v3.0 5 votes vote down vote up
public static @NotNull EconomyCore getEconomyCore(@NotNull EconomyCore def) {
    @Nullable RegisteredServiceProvider<? extends EconomyCore> registeredServiceProvider =
            Bukkit.getServicesManager().getRegistration(EconomyCore.class);
    if (registeredServiceProvider == null) {
        return def;
    } else {
        return registeredServiceProvider.getProvider();
    }
}
 
Example 13
Source File: VaultPermissionProvider.java    From QuickShop-Reremake with GNU General Public License v3.0 5 votes vote down vote up
@Deprecated
public VaultPermissionProvider() {
    RegisteredServiceProvider<Permission> rsp =
            Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
    if (rsp == null) {
        throw new ProviderIsEmptyException(getName());
    }
    api = rsp.getProvider();
}
 
Example 14
Source File: Wild.java    From WildernessTp with MIT License 5 votes vote down vote up
private boolean setupEconomy() {
    if (getServer().getPluginManager().getPlugin("Vault") == null) {
        return false;
    }
    RegisteredServiceProvider<Economy> rsp = getServer()
            .getServicesManager().getRegistration(Economy.class);
    if (rsp == null) {
        return false;
    }
    econ = rsp.getProvider();
    return econ != null;
}
 
Example 15
Source File: VaultManager.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
public static void setupEconomy(){
  	if(!GameManager.getGameManager().getConfiguration().getVaultLoaded()){
  		return;
}

  	RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
   if (economyProvider != null) {
       economy = economyProvider.getProvider();
   }else{
   	Bukkit.getLogger().severe("[UhcCore] Error trying to load economy provider. Check that you have a economy plugin installed");
   }
  }
 
Example 16
Source File: EconomyHandler.java    From MarriageMaster with GNU General Public License v3.0 4 votes vote down vote up
private boolean setupEconomy(MarriageMaster plugin)
{
	if(plugin.getServer().getPluginManager().getPlugin("Vault") == null) return false;
	RegisteredServiceProvider<Economy> economyProvider = plugin.getServer().getServicesManager().getRegistration(Economy.class);
	return (econ = (economyProvider != null) ? economyProvider.getProvider() : null) != null;
}
 
Example 17
Source File: Civs.java    From Civs with GNU General Public License v3.0 4 votes vote down vote up
private void setupPermissions() {
    RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
    if (permissionProvider != null) {
        perm = permissionProvider.getProvider();
    }
}
 
Example 18
Source File: Guilds.java    From Guilds with MIT License 4 votes vote down vote up
/**
 * Implement Vault's Economy API
 */
private void setupEconomy() {
    RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(Economy.class);
    if (economyProvider != null) economy = economyProvider.getProvider();
}
 
Example 19
Source File: VaultUtils.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
private boolean setupChat() {
    RegisteredServiceProvider<Chat> rsp = Bukkit.getServer().getServicesManager().getRegistration(Chat.class);
    chat = rsp.getProvider();
    return chat != null;
}
 
Example 20
Source File: Civs.java    From Civs with GNU General Public License v3.0 4 votes vote down vote up
private void setupEconomy() {
    RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
    if (rsp != null) {
        econ = rsp.getProvider();
    }
}