Switched form listening to player login events to player join events.
This commit is contained in:
parent
1a1cbab798
commit
89fdd622ca
@ -48,7 +48,7 @@ public class Plugin extends JavaPlugin
|
|||||||
// create listeners
|
// create listeners
|
||||||
PlayerMoveListener playerMoveListener = new PlayerMoveListener();
|
PlayerMoveListener playerMoveListener = new PlayerMoveListener();
|
||||||
PlayerTeleportListener playerTeleportListener = new PlayerTeleportListener();
|
PlayerTeleportListener playerTeleportListener = new PlayerTeleportListener();
|
||||||
PlayerLoginListener playerLoginListener = new PlayerLoginListener();
|
PlayerJoinListener playerJoinListener = new PlayerJoinListener();
|
||||||
PlayerQuitListener playerQuitListener = new PlayerQuitListener();
|
PlayerQuitListener playerQuitListener = new PlayerQuitListener();
|
||||||
|
|
||||||
// commands
|
// commands
|
||||||
@ -59,7 +59,7 @@ public class Plugin extends JavaPlugin
|
|||||||
PluginManager pm = this.getServer().getPluginManager();
|
PluginManager pm = this.getServer().getPluginManager();
|
||||||
pm.registerEvents(playerMoveListener, this);
|
pm.registerEvents(playerMoveListener, this);
|
||||||
pm.registerEvents(playerTeleportListener, this);
|
pm.registerEvents(playerTeleportListener, this);
|
||||||
pm.registerEvents(playerLoginListener, this);
|
pm.registerEvents(playerJoinListener, this);
|
||||||
pm.registerEvents(playerQuitListener, this);
|
pm.registerEvents(playerQuitListener, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,21 +17,19 @@
|
|||||||
package de.craftinc.borderprotection.events;
|
package de.craftinc.borderprotection.events;
|
||||||
|
|
||||||
import de.craftinc.borderprotection.Messages;
|
import de.craftinc.borderprotection.Messages;
|
||||||
import de.craftinc.borderprotection.Plugin;
|
|
||||||
import de.craftinc.borderprotection.util.ChunkGenerator;
|
import de.craftinc.borderprotection.util.ChunkGenerator;
|
||||||
import de.craftinc.borderprotection.util.UpdateHelper;
|
import de.craftinc.borderprotection.util.UpdateHelper;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
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")
|
@SuppressWarnings("unused")
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerLogin( PlayerLoginEvent e )
|
public void onPlayerLogin( PlayerJoinEvent e )
|
||||||
{
|
{
|
||||||
final Player player = e.getPlayer();
|
final Player player = e.getPlayer();
|
||||||
|
|
||||||
@ -39,20 +37,12 @@ public class PlayerLoginListener implements Listener
|
|||||||
{
|
{
|
||||||
if ( UpdateHelper.newVersionAvailable() )
|
if ( UpdateHelper.newVersionAvailable() )
|
||||||
{
|
{
|
||||||
// Schedule a task which delays 20 ticks (1 second) and then sends a message to the player
|
String updateMessage = Messages.updateMessage(UpdateHelper.cachedLatestVersion, UpdateHelper.getCurrentVersion());
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, new Runnable()
|
e.setJoinMessage(e.getJoinMessage() + "\n" + updateMessage);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
player.sendMessage(Messages.updateMessage(UpdateHelper.cachedLatestVersion,
|
|
||||||
UpdateHelper.getCurrentVersion()));
|
|
||||||
}
|
|
||||||
}, 20L);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
ChunkGenerator.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user