feat: add Time counter to MOTD
This commit is contained in:
parent
037f0641cc
commit
7de3a45ed7
2 changed files with 18 additions and 5 deletions
|
@ -50,7 +50,7 @@ public class Varo extends JavaPlugin {
|
||||||
this.banUtils = new BanUtils(this);
|
this.banUtils = new BanUtils(this);
|
||||||
this.varoUtils = new VaroUtils(this);
|
this.varoUtils = new VaroUtils(this);
|
||||||
|
|
||||||
this.config.addDefault("Varo.Start", "25.05.2020");
|
this.config.addDefault("Varo.Start", 1590427800000f);
|
||||||
this.config.addDefault("Varo.Debug", false);
|
this.config.addDefault("Varo.Debug", false);
|
||||||
this.config.addDefault("Varo.RetroHealthRegen", false);
|
this.config.addDefault("Varo.RetroHealthRegen", false);
|
||||||
this.config.addDefault("Varo.Bans", new ArrayList<String>());
|
this.config.addDefault("Varo.Bans", new ArrayList<String>());
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package de.cliffbreak.varo.listeners;
|
package de.cliffbreak.varo.listeners;
|
||||||
|
|
||||||
import java.util.Stack;
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||||
|
|
||||||
|
@ -48,7 +52,6 @@ public class PlayerJoinQuitListener implements Listener {
|
||||||
MessageUtils.getRichTextComponent(e.getPlayer().getName(), "§f hat den Server betreten.", true));
|
MessageUtils.getRichTextComponent(e.getPlayer().getName(), "§f hat den Server betreten.", true));
|
||||||
|
|
||||||
if (this.plugin.getConfig().getBoolean("Varo.Debug")) {
|
if (this.plugin.getConfig().getBoolean("Varo.Debug")) {
|
||||||
|
|
||||||
e.getPlayer().sendMessage("\n§7§l######### §9Cliffbreak.de - §lVaro §7§l#########\n \n"
|
e.getPlayer().sendMessage("\n§7§l######### §9Cliffbreak.de - §lVaro §7§l#########\n \n"
|
||||||
+ " §cWarning: §r§c Plugin is running in DEBUG mode!\n ");
|
+ " §cWarning: §r§c Plugin is running in DEBUG mode!\n ");
|
||||||
}
|
}
|
||||||
|
@ -73,7 +76,17 @@ public class PlayerJoinQuitListener implements Listener {
|
||||||
|
|
||||||
private void handlePaperServerListPing(final PaperServerListPingEvent e) {
|
private void handlePaperServerListPing(final PaperServerListPingEvent e) {
|
||||||
e.setHidePlayers(true);
|
e.setHidePlayers(true);
|
||||||
// TODO: Add day counter
|
|
||||||
e.setMotd("§9§l" + "VARO" + "§b§l " + "Tag: -1" + "\n§r§7" + "powered by " + "§4" + "Cliffbreak.de");
|
try {
|
||||||
|
Instant instant = Instant.ofEpochMilli(this.plugin.getConfig().getLong("Varo.Start"));
|
||||||
|
LocalDateTime start = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||||
|
final LocalDateTime current = LocalDateTime.now();
|
||||||
|
|
||||||
|
e.setMotd("§9§l" + "VARO" + "§b§l " + "Tag: " + (Duration.between(start, current).toDays() + 1) + "\n§r§7"
|
||||||
|
+ "powered by " + "§4" + "Cliffbreak.de");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
e.setMotd("§9§l" + "VARO" + "§b§l " + "Tag: -1" + "\n§r§7" + "powered by " + "§4" + "Cliffbreak.de");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue