Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ repositories {
url = uri("https://nexus.bencodez.com/repository/maven-public/")
name = "BenCodez Repo"
}
maven {
url = uri("https://repo.auxilor.io/repository/maven-public/")
name = "Auxilor Repo"
}
maven {
url = uri("https://repo.nightexpressdev.com/releases")
name = "night-releases"
}
}

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

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

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.0.11
version=1.0.12
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The `Currencies` enum allows easy management of various in-game currencies like
- [zMenu](https://www.spigotmc.org/resources/110402/) - `ZMENUITEMS`
- [EcoBits](https://www.spigotmc.org/resources/109967/) - `ECOBITS`
- [CoinsEngine](https://www.spigotmc.org/resources/84121/) - `COINSENGINE`
- [ExcellentEconomy](https://modrinth.com/plugin/excellenteconomy) - `EXCELLENTEECONOMY`
- [VotingPlugin](https://www.spigotmc.org/resources/15358/) - `VOTINGPLUGIN`
- [RedisEconomy](https://www.spigotmc.org/resources/105965/) - `REDISECONOMY`
- [RoyaleEconomy](https://polymart.org/product/113/royaleeconomy-1-8-1-21) - `ROYALEECONOMY`
Expand All @@ -46,7 +47,7 @@ To add the Currencies API to your project using Maven, add the following to your
<dependency>
<groupId>fr.traqueur.currencies</groupId>
<artifactId>currenciesapi</artifactId>
<version>1.0.11</version>
<version>1.0.12</version>
</dependency>
```

Expand All @@ -63,7 +64,7 @@ repositories {
}

dependencies {
implementation("fr.traqueur.currencies:currenciesapi:1.0.11")
implementation("fr.traqueur.currencies:currenciesapi:1.0.12")
}
```

Expand Down
23 changes: 7 additions & 16 deletions src/main/java/fr/traqueur/currencies/Currencies.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
package fr.traqueur.currencies;

import fr.traqueur.currencies.providers.BeastTokenProvider;
import fr.traqueur.currencies.providers.CoinsEngineProvider;
import fr.traqueur.currencies.providers.EcoBitProvider;
import fr.traqueur.currencies.providers.ElementalGemsProvider;
import fr.traqueur.currencies.providers.ElementalTokensProvider;
import fr.traqueur.currencies.providers.ExperienceProvider;
import fr.traqueur.currencies.providers.ItemProvider;
import fr.traqueur.currencies.providers.LevelProvider;
import fr.traqueur.currencies.providers.PlayerPointsProvider;
import fr.traqueur.currencies.providers.RedisEconomyProvider;
import fr.traqueur.currencies.providers.RoyaleEconomyProvider;
import fr.traqueur.currencies.providers.VaultProvider;
import fr.traqueur.currencies.providers.VotingProvider;
import fr.traqueur.currencies.providers.ZEssentialsProvider;
import fr.traqueur.currencies.providers.ZMenuItemProvider;
import fr.traqueur.currencies.providers.*;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;

Expand Down Expand Up @@ -90,7 +76,12 @@ public enum Currencies {
/**
* The currency RoyaleEconomy from the plugin RoyaleEconomy.
*/
ROYALEECONOMY("RoyaleEconomy", RoyaleEconomyProvider.class, true, true);
ROYALEECONOMY("RoyaleEconomy", RoyaleEconomyProvider.class, true, true),
/**
* The currency ExcellentEconomy from the plugin ExcellentEconomy (new name for CraftEngine)
*/
EXCELLENTEECONOMY("ExcellentEconomy", ExcellentEconomyProvider.class, true, true)
;

static {
Updater.checkUpdates();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package fr.traqueur.currencies.providers;

import fr.traqueur.currencies.CurrencyProvider;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import su.nightexpress.excellenteconomy.api.ExcellentEconomyAPI;
import su.nightexpress.excellenteconomy.api.currency.operation.OperationContext;

import java.math.BigDecimal;

public class ExcellentEconomyProvider implements CurrencyProvider {
private final ExcellentEconomyAPI api;
private final String currencyName;

public ExcellentEconomyProvider(String currencyName) {
this.currencyName = currencyName;
RegisteredServiceProvider<ExcellentEconomyAPI> provider = Bukkit.getServer().getServicesManager().getRegistration(ExcellentEconomyAPI.class);
if (provider == null) {
throw new IllegalStateException("ExcellentEconomy service not registered");
}
this.api = provider.getProvider();
}

@Override
public void deposit(OfflinePlayer player, BigDecimal amount, String reason) {
OperationContext ctx = OperationContext.custom(reason);
if (isOnline(player)) {
this.api.deposit(asOnline(player), this.currencyName, amount.doubleValue(), ctx);
} else {
this.api.depositAsync(player.getUniqueId(), this.currencyName, amount.doubleValue(), ctx);
}
}

@Override
public void withdraw(OfflinePlayer player, BigDecimal amount, String reason) {
OperationContext ctx = OperationContext.custom(reason);
if (isOnline(player)) {
this.api.withdraw(asOnline(player), this.currencyName, amount.doubleValue(), ctx);
} else {
this.api.withdrawAsync(player.getUniqueId(), this.currencyName, amount.doubleValue(), ctx);
}
}

@Override
public BigDecimal getBalance(OfflinePlayer player) {
double raw = isOnline(player)
? this.api.getBalance(asOnline(player), this.currencyName)
: this.api.getBalanceAsync(player.getUniqueId(), this.currencyName).join();
return BigDecimal.valueOf(raw);
}

private boolean isOnline(OfflinePlayer player) {
return player instanceof Player;
}

private Player asOnline(OfflinePlayer player) {
return (Player) player;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/currenciesapi.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.0.11
version=1.0.12
Loading