From 89fdd622ca3f80c0563e1aaf3800b42b49257244 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Tue, 11 Jun 2013 20:02:48 +0200 Subject: [PATCH] Switched form listening to player login events to player join events. --- .../de/craftinc/borderprotection/Plugin.java | 4 ++-- ...nListener.java => PlayerJoinListener.java} | 22 +++++-------------- 2 files changed, 8 insertions(+), 18 deletions(-) rename src/main/java/de/craftinc/borderprotection/events/{PlayerLoginListener.java => PlayerJoinListener.java} (63%) diff --git a/src/main/java/de/craftinc/borderprotection/Plugin.java b/src/main/java/de/craftinc/borderprotection/Plugin.java index e898d0f..af2e09a 100644 --- a/src/main/java/de/craftinc/borderprotection/Plugin.java +++ b/src/main/java/de/craftinc/borderprotection/Plugin.java @@ -48,7 +48,7 @@ public class Plugin extends JavaPlugin // create listeners PlayerMoveListener playerMoveListener = new PlayerMoveListener(); PlayerTeleportListener playerTeleportListener = new PlayerTeleportListener(); - PlayerLoginListener playerLoginListener = new PlayerLoginListener(); + PlayerJoinListener playerJoinListener = new PlayerJoinListener(); PlayerQuitListener playerQuitListener = new PlayerQuitListener(); // commands @@ -59,7 +59,7 @@ public class Plugin extends JavaPlugin PluginManager pm = this.getServer().getPluginManager(); pm.registerEvents(playerMoveListener, this); pm.registerEvents(playerTeleportListener, this); - pm.registerEvents(playerLoginListener, this); + pm.registerEvents(playerJoinListener, this); pm.registerEvents(playerQuitListener, this); } } diff --git a/src/main/java/de/craftinc/borderprotection/events/PlayerLoginListener.java b/src/main/java/de/craftinc/borderprotection/events/PlayerJoinListener.java similarity index 63% rename from src/main/java/de/craftinc/borderprotection/events/PlayerLoginListener.java rename to src/main/java/de/craftinc/borderprotection/events/PlayerJoinListener.java index 8089da0..93a22a0 100644 --- a/src/main/java/de/craftinc/borderprotection/events/PlayerLoginListener.java +++ b/src/main/java/de/craftinc/borderprotection/events/PlayerJoinListener.java @@ -17,21 +17,19 @@ package de.craftinc.borderprotection.events; import de.craftinc.borderprotection.Messages; -import de.craftinc.borderprotection.Plugin; import de.craftinc.borderprotection.util.ChunkGenerator; import de.craftinc.borderprotection.util.UpdateHelper; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerJoinEvent; -public class PlayerLoginListener implements Listener +public class PlayerJoinListener implements Listener { @SuppressWarnings("unused") @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerLogin( PlayerLoginEvent e ) + public void onPlayerLogin( PlayerJoinEvent e ) { final Player player = e.getPlayer(); @@ -39,20 +37,12 @@ public class PlayerLoginListener implements Listener { if ( UpdateHelper.newVersionAvailable() ) { - // Schedule a task which delays 20 ticks (1 second) and then sends a message to the player - Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, new Runnable() - { - @Override - public void run() - { - player.sendMessage(Messages.updateMessage(UpdateHelper.cachedLatestVersion, - UpdateHelper.getCurrentVersion())); - } - }, 20L); + String updateMessage = Messages.updateMessage(UpdateHelper.cachedLatestVersion, UpdateHelper.getCurrentVersion()); + e.setJoinMessage(e.getJoinMessage() + "\n" + updateMessage); } } - System.out.println("pausing generation"); + System.out.println("pausing generation"); // TODO: send message to player with correct permission about current progress of the generation. ChunkGenerator.pause(); } }