Skip to content

Commit

Permalink
1.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
BenceX100 committed Nov 20, 2024
1 parent f71a500 commit 993b9a0
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 68 deletions.
4 changes: 2 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>AxTrade</artifactId>
<version>1.10.0</version>
<version>1.10.1</version>
<packaging>jar</packaging>

<name>AxTrade</name>
Expand Down Expand Up @@ -116,7 +116,7 @@
<dependency>
<groupId>com.artillexstudios.axapi</groupId>
<artifactId>axapi</artifactId>
<version>1.4.396</version>
<version>1.4.403</version>
<scope>compile</scope>
<classifier>all</classifier>
</dependency>
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/artillexstudios/axtrade/AxTrade.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.artillexstudios.axapi.utils.MessageUtils;
import com.artillexstudios.axapi.utils.StringUtils;
import com.artillexstudios.axtrade.commands.Commands;
import com.artillexstudios.axtrade.currencyconverter.CurrencyConverter;
import com.artillexstudios.axtrade.hooks.HookManager;
import com.artillexstudios.axtrade.lang.LanguageManager;
import com.artillexstudios.axtrade.listeners.EntityInteractListener;
Expand Down Expand Up @@ -54,7 +53,6 @@ public void enable() {
CONFIG = new Config(new File(getDataFolder(), "config.yml"), getResource("config.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setKeepAll(true).setVersioning(new BasicVersioning("version")).build());
GUIS = new Config(new File(getDataFolder(), "guis.yml"), getResource("guis.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setKeepAll(true).setVersioning(new BasicVersioning("version")).build());
LANG = new Config(new File(getDataFolder(), "lang.yml"), getResource("lang.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setKeepAll(true).setVersioning(new BasicVersioning("version")).build());
new CurrencyConverter(new Config(new File(getDataFolder(), "currencies.yml")));
HOOKS = new Config(new File(getDataFolder(), "currencies.yml"), getResource("currencies.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setKeepAll(true).setVersioning(new BasicVersioning("version")).build());
TOGGLED = new Config(new File(getDataFolder(), "toggled.yml"), getResource("toggled.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.DEFAULT, DumperSettings.DEFAULT, UpdaterSettings.DEFAULT);

Expand All @@ -69,10 +67,10 @@ public void enable() {
getServer().getPluginManager().registerEvents(new EntityInteractListener(), this);
getServer().getPluginManager().registerEvents(new TradeListeners(), this);

new HookManager().setupHooks();
HookManager.setupHooks();
NumberUtils.reload();

new TradeTicker().start();
TradeTicker.start();

Commands.registerCommand();

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/artillexstudios/axtrade/api/AxTradeAPI.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package com.artillexstudios.axtrade.api;

import com.artillexstudios.axtrade.hooks.HookManager;
import com.artillexstudios.axtrade.hooks.currency.CurrencyHook;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;

public class AxTradeAPI {

public static void registerCurrencyHook(@NotNull Plugin plugin, @NotNull CurrencyHook currencyHook) {
HookManager.registerCurrencyHook(plugin, currencyHook);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,4 @@ public Player getSender() {
public Player getReceiver() {
return receiver;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
public class HookManager {
private static final ArrayList<CurrencyHook> currency = new ArrayList<>();

public void setupHooks() {
public static void setupHooks() {
updateHooks();
}

public void updateHooks() {
public static void updateHooks() {
currency.removeIf(currencyHook -> !currencyHook.isPersistent());

if (HOOKS.getBoolean("currencies.Experience.register", true))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.artillexstudios.axtrade.listeners;

import com.artillexstudios.axtrade.commands.Commands;
import com.artillexstudios.axtrade.request.Requests;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand All @@ -15,7 +15,7 @@ public class EntityInteractListener implements Listener {
private static final HashMap<Player, Long> cd = new HashMap<>();

@EventHandler (ignoreCancelled = true)
public void onClick(@NotNull PlayerInteractEntityEvent event) {
public void onInteract(@NotNull PlayerInteractEntityEvent event) {
if (!CONFIG.getBoolean("shift-click-send-request", true)) return;
final Player player = event.getPlayer();
if (!player.hasPermission("axtrade.trade")) return;
Expand All @@ -28,7 +28,7 @@ public void onClick(@NotNull PlayerInteractEntityEvent event) {
cd.put(player, System.currentTimeMillis());
if (!sendTo.isOnline()) return;

new Commands().trade(player, sendTo);
Requests.addRequest(player, sendTo);
}

public static void onQuit(Player player) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/artillexstudios/axtrade/trade/Trade.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class Trade {
protected final TradePlayer player1;
protected final TradePlayer player2;
protected boolean ended = false;
private boolean ended = false;
protected long prepTime = System.currentTimeMillis();

public Trade(Player p1, Player p2) {
Expand Down Expand Up @@ -163,4 +163,8 @@ public TradePlayer getPlayer2() {
public Player getOtherPlayer(Player player) {
return player1.getPlayer().equals(player) ? player2.getPlayer() : player1.getPlayer();
}

public boolean isEnded() {
return ended;
}
}
24 changes: 10 additions & 14 deletions src/main/java/com/artillexstudios/axtrade/trade/TradeGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.artillexstudios.axapi.gui.SignInput;
import com.artillexstudios.axapi.nms.NMSHandlers;
import com.artillexstudios.axapi.scheduler.ScheduledTask;
import com.artillexstudios.axapi.scheduler.Scheduler;
import com.artillexstudios.axapi.utils.StringUtils;
import com.artillexstudios.axtrade.utils.BlackListUtils;
Expand All @@ -25,7 +24,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

import static com.artillexstudios.axtrade.AxTrade.GUIS;
import static com.artillexstudios.axtrade.AxTrade.LANG;
Expand Down Expand Up @@ -76,16 +74,13 @@ public TradeGui(@NotNull Trade trade, @NotNull TradePlayer player) {

final BaseGui shulkerGui = Gui.storage().rows(3).title(StringUtils.format(Utils.getFormattedItemName(event.getCurrentItem()))).disableAllInteractions().create();
shulkerGui.getInventory().setContents(ShulkerUtils.getShulkerContents(event.getCurrentItem()));
shulkerGui.setCloseGuiAction(shulkerEvent -> Scheduler.get().run(new Consumer<>() {
@Override
public void accept(ScheduledTask scheduledTask) {
if (trade.ended) return;
trade.prepTime = System.currentTimeMillis();
gui.open(player.getPlayer());
inSign = false;
trade.update();
updateTitle();
}
shulkerGui.setCloseGuiAction(e -> Scheduler.get().run(t -> {
if (trade.isEnded()) return;
trade.prepTime = System.currentTimeMillis();
gui.open(player.getPlayer());
inSign = false;
trade.update();
updateTitle();
}));
shulkerGui.open(player.getPlayer());
return;
Expand Down Expand Up @@ -150,7 +145,7 @@ public void accept(ScheduledTask scheduledTask) {
trade.abort();
});

if (trade.ended) return;
if (trade.isEnded()) return;

update();
gui.open(player.getPlayer());
Expand Down Expand Up @@ -200,7 +195,7 @@ public void update() {
lines.set(0, Component.empty());

var sign = new SignInput.Builder().setLines(lines).setHandler((player1, result) -> {
if (trade.ended) return;
if (trade.isEnded()) return;
trade.prepTime = System.currentTimeMillis();
String am = PlainTextComponentSerializer.plainText().serialize(result[0]);
TradePlayer.Result addResult = player.setCurrency(currencyStr, am);
Expand All @@ -217,6 +212,7 @@ public void update() {
}
}
Scheduler.get().run(scheduledTask -> {
if (trade.isEnded()) return;
gui.open(player.getPlayer());
inSign = false;
trade.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class TradeTicker {

public void start() {
public static void start() {
Scheduler.get().runTimer(scheduledTask -> {
for (Trade trade : Trades.getTrades()) {
if (!(trade.player1.hasConfirmed() && trade.player2.hasConfirmed())) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class ShulkerUtils {
public static ItemStack[] getShulkerContents(@NotNull ItemStack item) {
if (!(item.getItemMeta() instanceof BlockStateMeta meta)) return new ItemStack[0];
if (meta.getBlockState() instanceof ShulkerBox shulker) {
// axshulkers viewer compatibility
if (ClassUtils.INSTANCE.classExists("com.artillexstudios.axshulkers.utils.ShulkerUtils") && com.artillexstudios.axshulkers.utils.ShulkerUtils.getShulkerUUID(item) != null) {
return com.artillexstudios.axshulkers.AxShulkers.getDB().getShulker(com.artillexstudios.axshulkers.utils.ShulkerUtils.getShulkerUUID(item));
}
Expand Down

0 comments on commit 993b9a0

Please sign in to comment.