Skip to content

Commit 608b8d3

Browse files
committed
economy実装
1 parent 39fd109 commit 608b8d3

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

src/main/java/com/github/elic0de/thejpspit/hook/EconomyHook.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ protected EconomyHook(TheJpsPit plugin, String name) {
1010
super(plugin, name);
1111
}
1212

13+
public abstract BigDecimal getBalance(PitPlayer player);
14+
1315
public abstract boolean hasMoney(PitPlayer player, BigDecimal amount);
1416

1517
public abstract void takeMoney(PitPlayer player, BigDecimal amount);

src/main/java/com/github/elic0de/thejpspit/hook/VaultEconomyHook.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public void onEnable() throws IllegalStateException {
2626
plugin.getLogger().log(Level.INFO, "Enabled Vault economy hook");
2727
}
2828

29-
private BigDecimal getBalance(PitPlayer player) {
29+
@Override
30+
public BigDecimal getBalance(PitPlayer player) {
3031
return BigDecimal.valueOf(economy.getBalance(player.getPlayer()));
3132
}
3233

src/main/java/com/github/elic0de/thejpspit/player/PitPlayer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.github.elic0de.thejpspit.leveler.Levels;
66
import com.github.elic0de.thejpspit.util.ShowHealth;
77
import fr.mrmicky.fastboard.FastBoard;
8+
import java.math.BigDecimal;
89
import java.util.UUID;
910
import java.util.stream.Stream;
1011
import org.bukkit.ChatColor;
@@ -99,6 +100,7 @@ public void addReward() {
99100

100101
inventory.addItem(new ItemStack(Material.GOLDEN_APPLE));
101102
player.updateInventory();
103+
TheJpsPit.getInstance().getEconomyHook().ifPresent(economyHook -> economyHook.giveMoney(this, BigDecimal.ONE));
102104
}
103105

104106
public void showHealth(PitPlayer targetPit) {

src/main/java/com/github/elic0de/thejpspit/scoreboard/GameScoreboard.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import com.github.elic0de.thejpspit.leveler.Levels;
55
import com.github.elic0de.thejpspit.player.PitPlayer;
66
import com.github.elic0de.thejpspit.player.PitPlayerManager;
7+
import java.math.BigDecimal;
78
import java.util.List;
9+
import java.util.concurrent.atomic.AtomicReference;
810
import java.util.stream.Collectors;
911
import java.util.stream.Stream;
1012
import org.bukkit.Bukkit;
@@ -22,6 +24,9 @@ public void update() {
2224
}
2325

2426
public List<String> boardLines(PitPlayer player) {
27+
AtomicReference<BigDecimal> bigDecimal = new AtomicReference<>(BigDecimal.ZERO);
28+
TheJpsPit.getInstance().getEconomyHook().ifPresent(economyHook -> bigDecimal.set(
29+
economyHook.getBalance(player)));
2530

2631
return Stream.of(
2732
"",
@@ -44,7 +49,7 @@ public List<String> boardLines(PitPlayer player) {
4449
.replaceAll("%bestRating%", player.getBestRating() + "%")
4550
.replaceAll("%streaks%", player.getStreaks() + "")
4651
.replaceAll("%bestStreaks%", player.getBestStreaks() + "")
47-
.replaceAll("%coins%", "0")
52+
.replaceAll("%coins%", bigDecimal + "")
4853
).collect(Collectors.toList());
4954
}
5055

0 commit comments

Comments
 (0)