From 6f2557f897295feec5e3beb166a4e3681ad9eb03 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 4 May 2020 10:42:24 +0200 Subject: [PATCH] feat: optimize changelog --- .../listeners/PlayerJoinQuitListener.java | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerJoinQuitListener.java b/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerJoinQuitListener.java index 9cbb411..9674a83 100644 --- a/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerJoinQuitListener.java +++ b/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerJoinQuitListener.java @@ -1,5 +1,7 @@ package de.cliffbreak.varo.listeners; +import java.util.Stack; + import com.destroystokyo.paper.event.server.PaperServerListPingEvent; import org.bukkit.Bukkit; @@ -15,6 +17,7 @@ import de.cliffbreak.varo.uitls.MessageUtils; public class PlayerJoinQuitListener implements Listener { private final Varo plugin; + private int task; public PlayerJoinQuitListener(final Varo plugin) { this.plugin = plugin; @@ -33,14 +36,33 @@ public class PlayerJoinQuitListener implements Listener { Bukkit.broadcast( MessageUtils.getRichTextComponent(e.getPlayer().getName(), "§f hat den Server betreten.", true)); e.getPlayer().sendMessage("\n§7§l#### §9Cliffbreak.de - §lVaro §r§9Changelog §7§l####\n \n" - + " §cWarning: §r§c Plugin is running in DEBUG mode!\n " - + "\n §7• §r§lADD: §rRedesigned Chat with Timestamp" - + "\n §7• §r§lADD: §rHover over Playername for Details (Team)" - + "\n §7• §r§lADD: §rControl Difficulty and Gamerules by the Plugin" - + "\n §7• §r§lADD: §rCustom Dynamic ServerListEntry" + "\n §7• §r§lADD: §r1.8 Health Regeneration" - + "\n §7• §r§lADD: §rBan Player on Death" + "\n §7• §r§lADD: §r/varo Command for Admins" - + "\n §7• §r§lFIX: §rOnly kick player after Entity isn't ticking anymore" - + "\n §7• §r§lFIX: §rCheck for Ban in AsyncPreLoginEvent"); + + " §cWarning: §r§c Plugin is running in DEBUG mode!\n "); + + final Stack changes = new Stack(); + + changes.push(" §7• §r§lFIX: §rCheck for Ban in AsyncPreLoginEvent"); + changes.push(" §7• §r§lFIX: §rOnly kick player after Entity isn't ticking anymore"); + changes.push(" §7• §r§lADD: §r/varo Command for Admins"); + changes.push(" §7• §r§lADD: §rBan Player on Death"); + changes.push(" §7• §r§lADD: §r1.8 Health Regeneration"); + changes.push(" §7• §r§lADD: §rCustom Dynamic ServerListEntry"); + changes.push(" §7• §r§lADD: §rControl Difficulty and Gamerules by the Plugin"); + changes.push(" §7• §r§lADD: §rHover over Playername for Details (Team)"); + changes.push(" §7• §r§lADD: §rRedesigned Chat with Timestamp"); + + this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { + + @Override + public void run() { + e.getPlayer().sendMessage(changes.pop()); + if (changes.empty()) + stopScheduler(); + } + }, 20, 20); + } + + private void stopScheduler() { + Bukkit.getScheduler().cancelTask(this.task); } @EventHandler()