Skip to content

Economy Integration

meta1203 edited this page Dec 16, 2012 · 1 revision

To implement Satoshis into your trade/shop plugin, simply add the following code to your Plugin's main class:

public SatoshisEconAPI satEcon = null;  
  
public SatoshisEconAPI getSatoshisEconomy() {  
  Plugin p = getServer().getPluginManager().getPlugin("Satoshis");  
  if (p == null || !p instanceof Satoshis) {  
    return null;  
  }  
  return (Satoshis)p.econ;  
}

Then, in your "onEnable()" function, add:

...  
satEcon = getSatoshisEconomy();  
...  

Add depend: [Satoshis] or softdepend: [Satoshis] to your plugin.yml, based on if you need or just want Satoshis to be available.

Finally, add this everytime you want to make a custom in-game transaction:

if (satEcon != null && satEcon.hasMoney(playerFrom, value)) {  
  satEcon.transact(playerFrom, playerTo, value);  
  // Perform movement of goods here...  
} else {  
  // Use any other economies you have implemented here...  
}
Clone this wiki locally