This repository explains how to use Badlion Client Timer Api.
It allows the server to display timers in the Badlion Client. This plugin is an API and you need to call it from your own plugins for it to work.
How to install the Badlion Client Timer API on your server.
- Download the latest bukkit plugin from our releases : https://github.com/BadlionNetwork/BadlionClientTimerAPI/releases
- Place the downloaded plugin into your
pluginsdirectory on your server. - Turn on the Bukkit server
Below is an example plugin with the four different timers types implemented.
importnet.badlion.timers.api.Timer;
importnet.badlion.timers.api.TimerApi;
importorg.bukkit.Material;
importorg.bukkit.event.EventHandler;
importorg.bukkit.event.Listener;
importorg.bukkit.event.player.PlayerJoinEvent;
importorg.bukkit.event.player.PlayerQuitEvent;
importorg.bukkit.inventory.ItemStack;
importorg.bukkit.plugin.java.JavaPlugin;
importjava.util.concurrent.TimeUnit;
publicclassExamplePluginextendsJavaPluginimplementsListener {
privateTimerApitimerApi;
privateTimertickTimer; // 1 minute tick timerprivateTimerrepeatingTickTimer; // 1 minute repeating tick timerprivateTimertimeTimer; // 1 minute time timerprivateTimerrepeatingTimeTimer; // 1 minute repeating time timer@OverridepublicvoidonEnable() {
// Get the timer api instanccethis.timerApi = TimerApi.getInstance();
// Create the timersthis.tickTimer = this.timerApi.createTickTimer("Tick Timer", newItemStack(Material.IRON_INGOT), false, 1200L);
this.repeatingTickTimer = this.timerApi.createTickTimer("Repeating Tick Timer", newItemStack(Material.GOLD_INGOT), true, 1200L);
this.timeTimer = this.timerApi.createTimeTimer("Time Timer", newItemStack(Material.DIAMOND), false, 1L, TimeUnit.MINUTES);
this.repeatingTimeTimer = this.timerApi.createTimeTimer("Repeating Tick Timer", newItemStack(Material.EMERALD), true, 1L, TimeUnit.MINUTES);
// Register the listenerthis.getServer().getPluginManager().registerEvents(this, this);
}
@OverridepublicvoidonDisable() {
// Remove the timersthis.timerApi.removeTimer(this.tickTimer);
this.timerApi.removeTimer(this.repeatingTickTimer);
this.timerApi.removeTimer(this.timeTimer);
this.timerApi.removeTimer(this.repeatingTimeTimer);
}
@EventHandlerpublicvoidonLogin(PlayerJoinEventevent) {
// Add the player to the timersthis.tickTimer.addReceiver(event.getPlayer());
this.repeatingTickTimer.addReceiver(event.getPlayer());
this.timeTimer.addReceiver(event.getPlayer());
this.repeatingTimeTimer.addReceiver(event.getPlayer());
}
@EventHandlerpublicvoidonLogout(PlayerQuitEventevent) {
// Remove the player from the timersthis.tickTimer.removeReceiver(event.getPlayer());
this.repeatingTickTimer.removeReceiver(event.getPlayer());
this.timeTimer.removeReceiver(event.getPlayer());
this.repeatingTimeTimer.removeReceiver(event.getPlayer());
}
}