Skip to content

Commit 27a44ef

Browse files
committed
Merge branch 'release/1.0.13'
2 parents 91cf969 + 0039464 commit 27a44ef

22 files changed

+209
-183
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,5 @@ runs/
116116

117117
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
118118
!gradle-wrapper.jar
119+
.claude/settings.local.json
120+
CLAUDE.md

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=1.0.12
1+
version=1.0.13

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ To add the Currencies API to your project using Maven, add the following to your
4747
<dependency>
4848
<groupId>fr.traqueur.currencies</groupId>
4949
<artifactId>currenciesapi</artifactId>
50-
<version>1.0.12</version>
50+
<version>1.0.13</version>
5151
</dependency>
5252
```
5353

@@ -64,7 +64,7 @@ repositories {
6464
}
6565

6666
dependencies {
67-
implementation("fr.traqueur.currencies:currenciesapi:1.0.12")
67+
implementation("fr.traqueur.currencies:currenciesapi:1.0.13")
6868
}
6969
```
7070

src/main/java/fr/traqueur/currencies/Currencies.java

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
import fr.traqueur.currencies.providers.*;
44
import org.bukkit.Bukkit;
5-
import org.bukkit.OfflinePlayer;
65

76
import java.lang.reflect.Constructor;
87
import java.math.BigDecimal;
98
import java.util.Arrays;
109
import java.util.HashMap;
1110
import java.util.Map;
11+
import java.util.UUID;
1212

