📖
zAuctionHouse
DiscordGroupeZServeur Minecraft Vote
  • â„šī¸Informations
    • 🍾Getting started
    • 🔌Installing zAuctionHouse
    • ❓Why i need zMenu ?
  • Configurations
    • 🏤Official Configurations
    • Multi servers
    • 🚉Statistics
    • 📔Commands and Permissions
    • đŸĒ§PlaceHolders
    • âšī¸Buttons
    • 💲Economy
    • 🎊Convert
    • 🔍Search / Filter
    • Messages
    • 💱Prices
    • 👨‍đŸ’ŧWhitelist
    • 🛑Blacklist
    • 🚖Tax
    • Categories
    • 🇨đŸ‡ĩItem Translation
  • đŸ—ƒī¸Plugins files
    • Config.yml
    • 💲Economies.yml
    • Inventories
    • Patterns
    • Blacklist.yml
    • Prices.yml
    • Taxs.yml
    • Whitelist.yml
  • Development Portal
    • â„šī¸Informations
    • 🌆Events
    • đŸŦCustom storage
    • Filter
    • 🛑Blacklist
    • 💸Custom economy
  • 👴Old Configurations
    • Items
    • Buttons
    • Placeholder buttons
Powered by GitBook
On this page

Was this helpful?

  1. Development Portal

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:

public class ExampleEconomy extends DefaultEconomy {

    public ExampleEconomy() {
        super("example", "%price%â‚Ŧ", "You dont have enough money", "e");
    }

    @Override
    public long getMoney(OfflinePlayer offlinePlayer) {
        return 10000;
    }

    @Override
    public void depositMoney(OfflinePlayer offlinePlayer, long l) {
        // Do Your Stuff
    }

    @Override
    public void withdrawMoney(OfflinePlayer offlinePlayer, long l) {
        // Do Your Stuff
    }
}

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

loadbefore:
  - zAuctionHouseV3

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

public class TestListener implements Listener {

    @EventHandler
    public void onLoad(AuctionLoadEconomyEvent event) {

        EconomyManager economyManager = event.getEconomyManager();
        economyManager.registerEconomy(new ExampleEconomy());
    }

}
PreviousBlacklistNextOld Configurations

Last updated 6 months ago

Was this helpful?

💸