Package games.stendhal.server.entity.npc
Class NPCList
java.lang.Object
games.stendhal.server.entity.npc.NPCList
- All Implemented Interfaces:
Iterable<SpeakerNPC>
This Singleton should contain all NPCs in the Stendhal world that are unique.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add(SpeakerNPC npc)
Adds an NPC to the NPCList.void
clear()
Removes all NPCs from this list.static NPCList
get()
Returns the Singleton instance.Returns the NPC with the given name.getNPCs()
Returns a list of all NPCs.boolean
Checks whether an NPC with the given name exists.iterator()
Removes an NPC from the NPCList.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
NPCList
protected NPCList()
-
-
Method Details
-
get
Returns the Singleton instance.- Returns:
- The instance
-
get
Returns the NPC with the given name.- Parameters:
name
- The NPC's name- Returns:
- The NPC, or null if there is no NPC with this name
-
has
Checks whether an NPC with the given name exists.- Parameters:
name
- The NPC's name- Returns:
- true iff an NPC with the given name exists
-
add
Adds an NPC to the NPCList. Does nothing if an NPC with the same name already exists. This makes sure that each NPC can be uniquely identified by his/her name.- Parameters:
npc
- The NPC that should be added
-
remove
Removes an NPC from the NPCList. Does nothing if no NPC with the given name exists.- Parameters:
name
- The name of the NPC that should be removed- Returns:
- SpeakerNPC or null in case it was not in the list
-
getNPCs
Returns a list of all NPCs.- Returns:
- list of npcs
-
clear
public void clear()Removes all NPCs from this list. -
iterator
- Specified by:
iterator
in interfaceIterable<SpeakerNPC>
- Returns:
- the interator over the SpeakerNPC objects.
-