Developers

How to Use

Extending ShotType

After including the API into your project, to make a shot type, create a class that extends ShotType and implement the constructor and methods.

public class NewShotType extends ShotType {

  public NewShotType(String string) {
    super(string);
    // TODO Auto-generated constructor stub
  }

  @Override
  public void onFocusLaunch(Player arg0, int arg1) {
    // TODO Auto-generated method stub

  }

  @Override
  public void onLaunch(Player arg0, int arg1) {
    // TODO Auto-generated method stub

  }
}

The String that goes into your super constructor is the name of your shot type (the name of the item that shoots it).

Adding Effects

Overwrite the onFocusLaunch and onLaunch methods.

public class NewShotType extends ShotType {

  public NewShotType(String string) {
    super(string);
  }

  @Override
  public void onFocusLaunch(Player arg0, int arg1) {
    for (int i = 0; i < arg1 + 1; i++) {
      arg0.launchProjectile(Snowball.class).setVelocity(arg0.getEyeLocation().getDirection().setY(i/3));
    }
  }

  @Override
  public void onLaunch(Player arg0, int arg1) {
    for (int i = 0; i < arg1 + 1; i++) {
      arg0.launchProjectile(Snowball.class).setVelocity(arg0.getEyeLocation().getDirection().setY(i));
    }
  }
}

These methods will be called when a player left clicks with an item with the name of the shot type (which doesn't exist yet).

Registering the ShotType

Use the method DanmakuBattleAPI.registerShotType(ShotType) to add it. If it returns true then it is successfully registered. Otherwise, there is another shot type with the same name registered.

public class StarterKit extends JavaPlugin {
  public void onEnable() {
    if (DanmakuBattleAPI.registerShotType(new NewShotType("Column"))) {
      getLogger().info("Shot Type Column successfully registered.");
    } else {
      getLogger().warning("Shot Type Column could not be registered. Perhaps another plugin already did?");
    }
  }
}

Other Methods

v1.0.0

DanmakuBattleAPI.deduct(Player, int) - Deducts a player's power. Returns true if successful. This can be used for powerful attacks or bombs that cost power to use.

DanmakuBattleAPI.clearPower(Player) - Sets a player's power to 0 but does not change their exp bar state.

v1.0.2

DanmakuBattleAPI.getItem(ItemType) - Returns an ItemStack for the given item type (It is a dye of a certain color with a randomly generated lore).

DanmakuBattleAPI.collectItem(Player, ItemType) - Does stuff as if the player has collected one of the items.

ItemType

The 4 ItemTypes are POWER, POINT, FULL_POWER, and ONE_UP.


Comments

Posts Quoted:
Reply
Clear All Quotes