mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 08:45:11 +00:00
cleared ActionManager on NPC delete
This commit is contained in:
1 parent
6a04a0ea28
commit
bc2bab889d
3 files changed
+48
-37
No files matched your search
@@ -149,9 +149,13 @@ public class Action implements IAction {
|
||||
return done;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kill() {
|
||||
if (actionThread != null)
|
||||
actionThread.stop();
|
||||
|
||||
dataStore.clear();
|
||||
done = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1407,6 +1407,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
roleInterface.delete();
|
||||
if (advanced.job != EnumJobType.None && jobInterface != null)
|
||||
jobInterface.delete();
|
||||
actionManager.clear();
|
||||
|
||||
super.setDead();
|
||||
}
|
||||
|
||||
|
||||
@@ -214,43 +214,6 @@ public class ScriptedActionManager implements IActionManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
actionQueue.clear();
|
||||
parallelActions.clear();
|
||||
conditionalActions.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancelAction(String name) {
|
||||
Iterator<IAction> acts = actionQueue.iterator();
|
||||
while (acts.hasNext()) {
|
||||
IAction act = acts.next();
|
||||
if (act.getName().equals(name)) {
|
||||
acts.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<IAction> pit = parallelActions.iterator();
|
||||
while (pit.hasNext()) {
|
||||
if (pit.next().getName().equals(name)) {
|
||||
pit.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<IConditionalAction> cons = conditionalActions.iterator();
|
||||
while (cons.hasNext()) {
|
||||
IConditionalAction con = cons.next();
|
||||
if (con.getName().equals(name)) {
|
||||
cons.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
// Conditionals
|
||||
@@ -368,6 +331,48 @@ public class ScriptedActionManager implements IActionManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
actionQueue.forEach((act) -> act.kill());
|
||||
actionQueue.clear();
|
||||
|
||||
parallelActions.forEach((act) -> act.kill());
|
||||
parallelActions.clear();
|
||||
|
||||
conditionalActions.forEach((act) -> act.kill());
|
||||
conditionalActions.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancelAction(String name) {
|
||||
Iterator<IAction> acts = actionQueue.iterator();
|
||||
while (acts.hasNext()) {
|
||||
IAction act = acts.next();
|
||||
if (act.getName().equals(name)) {
|
||||
acts.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<IAction> pit = parallelActions.iterator();
|
||||
while (pit.hasNext()) {
|
||||
if (pit.next().getName().equals(name)) {
|
||||
pit.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<IConditionalAction> cons = conditionalActions.iterator();
|
||||
while (cons.hasNext()) {
|
||||
IConditionalAction con = cons.next();
|
||||
if (con.getName().equals(name)) {
|
||||
cons.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IActionChain chain() {
|
||||
return new ActionChain(this);
|
||||
|
||||
Reference in new issue
Block a user