Skip to content

Commit d4a3701

Browse files
authored
Merge pull request #7 from 1robie/main
➕ Add ExcellentEconomy (CoinsEngine but renamed) supp…
2 parents 845f67c + ff35a1a commit d4a3701

6 files changed

Lines changed: 82 additions & 20 deletions

File tree

build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ repositories {
3030
url = uri("https://nexus.bencodez.com/repository/maven-public/")
3131
name = "BenCodez Repo"
3232
}
33+
maven {
34+
url = uri("https://repo.auxilor.io/repository/maven-public/")
35+
name = "Auxilor Repo"
36+
}
37+
maven {
38+
url = uri("https://repo.nightexpressdev.com/releases")
39+
name = "night-releases"
40+
}
3341
}
3442

3543
dependencies {
@@ -40,6 +48,7 @@ dependencies {
4048
compileOnly("com.willfp:EcoBits:1.8.4")
4149
compileOnly("com.bencodez:votingplugin:6.17.2")
4250
compileOnly("com.github.Emibergo02:RedisEconomy:4.3.19")
51+
compileOnly("su.nightexpress.coinsengine:CoinsEngine:2.7.0")
4352

4453
compileOnly("fr.maxlego08.menu:zmenu-api:1.1.0.6")
4554

gradle.properties

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

readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The `Currencies` enum allows easy management of various in-game currencies like
2020
- [zMenu](https://www.spigotmc.org/resources/110402/) - `ZMENUITEMS`
2121
- [EcoBits](https://www.spigotmc.org/resources/109967/) - `ECOBITS`
2222
- [CoinsEngine](https://www.spigotmc.org/resources/84121/) - `COINSENGINE`
23+
- [ExcellentEconomy](https://modrinth.com/plugin/excellenteconomy) - `EXCELLENTEECONOMY`
2324
- [VotingPlugin](https://www.spigotmc.org/resources/15358/) - `VOTINGPLUGIN`
2425
- [RedisEconomy](https://www.spigotmc.org/resources/105965/) - `REDISECONOMY`
2526
- [RoyaleEconomy](https://polymart.org/product/113/royaleeconomy-1-8-1-21) - `ROYALEECONOMY`
@@ -46,7 +47,7 @@ To add the Currencies API to your project using Maven, add the following to your
4647
<dependency>
4748
<groupId>fr.traqueur.currencies</groupId>
4849
<artifactId>currenciesapi</artifactId>
49-
<version>1.0.11</version>
50+
<version>1.0.12</version>
5051
</dependency>
5152
```
5253

@@ -63,7 +64,7 @@ repositories {
6364
}
6465

6566
dependencies {
66-
implementation("fr.traqueur.currencies:currenciesapi:1.0.11")
67+
implementation("fr.traqueur.currencies:currenciesapi:1.0.12")
6768
}
6869
```
6970

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

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
package fr.traqueur.currencies;
22

3-
import fr.traqueur.currencies.providers.BeastTokenProvider;
4-
import fr.traqueur.currencies.providers.CoinsEngineProvider;
5-
import fr.traqueur.currencies.providers.EcoBitProvider;
6-
import fr.traqueur.currencies.providers.ElementalGemsProvider;
7-
import fr.traqueur.currencies.providers.ElementalTokensProvider;
8-
import fr.traqueur.currencies.providers.ExperienceProvider;
9-
import fr.traqueur.currencies.providers.ItemProvider;
10-
import fr.traqueur.currencies.providers.LevelProvider;
11-
import fr.traqueur.currencies.providers.PlayerPointsProvider;
12-
import fr.traqueur.currencies.providers.RedisEconomyProvider;
13-
import fr.traqueur.currencies.providers.RoyaleEconomyProvider;
14-
import fr.traqueur.currencies.providers.VaultProvider;
15-
import fr.traqueur.currencies.providers.VotingProvider;
16-
import fr.traqueur.currencies.providers.ZEssentialsProvider;
17-
import fr.traqueur.currencies.providers.ZMenuItemProvider;
3+
import fr.traqueur.currencies.providers.*;
184
import org.bukkit.Bukkit;
195
import org.bukkit.OfflinePlayer;
206

@@ -90,7 +76,12 @@ public enum Currencies {
9076
/**
9177
* The currency RoyaleEconomy from the plugin RoyaleEconomy.
9278
*/
93-
ROYALEECONOMY("RoyaleEconomy", RoyaleEconomyProvider.class, true, true);
79+
ROYALEECONOMY("RoyaleEconomy", RoyaleEconomyProvider.class, true, true),
80+
/**
81+
* The currency ExcellentEconomy from the plugin ExcellentEconomy (new name for CraftEngine)
82+
*/
83+
EXCELLENTEECONOMY("ExcellentEconomy", ExcellentEconomyProvider.class, true, true)
84+
;
9485

9586
static {
9687
Updater.checkUpdates();
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package fr.traqueur.currencies.providers;
2+
3+
import fr.traqueur.currencies.CurrencyProvider;
4+
import org.bukkit.Bukkit;
5+
import org.bukkit.OfflinePlayer;
6+
import org.bukkit.entity.Player;
7+
import org.bukkit.plugin.RegisteredServiceProvider;
8+
import su.nightexpress.excellenteconomy.api.ExcellentEconomyAPI;
9+
import su.nightexpress.excellenteconomy.api.currency.operation.OperationContext;
10+
11+
import java.math.BigDecimal;
12+
13+
public class ExcellentEconomyProvider implements CurrencyProvider {
14+
private final ExcellentEconomyAPI api;
15+
private final String currencyName;
16+
17+
public ExcellentEconomyProvider(String currencyName) {
18+
this.currencyName = currencyName;
19+
RegisteredServiceProvider<ExcellentEconomyAPI> provider = Bukkit.getServer().getServicesManager().getRegistration(ExcellentEconomyAPI.class);
20+
if (provider == null) {
21+
throw new IllegalStateException("ExcellentEconomy service not registered");
22+
}
23+
this.api = provider.getProvider();
24+
}
25+
26+
@Override
27+
public void deposit(OfflinePlayer player, BigDecimal amount, String reason) {
28+
OperationContext ctx = OperationContext.custom(reason);
29+
if (isOnline(player)) {
30+
this.api.deposit(asOnline(player), this.currencyName, amount.doubleValue(), ctx);
31+
} else {
32+
this.api.depositAsync(player.getUniqueId(), this.currencyName, amount.doubleValue(), ctx);
33+
}
34+
}
35+
36+
@Override
37+
public void withdraw(OfflinePlayer player, BigDecimal amount, String reason) {
38+
OperationContext ctx = OperationContext.custom(reason);
39+
if (isOnline(player)) {
40+
this.api.withdraw(asOnline(player), this.currencyName, amount.doubleValue(), ctx);
41+
} else {
42+
this.api.withdrawAsync(player.getUniqueId(), this.currencyName, amount.doubleValue(), ctx);
43+
}
44+
}
45+
46+
@Override
47+
public BigDecimal getBalance(OfflinePlayer player) {
48+
double raw = isOnline(player)
49+
? this.api.getBalance(asOnline(player), this.currencyName)
50+
: this.api.getBalanceAsync(player.getUniqueId(), this.currencyName).join();
51+
return BigDecimal.valueOf(raw);
52+
}
53+
54+
private boolean isOnline(OfflinePlayer player) {
55+
return player instanceof Player;
56+
}
57+
58+
private Player asOnline(OfflinePlayer player) {
59+
return (Player) player;
60+
}
61+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=1.0.11
1+
version=1.0.12

0 commit comments

Comments
 (0)