Public-Api

There is a public API for CastCraft allowing you to add your own spells. Every spell has it's own class. Start off by creating a class for your spell, name it whatever you want however Spell<Spellname> is recommend ex SpellBoom. This class should extend src.john01dav.castcraft.Spell.

public class SpellStrike extends Spell{
        
        /*
        Returns how much fuel your spell costs
        */
	@Override
	public int GetFuelCost() {
		return 8;
	}
        
        /*
        Is called whenever a player casts your spell. the parameter is the player casting the spell. You do not need to worry about fuel levels as   these are handled by the plugin
        */
	@Override
	public void onCast(Player player) {
		player.getWorld().strikeLightning(player.getTargetBlock(null, 200).getLocation());
	}
        
        /*
        Returns the name of your spell to use in /cc spell.
        */
	@Override
	public String getName() {
		return "Strike";
	}

}

Now that you have the class created it is time to register the spell into CastCraft to do this call CastCraft.instance.getSpellManager().registerSpell(Spell arg0, int arg1) making arg0 your spell and arg1 your spell id. Every spell has a number associated with it this number is the spell id. All spell ids must be positive and less then 256 no two spells can have the same id. Spell ids work similar to block/item ids.

        public void onEnable(){
                CastCraft.instance.getSpellManager().registerSpell(new SpellStrike(), 157);
        }

You can also get and set players fuel levels like so.

        CastCraft.instance.getSpellManager().setFuelLevel(Player player, int level);

        int level = CastCraft.instance.getSpellManager().getPlayerFuelLevel(Player player);

In addition to the above you can set fuel levels for any item in minecraft.

        //Setting the fuel levels of an item
        CastCraft.instance.getFuelManager().setItemFuelLevel(Material item, int level);

Comments

Posts Quoted:
Reply
Clear All Quotes