diff --git a/src/main/java/org/maxgamer/quickshop/economy/Economy.java b/src/main/java/org/maxgamer/quickshop/economy/Economy.java index e5dc8777f..354ba816c 100644 --- a/src/main/java/org/maxgamer/quickshop/economy/Economy.java +++ b/src/main/java/org/maxgamer/quickshop/economy/Economy.java @@ -22,6 +22,7 @@ package org.maxgamer.quickshop.economy; import lombok.Getter; import lombok.Setter; +import org.bukkit.OfflinePlayer; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; import org.maxgamer.quickshop.QuickShop; @@ -56,6 +57,11 @@ public class Economy implements EconomyCore { return core.deposit(name, amount); } + @Override + public boolean deposit(OfflinePlayer trader, double amount) { + return core.deposit(trader, amount); + } + /** * Formats the given number... E.g. 50.5 becomes $50.5 Dollars, or 50 Dollars 5 Cents * @@ -73,6 +79,11 @@ public class Economy implements EconomyCore { return core.getBalance(name); } + @Override + public double getBalance(OfflinePlayer player) { + return core.getBalance(player); + } + @Override public boolean transfer(@NotNull UUID from, UUID to, double amount) { return core.transfer(from, to, amount); @@ -83,6 +94,11 @@ public class Economy implements EconomyCore { return core.withdraw(name, amount); } + @Override + public boolean withdraw(OfflinePlayer trader, double amount) { + return core.withdraw(trader, amount); + } + /** * Checks that this economy is valid. Returns false if it is not valid. * diff --git a/src/test/java/org/maxgamer/quickshop/economy/EconomyTransactionTest.java b/src/test/java/org/maxgamer/quickshop/economy/EconomyTransactionTest.java index 01589f734..dc03c85ec 100644 --- a/src/test/java/org/maxgamer/quickshop/economy/EconomyTransactionTest.java +++ b/src/test/java/org/maxgamer/quickshop/economy/EconomyTransactionTest.java @@ -20,8 +20,15 @@ package org.maxgamer.quickshop.economy; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.Statistic; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.junit.Test; import java.util.HashMap; @@ -37,7 +44,169 @@ public class EconomyTransactionTest { static final EconomyCore economy = new TestEconomy(); - static final UUID taxAccount = UUID.randomUUID(); + static final Trader taxAccount = Trader.adapt(new OfflinePlayer() { + private final UUID uuid = UUID.randomUUID(); + + @Override + public boolean isOnline() { + return false; + } + + @Override + public @Nullable String getName() { + return null; + } + + @Override + public @NotNull UUID getUniqueId() { + return uuid; + } + + @Override + public boolean isBanned() { + return false; + } + + @Override + public boolean isWhitelisted() { + return false; + } + + @Override + public void setWhitelisted(boolean value) { + + } + + @Override + public @Nullable Player getPlayer() { + return null; + } + + @Override + public long getFirstPlayed() { + return 0; + } + + @Override + public long getLastPlayed() { + return 0; + } + + @Override + public boolean hasPlayedBefore() { + return false; + } + + @Override + public @Nullable Location getBedSpawnLocation() { + return null; + } + + @Override + public void incrementStatistic(@NotNull Statistic statistic) throws IllegalArgumentException { + + } + + @Override + public void decrementStatistic(@NotNull Statistic statistic) throws IllegalArgumentException { + + } + + @Override + public void incrementStatistic(@NotNull Statistic statistic, int amount) throws IllegalArgumentException { + + } + + @Override + public void decrementStatistic(@NotNull Statistic statistic, int amount) throws IllegalArgumentException { + + } + + @Override + public void setStatistic(@NotNull Statistic statistic, int newValue) throws IllegalArgumentException { + + } + + @Override + public int getStatistic(@NotNull Statistic statistic) throws IllegalArgumentException { + return 0; + } + + @Override + public void incrementStatistic(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException { + + } + + @Override + public void decrementStatistic(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException { + + } + + @Override + public int getStatistic(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException { + return 0; + } + + @Override + public void incrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount) throws IllegalArgumentException { + + } + + @Override + public void decrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount) throws IllegalArgumentException { + + } + + @Override + public void setStatistic(@NotNull Statistic statistic, @NotNull Material material, int newValue) throws IllegalArgumentException { + + } + + @Override + public void incrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType) throws IllegalArgumentException { + + } + + @Override + public void decrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType) throws IllegalArgumentException { + + } + + @Override + public int getStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType) throws IllegalArgumentException { + return 0; + } + + @Override + public void incrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount) throws IllegalArgumentException { + + } + + @Override + public void decrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount) { + + } + + @Override + public void setStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int newValue) { + + } + + @Override + public @NotNull Map serialize() { + return null; + } + + @Override + public boolean isOp() { + return false; + } + + @Override + public void setOp(boolean value) { + + } + }); static { economy.getBalance(taxAccount); @@ -122,6 +291,11 @@ public class EconomyTransactionTest { return true; } + @Override + public boolean deposit(OfflinePlayer trader, double amount) { + return deposit(trader.getUniqueId(), amount); + } + @Override public String format(double balance) { return Double.toString(balance); @@ -132,6 +306,11 @@ public class EconomyTransactionTest { return getOrCreateAccount(name); } + @Override + public double getBalance(OfflinePlayer player) { + return getBalance(player.getUniqueId()); + } + @Override public boolean transfer(UUID from, UUID to, double amount) { double formBalance = getBalance(from); @@ -146,6 +325,11 @@ public class EconomyTransactionTest { return true; } + @Override + public boolean withdraw(OfflinePlayer trader, double amount) { + return withdraw(trader.getUniqueId(), amount); + } + @Override public boolean isValid() { return true;