Class SpeakerNPCFactory

java.lang.Object
games.stendhal.server.entity.npc.SpeakerNPCFactory
All Implemented Interfaces:
ConfigurableFactory

public class SpeakerNPCFactory extends Object implements ConfigurableFactory
A base factory for SpeakerNPC objects.
  • Constructor Details

    • SpeakerNPCFactory

      public SpeakerNPCFactory()
  • Method Details

    • instantiate

      protected SpeakerNPC instantiate(String name)
      Creates a new SpeakerNPC. Override this if you want to use a subclass of SpeakerNPC.
      Parameters:
      name - The NPC name.
      Returns:
      An object of class SpeakerNPC or a subclass.
    • getName

      protected String getName(ConfigurableFactoryContext ctx)
      Extract the NPC name from a context.
      Parameters:
      ctx - The configuration context.
      Returns:
      The name
      Throws:
      IllegalArgumentException - If the attribute is missing.
    • getClass

      protected String getClass(ConfigurableFactoryContext ctx)
      Extract the NPC class (i.e. its visual appearance) from a context.
      Parameters:
      ctx - The configuration context.
      Returns:
      The class.
      Throws:
      IllegalArgumentException - If the attribute is missing.
    • getHP

      protected int getHP(ConfigurableFactoryContext ctx)
      Extract the NPC hitpoints from a context.
      Parameters:
      ctx - The configuration context.
      Returns:
      The hitpoints.
    • getLevel

      protected int getLevel(ConfigurableFactoryContext ctx)
      Extract the NPC level from a context.
      Parameters:
      ctx - The configuration context.
      Returns:
      The level of experience.
    • getDescription

      protected String getDescription(ConfigurableFactoryContext ctx)
      Extract the NPC description from a context.
      Parameters:
      ctx - The configuration context.
      Returns:
      The text that will be shown when a player looks at the NPC, or null if the default description should be used.
    • getDirection

      protected Direction getDirection(ConfigurableFactoryContext ctx)
      Extract the direction in which the NPC faces from a context.
      Parameters:
      ctx - The configuration context.
      Returns:
      The hitpoints.
    • createDialog

      public void createDialog(SpeakerNPC npc)
    • getPath

      protected List<Node> getPath(ConfigurableFactoryContext ctx)
    • create

      public Object create(ConfigurableFactoryContext ctx)
      Create a damaging area.
      Specified by:
      create in interface ConfigurableFactory
      Parameters:
      ctx - Configuration context.
      Returns:
      A SpeakerNPC.
      Throws:
      IllegalArgumentException - If there is a problem with the attributes. The exception message should be a value suitable for meaningful user interpretation.
      See Also:
      SpeakerNPC