Skip to content

13.5.2020 Sponge & Spigot

Compare
Choose a tag to compare
@NeumimTo NeumimTo released this 13 May 21:48
· 120 commits to 2.1.0 since this release
  • Improved Scripting API

    • Scripts are now compiled by Nashorn
    • you can no longer define skill logic in scripts/*.conf files
    • If you are upgrading from previous versions delete Main.js & you will have to edit most of your scripts
  • Changed & Simplified skill execution pipeline

    • reduced unnecessary overhead
  • Plugin is much less strict on missconfiguration during startup.

    • If zou happend to have something wrong in conf files, the plugin will only print warning to the console, and wont disable itself. (you can fix the issues and then do /nadmin reload)

New skill scripting api

  • Create a .js file in scripts/ folder
  • You need to register skill handlers, that contains your skill's logic
  1. registerSkillHandler(String, Anonymous function)
registerSkillHandler('mynamespace:myid',{
    onCast: function(character, context) {
       <main logic>
       return SkillResult.OK;
    }
})

For active skills create function onCast: function(character, context)
For targetted skills create function castOnTarget: function(character, context, target)
For passive skills create function init: function(character, context)

  • JS api for passive skills is not yet fully functional, and wont yet work.
  1. create the skill in one of scripts/*.conf files
    {
        # Id must be unique
        Id: "somenamespace:someSkillId"

        # Skill types
        Skill-Types: [
            "ntrpg:aoe",
            "ntrpg:lightning"
        ]

        # If the skill may deal damage there must be node DamageType.
        # If the skill deals no damage to anyone (eg simple healing) this node should not be defined
        Damage-Type: "magic"
        Handler: "mynamespace:myid"
    }
  1. Put the skill into any of your skilltrees
  • To read current skilltree setting param function was changed
    • param(String, context)
    • param("damage", context)

JS Listeners

  • Generally the same, just reduced some syntactic sugar
registerEventListener({
    type: "org.spongepowered.api.event.network.ClientConnectionEvent",
    consumer: function (event) {
        log("I'm javascript Event handler")
    },
    order:"BEFORE_POST",
    beforeModifications: false
});
  • type - no longer need to call Java.type()
  • consumer - no longer needed to inherit from Consumer