refactor: fix logger
This commit is contained in:
parent
19eb0fe80a
commit
97a93c2cb0
2 changed files with 19 additions and 13 deletions
|
@ -1,20 +1,27 @@
|
||||||
package de.cliffbreak.varo.listeners;
|
package de.cliffbreak.varo.listeners;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
|
||||||
|
import de.cliffbreak.varo.Varo;
|
||||||
|
|
||||||
public class CreatureSpawnListener implements Listener {
|
public class CreatureSpawnListener implements Listener {
|
||||||
|
|
||||||
|
private Varo plugin;
|
||||||
|
|
||||||
|
public CreatureSpawnListener(final Varo plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler()
|
@EventHandler()
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent e) {
|
public void onCreatureSpawn(CreatureSpawnEvent e) {
|
||||||
LivingEntity livingEntity = e.getEntity();
|
LivingEntity livingEntity = e.getEntity();
|
||||||
if (livingEntity.getType().equals(EntityType.WANDERING_TRADER)
|
if (livingEntity.getType().equals(EntityType.WANDERING_TRADER)
|
||||||
|| livingEntity.getType().equals(EntityType.TRADER_LLAMA)) {
|
|| livingEntity.getType().equals(EntityType.TRADER_LLAMA)) {
|
||||||
Bukkit.getLogger().info("Denied Wandering-Trader Spawn");
|
plugin.getLogger().info("Denied Wandering-Trader Spawn");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.server.ServerListPingEvent;
|
import org.bukkit.event.server.ServerListPingEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import de.cliffbreak.varo.Varo;
|
import de.cliffbreak.varo.Varo;
|
||||||
import de.cliffbreak.varo.uitls.MessageUtils;
|
import de.cliffbreak.varo.uitls.MessageUtils;
|
||||||
|
@ -17,7 +18,6 @@ import de.cliffbreak.varo.uitls.MessageUtils;
|
||||||
public class PlayerJoinQuitListener implements Listener {
|
public class PlayerJoinQuitListener implements Listener {
|
||||||
|
|
||||||
private final Varo plugin;
|
private final Varo plugin;
|
||||||
private int task;
|
|
||||||
|
|
||||||
public PlayerJoinQuitListener(final Varo plugin) {
|
public PlayerJoinQuitListener(final Varo plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
@ -40,6 +40,10 @@ public class PlayerJoinQuitListener implements Listener {
|
||||||
|
|
||||||
final Stack<String> changes = new Stack<String>();
|
final Stack<String> changes = new Stack<String>();
|
||||||
|
|
||||||
|
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: §rCheck for Ban in AsyncPreLoginEvent");
|
||||||
changes.push(" §7• §r§lFIX: §rOnly kick player after Entity isn't ticking anymore");
|
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: §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: §rHover over Playername for Details (Team)");
|
||||||
changes.push(" §7• §r§lADD: §rRedesigned Chat with Timestamp");
|
changes.push(" §7• §r§lADD: §rRedesigned Chat with Timestamp");
|
||||||
|
|
||||||
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
new BukkitRunnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!e.getPlayer().isOnline()) {
|
if (!e.getPlayer().isOnline()) {
|
||||||
stopScheduler();
|
this.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (changes.empty()) {
|
if (changes.empty()) {
|
||||||
stopScheduler();
|
this.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.getPlayer().sendMessage(changes.pop());
|
e.getPlayer().sendMessage(changes.pop());
|
||||||
}
|
}
|
||||||
}, 20, 20);
|
}.runTaskTimer(plugin, 20, 20);
|
||||||
}
|
|
||||||
|
|
||||||
private void stopScheduler() {
|
|
||||||
Bukkit.getScheduler().cancelTask(this.task);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler()
|
@EventHandler()
|
||||||
|
@ -76,7 +75,7 @@ public class PlayerJoinQuitListener implements Listener {
|
||||||
if (event instanceof PaperServerListPingEvent) {
|
if (event instanceof PaperServerListPingEvent) {
|
||||||
handlePaperServerListPing((PaperServerListPingEvent) event);
|
handlePaperServerListPing((PaperServerListPingEvent) event);
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getLogger().info("Error: Plugin is not running on a PaperServer");
|
plugin.getLogger().info("Error: Plugin is not running on a PaperServer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue