Skip to content

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
BenceX100 committed Dec 24, 2023
1 parent 1077dab commit 9c2039d
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 5 deletions.
14 changes: 12 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.artillexstudios</groupId>
<artifactId>AxRankMenu</artifactId>
<version>1.1.0</version>
<version>1.0.3</version>
<packaging>jar</packaging>

<name>AxRankMenu</name>
Expand Down Expand Up @@ -100,6 +100,10 @@
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>techscode</id>
<url>https://repo.techscode.com/repository/maven-releases/</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -112,7 +116,7 @@
<dependency>
<groupId>com.artillexstudios.axapi</groupId>
<artifactId>axapi</artifactId>
<version>1.4.6</version>
<version>1.4.10</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -194,5 +198,11 @@
<version>2.11.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.TechsCode</groupId>
<artifactId>UltraEconomyAPI</artifactId>
<version>2.6.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.artillexstudios.axrankmenu.hooks.currency.CurrencyHook;
import com.artillexstudios.axrankmenu.hooks.currency.PlayerPointsHook;
import com.artillexstudios.axrankmenu.hooks.currency.RoyaleEconomyHook;
import com.artillexstudios.axrankmenu.hooks.currency.UltraEconomyHook;
import com.artillexstudios.axrankmenu.hooks.currency.VaultHook;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
Expand Down Expand Up @@ -40,13 +41,20 @@ public void updateHooks() {
} else {
Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("&#FF3333[AxRankMenu] CoinsEngine is set in config.yml, but it isn't installed, please download it or change it in the config to stop errors!"));
}

if (CONFIG.getBoolean("hooks.RoyaleEconomy.register", true) && Bukkit.getPluginManager().getPlugin("RoyaleEconomy") != null) {
currency.add(new RoyaleEconomyHook());
Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("&#33FF33[AxRankMenu] Hooked into RoyaleEconomy!"));
} else {
Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("&#FF3333[AxRankMenu] RoyaleEconomy is set in config.yml, but it isn't installed, please download it or change it in the config to stop errors!"));
}

if (CONFIG.getBoolean("hooks.UltraEconomy.register", true) && Bukkit.getPluginManager().getPlugin("UltraEconomy") != null) {
currency.add(new UltraEconomyHook());
Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("&#33FF33[AxRankMenu] Hooked into UltraEconomy!"));
} else {
Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("&#FF3333[AxRankMenu] UltraEconomy is set in config.yml, but it isn't installed, please download it or change it in the config to stop errors!"));
}

for (CurrencyHook hook : currency) hook.setup();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.artillexstudios.axrankmenu.hooks.currency;

import me.TechsCode.UltraEconomy.UltraEconomy;
import me.TechsCode.UltraEconomy.objects.Account;
import me.TechsCode.UltraEconomy.objects.Currency;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.Optional;

import static com.artillexstudios.axrankmenu.AxRankMenu.CONFIG;

public class UltraEconomyHook implements CurrencyHook {
private Currency currency = null;

@Override
public void setup() {
final Optional<Currency> currencyOptional = UltraEconomy.getAPI().getCurrencies().name(CONFIG.getString("hook-settings.UltraEconomy.currency-name", "coins"));
if (!currencyOptional.isPresent()) throw new RuntimeException("Currency not found!");
currency = currencyOptional.get();
}

@Override
public String getName() {
return "UltraEconomy";
}

@Override
public double getBalance(@NotNull Player p) {
final Optional<Account> account = UltraEconomy.getAPI().getAccounts().uuid(p.getUniqueId());
if (!account.isPresent()) return 0.0D;
return account.get().getBalance(currency).getOnHand();
}

@Override
public void giveBalance(@NotNull Player p, double amount) {
final Optional<Account> account = UltraEconomy.getAPI().getAccounts().uuid(p.getUniqueId());
if (!account.isPresent()) return;
account.get().addBalance(currency, amount);
}

@Override
public void takeBalance(@NotNull Player p, double amount) {
final Optional<Account> account = UltraEconomy.getAPI().getAccounts().uuid(p.getUniqueId());
if (!account.isPresent()) return;
account.get().removeBalance(currency, amount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class PlaceholderUtils {
public static String parsePlaceholders(@NotNull String string, @NotNull Section section) {
string = string.replace("%price%", StringUtils.formatNumber("#,###.##", section.getDouble("price")));

LuckPerms lpApi = LuckPermsProvider.get();
ImmutableContextSet set = lpApi.getContextManager().getStaticContext();
final LuckPerms lpApi = LuckPermsProvider.get();
final ImmutableContextSet set = lpApi.getContextManager().getStaticContext();
string = string.replace("%server%", (section.getString("server").equals("") && set.getAnyValue("server").isPresent()) ? set.getAnyValue("server").get() : section.getString("server"));

if (HookManager.getPapi() != null)
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ hooks:
CoinsEngine:
register: true
currency-name: "coins"
UltraEconomy:
register: true
currency-name: "coins"
PlaceholderAPI:
register: true

Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ folia-supported: true
depend:
- LuckPerms

softdepend:
- PlaceholderAPI
- CoinsEngine
- PlayerPoints
- RoyaleEconomy
- UltraEconomy

commands:
axrankmenu:
usage: /<command>
Expand Down

0 comments on commit 9c2039d

Please sign in to comment.