This commit is contained in:
BenceX100 2024-07-04 15:20:26 +02:00
parent 46ac53683d
commit 09c771e1c1
7 changed files with 81 additions and 12 deletions

11
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>com.artillexstudios</groupId>
<artifactId>AxTrade</artifactId>
<version>1.6.0</version>
<version>1.6.1</version>
<packaging>jar</packaging>
<name>AxTrade</name>
@ -112,7 +112,7 @@
<dependency>
<groupId>com.artillexstudios.axapi</groupId>
<artifactId>axapi</artifactId>
<version>1.4.259</version>
<version>1.4.280</version>
<scope>compile</scope>
<classifier>all</classifier>
</dependency>
@ -255,5 +255,12 @@
<version>main-3338e61c6c-1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.mraxetv.beasttokens.api</groupId>
<artifactId>BeastTokens</artifactId>
<version>3.13.3</version>
<systemPath>${project.basedir}/libs/bt-api-3.13.3.jar</systemPath>
<scope>system</scope>
</dependency>
</dependencies>
</project>

View File

@ -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();

View File

@ -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("&#33FF33[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("&#33FF33[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)));

View File

@ -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);
}
}

View File

@ -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

View File

@ -70,6 +70,9 @@ currencies:
enabled:
- currency-name: "coins"
name: "coins"
BeastTokens:
register: true
name: "tokens"
# do not change this
version: 6
version: 7

View File

@ -22,4 +22,5 @@ softdepend:
- TheOnly-MobCoins
- TokenManager
- UltraEconomy
- RedisEconomy
- RedisEconomy
- BeastTokens