summaryrefslogtreecommitdiffstats
path: root/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-10-26 19:39:01 +0200
committersnowleo <schneeleo@gmail.com>2011-10-26 19:39:01 +0200
commit48f8eb9788dd1c49f563d7b5f2d06c27b7ab3201 (patch)
treee26fdb901b68ecc4f473c1151d1678de3f89e723 /EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java
parent7f825750f076e570ffaeecc7de6cb26f202e84ca (diff)
downloadEssentials-48f8eb9788dd1c49f563d7b5f2d06c27b7ab3201.tar
Essentials-48f8eb9788dd1c49f563d7b5f2d06c27b7ab3201.tar.gz
Essentials-48f8eb9788dd1c49f563d7b5f2d06c27b7ab3201.tar.lz
Essentials-48f8eb9788dd1c49f563d7b5f2d06c27b7ab3201.tar.xz
Essentials-48f8eb9788dd1c49f563d7b5f2d06c27b7ab3201.zip
Cleanly resume the installation, if the player quits the game and reconnects
If the installation is already running in background after the wizard, it will not stop, if the player quits the game.
Diffstat (limited to 'EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java')
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java
index 80434480f..c582ebd53 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java
@@ -1,10 +1,13 @@
package com.earth2me.essentials.update;
+import com.earth2me.essentials.update.states.InstallationFinishedEvent;
import com.earth2me.essentials.update.states.StateMachine;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.event.CustomEventListener;
+import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerChatEvent;
@@ -32,6 +35,18 @@ public class UpdateProcess extends PlayerListener
final PluginManager pluginManager = plugin.getServer().getPluginManager();
pluginManager.registerEvent(Type.PLAYER_QUIT, this, Priority.Low, plugin);
pluginManager.registerEvent(Type.PLAYER_CHAT, this, Priority.Lowest, plugin);
+ pluginManager.registerEvent(Type.PLAYER_JOIN, this, Priority.Normal, plugin);
+ pluginManager.registerEvent(Type.CUSTOM_EVENT, new CustomEventListener(){
+
+ @Override
+ public void onCustomEvent(final Event event)
+ {
+ if(event instanceof InstallationFinishedEvent) {
+ UpdateProcess.this.currentPlayer = null;
+ }
+ }
+
+ }, Priority.Normal, plugin);
}
@Override
@@ -58,6 +73,13 @@ public class UpdateProcess extends PlayerListener
public void onPlayerJoin(final PlayerJoinEvent event)
{
final Player player = event.getPlayer();
+ if (currentPlayer.getName().equals(player.getName())) {
+ currentPlayer = player;
+ player.sendMessage("You quit the game, while the installion wizard was running.");
+ player.sendMessage("The installation wizard will now resume.");
+ player.sendMessage("You can exit the wizard by typing quit into the chat.");
+ stateMachine.resumeInstallation(player);
+ }
if (player.hasPermission("essentials.update") && !updateCheck.isEssentialsInstalled())
{
player.sendMessage("Hello " + player.getDisplayName());