-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f78433c
commit 97e4dcd
Showing
7 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
Bukkit/src/main/java/info/preva1l/fadah/currency/CoinsEngineCurrency.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package info.preva1l.fadah.currency; | ||
|
||
import info.preva1l.fadah.Fadah; | ||
import info.preva1l.fadah.config.Config; | ||
import info.preva1l.fadah.config.SubEconomy; | ||
import lombok.Getter; | ||
import org.bukkit.OfflinePlayer; | ||
import su.nightexpress.coinsengine.api.CoinsEngineAPI; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Getter | ||
public class CoinsEngineCurrency implements MultiCurrency { | ||
private final String id = "coins_engine"; | ||
private final String name = "Coins Engine"; | ||
private final String requiredPlugin = "CoinsEngine"; | ||
private final List<Currency> currencies = new ArrayList<>(); | ||
|
||
@Override | ||
public boolean preloadChecks() { | ||
for (SubEconomy eco : Config.i().getCurrency().getCoinsEngine().getCurrencies()) { | ||
Currency subCur = new SubCurrency(id + "_" + eco.economy(), eco.displayName(), requiredPlugin) { | ||
@Override | ||
public void withdraw(OfflinePlayer player, double amountToTake) { | ||
CoinsEngineAPI.addBalance(player.getUniqueId(), getCurrency(), amountToTake); | ||
} | ||
|
||
@Override | ||
public void add(OfflinePlayer player, double amountToAdd) { | ||
CoinsEngineAPI.addBalance(player.getUniqueId(), getCurrency(), amountToAdd); | ||
} | ||
|
||
@Override | ||
public double getBalance(OfflinePlayer player) { | ||
return CoinsEngineAPI.getBalance(player.getUniqueId(), getCurrency()); | ||
} | ||
|
||
private su.nightexpress.coinsengine.api.currency.Currency getCurrency() { | ||
return CoinsEngineAPI.getCurrency(eco.economy()); | ||
} | ||
|
||
@Override | ||
public boolean preloadChecks() { | ||
if (getCurrency() == null) { | ||
Fadah.getConsole().severe("-------------------------------------"); | ||
Fadah.getConsole().severe("Cannot enable coins engine currency!"); | ||
Fadah.getConsole().severe("No currency with name: " + eco.economy()); | ||
Fadah.getConsole().severe("-------------------------------------"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
}; | ||
currencies.add(subCur); | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.