mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 18:29:05 +00:00
Prevent Action Crashing
This commit is contained in:
1 parent
b34fb1a226
commit
8952963c74
3 files changed
+37
-16
No files matched your search
+1
-1
@@ -5,7 +5,7 @@ plugins {
|
||||
id 'idea'
|
||||
}
|
||||
|
||||
version = "1.10-testingbeta18.2"
|
||||
version = "1.10-testingbeta18.4"
|
||||
group= "kamkeel.customnpc-plus"
|
||||
archivesBaseName = "CustomNPC-Plus"
|
||||
|
||||
|
||||
@@ -69,8 +69,14 @@ public class Action implements IAction {
|
||||
return;
|
||||
}
|
||||
if (ticksExisted % updateEveryXTick == 0 && task != null) {
|
||||
task.accept(this);
|
||||
count++;
|
||||
try {
|
||||
task.accept(this);
|
||||
count++;
|
||||
} catch (Throwable t) {
|
||||
System.err.println("Scripted action '" + name + "' threw an exception:");
|
||||
t.printStackTrace();
|
||||
markDone();
|
||||
}
|
||||
}
|
||||
duration++;
|
||||
}
|
||||
|
||||
@@ -48,23 +48,38 @@ public class ConditionalAction extends Action implements IConditionalAction {
|
||||
@Override
|
||||
public void tick(int ticksExisted) {
|
||||
if (isDone()) return;
|
||||
if (ticksExisted % updateEveryXTick == 0) {
|
||||
checkCount++;
|
||||
boolean terminated = terminateWhen != null && terminateWhen.get();
|
||||
if (terminated && onTermination != null)
|
||||
onTermination.accept(this);
|
||||
|
||||
if ((maxChecks >= 0 && checkCount > maxChecks) || terminated) {
|
||||
markDone();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (ticksExisted % updateEveryXTick == 0) {
|
||||
checkCount++;
|
||||
boolean terminated = terminateWhen != null && terminateWhen.get();
|
||||
|
||||
if (condition != null && condition.get()) {
|
||||
task.accept(this);
|
||||
taskExecuted = true;
|
||||
if (terminated && onTermination != null) {
|
||||
try {
|
||||
onTermination.accept(this);
|
||||
} catch (Throwable t) {
|
||||
System.err.println("Error in onTermination for conditional '" + getName() + "':");
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if ((maxChecks >= 0 && checkCount > maxChecks) || terminated) {
|
||||
markDone();
|
||||
return;
|
||||
}
|
||||
|
||||
if (condition != null && condition.get()) {
|
||||
task.accept(this);
|
||||
taskExecuted = true;
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
System.err.println("Scripted conditional '" + getName() + "' threw an exception:");
|
||||
t.printStackTrace();
|
||||
markDone();
|
||||
} finally {
|
||||
duration++;
|
||||
}
|
||||
duration++;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user