From 9dcbb71e1ab71ea45fe6d9d21b8d10fc2413b2e8 Mon Sep 17 00:00:00 2001 From: Daniel Naylor Date: Sun, 13 Mar 2016 15:45:14 +0000 Subject: [PATCH] Update for API 4.0.3 * The 4.0.0-SNAPSHOT dependency didn't have everything that was in the final 4.0.x build. This commit updates to 4.0.3 and resolves all compiletime issues. --- pom.xml | 4 ++-- src/me/Flibio/EconomyLite/API/LiteCurrency.java | 9 +++++++++ src/me/Flibio/EconomyLite/API/LiteUniqueAccount.java | 6 ++++-- src/me/Flibio/EconomyLite/API/LiteVirtualAccount.java | 6 ++++-- src/me/Flibio/EconomyLite/Commands/AddCommand.java | 3 ++- .../EconomyLite/Commands/BusinessDeleteCommand.java | 3 ++- .../EconomyLite/Commands/BusinessTransferCommand.java | 3 ++- src/me/Flibio/EconomyLite/Commands/PayCommand.java | 7 ++++--- .../Flibio/EconomyLite/Commands/PayOverrideCommand.java | 7 ++++--- src/me/Flibio/EconomyLite/Commands/RemoveCommand.java | 3 ++- src/me/Flibio/EconomyLite/Commands/SetCommand.java | 3 ++- src/me/Flibio/EconomyLite/EconomyLite.java | 2 +- src/me/Flibio/EconomyLite/Events/BalanceChangeEvent.java | 4 +++- .../EconomyLite/Events/LiteEconomyTransactionEvent.java | 4 +++- 14 files changed, 44 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index 791a459..248e7b7 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ org.spongepowered spongeapi - 4.0.0-SNAPSHOT + 4.0.3 provided @@ -76,4 +76,4 @@ compile - \ No newline at end of file + diff --git a/src/me/Flibio/EconomyLite/API/LiteCurrency.java b/src/me/Flibio/EconomyLite/API/LiteCurrency.java index 0fce659..5c864a4 100644 --- a/src/me/Flibio/EconomyLite/API/LiteCurrency.java +++ b/src/me/Flibio/EconomyLite/API/LiteCurrency.java @@ -49,4 +49,13 @@ public Text format(BigDecimal amount, int arg1) { } } + @Override + public String getId() { + return "economylite:currency"; + } + + @Override + public String getName() { + return "EconomyLite Currency"; + } } diff --git a/src/me/Flibio/EconomyLite/API/LiteUniqueAccount.java b/src/me/Flibio/EconomyLite/API/LiteUniqueAccount.java index a2f1c18..fce9cc9 100644 --- a/src/me/Flibio/EconomyLite/API/LiteUniqueAccount.java +++ b/src/me/Flibio/EconomyLite/API/LiteUniqueAccount.java @@ -89,8 +89,10 @@ public TransactionResult resetBalance(Currency currency, Cause cause, } @Override - public TransactionResult resetBalances(Cause cause, Set contexts) { - return resetBalance(liteCurrency,cause,contexts); + public Map resetBalances(Cause cause, Set contexts) { + Map map = new HashMap<>(); + map.put(liteCurrency, resetBalance(liteCurrency,cause,contexts)); + return map; } @Override diff --git a/src/me/Flibio/EconomyLite/API/LiteVirtualAccount.java b/src/me/Flibio/EconomyLite/API/LiteVirtualAccount.java index 07cf444..a37ccaa 100644 --- a/src/me/Flibio/EconomyLite/API/LiteVirtualAccount.java +++ b/src/me/Flibio/EconomyLite/API/LiteVirtualAccount.java @@ -91,8 +91,10 @@ public TransactionResult resetBalance(Currency currency, Cause cause, } @Override - public TransactionResult resetBalances(Cause cause, Set contexts) { - return resetBalance(liteCurrency,cause,contexts); + public Map resetBalances(Cause cause, Set contexts) { + Map map = new HashMap<>(); + map.put(liteCurrency, resetBalance(liteCurrency,cause,contexts)); + return map; } @Override diff --git a/src/me/Flibio/EconomyLite/Commands/AddCommand.java b/src/me/Flibio/EconomyLite/Commands/AddCommand.java index 2959f11..fe964cb 100644 --- a/src/me/Flibio/EconomyLite/Commands/AddCommand.java +++ b/src/me/Flibio/EconomyLite/Commands/AddCommand.java @@ -10,6 +10,7 @@ import org.spongepowered.api.command.args.CommandContext; import org.spongepowered.api.command.spec.CommandExecutor; import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.scheduler.Task.Builder; import org.spongepowered.api.service.economy.Currency; import org.spongepowered.api.service.economy.EconomyService; @@ -63,7 +64,7 @@ public void run() { return; } //Set the player's balance - if(account.setBalance(currency, BigDecimal.valueOf(newAmount), Cause.of("EconomyLite")).getResult().equals(ResultType.SUCCESS)) { + if(account.setBalance(currency, BigDecimal.valueOf(newAmount), Cause.of(NamedCause.owner(EconomyLite.access))).getResult().equals(ResultType.SUCCESS)) { //Successful source.sendMessage(textUtils.successfulBalanceChangeText(playerName, newAmount)); return; diff --git a/src/me/Flibio/EconomyLite/Commands/BusinessDeleteCommand.java b/src/me/Flibio/EconomyLite/Commands/BusinessDeleteCommand.java index bd958c5..195dbb9 100644 --- a/src/me/Flibio/EconomyLite/Commands/BusinessDeleteCommand.java +++ b/src/me/Flibio/EconomyLite/Commands/BusinessDeleteCommand.java @@ -11,6 +11,7 @@ import org.spongepowered.api.command.spec.CommandExecutor; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.scheduler.Task.Builder; import org.spongepowered.api.service.economy.Currency; import org.spongepowered.api.service.economy.EconomyService; @@ -95,7 +96,7 @@ public void run() { return; } else { UniqueAccount account = uOpt.get(); - account.deposit(currency, BigDecimal.valueOf(eachGet), Cause.of("EconomyLite")); + account.deposit(currency, BigDecimal.valueOf(eachGet), Cause.of(NamedCause.owner(EconomyLite.access))); } } return; diff --git a/src/me/Flibio/EconomyLite/Commands/BusinessTransferCommand.java b/src/me/Flibio/EconomyLite/Commands/BusinessTransferCommand.java index 1838cac..0d7611f 100644 --- a/src/me/Flibio/EconomyLite/Commands/BusinessTransferCommand.java +++ b/src/me/Flibio/EconomyLite/Commands/BusinessTransferCommand.java @@ -11,6 +11,7 @@ import org.spongepowered.api.command.spec.CommandExecutor; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.scheduler.Task.Builder; import org.spongepowered.api.service.economy.Currency; import org.spongepowered.api.service.economy.EconomyService; @@ -92,7 +93,7 @@ public void run() { player.sendMessage(textUtils.basicText("An internal error has occured!", TextColors.RED)); return; } - if(!account.setBalance(currency, BigDecimal.valueOf(playerBalance+amount), Cause.of("EconomyLite")).getResult().equals(ResultType.SUCCESS)) { + if(!account.setBalance(currency, BigDecimal.valueOf(playerBalance+amount), Cause.of(NamedCause.owner(EconomyLite.access))).getResult().equals(ResultType.SUCCESS)) { player.sendMessage(textUtils.basicText("An internal error has occured!", TextColors.RED)); return; } diff --git a/src/me/Flibio/EconomyLite/Commands/PayCommand.java b/src/me/Flibio/EconomyLite/Commands/PayCommand.java index d238e82..6beccc8 100644 --- a/src/me/Flibio/EconomyLite/Commands/PayCommand.java +++ b/src/me/Flibio/EconomyLite/Commands/PayCommand.java @@ -13,6 +13,7 @@ import org.spongepowered.api.command.spec.CommandExecutor; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.scheduler.Task.Builder; import org.spongepowered.api.service.economy.Currency; import org.spongepowered.api.service.economy.EconomyService; @@ -133,7 +134,7 @@ private void payBusiness(String uuid, int amount, Player player, String business return; } else { //Process transaction - if(account.withdraw(currency,BigDecimal.valueOf(amount),Cause.of("EconomyLite")).getResult().equals(ResultType.SUCCESS)&& + if(account.withdraw(currency,BigDecimal.valueOf(amount),Cause.of(NamedCause.owner(EconomyLite.access))).getResult().equals(ResultType.SUCCESS)&& businessManager.setBusinessBalance(businessName, newBalance)) { //Success player.sendMessage(textUtils.paySuccess(businessName, amount)); @@ -179,8 +180,8 @@ private void payPlayer(String uuid, int amount, Player player, String playerName return; } else { //Process transaction - if(account.withdraw(currency,BigDecimal.valueOf(amount),Cause.of("EconomyLite")).getResult().equals(ResultType.SUCCESS)&& - targetAccount.setBalance(currency,BigDecimal.valueOf(newBalance),Cause.of("EconomyLite")).getResult().equals(ResultType.SUCCESS)) { + if(account.withdraw(currency,BigDecimal.valueOf(amount),Cause.of(NamedCause.owner(EconomyLite.access))).getResult().equals(ResultType.SUCCESS)&& + targetAccount.setBalance(currency,BigDecimal.valueOf(newBalance),Cause.of(NamedCause.owner(EconomyLite.access))).getResult().equals(ResultType.SUCCESS)) { //Success player.sendMessage(textUtils.paySuccess(playerName, amount)); for(Player oPlayer : Sponge.getServer().getOnlinePlayers()) { diff --git a/src/me/Flibio/EconomyLite/Commands/PayOverrideCommand.java b/src/me/Flibio/EconomyLite/Commands/PayOverrideCommand.java index ca64fe0..f17dd77 100644 --- a/src/me/Flibio/EconomyLite/Commands/PayOverrideCommand.java +++ b/src/me/Flibio/EconomyLite/Commands/PayOverrideCommand.java @@ -13,6 +13,7 @@ import org.spongepowered.api.command.spec.CommandExecutor; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.scheduler.Task.Builder; import org.spongepowered.api.service.economy.Currency; import org.spongepowered.api.service.economy.EconomyService; @@ -127,7 +128,7 @@ private void payBusiness(String uuid, int amount, Player player, String business return; } else { //Process transaction - if(account.withdraw(currency,BigDecimal.valueOf(amount),Cause.of("EconomyLite")).getResult().equals(ResultType.SUCCESS)&& + if(account.withdraw(currency,BigDecimal.valueOf(amount),Cause.of(NamedCause.owner(EconomyLite.access))).getResult().equals(ResultType.SUCCESS)&& businessManager.setBusinessBalance(businessName, newBalance)) { //Success player.sendMessage(textUtils.paySuccess(businessName, amount)); @@ -173,8 +174,8 @@ private void payPlayer(String uuid, int amount, Player player, String playerName return; } else { //Process transaction - if(account.withdraw(currency,BigDecimal.valueOf(amount),Cause.of("EconomyLite")).getResult().equals(ResultType.SUCCESS)&& - targetAccount.setBalance(currency,BigDecimal.valueOf(newBalance),Cause.of("EconomyLite")).getResult().equals(ResultType.SUCCESS)) { + if(account.withdraw(currency,BigDecimal.valueOf(amount),Cause.of(NamedCause.owner(EconomyLite.access))).getResult().equals(ResultType.SUCCESS)&& + targetAccount.setBalance(currency,BigDecimal.valueOf(newBalance),Cause.of(NamedCause.owner(EconomyLite.access))).getResult().equals(ResultType.SUCCESS)) { //Success player.sendMessage(textUtils.paySuccess(playerName, amount)); for(Player oPlayer : Sponge.getServer().getOnlinePlayers()) { diff --git a/src/me/Flibio/EconomyLite/Commands/RemoveCommand.java b/src/me/Flibio/EconomyLite/Commands/RemoveCommand.java index 8ef2724..cef5a90 100644 --- a/src/me/Flibio/EconomyLite/Commands/RemoveCommand.java +++ b/src/me/Flibio/EconomyLite/Commands/RemoveCommand.java @@ -10,6 +10,7 @@ import org.spongepowered.api.command.args.CommandContext; import org.spongepowered.api.command.spec.CommandExecutor; import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.scheduler.Task.Builder; import org.spongepowered.api.service.economy.Currency; import org.spongepowered.api.service.economy.EconomyService; @@ -64,7 +65,7 @@ public void run() { return; } //Set the player's balance - if(account.setBalance(currency,BigDecimal.valueOf(newAmount),Cause.of("EconomyLite")).getResult().equals(ResultType.SUCCESS)) { + if(account.setBalance(currency,BigDecimal.valueOf(newAmount),Cause.of(NamedCause.owner(EconomyLite.access))).getResult().equals(ResultType.SUCCESS)) { //Successful source.sendMessage(textUtils.successfulBalanceChangeText(playerName, newAmount)); return; diff --git a/src/me/Flibio/EconomyLite/Commands/SetCommand.java b/src/me/Flibio/EconomyLite/Commands/SetCommand.java index 6a8081b..44609ae 100644 --- a/src/me/Flibio/EconomyLite/Commands/SetCommand.java +++ b/src/me/Flibio/EconomyLite/Commands/SetCommand.java @@ -10,6 +10,7 @@ import org.spongepowered.api.command.args.CommandContext; import org.spongepowered.api.command.spec.CommandExecutor; import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.scheduler.Task.Builder; import org.spongepowered.api.service.economy.Currency; import org.spongepowered.api.service.economy.EconomyService; @@ -61,7 +62,7 @@ public void run() { return; } //Set the player's balance - if(account.setBalance(currency,BigDecimal.valueOf(amount),Cause.of("EconomyLite")).getResult().equals(ResultType.SUCCESS)) { + if(account.setBalance(currency,BigDecimal.valueOf(amount),Cause.of(NamedCause.owner(EconomyLite.access))).getResult().equals(ResultType.SUCCESS)) { //Successful source.sendMessage(textUtils.successfulBalanceChangeText(playerName, amount)); return; diff --git a/src/me/Flibio/EconomyLite/EconomyLite.java b/src/me/Flibio/EconomyLite/EconomyLite.java index 1529e39..6aa2d7b 100644 --- a/src/me/Flibio/EconomyLite/EconomyLite.java +++ b/src/me/Flibio/EconomyLite/EconomyLite.java @@ -46,7 +46,7 @@ import java.util.Optional; @Updatifier(repoName = "EconomyLite", repoOwner = "Flibio", version = "v1.2.0") -@Plugin(id = "EconomyLite", name = "EconomyLite", version = "1.2.0", dependencies = @Dependency(id = "Updatifier", optional = true)) +@Plugin(id = "me.flibio.economylite.economylite", name = "EconomyLite", version = "1.2.0", description = "EconmyLite provides simple economy handling.", dependencies = @Dependency(id = "Updatifier", optional = true)) public class EconomyLite { @Inject diff --git a/src/me/Flibio/EconomyLite/Events/BalanceChangeEvent.java b/src/me/Flibio/EconomyLite/Events/BalanceChangeEvent.java index a084814..1e5c81d 100644 --- a/src/me/Flibio/EconomyLite/Events/BalanceChangeEvent.java +++ b/src/me/Flibio/EconomyLite/Events/BalanceChangeEvent.java @@ -1,7 +1,9 @@ package me.Flibio.EconomyLite.Events; +import me.Flibio.EconomyLite.EconomyLite; import org.spongepowered.api.event.Cancellable; import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.event.impl.AbstractEvent; import java.util.UUID; @@ -40,7 +42,7 @@ public UUID getPlayerUUID(){ @Override public Cause getCause() { - return Cause.of("EconomyLite"); + return Cause.of(NamedCause.owner(EconomyLite.access)); } } diff --git a/src/me/Flibio/EconomyLite/Events/LiteEconomyTransactionEvent.java b/src/me/Flibio/EconomyLite/Events/LiteEconomyTransactionEvent.java index e4a0a38..18cc9a2 100644 --- a/src/me/Flibio/EconomyLite/Events/LiteEconomyTransactionEvent.java +++ b/src/me/Flibio/EconomyLite/Events/LiteEconomyTransactionEvent.java @@ -1,6 +1,8 @@ package me.Flibio.EconomyLite.Events; +import me.Flibio.EconomyLite.EconomyLite; import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.event.economy.EconomyTransactionEvent; import org.spongepowered.api.service.economy.transaction.TransactionResult; @@ -14,7 +16,7 @@ public LiteEconomyTransactionEvent(TransactionResult result) { @Override public Cause getCause() { - return Cause.of("EconomyLite"); + return Cause.of(NamedCause.owner(EconomyLite.access)); } @Override