AbstractScript uses NPC templates to register events.

This commit is contained in:
MobiusDevelopment
2021-09-17 14:03:38 +00:00
parent 6b6e2585c8
commit 3918bbc997
42 changed files with 151 additions and 46 deletions

View File

@@ -1511,6 +1511,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1511,6 +1511,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1511,6 +1511,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1511,6 +1511,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1511,6 +1511,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1511,6 +1511,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1511,6 +1511,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1511,6 +1511,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1512,6 +1512,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1512,6 +1512,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1751,8 +1751,14 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPC's within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event
* @param radius - radius to send event * @param radius - radius to send event
* @param reference - WorldObject to pass, if needed * @param reference - WorldObject to pass, if needed
@@ -1761,7 +1767,7 @@ public class Npc extends Creature
{ {
World.getInstance().forEachVisibleObjectInRange(this, Npc.class, radius, obj -> World.getInstance().forEachVisibleObjectInRange(this, Npc.class, radius, obj ->
{ {
if (obj.isNpc() && obj.hasListener(EventType.ON_NPC_EVENT_RECEIVED)) if (obj.hasListener(EventType.ON_NPC_EVENT_RECEIVED))
{ {
EventDispatcher.getInstance().notifyEventAsync(new OnNpcEventReceived(eventName, this, obj, reference), obj); EventDispatcher.getInstance().notifyEventAsync(new OnNpcEventReceived(eventName, this, obj, reference), obj);
} }

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1751,8 +1751,14 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPC's within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event
* @param radius - radius to send event * @param radius - radius to send event
* @param reference - WorldObject to pass, if needed * @param reference - WorldObject to pass, if needed
@@ -1761,7 +1767,7 @@ public class Npc extends Creature
{ {
World.getInstance().forEachVisibleObjectInRange(this, Npc.class, radius, obj -> World.getInstance().forEachVisibleObjectInRange(this, Npc.class, radius, obj ->
{ {
if (obj.isNpc() && obj.hasListener(EventType.ON_NPC_EVENT_RECEIVED)) if (obj.hasListener(EventType.ON_NPC_EVENT_RECEIVED))
{ {
EventDispatcher.getInstance().notifyEventAsync(new OnNpcEventReceived(eventName, this, obj, reference), obj); EventDispatcher.getInstance().notifyEventAsync(new OnNpcEventReceived(eventName, this, obj, reference), obj);
} }

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1511,6 +1511,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1511,6 +1511,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1511,6 +1511,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1523,6 +1523,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1523,6 +1523,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1523,6 +1523,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1495,6 +1495,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1524,6 +1524,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**

View File

@@ -1524,6 +1524,12 @@ public class Npc extends Creature
return vars != null ? vars : addScript(new NpcVariables()); return vars != null ? vars : addScript(new NpcVariables());
} }
@Override
public boolean hasListener(EventType type)
{
return getTemplate().hasListener(type);
}
/** /**
* Send an "event" to all NPCs within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event

View File

@@ -108,8 +108,7 @@ public class ListenersContainer
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
// FIXME: return (_listeners != null) && !getListeners(type).isEmpty(); return (_listeners != null) && !getListeners(type).isEmpty();
return !getListeners(type).isEmpty();
} }
/** /**