本文整理了Java中org.bukkit.Bukkit.getServicesManager()
方法的一些代码示例,展示了Bukkit.getServicesManager()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bukkit.getServicesManager()
方法的具体详情如下:
包路径:org.bukkit.Bukkit
类名称:Bukkit
方法名:getServicesManager
暂无
代码示例来源:origin: lucko/helper
/**
* 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;
}
代码示例来源:origin: me.lucko/helper
/**
* 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;
}
代码示例来源:origin: me.lucko/helper
/**
* Loads a service instance
*
* @param clazz the service class
* @param <T> the service class type
* @return the service instance, as an optional
*/
@Nonnull
public static <T> Optional<T> get(@Nonnull Class<T> clazz) {
Objects.requireNonNull(clazz, "clazz");
RegisteredServiceProvider<T> registration = Bukkit.getServicesManager().getRegistration(clazz);
if (registration == null) {
return Optional.empty();
}
return Optional.ofNullable(registration.getProvider());
}
代码示例来源:origin: lucko/helper
/**
* Loads a service instance
*
* @param clazz the service class
* @param <T> the service class type
* @return the service instance, as an optional
*/
@Nonnull
public static <T> Optional<T> get(@Nonnull Class<T> clazz) {
Objects.requireNonNull(clazz, "clazz");
RegisteredServiceProvider<T> registration = Bukkit.getServicesManager().getRegistration(clazz);
if (registration == null) {
return Optional.empty();
}
return Optional.ofNullable(registration.getProvider());
}
代码示例来源:origin: PyvesB/AdvancedAchievements
@Inject
public RewardParser(@Named("main") CommentedYamlConfiguration mainConfig,
@Named("lang") CommentedYamlConfiguration langConfig, MaterialHelper materialHelper) {
this.mainConfig = mainConfig;
this.langConfig = langConfig;
this.materialHelper = materialHelper;
// Try to retrieve an Economy instance from Vault.
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
RegisteredServiceProvider<Economy> rsp = Bukkit.getServicesManager().getRegistration(Economy.class);
if (rsp != null) {
economy = rsp.getProvider();
}
}
}
代码示例来源:origin: com.greatmancode/tools
@Override
public void setVaultEconomyHook(VaultEconomy instance, com.greatmancode.tools.utils.ServicePriority priority) {
Bukkit.getServicesManager().register(Economy.class, instance, (Plugin) getLoader(), ServicePriority.valueOf(priority.name().toUpperCase()));
}
}
代码示例来源:origin: games647/ScoreboardStats
public McPrisonVariables(ReplacerAPI replaceManager, Plugin plugin) throws UnsupportedPluginException {
super(replaceManager, plugin);
RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServicesManager().getRegistration(Economy.class);
if (economyProvider == null) {
throw new UnsupportedPluginException("Couldn't find an economy plugin");
} else {
eco = economyProvider.getProvider();
}
}
代码示例来源:origin: io.github.bedwarsrel/BedwarsRel-Common
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
try {
service.getField("B_STATS_VERSION"); // Our identifier :)
service.getMethod("getPluginData").invoke(Bukkit.getServicesManager().load(service)));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
代码示例来源:origin: games647/ScoreboardStats
public VaultVariables(ReplacerAPI replaceManager, Plugin plugin) throws UnsupportedPluginException {
super(replaceManager, plugin);
RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServicesManager().getRegistration(Economy.class);
if (economyProvider == null) {
//check if an economy plugin is installed otherwise it would throw a exception if the want to replace
throw new UnsupportedPluginException("Cannot find an economy plugin");
} else {
economy = economyProvider.getProvider();
}
}
代码示例来源:origin: bergerkiller/BKCommonLib
public void updateDependency(Plugin plugin, String pluginName, boolean enabled) {
if (pluginName.equals("Vault")) {
if (this.vaultEnabled == enabled) {
return;
}
if (enabled) {
// Enable the support for Vault
RegisteredServiceProvider<Permission> permissionProvider = Bukkit.getServicesManager().getRegistration(Permission.class);
if (permissionProvider != null) {
this.vaultPermission = permissionProvider.getProvider();
this.vaultEnabled = this.vaultPermission != null;
}
} else {
// Disable the support for Vault
this.vaultPermission = null;
this.vaultEnabled = false;
}
if (this.vaultEnabled) {
this.needsWildcardCheck.set();
}
}
}
代码示例来源:origin: Bastian/bStats-Metrics
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
try {
service.getField("B_STATS_VERSION"); // Our identifier :)
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
try {
pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
代码示例来源:origin: aadnk/ProtocolLib
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
try {
service.getField("B_STATS_VERSION"); // Our identifier :)
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
try {
pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
代码示例来源:origin: Bkm016/TabooLib
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
try {
service.getField("B_STATS_VERSION"); // Our identifier :)
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
try {
pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
代码示例来源:origin: sgtcaze/NametagEdit
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
try {
service.getField("B_STATS_VERSION"); // Our identifier :)
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
try {
pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
代码示例来源:origin: Bastian/bStats-Metrics
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
try {
service.getField("B_STATS_VERSION"); // Our identifier :)
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
try {
pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
代码示例来源:origin: filoghost/ChestCommands
public static boolean setupEconomy() {
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = Bukkit.getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
economy = rsp.getProvider();
return economy != null;
}
代码示例来源:origin: EngineHub/CommandHelper
for(Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
try {
service.getField("B_STATS_VERSION"); // Our identifier :)
for(RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
try {
pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
代码示例来源:origin: nsporillo/GlobalWarming
/**
* Economy (soft-dependency on Vault)
* - If a Vault-based economy was not found, disable the bounty system
*/
private static void setupEconomy() {
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServicesManager().getRegistration(Economy.class);
if (economyProvider != null) {
economy = economyProvider.getProvider();
}
}
if (economy == null) {
instance.getLogger().warning("Bounty-system [disabled], Vault economy not found");
for (Permission permission : Bukkit.getPluginManager().getDefaultPermissions(false)) {
if (permission.getName().startsWith("globalwarming.bounty")) {
Bukkit.getPluginManager().getPermission(permission.getName())
.setDefault(PermissionDefault.FALSE);
}
}
} else {
instance.getLogger().info("Bounty-system [enabled], Vault economy found");
}
}
代码示例来源:origin: Multiverse/Multiverse-Core
private boolean setupVaultEconomy() {
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
final RegisteredServiceProvider<Economy> economyProvider =
Bukkit.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
Logging.fine("Vault economy enabled.");
economy = economyProvider.getProvider();
} else {
Logging.finer("Vault economy not detected.");
economy = null;
}
} else {
Logging.finer("Vault was not found.");
economy = null;
}
return (economy != null);
}
代码示例来源:origin: lucko/helper
@Override
public void supplyBindings(Script script, BindingsBuilder bindings) {
// provide a terminable registry
CompositeTerminable registry = CompositeTerminable.create();
script.getClosables().bind(registry);
bindings.put("registry", registry);
// provide core server classes
bindings.put("server", Bukkit.getServer());
bindings.put("plugin", this.plugin);
bindings.put("services", Bukkit.getServicesManager());
// some util functions
bindings.put("colorize", (Function<Object, String>) HelperScriptBindings::colorize);
bindings.put("newMetadataKey", (Function<Object, MetadataKey>) HelperScriptBindings::newMetadataKey);
bindings.put("newEmptyScheme", (Supplier<MenuScheme>) HelperScriptBindings::newScheme);
bindings.put("newScheme", (Function<SchemeMapping, MenuScheme>) HelperScriptBindings::newScheme);
}
内容来源于网络,如有侵权,请联系作者删除!