From 97a93c2cb0709a18d9303ddc80a016e3b3b35bd7 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 4 May 2020 18:33:53 +0200 Subject: [PATCH] refactor: fix logger --- .../varo/listeners/CreatureSpawnListener.java | 11 ++++++++-- .../listeners/PlayerJoinQuitListener.java | 21 +++++++++---------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/varo/src/main/java/de/cliffbreak/varo/listeners/CreatureSpawnListener.java b/varo/src/main/java/de/cliffbreak/varo/listeners/CreatureSpawnListener.java index 970e935..1791bad 100644 --- a/varo/src/main/java/de/cliffbreak/varo/listeners/CreatureSpawnListener.java +++ b/varo/src/main/java/de/cliffbreak/varo/listeners/CreatureSpawnListener.java @@ -1,20 +1,27 @@ package de.cliffbreak.varo.listeners; -import org.bukkit.Bukkit; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.CreatureSpawnEvent; +import de.cliffbreak.varo.Varo; + public class CreatureSpawnListener implements Listener { + private Varo plugin; + + public CreatureSpawnListener(final Varo plugin) { + this.plugin = plugin; + } + @EventHandler() public void onCreatureSpawn(CreatureSpawnEvent e) { LivingEntity livingEntity = e.getEntity(); if (livingEntity.getType().equals(EntityType.WANDERING_TRADER) || livingEntity.getType().equals(EntityType.TRADER_LLAMA)) { - Bukkit.getLogger().info("Denied Wandering-Trader Spawn"); + plugin.getLogger().info("Denied Wandering-Trader Spawn"); e.setCancelled(true); } } 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 e9ae496..ec563c2 100644 --- a/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerJoinQuitListener.java +++ b/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerJoinQuitListener.java @@ -10,6 +10,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.scheduler.BukkitRunnable; import de.cliffbreak.varo.Varo; import de.cliffbreak.varo.uitls.MessageUtils; @@ -17,7 +18,6 @@ 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; @@ -40,6 +40,10 @@ public class PlayerJoinQuitListener implements Listener { final Stack changes = new Stack(); + changes.push(" §7• §r§lFIX: §r/varo Command is only usable by Server Operators now"); + changes.push(" §7• §r§lADD: §rDisallow special Items (Enchanted Golden Apple, Fishing Rod, Totem of Undying)"); + changes.push(" §7• §r§lADD: §rUse Vanilla Hearts"); + changes.push(" §7• §r§lADD: §rDisable Fishing Rod Crafting Recipe"); 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"); @@ -50,25 +54,20 @@ public class PlayerJoinQuitListener implements Listener { 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() { - + new BukkitRunnable() { @Override public void run() { if (!e.getPlayer().isOnline()) { - stopScheduler(); + this.cancel(); return; } if (changes.empty()) { - stopScheduler(); + this.cancel(); return; } e.getPlayer().sendMessage(changes.pop()); } - }, 20, 20); - } - - private void stopScheduler() { - Bukkit.getScheduler().cancelTask(this.task); + }.runTaskTimer(plugin, 20, 20); } @EventHandler() @@ -76,7 +75,7 @@ public class PlayerJoinQuitListener implements Listener { if (event instanceof PaperServerListPingEvent) { handlePaperServerListPing((PaperServerListPingEvent) event); } else { - Bukkit.getLogger().info("Error: Plugin is not running on a PaperServer"); + plugin.getLogger().info("Error: Plugin is not running on a PaperServer"); } }