mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 01:27:27 +00:00
More constructors and setters
This commit is contained in:
1 parent
b757e5ed8d
commit
05bcb6f29a
2 files changed
+49
-12
No files matched your search
+1
-1
Submodule src/api updated: 0bbb00f1e1...d053084ee0.
@@ -22,6 +22,16 @@ public class ScriptedActionManager implements IActionManager {
|
||||
private final Deque<IAction> actionQueue = new LinkedList<>();
|
||||
private final List<IConditionalAction> conditionalActions = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public IAction create(String name) {
|
||||
return new Action(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAction create(Consumer<IAction> t) {
|
||||
return new Action(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAction create(String name, int maxDuration, int startAfterTicks, Consumer<IAction> task) {
|
||||
return new Action(name, maxDuration, startAfterTicks, task);
|
||||
@@ -42,11 +52,6 @@ public class ScriptedActionManager implements IActionManager {
|
||||
return new Action(name, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAction create(Consumer<IAction> t) {
|
||||
return new Action(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConditionalAction create(Supplier<Boolean> predicate, Consumer<IAction> task) {
|
||||
return new ConditionalAction(predicate, task);
|
||||
@@ -235,9 +240,17 @@ public class ScriptedActionManager implements IActionManager {
|
||||
protected int duration;
|
||||
protected int maxDuration = -1;
|
||||
protected int updateEveryXTick = 5;
|
||||
protected final Consumer<IAction> task;
|
||||
protected Consumer<IAction> task;
|
||||
private boolean done = false;
|
||||
|
||||
protected ActionBase(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
protected ActionBase(Consumer<IAction> task) {
|
||||
this(task.toString());
|
||||
this.task = task;
|
||||
}
|
||||
protected ActionBase(String name, int maxDuration, int startAfterTicks, Consumer<IAction> task) {
|
||||
this.name = name;
|
||||
this.maxDuration = maxDuration;
|
||||
@@ -261,10 +274,12 @@ public class ScriptedActionManager implements IActionManager {
|
||||
this.startAfterTicks = startAfterTicks;
|
||||
}
|
||||
|
||||
protected ActionBase(Consumer<IAction> task) {
|
||||
this.name = task.toString();
|
||||
@Override
|
||||
public IAction setTask(Consumer<IAction> task) {
|
||||
this.task = task;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once per global tick; respects delay, interval, duration & done‐flag.
|
||||
*/
|
||||
@@ -306,6 +321,12 @@ public class ScriptedActionManager implements IActionManager {
|
||||
return maxDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAction setMaxDuration(int x) {
|
||||
maxDuration = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDone() {
|
||||
done = true;
|
||||
@@ -328,6 +349,12 @@ public class ScriptedActionManager implements IActionManager {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAction removeData(String key) {
|
||||
dataStore.remove(key);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpdateEveryXTick() {
|
||||
return updateEveryXTick;
|
||||
@@ -344,6 +371,11 @@ public class ScriptedActionManager implements IActionManager {
|
||||
return startAfterTicks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAction pauseFor(int ticks) {
|
||||
startAfterTicks = ticks;
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public IAction getNext() {
|
||||
int idx = getIndex(this);
|
||||
@@ -434,6 +466,14 @@ public class ScriptedActionManager implements IActionManager {
|
||||
}
|
||||
|
||||
private class Action extends ActionBase {
|
||||
|
||||
public Action(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public Action(Consumer<IAction> task) {
|
||||
super(task);
|
||||
}
|
||||
public Action(String name, int maxDuration, int startAfterTicks, Consumer<IAction> task) {
|
||||
super(name, maxDuration, startAfterTicks, task);
|
||||
}
|
||||
@@ -450,9 +490,6 @@ public class ScriptedActionManager implements IActionManager {
|
||||
super(startAfterTicks, task);
|
||||
}
|
||||
|
||||
public Action(Consumer<IAction> task) {
|
||||
super(task);
|
||||
}
|
||||
|
||||
@Override public int getCheckCount() { return 0; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user