Open SirFancyBacon opened 4 years ago
I definitely know this will not work.. But to expand upon the above into more Java-esque syntax.
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.service.economy.EconomyService;
import org.spongepowered.api.service.economy.account.UniqueAccount;
import java.math.BigDecimal;
import java.util.Optional;
import com.onaple.brawlator.events.BrawlatorEntityDiedEvent;
import com.onaple.brawlator.BrawlatorKeys;
Optional<EconomyService> serviceOpt = Sponge.getServiceManager().provide(EconomyService.class);
if (serviceOpt.isPresent()) {
EconomyService economyService = serviceOpt.get();
//Do stuff wheb a Mob dies below this line...
Account account = economyService.getOrCreateAccount(UUID.fromString(getPlayer.getUUID()); //gets Economy Account for the Player. **Need to get UUID of player that killed Mob this probably won't work.
BigDecimal depositAmount = BigDecimal.valueOf(BrawlatorKeys.CURRENCYDROP); //Loads data from Brawlator Config for amount of currency to drop. **Needs configuration in Brawlator.
if (depositAmount.isPresent()) {
account.deposit(economyService.getDefaultCurrency(),depositAmount,Sponge.getCauseStackManager().getCurrentCause()); //Think this should work but honestly it's untested; should also add a cause since it'll just do it when the code runs.
}
}else{
log("No Economy plugin detected... Skipping Economy Support"); //can you use log in Java? needs testing.
}
It is definitely doable if it is among the Sponge library features!
We would probably add the money property (or interval if randomly picked between x and y) in the monster configuration. (We could also consider it like a loot in the loot tables for more control... But I believe this would be more confusing)
Not a very hard task either I believe. Will see what I can do next time I work on this
I will be first to admit i have never written a line of Java in my life!
But i believe this captures the idea of what i mean, and how it works.
https://docs.spongepowered.org/stable/en/plugin/economy/index.html