mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 19:34:09 +00:00
IActionListener Comments
This commit is contained in:
1 parent
41d4ca8c27
commit
1b76f1ab7e
3 files changed
+40
-38
No files matched your search
@@ -262,18 +262,18 @@ public class Action implements IAction {
|
||||
//////////////////////////////////////////////////
|
||||
// Listener
|
||||
|
||||
public IAction listenTo(String hook, Object object) {
|
||||
return listenTo(hook, manager.getOrCreateListener(object));
|
||||
}
|
||||
|
||||
public IAction listenTo(String hook, IActionListener listener) {
|
||||
return listenTo(listener.getOrCreateHook(hook));
|
||||
}
|
||||
|
||||
public IAction listenTo(ActionListener.Hook hook) {
|
||||
hook.schedule(this);
|
||||
return this;
|
||||
}
|
||||
// public IAction listenTo(String hook, Object object) {
|
||||
// return listenTo(hook, manager.getOrCreateListener(object));
|
||||
// }
|
||||
//
|
||||
// public IAction listenTo(String hook, IActionListener listener) {
|
||||
// return listenTo(listener.getOrCreateHook(hook));
|
||||
// }
|
||||
//
|
||||
// public IAction listenTo(ActionListener.Hook hook) {
|
||||
// hook.schedule(this);
|
||||
// return this;
|
||||
// }
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
@@ -38,8 +38,7 @@ public class ActionManager implements IActionManager {
|
||||
protected boolean debug;
|
||||
protected ScriptContainer reportTo;
|
||||
|
||||
public ActionManager() {
|
||||
}
|
||||
public ActionManager() {}
|
||||
|
||||
public ActionManager(String name) {
|
||||
this.name = name;
|
||||
@@ -87,30 +86,32 @@ public class ActionManager implements IActionManager {
|
||||
///////////////////////////////////////////////////
|
||||
// Listeners
|
||||
|
||||
public IActionListener getOrCreateListener(Object obj) {
|
||||
return listeners.computeIfAbsent(obj, o -> new ActionListener(o));
|
||||
}
|
||||
// IActionListener Comments
|
||||
// public IActionListener getOrCreateListener(Object obj) {
|
||||
// return listeners.computeIfAbsent(obj, o -> new ActionListener(o));
|
||||
// }
|
||||
|
||||
public IActionListener getListener(Object obj) {
|
||||
return listeners.get(obj);
|
||||
}
|
||||
// public IActionListener getListener(Object obj) {
|
||||
// return listeners.get(obj);
|
||||
// }
|
||||
|
||||
public boolean removeListener(Object obj) {
|
||||
if (listeners.containsKey(obj)) {
|
||||
listeners.remove(obj);
|
||||
return true;
|
||||
}
|
||||
// public boolean removeListener(Object obj) {
|
||||
// if (listeners.containsKey(obj)) {
|
||||
// listeners.remove(obj);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
// public boolean fireListener(String hookName, Object obj) {
|
||||
// IActionListener listener = getListener(obj);
|
||||
// if (listener != null)
|
||||
// return listener.fire(hookName);
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public boolean fireListener(String hookName, Object obj) {
|
||||
IActionListener listener = getListener(obj);
|
||||
if (listener != null)
|
||||
return listener.fire(hookName);
|
||||
|
||||
return false;
|
||||
}
|
||||
///////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
// Creators
|
||||
@@ -496,9 +497,10 @@ public class ActionManager implements IActionManager {
|
||||
}
|
||||
}
|
||||
// ─── All Listeners ─────────────────────────────────────────
|
||||
if (this == GLOBAL) {
|
||||
listeners.forEach((obj, listener) -> ((ActionListener) listener).tick());
|
||||
}
|
||||
// IActionListener Comments
|
||||
// if (this == GLOBAL) {
|
||||
// listeners.forEach((obj, listener) -> ((ActionListener) listener).tick());
|
||||
// }
|
||||
|
||||
if (debug && active)
|
||||
LOGGER.finish("Finished Tick Cycle",this);
|
||||
|
||||
Reference in new issue
Block a user