Don't forget to add AxAuctions to your plugin's plugin.yml, like this:
depend:
- AxAuctions
or:
softdepend:
- AxAuctions
Adding your own currency:
Create a new class and make it implement com.artillexstudios.axauctions.hooks.currency.CurrencyHook, it should look something like this:
public class ExampleCurrency implements CurrencyHook {
@Override
public void setup() {
// this only gets called once when the hook gets registered
}
@Override
public String getName() {
// the name of your hook, make sure to use this in the currencies.yml
return "ExampleCurrency";
}
@Override
public boolean worksOffline() {
// does your hook work with offline players?
return false;
}
@Override
public boolean usesDouble() {
// does your hook work uses double/float or not?
return false;
}
@Override
public boolean isPersistent() {
// should the plugin unregister the hook when it gets reloaded?
// you should keep this on true
return true;
}
@Override
public double getBalance(@NotNull UUID player) {
// your code here
return 0;
}
@Override
public void giveBalance(@NotNull UUID player, double amount) {
// your code here
}
@Override
public void takeBalance(Consumer<Boolean> successful, @NotNull UUID player, double amount) {
// your code here
// the Consumer is meant to be used for async plugins, for example if your async sql query fails, return false to prevent giving the item
successful.accept(true); // it is VERY IMPORTANT to accept the consumer if everything worked!!!
}
}
Next is, you will have to create a section in the currencies.yml, copy paste one of the other currencies, for example, like this:
ExampleCurrency: # < the name of your currency
register: true
tax: 0
display:
# the way the currency will be shown in the lores of the auction gui
gui: "&f%price% &#AAFFFFcoins"
# used in the currency switcher and tab completion
raw: "My Currency"
# the item shown in the currency selector
item:
material: GOLD_INGOT
name: "�DDFFMy Currency"
lore:
- " "
- "�DDFF&l(!) �DDFFClick here to select!"
Create your implementation for all these methods, after that is done, you will have to register it by using the com.artillexstudios.axauctions.hooks.HookManager.registerCurrencyHook() method, for the plugin parameter give the instance of your plugin's main class.
And if all of this is done, congratulations, you have added a new currency to AxAuctions!