DroneAPI - MathiasMC/BattleDrones GitHub Wiki

How to add heads

DroneAPI.getInstance().getDroneHeads().put("head-name", DroneAPI.getInstance().getHeadTexture("url"));

How to register your drone

MyClass myClass = new MyClass(plugin, "droneName", "droneCategory");
myClass.register();

How to make a drone with a new category

This will add your new category to the gui files automatically (only need run once)

DroneAPI.getInstance().setupMenu("displayName", lores, "MATERIAL", null, 1, 24, "droneCategory");
DroneAPI.getInstance().setupShop("displayName", lores, "MATERIAL", null, 1, 24, "droneCategory");

How to make the class for your drone by default drone will have no ability

You need to make the class extends DroneRegistry

import me.MathiasMC.BattleDrones.api.DroneRegistry;
import me.MathiasMC.BattleDrones.data.DroneHolder;
import me.MathiasMC.BattleDrones.data.PlayerConnect;
import org.bukkit.entity.Player;

public class MyClass extends DroneRegistry {

    public MyClass(MyPlugin plugin, String droneName, String droneCategory) {
        super(plugin, droneName, droneCategory);
    }

    @Override
    public void ability(Player player, PlayerConnect playerConnect, DroneHolder droneHolder) {
        
    }
}

Ability

By default it will have no ability you will have to make one

    @Override
    public void ability(Player player, PlayerConnect playerConnect, DroneHolder droneHolder) {
        final String uuid = player.getUniqueId().toString();
        final ArmorStand drone = playerConnect.head;
        final FileConfiguration file = DroneAPI.getInstance().getDroneFiles().get(droneName);
        final String path = playerConnect.getGroup() + "." + droneHolder.getLevel() + ".";
        final List<String> list = DroneAPI.getInstance().getFileUtils().getBlockCheck(file, path);
        playerConnect.ability = myPlugin.getServer().getScheduler().runTaskTimer(myPlugin, () -> {
            final LivingEntity target = DroneAPI.getInstance().getDroneTargets().get(uuid);
            if (target != null) {
                if (droneHolder.getAmmo() > 0) {
                    final Location droneLocation = drone.getLocation();
                    final Location targetLocation = target.getEyeLocation();
                    if (drone.hasLineOfSight(target) && DroneAPI.getInstance().getEntityManager().hasBlockSight(drone, droneLocation, targetLocation, list)) {

                    }
                }
                playerConnect.setHealing(false);
            } else {
                playerConnect.setHealing(true);
            }
        }, 0, 20).getTaskId();
    }

Follow

if you don't include this it will use the build in follow task

You will have to look at the source code to see the default one

    @Override
    public void follow(Player player, PlayerConnect playerConnect, DroneHolder droneHolder) {
        
    }

Healing

if you don't include this it will use the build in healing task

    @Override
    public void healing(Player player, PlayerConnect playerConnect, DroneHolder droneHolder) {
        final String path = playerConnect.getGroup() + "." + droneHolder.getLevel();
        final FileConfiguration file = DroneAPI.getInstance().getDroneFiles().get(droneHolder.getDrone());
        final int health = file.getInt(path + ".healing.health");
        if (file.getLong(path + ".healing.delay") != 0) {
            playerConnect.healing = myPlugin.getServer().getScheduler().runTaskTimer(myPlugin, () -> {
                if (playerConnect.isHealing()) {
                    final int add_health = droneHolder.getHealth() + health;
                    if (file.getInt(path + ".health") >= add_health) {
                        droneHolder.setHealth(add_health);
                    }
                }
            }, file.getLong(path + ".healing.delay") * 20, file.getLong(path + ".healing.delay") * 20).getTaskId();
        }
    }

Find target

if you don't include this it will use the build in find task

You will have to look at the source code to see the default one

    @Override
    public void find(Player player, PlayerConnect playerConnect, DroneHolder droneHolder) {
        
    }

Placeholders

/bd drone custom placeholders used by upgrade and infomation about drone

This will override all placeholders in the drone gui for this custom drone

    @Override
    public String onPlaceholderRequest(Player player, PlayerConnect playerConnect, DroneHolder droneHolder, String placeholder) {
        if (placeholder.equals("myPlaceholder")) {
            return "Text";
        }
        return null;
    }

How to setup gui files

You will need to add inside the plugin

You will need 4 files for insert a drone into an existing category

gui/droneName/droneName.yml
gui/droneName/whitelist.yml
gui/droneName/ammo.yml
drones/droneCategory/droneName.yml

and 2 more files if you create your own category

gui/player/droneCategory.yml
gui/shop/droneCategory.yml

You can see the default files here

Events

DroneAmmoEvent (Put ammo in drone) (Type none)

DroneBuyEvent (Player buy a drone) (Type none)

DroneDamageEvent (Drone is damaged) (Type none)

DroneDeathEvent (Drone is killed) (Type PLAYER, WEAR)

DroneKillEvent (Drone is killed) (Type none)

DroneParkEvent (Drone is parked) (Type PARK, UNPARK)

DroneRemoveEvent (Drone is removed by player) (Type SWAP GUI, COMMAND_ALL, COMMAND_DRONE, COMMAND_PLAYER)

DroneSpawnEvent (Drone is spawned) (Type SWAP, GUI, TELEPORT, RESPAWN, UPGRADE)

DroneUpgradeEvent (Player upgrades a drone) (Type none)

In some events you can check with Type.PARK, UNPARK, UPGRADE, TELEPORT, RESPAWN, COMMAND, SWAP, GUI, COMMAND_ALL, COMMAND_DRONE, COMMAND_PLAYER, PLAYER, WEAR

Example plugin

To add new category to gui use command /exampledrones

ExampleDrones.jar

⚠️ **GitHub.com Fallback** ⚠️