Plugging in

Plugging in

Other plugins can plug into this one. The largest reason for this would be adding additional spell effect definitions, so I've made this as simple as I could.

Adding custom spell effect definitions.

You can add a spell effect definitions using the following code, with relevant imports. There are two "spell effect" classes, but SpellEffect is a basic class only intended for other spell effect types to be based on. You can use it, but it doesn't provide any of the additional support that SpellEffectStandard does; I'm probably going to add more in the future as the need arises. SpellEffectStandard allows the spell effect to be performed in the same way as I've implemented the Harm, Heal, and ScryMob spell effect definitions, and allows them to interact easily with standard spell words (through the SpellParams list and already handled values like Damage). For illustrative purposes, I'll demonstrate adding an effect definition using both SpellEffect and SpellEffectStandard.

(untested and purely for the purposes of demonstration. You may have to copy + paste it into a text editor or IDE to read it properly.):

void registerCustomSpellEffectDefinition()
{
    List<SpellEffectDefinitionRegistry.Definition> defs = new ArrayList<SpellEffectDefinitionRegistry.Definition>();

    defs.add(new SpellEffectDefinitionRegistry.Definition("FirstEffect")
    {
        @Override
        protected SpellEffect MakeEffect(String effectname, List<String[]> effectparameters)
        {
            return new SpellEffect(effectname, "FirstEffect", effectparameters)
            {
                @Override
                protected void PerformEffect(Player caster, String... parameters)
                {
                    /* What your spell effect should do here */
                }

                @Override
                protected int getManaCost(Player caster)
                {
                    /* Your logic for determining mana cost here. */ return 1;
                }
            }
        }
    });

    SpellEffectDefinitionRegistry.AddDefinitions(defs);
}

void registerCustomSpellEffectStandardDefinition()
{
    List<SpellEffectDefinitionRegistry.Definition> defs = new ArrayList<SpellEffectDefinitionRegistry.Definition>();

    defs.add(new SpellEffectDefinitionRegistry.Definition("AnotherEffect")
    {
        @Override
        protected SpellEffect MakeEffect(String effectname, List<String[]> effectparameters)
        {
            return new SpellEffectStandard(effectname, "AnotherEffect", effectparameters)
            {
                @Override
                protected void PerformEffectOnTarget(Player caster, LivingEntity hittarget, List<SpellParam> SpellParams, String... params)
                {
                    /* What you want to happen to each living entity affected by the spell effect.
                       Configuration options for deciding which mobs are affected and are not are handled before this method call;
                       This is only called on mobs that are supposed to be affected. */
                }

                @Override
                protected void PerformEffectAtLocation(Player caster, Location hitlocation, List<SpellParam> SpellParams, String... params)
                {
                    new BasicFireworkGlitter(this.getGlitColours().toArray(new DyeColor[0])).Glit(hitlocation, aoe, target);
                    /* What happens at the location the spell effect goes off.
                       Should mostly be reserved for particle effects.
                       The above code generates the standard particle effect using the colours defined in the config file for the effect.*/
                }

                @Override
                protected int getManaCost(Player caster, List<LivingEntity> HitTargets, Location HitLocation, List<SpellParam> SpellParams, String... params)
                {
                    return this.getManaCostBase() + (this.getManaCostPerTarget() * HitTargets.size());
                    /* Or your own logic for determining the mana cost.
                       The above simply uses the ManaCostBase and ManaCostPerTarget as defined for the spell effect in the config file. */
                }
            }
        }
    });

    SpellEffectDefinitionRegistry.AddDefinitions(defs);
}

The above code WILL change while this is still in alpha/beta, but I'll post a separate changelog for changes to this part of the code when they're made.

Changelog

0.4.1 - Replaced SpellTarget and SpellAreaOfEffect with a List<SpellParam>; The SpellTarget, SpellAreaOfEffect, and new SpellAreaSize enum values inherit from SpellParam and are passed into the list. This saves me having to edit the abstract method signatures in the future every time I change the spell parameters possible.

Working with stored exp/mana

The Exp/mana storage class is at puppy.hanii.bukkit.arcanebooks.Registries.ExpStorage. The methods available should be fairly self-explanatory. Javadoc should also be available.


Comments

Posts Quoted:
Reply
Clear All Quotes