Search in sources :

Example 1 with UniqueAccount

use of org.spongepowered.api.service.economy.account.UniqueAccount in project Almura by AlmuraDev.

the class ServerHeadUpDisplayManager method onEconomyTransaction.

@Listener(order = Order.LAST)
public void onEconomyTransaction(EconomyTransactionEvent event) {
    final TransactionResult result = event.getTransactionResult();
    final Account account = result.getAccount();
    if (account instanceof UniqueAccount) {
        Sponge.getServer().getPlayer(((UniqueAccount) account).getUniqueId()).ifPresent(player -> Task.builder().delayTicks(1).execute(() -> {
            final ClientboundPlayerCurrencyPacket packet = this.createPlayerCurrencyPacket(player);
            if (packet != null) {
                this.network.sendTo(player, packet);
            }
        }).submit(this.container));
    }
}
Also used : Account(org.spongepowered.api.service.economy.account.Account) UniqueAccount(org.spongepowered.api.service.economy.account.UniqueAccount) TransactionResult(org.spongepowered.api.service.economy.transaction.TransactionResult) UniqueAccount(org.spongepowered.api.service.economy.account.UniqueAccount) ClientboundPlayerCurrencyPacket(com.almuradev.almura.feature.hud.network.ClientboundPlayerCurrencyPacket) Listener(org.spongepowered.api.event.Listener)

Aggregations

ClientboundPlayerCurrencyPacket (com.almuradev.almura.feature.hud.network.ClientboundPlayerCurrencyPacket)1 Listener (org.spongepowered.api.event.Listener)1 Account (org.spongepowered.api.service.economy.account.Account)1 UniqueAccount (org.spongepowered.api.service.economy.account.UniqueAccount)1 TransactionResult (org.spongepowered.api.service.economy.transaction.TransactionResult)1