🕳️Class API

Creating your own class

You can create your own class via Wizards API. Please note that you'll have to manually add your class to the shop.yml if you are using Wizards menu system.

A quick note on this, you cannot use the class reload command when using the API to inject a new class, it will not register the class injected via API. Create your own reload command and access the API to manually reload and register your class again.

To create your own class, simple create a new Class that extends WizardClass and register on your onEnable using

WizardClasses.injectClass(Class<? extends WizardClass> clazz, String name, String fileName);

Where Class<? extends WizardClass> will be your Class, name the (original) name of the class and fileName the file name that will be generated.

After that, you need to manually add your class to the shop.yml.

Example of a Wizard Class

import com.floodeer.wizards.Wizards;
import com.floodeer.wizards.game.GamePlayer;
import com.floodeer.wizards.game.classes.WizardClass;
import com.floodeer.wizards.particles.ParticleEffect;
import com.floodeer.wizards.script.ScriptManager;
import com.floodeer.wizards.util.ItemFactory;
import com.floodeer.wizards.util.LocationUtils;
import com.floodeer.wizards.util.Util;
import org.bukkit.Location;
import org.bukkit.entity.Player;

import java.io.File;

public class Reaper extends WizardClass  {

    public Reaper(String name, File configFile) {
        super(name, configFile);
    }

    @Override
    public void give(Player player) {
        player.getInventory().addItem(ItemFactory.unbreakable(getWeapon()));
        player.getInventory().setHelmet(ItemFactory.unbreakable(getHelmet()));
        player.getInventory().setChestplate(ItemFactory.unbreakable(getChesplate()));
        player.getInventory().setLeggings(ItemFactory.unbreakable(getLeggings()));
        player.getInventory().setBoots(ItemFactory.unbreakable(getBoots()));
    }

    @Override
    public void onInteract(Player player) {
        GamePlayer gp = GamePlayer.get(player.getUniqueId());
        if (gp.getMana() < getManaCost()) { //Mana Manager
            if(!Wizards.get().getMessages().enoughMana.isEmpty())
                gp.getP().sendMessage(Util.colorString(Wizards.get().getMessages().enoughMana.replaceAll("%prefix%", Wizards.get().getMessages().prefix)));
            if(!Wizards.get().getOptions().enoughMana.isEmpty())
                Util.playSound(gp.getP(), Wizards.get().getOptions().enoughMana);
        } else {
            ScriptManager.run(gp, getScript()); //Script system, if enabled

            gp.setMana(gp.getMana() - getManaCost()); //Remove player mana

            //Skill start
            Location location = player.getLocation();

            //Skill Particle Effect
            LocationUtils.getCircle(location.clone().add(0.0D, 1.0D, 0.0D), 5.0D, 40).forEach(l -> {
                ParticleEffect.CRIT_MAGIC.display(0.0F, 0.0F, 0.0F, 0.1F, 3, l, 126);
                ParticleEffect.CLOUD.display(0.0F, 0.0F, 0.0F, 0.01F, 1, l, 126);
            });

            //Apply skill damage and effects
            Util.filterAreaDamage(player, getDamage(), location, getAreaDamage(), false, Wizards.get().getMessages().magic).forEach(target -> {
                ScriptManager.run(gp, GamePlayer.get(target), getTargetScript());
                GamePlayer targetgp = GamePlayer.get(target);
                targetgp.setMana(0);
                target.sendMessage(Util.colorString("&cYour mana has been devoured by &4" + player.getName() + "&c!"));
            });

            //Skill end
        }
    }
}

Now let's register this class

 WizardClasses.injectClass(Reaper.class, "Reaper", "reaper.yml");

And let's add it to the shop

reaper:
  item: 'DIAMOND_SWORD : 1'
  name: '&6Reaper Class'
  lore:
    - '&7Removes mana from'
    - '&7nearby players.'
  slot: 23

That's pretty much it, the reaper.yml file will be generated via the class loader and you will be able to change things if you need.

Here's everything you may need from WizardClass

    public String getOriginalName();
 
    public String getDisplayName();
 
    public List<String> getDescription();
 
    public int getPrice();
 
    public int getMaxDistance();
 
    public int getManaCost();

    public ItemStack getHelmet();
 
    public ItemStack getChesplate();
 
    public ItemStack getLeggings();
 
    public ItemStack getBoots();
 
    public ItemStack getWeapon();
 
    public double getDamage();
 
    public double getAreaDamage();
 
    public double getExplosionRadius();
 
    public List<String> getScript();
 
    public List<String> getTargetScript();
 
    public int getManaPerHit();

    public Collection<PotionEffect> getEffects();

    public List<ItemStack> getItems();

Everything from here is taken from your class.yml, you can, of course, ignore all of that and create the class however you want without interacting with the class file.

Last updated