Update2.0 #22
@ -35,41 +35,31 @@ public class Script {
|
|||||||
private class ScriptExecutor {
|
private class ScriptExecutor {
|
||||||
|
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
|
||||||
private final RunnableScriptEvent runnableScriptEvent;
|
private final RunnableScriptEvent runnableScriptEvent;
|
||||||
|
|
||||||
public ScriptExecutor(RunnableScriptEvent runnableScriptEvent) {
|
public ScriptExecutor(RunnableScriptEvent runnableScriptEvent) {
|
||||||
this.runnableScriptEvent = runnableScriptEvent;
|
this.runnableScriptEvent = runnableScriptEvent;
|
||||||
}
|
|
||||||
|
|
||||||
public void start() {
|
|
||||||
resume();
|
resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resume() {
|
private void resume() {
|
||||||
while (index < runnableScriptList.size()) {
|
while (index < runnableScriptList.size()) {
|
||||||
RunnableScript runnableScript = runnableScriptList.get(index);
|
RunnableScript runnableScript = runnableScriptList.get(index++);
|
||||||
if (runnableScript instanceof DelayScript) {
|
if (runnableScript instanceof DelayScript) {
|
||||||
|
|||||||
index++;
|
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::resume, ((DelayScript) runnableScript).getDelayTime());
|
||||||
resumeLater(((DelayScript) runnableScript).getDelayTime());
|
return;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (!runnableScript.execute(runnableScriptEvent)) {
|
if (!runnableScript.execute(runnableScriptEvent)) {
|
||||||
index = runnableScriptList.size();
|
index = runnableScriptList.size();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resumeLater(int delayTime) {
|
|
||||||
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::resume, delayTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(RunnableScriptEvent runnableScriptEvent) {
|
public void execute(RunnableScriptEvent runnableScriptEvent) {
|
||||||
new ScriptExecutor(runnableScriptEvent).start();
|
new ScriptExecutor(runnableScriptEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(RunnableScript runnableScript) {
|
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.