本文整理汇总了Java中org.bukkit.event.server.ServiceRegisterEvent类的典型用法代码示例。如果您正苦于以下问题:Java ServiceRegisterEvent类的具体用法?Java ServiceRegisterEvent怎么用?Java ServiceRegisterEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceRegisterEvent类属于org.bukkit.event.server包,在下文中一共展示了ServiceRegisterEvent类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: register
import org.bukkit.event.server.ServiceRegisterEvent; //导入依赖的package包/类
/**
* 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));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:32,代码来源:SimpleServicesManager.java
示例2: ServiceCallback
import org.bukkit.event.server.ServiceRegisterEvent; //导入依赖的package包/类
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());
}
开发者ID:lucko,项目名称:helper,代码行数:10,代码来源:ServiceCallback.java
示例3: onServiceChange
import org.bukkit.event.server.ServiceRegisterEvent; //导入依赖的package包/类
@EventHandler
public void onServiceChange(ServiceRegisterEvent e) {
if (e.getProvider().getService() == Chat.class) {
refreshVault();
}
}
开发者ID:lucko,项目名称:VaultChatFormatter,代码行数:7,代码来源:ChatFormatterPlugin.java
注:本文中的org.bukkit.event.server.ServiceRegisterEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论