For the complete documentation index, see llms.txt. This page is also available as Markdown.

πŸ’ΈCustom economy

Add your economies

With the zAuctionHouse API, you can create an infinite amount of AuctionEconomy! To do this, you need to create a class that implements the AuctionEconomy interface. Then, simply implement each method in the interface.

Here is an example of an economy with the level of the players:

package fr.maxlego08.zauctionhouse.economy;

import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;

import fr.maxlego08.zauctionhouse.api.economy.AuctionEconomy;

public class LevelEconomy implements AuctionEconomy {

  @Override
  public long getMoney(OfflinePlayer offlinePlayer) {
    return offlinePlayer.isOnline() ? ((Player) offlinePlayer).getLevel() : 0;
  }

  @Override
  public boolean hasMoney(OfflinePlayer offlinePlayer, long price) {
    return getMoney(offlinePlayer) >= price;
  }

  @Override
  public void depositMoney(OfflinePlayer offlinePlayer, long value) {
    if (offlinePlayer.isOnline()) {
      int level = offlinePlayer.getPlayer().getLevel();
      offlinePlayer.getPlayer().setLevel((int) (level + value));
    }
  }

  @Override
  public void withdrawMoney(OfflinePlayer offlinePlayer, long value) {
    if (offlinePlayer.isOnline()) {
       int level = offlinePlayer.getPlayer().getLevel();
       offlinePlayer.getPlayer().setLevel((int) (level - value));
    }
  }

  @Override
  public String getCurrency() {
    return "%price%L";
  }

  @Override
  public String getFormat() {
    return "l";
  }

  @Override
  public boolean isEnable() {  
    return true;
  }

  @Override
  public String getName() {
    return "LEVEL";
  }
  
}

If you directly imported the jar of the plugin you can use the DefaultEconomy class like that:

Vous devez ajouter dans votre plugin.yml le loadBefore pour zAuctionHouse. Cela va indiquer a votre serveur que votre plugin doit charger avant zAuctionHouse.

Then you need to create a listener for the event AuctionLoadEconomyEvent, this event will allow to retrieve the EconomyManager interface to register your economy.

Last updated