From b37f9a7ea4ea686029ac6c631c5e490e75cd300c Mon Sep 17 00:00:00 2001 From: bigguy345 Date: Tue, 8 Jul 2025 12:00:37 +0300 Subject: [PATCH] Added Action.getIdentifier --- .../noppes/npcs/controllers/data/action/Action.java | 13 +++++++++---- .../npcs/controllers/data/action/ActionQueue.java | 8 ++++---- .../data/action/action/ConditionalAction.java | 3 +-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/noppes/npcs/controllers/data/action/Action.java b/src/main/java/noppes/npcs/controllers/data/action/Action.java index 3951b09b2..76df3d8e6 100644 --- a/src/main/java/noppes/npcs/controllers/data/action/Action.java +++ b/src/main/java/noppes/npcs/controllers/data/action/Action.java @@ -107,7 +107,7 @@ public class Action implements IAction { this.isScheduled = true; if (manager.debug) - manager.LOGGER.log(String.format("Scheduled Action '%s'", name), queue); + manager.LOGGER.log(String.format("Scheduled %s", getIdentifier()), queue); } @Override @@ -278,7 +278,7 @@ public class Action implements IAction { } if (duration == 0 && onStart != null) - execute("start", this::executeOnStart); + execute("onStart", this::executeOnStart); if (done) return; @@ -369,7 +369,7 @@ public class Action implements IAction { @Override public void kill() { if (manager.debug) - manager.LOGGER.log(String.format("Killing Action '%s'...", name), queue); + manager.LOGGER.log(String.format("Killing %s...", getIdentifier()), queue); if (actionThread != null) actionThread.stop(); @@ -380,8 +380,13 @@ public class Action implements IAction { } + @Override + public String getIdentifier() { + return String.format("%s '%s'", getClass().getSimpleName(), name); + } + public String toString() { - return String.format("%s '%s' [queue='%s', scheduled=%s, done=%s, paused=%s, updateEvery=%s, duration=%d/%d, count=%d/%d, threaded=%s]", getClass().getSimpleName(), name != null ? name : "unnamed", getQueueName(), isScheduled, done, isPaused(), updateEveryXTick, duration, maxDuration, count, maxCount, isThreaded); + return String.format("%s [queue='%s', scheduled=%s, done=%s, paused=%s, updateEvery=%s, duration=%d/%d, count=%d/%d, threaded=%s]", getIdentifier(), getQueueName(), isScheduled, done, isPaused(), updateEveryXTick, duration, maxDuration, count, maxCount, isThreaded); } /////////////////////////////////////////////////// ////////////////////////////////////////////////// diff --git a/src/main/java/noppes/npcs/controllers/data/action/ActionQueue.java b/src/main/java/noppes/npcs/controllers/data/action/ActionQueue.java index 1a07eee03..cd06bacf2 100644 --- a/src/main/java/noppes/npcs/controllers/data/action/ActionQueue.java +++ b/src/main/java/noppes/npcs/controllers/data/action/ActionQueue.java @@ -264,12 +264,12 @@ public class ActionQueue implements IActionQueue { public boolean finish(Action a) { if (a.isDone()) { if (a.onDone != null) - a.execute("done", a::executeOnDone); + a.execute("onDone", a::executeOnDone); a.kill(); if (manager.debug) - manager.LOGGER.finish(String.format("Removing Action '%s' from queue", a.name), this); + manager.LOGGER.finish(String.format("Removing %s from queue", a.getIdentifier()), this); return true; } @@ -281,12 +281,12 @@ public class ActionQueue implements IActionQueue { boolean wasDone = a.isDone(); if (manager.debug && !wasDone) - manager.LOGGER.push(this).log(String.format("Started ticking Action '%s' ", a.name), this).push(a); + manager.LOGGER.push(this).log(String.format("Started ticking %s", a.getIdentifier(), a.name), this).push(a); a.tick(); if (manager.debug && !wasDone) - manager.LOGGER.pop().finish(String.format("Finished ticking Action '%s' ", a.name), this).pop(); + manager.LOGGER.pop().finish(String.format("Finished ticking %s", a.getIdentifier(), a.name), this).pop(); return finish(a); } diff --git a/src/main/java/noppes/npcs/controllers/data/action/action/ConditionalAction.java b/src/main/java/noppes/npcs/controllers/data/action/action/ConditionalAction.java index 04eddd3b3..7bcd0ef97 100644 --- a/src/main/java/noppes/npcs/controllers/data/action/action/ConditionalAction.java +++ b/src/main/java/noppes/npcs/controllers/data/action/action/ConditionalAction.java @@ -155,8 +155,7 @@ public class ConditionalAction extends Action implements IConditionalAction { public String toString() { - return String.format("%s '%s' [queue='%s', scheduled=%s, done=%s, paused=%s, updateEvery=%s, duration=%d/%d, count=%d/%d, checks=%d/%d, taskExecuted=%s, threaded=%s]", getClass().getSimpleName(), - name != null ? name : "unnamed", getQueueName(), + return String.format("%s [queue='%s', scheduled=%s, done=%s, paused=%s, updateEvery=%s, duration=%d/%d, count=%d/%d, checks=%d/%d, taskExecuted=%s, threaded=%s]", getIdentifier(), getQueueName(), isScheduled, done, isPaused(),