mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-08-26 15:32:50 +02:00
Abort the installation wizard if a runtime exception happens
This commit is contained in:
parent
48f8eb9788
commit
5641b1173c
|
@ -71,6 +71,8 @@ public abstract class AbstractState
|
|||
abort();
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
final boolean found = reactOnAnswer(trimmedAnswer);
|
||||
if (found)
|
||||
{
|
||||
|
@ -82,6 +84,12 @@ public abstract class AbstractState
|
|||
return this;
|
||||
}
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
sender.sendMessage(ex.toString());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do something based on the answer, that the user gave.
|
||||
|
|
|
@ -32,15 +32,19 @@ public class StateMachine extends WorkListener
|
|||
}
|
||||
|
||||
public MachineResult askQuestion()
|
||||
{
|
||||
try
|
||||
{
|
||||
while (current.guessAnswer())
|
||||
{
|
||||
|
||||
current = current.getNextState();
|
||||
if (current == null)
|
||||
{
|
||||
result = MachineResult.DONE;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (current != null)
|
||||
{
|
||||
|
@ -50,6 +54,13 @@ public class StateMachine extends WorkListener
|
|||
}
|
||||
result = MachineResult.WAIT;
|
||||
}
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
player.sendMessage(ex.getMessage());
|
||||
finish();
|
||||
result = MachineResult.ABORT;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -135,6 +146,7 @@ public class StateMachine extends WorkListener
|
|||
|
||||
private void finish()
|
||||
{
|
||||
current = null;
|
||||
iterator = null;
|
||||
states.clear();
|
||||
getPlugin().getServer().getPluginManager().callEvent(new InstallationFinishedEvent());
|
||||
|
|
Loading…
Reference in New Issue
Block a user