Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Update for API 4.0.3
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
dualspiral committed Mar 13, 2016
1 parent 6ea16fd commit 9dcbb71
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 20 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.3</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -76,4 +76,4 @@
<scope>compile</scope>
</dependency>
</dependencies>
</project>
</project>
9 changes: 9 additions & 0 deletions src/me/Flibio/EconomyLite/API/LiteCurrency.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
6 changes: 4 additions & 2 deletions src/me/Flibio/EconomyLite/API/LiteUniqueAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ public TransactionResult resetBalance(Currency currency, Cause cause,
}

@Override
public TransactionResult resetBalances(Cause cause, Set<Context> contexts) {
return resetBalance(liteCurrency,cause,contexts);
public Map<Currency, TransactionResult> resetBalances(Cause cause, Set<Context> contexts) {
Map<Currency, TransactionResult> map = new HashMap<>();
map.put(liteCurrency, resetBalance(liteCurrency,cause,contexts));
return map;
}

@Override
Expand Down
6 changes: 4 additions & 2 deletions src/me/Flibio/EconomyLite/API/LiteVirtualAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ public TransactionResult resetBalance(Currency currency, Cause cause,
}

@Override
public TransactionResult resetBalances(Cause cause, Set<Context> contexts) {
return resetBalance(liteCurrency,cause,contexts);
public Map<Currency, TransactionResult> resetBalances(Cause cause, Set<Context> contexts) {
Map<Currency, TransactionResult> map = new HashMap<>();
map.put(liteCurrency, resetBalance(liteCurrency,cause,contexts));
return map;
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/me/Flibio/EconomyLite/Commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions src/me/Flibio/EconomyLite/Commands/PayCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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()) {
Expand Down
7 changes: 4 additions & 3 deletions src/me/Flibio/EconomyLite/Commands/PayOverrideCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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()) {
Expand Down
3 changes: 2 additions & 1 deletion src/me/Flibio/EconomyLite/Commands/RemoveCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/me/Flibio/EconomyLite/Commands/SetCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/me/Flibio/EconomyLite/EconomyLite.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/me/Flibio/EconomyLite/Events/BalanceChangeEvent.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -40,7 +42,7 @@ public UUID getPlayerUUID(){

@Override
public Cause getCause() {
return Cause.of("EconomyLite");
return Cause.of(NamedCause.owner(EconomyLite.access));
}

}
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -14,7 +16,7 @@ public LiteEconomyTransactionEvent(TransactionResult result) {

@Override
public Cause getCause() {
return Cause.of("EconomyLite");
return Cause.of(NamedCause.owner(EconomyLite.access));
}

@Override
Expand Down

0 comments on commit 9dcbb71

Please sign in to comment.