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
commit0dc7b73337c5259fafc598852c27978ca007aba0 (patch)
tree52b47ef3602536f7d289d3d92ad82e84d896d3de /EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java
parent4fc08153ad6a53e06a8f284a109200d6c4242d6f (diff)
downloadEssentials-0dc7b73337c5259fafc598852c27978ca007aba0.tar
Essentials-0dc7b73337c5259fafc598852c27978ca007aba0.tar.gz
Essentials-0dc7b73337c5259fafc598852c27978ca007aba0.tar.lz
Essentials-0dc7b73337c5259fafc598852c27978ca007aba0.tar.xz
Essentials-0dc7b73337c5259fafc598852c27978ca007aba0.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());