Added services manager framework. Services are interfaces that specifies capabilities to be implemented by providers. Example services include economy, <insert example 2>, etc.

This commit is contained in:
sk89q
2011-05-02 11:31:00 -07:00
parent 267814484a
commit 67f1d7b041
6 changed files with 469 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
package org.bukkit.plugin;
/**
* A registered service provider.
*
* @author sk89q
* @param <T> Service
*/
public class RegisteredServiceProvider<T>
implements Comparable<RegisteredServiceProvider<?>> {
private Class<T> service;
private Plugin plugin;
private T provider;
private ServicePriority priority;
public RegisteredServiceProvider(Class<T> service, T provider,
ServicePriority priority, Plugin plugin) {
this.service = service;
this.plugin = plugin;
this.provider = provider;
this.priority = priority;
}
public Class<T> getService() {
return service;
}
public Plugin getPlugin() {
return plugin;
}
public T getProvider() {
return provider;
}
public ServicePriority getPriority() {
return priority;
}
public int compareTo(RegisteredServiceProvider<?> other) {
if (priority.ordinal() == other.getPriority().ordinal()) {
return 0;
} else {
return priority.ordinal() < other.getPriority().ordinal() ? 1 : -1;
}
}
}