Developer API

Creating a custom CurrencyManager

public void example() {
    /**
     * #setCostCurrencyManager changes the currency used to purchase robot upgrades
     * #setGeneratorCurrencyManager changes the currency used to generate money from the robots.
     */
    Core.c.setCostCurrencyManager(
            new CurrencyManager() {
                
                @Override
                public void load() {
                    // Pre-Load method to setup currency manager
                }

                @Override
                public double getCurrentBalance(Player p) {
                    // Get the current balance of a Player. 
                    return 0;
                }

                @Override
                public boolean chargeAmount(Player p, double amt) {
                    // Charge the player for upgrades
                    return false;
                }

                @Override
                public boolean withdraw(Player p, double amt) {
                    // Withdraw _to_ a players account.
                    return false;
                }
            }
    );
}

Getting Robots from by Location

Robot r = Robots.get().getByLocation(e.getRightClicked().getLocation());
if (r == null) return;

if (!r.getOwner().equals(e.getPlayer().getUniqueId().toString())) {
    Core.c.getMsg().sendMessage(e.getPlayer(), Lang.notYourRobot);
    return;
}

Last updated