1313
/**
1414
* The list of all the currencies that can be used in the plugin.
@@ -154,88 +154,91 @@ private boolean isDisable() {
154154
/**
155155
* Add some money to a player.
156156
*
157-
* @param player The player to add the money.
158-
* @param amount The amount of money to add.
159-
* @param reason The reason of the deposit.
157+
* @param playerId The UUID of the player to add the money.
158+
* @param amount The amount of money to add.
159+
* @param reason The reason of the deposit.
160160
*/
161-
public void deposit(OfflinePlayer player, BigDecimal amount, String reason) {
162-
this.deposit(player, amount, "default", reason);
161+
public void deposit(UUID playerId, BigDecimal amount, String reason) {
162+
this.deposit(playerId, amount, "default", reason);
163163
}
164164

165165
/**
166166
* Remove some money from a player.
167167
*
168-
* @param player The player to remove the money.
169-
* @param amount The amount of money to remove.
170-
* @param reason The reason of the withdrawal.
168+
* @param playerId The UUID of the player to remove the money.
169+
* @param amount The amount of money to remove.
170+
* @param reason The reason of the withdrawal.
171171
*/
172-
public void withdraw(OfflinePlayer player, BigDecimal amount, String reason) {
173-
this.withdraw(player, amount, "default", reason);
172+
public void withdraw(UUID playerId, BigDecimal amount, String reason) {
173+
this.withdraw(playerId, amount, "default", reason);
174174
}
175175

176176
/**
177177
* Add some money to a player.
178178
*
179-
* @param player The player to add the money.
180-
* @param amount The amount of money to add.
179+
* @param playerId The UUID of the player to add the money.
180+
* @param amount The amount of money to add.
181181
*/
182-
public void deposit(OfflinePlayer player, BigDecimal amount) {
183-
this.deposit(player, amount, "default", "No reason");
182+
public void deposit(UUID playerId, BigDecimal amount) {
183+
this.deposit(playerId, amount, "default", "No reason");
184184
}
185185

186186
/**
187187
* Remove some money from a player.
188188
*
189-
* @param player The player to remove the money.
190-
* @param amount The amount of money to remove.
189+
* @param playerId The UUID of the player to remove the money.
190+
* @param amount The amount of money to remove.
191191
*/
192-
public void withdraw(OfflinePlayer player, BigDecimal amount) {
193-
this.withdraw(player, amount, "default", "No reason");
192+
public void withdraw(UUID playerId, BigDecimal amount) {
193+
this.withdraw(playerId, amount, "default", "No reason");
194194
}
195195

196196
/**
197197
* Get the balance of a player.
198198
*
199-
* @param player The player to get the balance.
199+
* @param playerId The UUID of the player to get the balance.
200200
* @return The balance of the player.
201201
*/
202-
public BigDecimal getBalance(OfflinePlayer player) {
203-
return getBalance(player, "default");
202+
public BigDecimal getBalance(UUID playerId) {
203+
return getBalance(playerId, "default");
204204
}
205205

206206
/**
207207
* Add some money to a player.
208208
*
209-
* @param player The player to add the money.
210-
* @param amount The amount of money to add.
211-
* @param reason The reason of the deposit.
209+
* @param playerId The UUID of the player to add the money.
210+
* @param amount The amount of money to add.
211+
* @param currencyName The name of the currency.
212+
* @param reason The reason of the deposit.
212213
*/
213-
public void deposit(OfflinePlayer player, BigDecimal amount, String currencyName, String reason) {
214+
public void deposit(UUID playerId, BigDecimal amount, String currencyName, String reason) {
214215
this.canBeUse(currencyName);
215-
this.providers.get(currencyName).deposit(player, amount, reason);
216+
this.providers.get(currencyName).deposit(playerId, amount, reason);
216217
}
217218

218219
/**
219220
* Remove some money from a player.
220221
*
221-
* @param player The player to remove the money.
222-
* @param amount The amount of money to remove.
223-
* @param reason The reason of the withdrawal.
222+
* @param playerId The UUID of the player to remove the money.
223+
* @param amount The amount of money to remove.
224+
* @param currencyName The name of the currency.
225+
* @param reason The reason of the withdrawal.
224226
*/
225-
public void withdraw(OfflinePlayer player, BigDecimal amount, String currencyName, String reason) {
227+
public void withdraw(UUID playerId, BigDecimal amount, String currencyName, String reason) {
226228
this.canBeUse(currencyName);
227-
this.providers.get(currencyName).withdraw(player, amount, reason);
229+
this.providers.get(currencyName).withdraw(playerId, amount, reason);
228230
}
229231

230232
/**
231233
* Get the balance of a player.
232234
*
233-
* @param player The player to get the balance.
235+
* @param playerId The UUID of the player to get the balance.
236+
* @param currencyName The name of the currency.
234237
* @return The balance of the player.
235238
*/
236-
public BigDecimal getBalance(OfflinePlayer player, String currencyName) {
239+
public BigDecimal getBalance(UUID playerId, String currencyName) {
237240
this.canBeUse(currencyName);
238-
return this.providers.get(currencyName).getBalance(player);
241+
return this.providers.get(currencyName).getBalance(playerId);
239242
}
240243

241244
private void canBeUse(String currencyName) {
@@ -254,4 +257,4 @@ private void canBeUse(String currencyName) {
254257
throw new IllegalStateException("You must create the provider for the plugin " + this.name + currency + " before using it.");
255258
}
256259
}
257-
}
260+
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package fr.traqueur.currencies;
22

3-
import org.bukkit.OfflinePlayer;
4-
53
import java.math.BigDecimal;
4+
import java.util.UUID;
65

76
/**
87
* Interface used to interact with a currency provider.
@@ -14,27 +13,27 @@ public interface CurrencyProvider {
1413
/**
1514
* Deposit a certain amount of currency to a player.
1615
*
17-
* @param offlinePlayer The player to deposit the money.
18-
* @param amount The amount of currency to deposit.
19-
* @param reason The reason of the deposit.
16+
* @param playerId The UUID of the player to deposit the money.
17+
* @param amount The amount of currency to deposit.
18+
* @param reason The reason of the deposit.
2019
*/
21-
void deposit(OfflinePlayer offlinePlayer, BigDecimal amount, String reason);
20+
void deposit(UUID playerId, BigDecimal amount, String reason);
2221

2322
/**
2423
* Withdraw a certain amount of currency from a player.
2524
*
26-
* @param offlinePlayer The player to withdraw the money.
27-
* @param amount The amount of currency to withdraw.
28-
* @param reason The reason of the withdrawal.
25+
* @param playerId The UUID of the player to withdraw the money.
26+
* @param amount The amount of currency to withdraw.
27+
* @param reason The reason of the withdrawal.
2928
*/
30-
void withdraw(OfflinePlayer offlinePlayer, BigDecimal amount, String reason);
29+
void withdraw(UUID playerId, BigDecimal amount, String reason);
3130

3231
/**
3332
* Get the balance of a player.
3433
*
35-
* @param offlinePlayer The player to get the balance.
34+
* @param playerId The UUID of the player to get the balance.
3635
* @return The balance of the player.
3736
*/
38-
BigDecimal getBalance(OfflinePlayer offlinePlayer);
37+
BigDecimal getBalance(UUID playerId);
3938

4039
}

src/main/java/fr/traqueur/currencies/providers/BeastTokenProvider.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
import fr.traqueur.currencies.CurrencyProvider;
44
import me.mraxetv.beasttokens.api.BeastTokensAPI;
5+
import org.bukkit.Bukkit;
56
import org.bukkit.OfflinePlayer;
67

78
import java.math.BigDecimal;
9+
import java.util.UUID;
810

911
public class BeastTokenProvider implements CurrencyProvider {
1012
@Override
11-
public void deposit(OfflinePlayer offlinePlayer, BigDecimal amount, String reason) {
13+
public void deposit(UUID playerId, BigDecimal amount, String reason) {
14+
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerId);
1215
if (offlinePlayer.isOnline()) {
1316
BeastTokensAPI.getTokensManager().addTokens(offlinePlayer.getPlayer(), amount.doubleValue());
1417
} else {
@@ -17,7 +20,8 @@ public void deposit(OfflinePlayer offlinePlayer, BigDecimal amount, String reaso
1720
}
1821

1922
@Override
20-
public void withdraw(OfflinePlayer offlinePlayer, BigDecimal amount, String reason) {
23+
public void withdraw(UUID playerId, BigDecimal amount, String reason) {
24+
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerId);
2125
if (offlinePlayer.isOnline()) {
2226
BeastTokensAPI.getTokensManager().removeTokens(offlinePlayer.getPlayer(), amount.doubleValue());
2327
} else {
@@ -26,7 +30,8 @@ public void withdraw(OfflinePlayer offlinePlayer, BigDecimal amount, String reas
2630
}
2731

2832
@Override
29-
public BigDecimal getBalance(OfflinePlayer offlinePlayer) {
33+
public BigDecimal getBalance(UUID playerId) {
34+
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerId);
3035
return BigDecimal.valueOf(offlinePlayer.isOnline() ? BeastTokensAPI.getTokensManager().getTokens(offlinePlayer.getPlayer()) : BeastTokensAPI.getTokensManager().getTokens(offlinePlayer));
3136
}
3237
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package fr.traqueur.currencies.providers;
22

33
import fr.traqueur.currencies.CurrencyProvider;
4-
import org.bukkit.OfflinePlayer;
54
import su.nightexpress.coinsengine.api.CoinsEngineAPI;
65

76
import java.math.BigDecimal;
7+
import java.util.UUID;
88

99
public class CoinsEngineProvider implements CurrencyProvider {
1010

@@ -15,17 +15,17 @@ public CoinsEngineProvider(String currencyName) {
1515
}
1616

1717
@Override
18-
public void deposit(OfflinePlayer offlinePlayer, BigDecimal amount, String reason) {
19-
CoinsEngineAPI.addBalance(offlinePlayer.getUniqueId(), this.currencyName, amount.doubleValue());
18+
public void deposit(UUID playerId, BigDecimal amount, String reason) {
19+
CoinsEngineAPI.addBalance(playerId, this.currencyName, amount.doubleValue());
2020
}
2121

2222
@Override
23-
public void withdraw(OfflinePlayer offlinePlayer, BigDecimal amount, String reason) {
24-
CoinsEngineAPI.removeBalance(offlinePlayer.getUniqueId(), this.currencyName, amount.doubleValue());
23+
public void withdraw(UUID playerId, BigDecimal amount, String reason) {
24+
CoinsEngineAPI.removeBalance(playerId, this.currencyName, amount.doubleValue());
2525
}
2626

2727
@Override
28-
public BigDecimal getBalance(OfflinePlayer offlinePlayer) {
29-
return BigDecimal.valueOf(CoinsEngineAPI.getBalance(offlinePlayer.getUniqueId(), this.currencyName));
28+
public BigDecimal getBalance(UUID playerId) {
29+
return BigDecimal.valueOf(CoinsEngineAPI.getBalance(playerId, this.currencyName));
3030
}
3131
}

src/main/java/fr/traqueur/currencies/providers/EcoBitProvider.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import com.willfp.ecobits.currencies.Currency;
55
import com.willfp.ecobits.currencies.CurrencyUtils;
66
import fr.traqueur.currencies.CurrencyProvider;
7+
import org.bukkit.Bukkit;
78
import org.bukkit.OfflinePlayer;
89

910
import java.math.BigDecimal;
11+
import java.util.UUID;
1012

1113
public class EcoBitProvider implements CurrencyProvider {
1214

@@ -24,20 +26,23 @@ private void initialize() {
2426
}
2527

2628
@Override
27-
public void deposit(OfflinePlayer offlinePlayer, BigDecimal amount, String reason) {
29+
public void deposit(UUID playerId, BigDecimal amount, String reason) {
2830
initialize();
31+
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerId);
2932
CurrencyUtils.adjustBalance(offlinePlayer, currency, amount);
3033
}
3134

3235
@Override
33-
public void withdraw(OfflinePlayer offlinePlayer, BigDecimal amount, String reason) {
36+
public void withdraw(UUID playerId, BigDecimal amount, String reason) {
3437
initialize();
38+
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerId);
3539
CurrencyUtils.adjustBalance(offlinePlayer, currency, amount.negate());
3640
}
3741

3842
@Override
39-
public BigDecimal getBalance(OfflinePlayer offlinePlayer) {
43+
public BigDecimal getBalance(UUID playerId) {
4044
initialize();
45+
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerId);
4146
return CurrencyUtils.getBalance(offlinePlayer, currency);
4247
}
4348
}

src/main/java/fr/traqueur/currencies/providers/ElementalGemsProvider.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
import fr.traqueur.currencies.CurrencyProvider;
44
import me.elementalgaming.ElementalGems.GemAPI;
5-
import org.bukkit.OfflinePlayer;
65

76
import java.math.BigDecimal;
7+
import java.util.UUID;
88

99
public class ElementalGemsProvider implements CurrencyProvider {
1010
@Override
11-
public void deposit(OfflinePlayer offlinePlayer, BigDecimal amount, String reason) {
12-
GemAPI.addGems(offlinePlayer.getUniqueId(), amount.doubleValue());
11+
public void deposit(UUID playerId, BigDecimal amount, String reason) {
12+
GemAPI.addGems(playerId, amount.doubleValue());
1313
}
1414

1515
@Override
16-
public void withdraw(OfflinePlayer offlinePlayer, BigDecimal amount, String reason) {
17-
GemAPI.removeGems(offlinePlayer.getUniqueId(), amount.doubleValue());
16+
public void withdraw(UUID playerId, BigDecimal amount, String reason) {
17+
GemAPI.removeGems(playerId, amount.doubleValue());
1818
}
1919

2020
@Override
21-
public BigDecimal getBalance(OfflinePlayer offlinePlayer) {
22-
return BigDecimal.valueOf(GemAPI.getGems(offlinePlayer.getUniqueId()));
21+
public BigDecimal getBalance(UUID playerId) {
22+
return BigDecimal.valueOf(GemAPI.getGems(playerId));
2323
}
2424
}

src/main/java/fr/traqueur/currencies/providers/ElementalTokensProvider.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
import fr.traqueur.currencies.CurrencyProvider;
44
import me.elementalgaming.ElementalTokens.TokenAPI;
5-
import org.bukkit.OfflinePlayer;
65

76
import java.math.BigDecimal;
7+
import java.util.UUID;
88

99
public class ElementalTokensProvider implements CurrencyProvider {
1010
@Override
11-
public void deposit(OfflinePlayer offlinePlayer, BigDecimal amount, String reason) {
12-
TokenAPI.addTokens(offlinePlayer.getUniqueId(), amount.longValue());
11+
public void deposit(UUID playerId, BigDecimal amount, String reason) {
12+
TokenAPI.addTokens(playerId, amount.longValue());
1313
}
1414

1515
@Override
16-
public void withdraw(OfflinePlayer offlinePlayer, BigDecimal amount, String reason) {
17-
TokenAPI.removeTokens(offlinePlayer.getUniqueId(), amount.longValue());
16+
public void withdraw(UUID playerId, BigDecimal amount, String reason) {
17+
TokenAPI.removeTokens(playerId, amount.longValue());
1818
}
1919

2020
@Override
21-
public BigDecimal getBalance(OfflinePlayer offlinePlayer) {
22-
return BigDecimal.valueOf(TokenAPI.getTokens(offlinePlayer.getUniqueId()));
21+
public BigDecimal getBalance(UUID playerId) {
22+
return BigDecimal.valueOf(TokenAPI.getTokens(playerId));
2323
}
2424
}

0 commit comments

Comments
 (0)