Class ScriptTrait

java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.trait.ScriptTrait
All Implemented Interfaces:
Runnable, Listener

public class ScriptTrait extends Trait
Stores a list of scripts, which are pieces of arbitrary code that can be run every tick.
See Also:
  • Field Details

  • Constructor Details

    • ScriptTrait

      public ScriptTrait()
  • Method Details

    • addScripts

      public void addScripts(List<String> scripts)
      Add and load all given script file names
      See Also:
    • getScripts

      public List<String> getScripts()
    • load

      public void load(DataKey key)
      Description copied from class: Trait
      Loads a trait.
      Overrides:
      load in class Trait
      Parameters:
      key - DataKey to load from
    • loadScript

      public void loadScript(String file)
      Compile and load a script given by the file name.
      Parameters:
      file - the script file name relative to the script folder
      See Also:
    • removeScripts

      public void removeScripts(List<String> scripts)
      Removes the given script file names.
    • run

      public void run()
      Description copied from class: Trait
      Called every tick if overridden.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Trait
    • validateFile

      public boolean validateFile(String file)
      Whether the file exists and can be compiled by the system ScriptCompiler.