Implementation

Implement your own plugins

Supported Plugins

To have your plugin appear here, contact me on the discord: https://discord.groupez.dev/

zKoth

implementation: 
  name: ZKOTH 
  koth_name: "koth_name" 
  start_now: false

zTotem

implementation: 
  name: ZTOTEM
  totem_name: "totem_name" 
  start_now: false

zAuctionHouse

implementation: 
  name: ZAUCTIOHOUSE

This implementation allows you to manage the backup of the items.json file

Create an implementation

Source code: https://github.com/Maxlego08/zSchedulers

First step

The first step is to get the SchedulerManager

@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;
}

Implementation

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);
    }
  }
}

Now you need to register your implementation:

SchedulerManager schedulerManager = this.getProvider(SchedulerManager.class);
schedulerManager.registerImplementation(new ZkothImplementation(this));

Last updated