Switched form listening to player login events to player join events.

This commit is contained in:
Tobias Ottenweller 2013-06-11 20:02:48 +02:00
parent 1a1cbab798
commit 89fdd622ca
2 changed files with 8 additions and 18 deletions

View File

@ -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);
}
}

View File

@ -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();
}
}