mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-03 14:14:43 +02:00
Various
sponge changes / documentation / cleanup / event tweak
This commit is contained in:
Bukkit/src/main/java/com
Core/src
main
java
com
intellectualcrafters
plot
commands
generator
object
util
test
java
com
intellectualcrafters
plot
Sponge/src/main/java/com/plotsquared/sponge
@ -1,24 +1,22 @@
|
||||
package com.plotsquared.sponge.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.cause.Cause;
|
||||
import org.spongepowered.api.event.service.ChangeServiceProviderEvent;
|
||||
import org.spongepowered.api.service.economy.EconomyService;
|
||||
import org.spongepowered.api.service.economy.account.UniqueAccount;
|
||||
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.sponge.object.SpongePlayer;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.service.ChangeServiceProviderEvent;
|
||||
import org.spongepowered.api.service.economy.EconomyService;
|
||||
import org.spongepowered.api.service.economy.account.UniqueAccount;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Optional;
|
||||
|
||||
public class SpongeEconHandler extends EconHandler {
|
||||
private EconomyService econ;
|
||||
|
||||
|
||||
public SpongeEconHandler() {
|
||||
if (Sponge.getServiceManager().isRegistered(EconomyService.class)) {
|
||||
econ = Sponge.getServiceManager().provide(EconomyService.class).get();
|
||||
@ -35,11 +33,11 @@ public class SpongeEconHandler extends EconHandler {
|
||||
@Override
|
||||
public void withdrawMoney(PlotPlayer player, double amount) {
|
||||
if (econ != null) {
|
||||
Optional<UniqueAccount> accOpt = econ.getAccount(player.getUUID());
|
||||
Optional<UniqueAccount> accOpt = econ.getOrCreateAccount(player.getUUID());
|
||||
if (accOpt.isPresent()) {
|
||||
UniqueAccount acc = accOpt.get();
|
||||
|
||||
acc.withdraw(econ.getDefaultCurrency(), new BigDecimal(amount), Cause.of("PlotSquared"));
|
||||
acc.withdraw(econ.getDefaultCurrency(), new BigDecimal(amount), SpongeUtil.CAUSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -47,10 +45,10 @@ public class SpongeEconHandler extends EconHandler {
|
||||
@Override
|
||||
public void depositMoney(PlotPlayer player, double amount) {
|
||||
if (econ != null) {
|
||||
Optional<UniqueAccount> accOpt = econ.getAccount(player.getUUID());
|
||||
Optional<UniqueAccount> accOpt = econ.getOrCreateAccount(player.getUUID());
|
||||
if (accOpt.isPresent()) {
|
||||
UniqueAccount acc = accOpt.get();
|
||||
acc.deposit(econ.getDefaultCurrency(), new BigDecimal(amount), Cause.of("PlotSquared"));
|
||||
acc.deposit(econ.getDefaultCurrency(), new BigDecimal(amount), SpongeUtil.CAUSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,10 +56,10 @@ public class SpongeEconHandler extends EconHandler {
|
||||
@Override
|
||||
public void depositMoney(OfflinePlotPlayer player, double amount) {
|
||||
if (econ != null) {
|
||||
Optional<UniqueAccount> accOpt = econ.getAccount(player.getUUID());
|
||||
Optional<UniqueAccount> accOpt = econ.getOrCreateAccount(player.getUUID());
|
||||
if (accOpt.isPresent()) {
|
||||
UniqueAccount acc = accOpt.get();
|
||||
acc.deposit(econ.getDefaultCurrency(), new BigDecimal(amount), Cause.of("PlotSquared"));
|
||||
acc.deposit(econ.getDefaultCurrency(), new BigDecimal(amount), SpongeUtil.CAUSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -85,7 +83,7 @@ public class SpongeEconHandler extends EconHandler {
|
||||
@Override
|
||||
public double getBalance(PlotPlayer player) {
|
||||
if (econ != null) {
|
||||
Optional<UniqueAccount> accOpt = econ.getAccount(player.getUUID());
|
||||
Optional<UniqueAccount> accOpt = econ.getOrCreateAccount(player.getUUID());
|
||||
if (accOpt.isPresent()) {
|
||||
UniqueAccount acc = accOpt.get();
|
||||
BigDecimal balance = acc.getBalance(econ.getDefaultCurrency());
|
||||
|
Reference in New Issue
Block a user