diff --git a/pom.xml b/pom.xml index d9715b2..5ef8aff 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.artillexstudios AxTrade - 1.6.0 + 1.6.1 jar AxTrade @@ -112,7 +112,7 @@ com.artillexstudios.axapi axapi - 1.4.259 + 1.4.280 compile all @@ -255,5 +255,12 @@ main-3338e61c6c-1 provided + + me.mraxetv.beasttokens.api + BeastTokens + 3.13.3 + ${project.basedir}/libs/bt-api-3.13.3.jar + system + diff --git a/src/main/java/com/artillexstudios/axtrade/commands/Commands.java b/src/main/java/com/artillexstudios/axtrade/commands/Commands.java index dac6d61..0f2de40 100644 --- a/src/main/java/com/artillexstudios/axtrade/commands/Commands.java +++ b/src/main/java/com/artillexstudios/axtrade/commands/Commands.java @@ -1,7 +1,6 @@ package com.artillexstudios.axtrade.commands; import com.artillexstudios.axapi.nms.NMSHandlers; -import com.artillexstudios.axapi.reflection.FastFieldAccessor; import com.artillexstudios.axapi.utils.StringUtils; import com.artillexstudios.axtrade.AxTrade; import com.artillexstudios.axtrade.hooks.HookManager; @@ -13,7 +12,6 @@ import com.artillexstudios.axtrade.utils.NumberUtils; import com.artillexstudios.axtrade.utils.SoundUtils; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.Warning; import org.bukkit.command.CommandSender; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; @@ -140,11 +138,7 @@ public class Commands implements OrphanCommand { private static BukkitCommandHandler handler = null; public static void registerCommand() { if (handler == null) { - Warning.WarningState prevState = Bukkit.getWarningState(); - FastFieldAccessor accessor = FastFieldAccessor.forClassField(Bukkit.getServer().getClass().getPackage().getName() + ".CraftServer", "warningState"); - accessor.set(Bukkit.getServer(), Warning.WarningState.OFF); handler = BukkitCommandHandler.create(AxTrade.getInstance()); - accessor.set(Bukkit.getServer(), prevState); handler.registerValueResolver(0, OfflinePlayer.class, context -> { String value = context.pop(); diff --git a/src/main/java/com/artillexstudios/axtrade/hooks/HookManager.java b/src/main/java/com/artillexstudios/axtrade/hooks/HookManager.java index 9fd644f..e8ec4d1 100644 --- a/src/main/java/com/artillexstudios/axtrade/hooks/HookManager.java +++ b/src/main/java/com/artillexstudios/axtrade/hooks/HookManager.java @@ -2,6 +2,7 @@ package com.artillexstudios.axtrade.hooks; import com.artillexstudios.axapi.utils.StringUtils; import com.artillexstudios.axtrade.hooks.currency.AxQuestBoardHook; +import com.artillexstudios.axtrade.hooks.currency.BeastTokensHook; import com.artillexstudios.axtrade.hooks.currency.CoinsEngineHook; import com.artillexstudios.axtrade.hooks.currency.CurrencyHook; import com.artillexstudios.axtrade.hooks.currency.ExperienceHook; @@ -105,6 +106,11 @@ public class HookManager { Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("!FF33[AxTrade] Hooked into RedisEconomy!")); } + if (HOOKS.getBoolean("currencies.BeastTokens.register", true) && Bukkit.getPluginManager().getPlugin("BeastTokens") != null) { + currency.add(new BeastTokensHook()); + Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("!FF33[AxTrade] Hooked into BeastTokens!")); + } + for (String str : HOOKS.getSection("placeholder-currencies").getRoutesAsStrings(false)) { if (!HOOKS.getBoolean("placeholder-currencies." + str + ".register", false)) continue; currency.add(new PlaceholderCurrencyHook(str, HOOKS.getSection("placeholder-currencies." + str))); diff --git a/src/main/java/com/artillexstudios/axtrade/hooks/currency/BeastTokensHook.java b/src/main/java/com/artillexstudios/axtrade/hooks/currency/BeastTokensHook.java new file mode 100644 index 0000000..ae24883 --- /dev/null +++ b/src/main/java/com/artillexstudios/axtrade/hooks/currency/BeastTokensHook.java @@ -0,0 +1,56 @@ +package com.artillexstudios.axtrade.hooks.currency; + +import me.mraxetv.beasttokens.api.BeastTokensAPI; +import org.bukkit.Bukkit; +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +import static com.artillexstudios.axtrade.AxTrade.HOOKS; + +public class BeastTokensHook implements CurrencyHook { + + @Override + public void setup() { + } + + @Override + public String getName() { + return "BeastTokens"; + } + + @Override + public String getDisplayName() { + return HOOKS.getString("currencies.BeastTokens.name"); + } + + @Override + public boolean worksOffline() { + return true; + } + + @Override + public boolean usesDouble() { + return true; + } + + @Override + public boolean isPersistent() { + return false; + } + + @Override + public double getBalance(@NotNull UUID player) { + return BeastTokensAPI.getTokensManager().getTokens(Bukkit.getOfflinePlayer(player)); + } + + @Override + public void giveBalance(@NotNull UUID player, double amount) { + BeastTokensAPI.getTokensManager().addTokens(Bukkit.getOfflinePlayer(player), amount); + } + + @Override + public void takeBalance(@NotNull UUID player, double amount) { + BeastTokensAPI.getTokensManager().removeTokens(Bukkit.getOfflinePlayer(player), amount); + } +} \ No newline at end of file diff --git a/src/main/java/com/artillexstudios/axtrade/utils/UpdateNotifier.java b/src/main/java/com/artillexstudios/axtrade/utils/UpdateNotifier.java index ffb5ad1..cca33d1 100644 --- a/src/main/java/com/artillexstudios/axtrade/utils/UpdateNotifier.java +++ b/src/main/java/com/artillexstudios/axtrade/utils/UpdateNotifier.java @@ -41,9 +41,11 @@ public class UpdateNotifier implements Listener { this.newest = isLatest(current); if (latest == null || newest) return; - Bukkit.getConsoleSender().sendMessage(getMessage()); + Scheduler.get().runLaterAsync(t2 -> { + Bukkit.getConsoleSender().sendMessage(getMessage()); + }, 50L); t.cancel(); - }, 50L, time); + }, 0, time); } @EventHandler diff --git a/src/main/resources/currencies.yml b/src/main/resources/currencies.yml index 442d376..f34e358 100644 --- a/src/main/resources/currencies.yml +++ b/src/main/resources/currencies.yml @@ -70,6 +70,9 @@ currencies: enabled: - currency-name: "coins" name: "coins" + BeastTokens: + register: true + name: "tokens" # do not change this -version: 6 \ No newline at end of file +version: 7 \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 2da8442..75d2987 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -22,4 +22,5 @@ softdepend: - TheOnly-MobCoins - TokenManager - UltraEconomy - - RedisEconomy \ No newline at end of file + - RedisEconomy + - BeastTokens \ No newline at end of file