implementation:
name: ZKOTH
koth_name: "koth_name"
start_now: false
implementation:
name: ZTOTEM
totem_name: "totem_name"
start_now: false
implementation:
name: ZAUCTIOHOUSE
@Override
public void onEnable() {
SchedulerManager manager = getProvider(SchedulerManager.class);
}
private <T> T getProvider(Class<T> classz) {
RegisteredServiceProvider<T> provider = getServer().getServicesManager().getRegistration(classz);
return provider == null ? null : provider.getProvider() != null ? (T) provider.getProvider() : null;
}
Create a class which will implement Implementation interface.
public class ZkothImplementation implements Implementation {
private final ZKothPlugin plugin;
public ZkothImplementation(ZKothPlugin plugin) {
super();
this.plugin = plugin;
}
@Override
public String getName() {
return "ZKOTH";
}
@Override
public void schedule(Scheduler scheduler) {
String kothName = (String) scheduler.getImplementationValues().getOrDefault("koth_name", "");
boolean startNow = (boolean) scheduler.getImplementationValues().getOrDefault("start_now", false);
Optional<Koth> optional = this.plugin.getKothManager().getKoth(kothName);
if (optional.isPresent()) {
Koth koth = optional.get();
koth.spawn(startNow);
} else {
Logger.info("Koth with name " + kothName + " was not found with scheduler " + scheduler.getName(),
LogType.ERROR);
}
}
}
SchedulerManager schedulerManager = this.getProvider(SchedulerManager.class);
schedulerManager.registerImplementation(new ZkothImplementation(this));