Solved Something very difficult

Discussion in 'Spigot Plugin Development' started by Giorgino, Feb 14, 2020.

  1. Hello everyone, by chance does anyone know how I can create rounds? For example, once the time is over, a new round is started.
     
    • Funny Funny x 2
  2. You can create an event by extending the Event class, https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/package-summary.html // https://www.spigotmc.org/wiki/using-the-event-api/, which allows you to call an event when a round ends, and start a new one in a listener class right away. vague example code:
    Code (Java):

    public class RoundEndEvent extends Event {
    public RoundEndEvent(/*event parameters*/) {
    // etc etc
     
    Code (Java):

    public class WhereYourRoundEnds {
    public void endRound() {
        Bukkit.getServer().getPluginManager().callEvent(new RoundEndEvent(parameters);
        // etc etc etc
    }
    //etc etc etc
     
    Code (Java):

    public class RoundEndListener implements Listener {
    @EventHandler
    public void on(RoundEndEvent e) {
        //start a new round, do whatever (anything that is public in RoundEndEvent can be accessed using e here)
        // etc etc etc
     
    Don't forget to register your listeners with Bukkit.getServer().getPluginManager().registerEvents();!