Update2.0 #22
@ -35,41 +35,31 @@ public class Script {
|
||||
private class ScriptExecutor {
|
||||
|
||||
private int index = 0;
|
||||
|
||||
private final RunnableScriptEvent runnableScriptEvent;
|
||||
|
||||
public ScriptExecutor(RunnableScriptEvent runnableScriptEvent) {
|
||||
this.runnableScriptEvent = runnableScriptEvent;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
resume();
|
||||
}
|
||||
|
||||
private void resume() {
|
||||
while (index < runnableScriptList.size()) {
|
||||
RunnableScript runnableScript = runnableScriptList.get(index);
|
||||
RunnableScript runnableScript = runnableScriptList.get(index++);
|
||||
if (runnableScript instanceof DelayScript) {
|
||||
|
||||
index++;
|
||||
resumeLater(((DelayScript) runnableScript).getDelayTime());
|
||||
break;
|
||||
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::resume, ((DelayScript) runnableScript).getDelayTime());
|
||||
return;
|
||||
}
|
||||
if (!runnableScript.execute(runnableScriptEvent)) {
|
||||
index = runnableScriptList.size();
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
private void resumeLater(int delayTime) {
|
||||
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::resume, delayTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void execute(RunnableScriptEvent runnableScriptEvent) {
|
||||
new ScriptExecutor(runnableScriptEvent).start();
|
||||
new ScriptExecutor(runnableScriptEvent);
|
||||
}
|
||||
|
||||
private void add(RunnableScript runnableScript) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Wäre hier nicht eher eine For oder Foreach Schleife angebracht.
?
Nein weil sie auch abgebrochen werden kann mit dem Delay und danach wieder angefangen wird. Somit ist beides keine Option.