Skip to content

Commit 5c997ee

Browse files
committed
コマンドからコインを変更できるように
1 parent 0ef4218 commit 5c997ee

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/main/java/com/github/elic0de/thejpspit/spigot/command/PitCommand.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ public void onRegen(Player player, int amount) {
5555
player.sendMessage("変更しました");
5656
}
5757

58+
@Subcommand("set killcoin")
59+
@CommandPermission("tjp.regen")
60+
public void onKillCoin(Player player, int amount) {
61+
pit.getPitPreferences().ifPresent(pitPreferences -> pitPreferences.setAmountReward(amount));
62+
pit.getPitPreferences().ifPresent(preferences -> pit.getDatabase().updatePitPreferences(preferences));
63+
player.sendMessage("変更しました");
64+
}
65+
5866
@Subcommand("shop")
5967
@CommandPermission("tjp.shop")
6068
public void onCreateShop(Player player) {

src/main/java/com/github/elic0de/thejpspit/spigot/config/PitPreferences.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ public class PitPreferences {
1717
@SerializedName("amount_regen_health")
1818
private int amountRegenHealth;
1919

20+
@Expose
21+
@SerializedName("amount_reward")
22+
private int amountReward;
23+
2024
public static PitPreferences getDefaults() {
2125
final Location location = Bukkit.getWorlds().stream().findAny().get().getSpawnLocation();
2226
return new PitPreferences(LocationData.at(location.getX(), location.getY(), location.getZ(), location.getWorld()));
@@ -25,6 +29,7 @@ public static PitPreferences getDefaults() {
2529
private PitPreferences(LocationData spawn) {
2630
this.spawn = spawn;
2731
this.amountRegenHealth = 1;
32+
this.amountReward = 10;
2833
}
2934

3035
public Optional<LocationData> getSpawn() {
@@ -42,4 +47,12 @@ public int getAmountRegenHealth() {
4247
public void setAmountRegenHealth(int amountRegenHealth) {
4348
this.amountRegenHealth = amountRegenHealth;
4449
}
50+
51+
public int getAmountReward() {
52+
return amountReward;
53+
}
54+
55+
public void setAmountReward(int amountReward) {
56+
this.amountReward = amountReward;
57+
}
4558
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ public void addReward() {
103103

104104
inventory.addItem(new ItemStack(Material.GOLDEN_APPLE));
105105
player.updateInventory();
106-
TheJpsPit.getInstance().getEconomyHook().ifPresent(economyHook -> economyHook.giveMoney(this, BigDecimal.valueOf(10)));
106+
TheJpsPit.getInstance().getPitPreferences().ifPresent(pitPreferences -> {
107+
TheJpsPit.getInstance().getEconomyHook().ifPresent(economyHook -> economyHook.giveMoney(this, BigDecimal.valueOf(pitPreferences.getAmountReward())));
108+
});
107109
}
108110

109111
public void showHealth(PitPlayer targetPit) {

0 commit comments

Comments
 (0)