diff --git a/pom.xml b/pom.xml index 822e073..5a959e5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.artillexstudios AxTrade - 1.8.0 + 1.8.1 jar AxTrade @@ -106,13 +106,17 @@ rosewood-repo https://repo.rosewooddev.io/repository/public/ + + alessiodp + https://repo.alessiodp.com/releases/ + com.artillexstudios.axapi axapi - 1.4.332 + 1.4.385 compile all @@ -252,7 +256,7 @@ com.github.Emibergo02 RedisEconomy - main-3338e61c6c-1 + 4.3.9 provided diff --git a/src/main/java/com/artillexstudios/axtrade/commands/Commands.java b/src/main/java/com/artillexstudios/axtrade/commands/Commands.java index bb4a25c..9a41eb4 100644 --- a/src/main/java/com/artillexstudios/axtrade/commands/Commands.java +++ b/src/main/java/com/artillexstudios/axtrade/commands/Commands.java @@ -64,7 +64,7 @@ public class Commands implements OrphanCommand { @Subcommand("accept") public void accept(@NotNull Player sender, @NotNull Player other) { var request = Requests.getRequest(sender, other); - if (request == null || request.getSender().equals(sender)) { + if (request == null || request.getSender().equals(sender) || !request.isActive()) { MESSAGEUTILS.sendLang(sender, "request.no-request", Map.of("%player%", other.getName())); return; } @@ -75,12 +75,12 @@ public class Commands implements OrphanCommand { @Subcommand("deny") public void deny(@NotNull Player sender, @NotNull Player other) { var request = Requests.getRequest(sender, other); - if (request == null || request.getSender().equals(sender) || request.isDeclined()) { + if (request == null || request.getSender().equals(sender) || !request.isActive()) { MESSAGEUTILS.sendLang(sender, "request.no-request", Map.of("%player%", other.getName())); return; } - request.decline(); + request.deactivate(); MESSAGEUTILS.sendLang(request.getSender(), "request.deny-sender", Map.of("%player%", request.getReceiver().getName())); MESSAGEUTILS.sendLang(request.getReceiver(), "request.deny-receiver", Map.of("%player%", request.getSender().getName())); SoundUtils.playSound(request.getSender(), "deny"); diff --git a/src/main/java/com/artillexstudios/axtrade/listeners/TradeListeners.java b/src/main/java/com/artillexstudios/axtrade/listeners/TradeListeners.java index d0a6e69..f1419a4 100644 --- a/src/main/java/com/artillexstudios/axtrade/listeners/TradeListeners.java +++ b/src/main/java/com/artillexstudios/axtrade/listeners/TradeListeners.java @@ -46,6 +46,7 @@ public class TradeListeners implements Listener { } if (request.getReceiver().equals(event.getPlayer())) { iterator.remove(); + if (!request.isActive()) continue; MESSAGEUTILS.sendLang(request.getSender(), "request.expired", Map.of("%player%", request.getReceiver().getName())); } } diff --git a/src/main/java/com/artillexstudios/axtrade/request/Request.java b/src/main/java/com/artillexstudios/axtrade/request/Request.java index c9edde4..34533af 100644 --- a/src/main/java/com/artillexstudios/axtrade/request/Request.java +++ b/src/main/java/com/artillexstudios/axtrade/request/Request.java @@ -6,7 +6,7 @@ public class Request { private final long time; private final Player sender; private final Player receiver; - private boolean declined = false; + private boolean active = true; public Request(Player sender, Player receiver) { this.time = System.currentTimeMillis(); @@ -26,11 +26,11 @@ public class Request { return sender; } - public boolean isDeclined() { - return declined; + public boolean isActive() { + return active; } - public void decline() { - declined = true; + public void deactivate() { + this.active = false; } } diff --git a/src/main/java/com/artillexstudios/axtrade/request/Requests.java b/src/main/java/com/artillexstudios/axtrade/request/Requests.java index b1f734b..b1b0f0b 100644 --- a/src/main/java/com/artillexstudios/axtrade/request/Requests.java +++ b/src/main/java/com/artillexstudios/axtrade/request/Requests.java @@ -63,9 +63,10 @@ public class Requests { if (!request.getSender().equals(sender)) { Trades.addTrade(sender, receiver); requests.remove(request); + request.deactivate(); return; } - if (request.isDeclined() || System.currentTimeMillis() - request.getTime() < CONFIG.getInt("trade-request-expire-seconds", 60) * 1_000L) { + if (!request.isActive() || System.currentTimeMillis() - request.getTime() < CONFIG.getInt("trade-request-expire-seconds", 60) * 1_000L) { MESSAGEUTILS.sendLang(sender, "request.already-sent", replacements); return; } diff --git a/src/main/java/com/artillexstudios/axtrade/trade/GuiFrame.java b/src/main/java/com/artillexstudios/axtrade/trade/GuiFrame.java index 38d0ab0..a3056a5 100644 --- a/src/main/java/com/artillexstudios/axtrade/trade/GuiFrame.java +++ b/src/main/java/com/artillexstudios/axtrade/trade/GuiFrame.java @@ -56,8 +56,8 @@ public class GuiFrame { final Pair otherTextures = NMSHandlers.getNmsHandler().textures(trade.getOtherPlayer(player.getPlayer())); final HashMap map = new HashMap<>(Map.of( - "%own-head%", selfTextures == null ? "" : selfTextures.getFirst(), - "%partner-head%", otherTextures == null ? "" : otherTextures.getFirst() + "%own-head%", selfTextures == null ? "" : selfTextures.getKey(), + "%partner-head%", otherTextures == null ? "" : otherTextures.getKey() )); map.putAll(replacements); diff --git a/src/main/resources/lang.yml b/src/main/resources/lang.yml index e931666..8e418c0 100644 --- a/src/main/resources/lang.yml +++ b/src/main/resources/lang.yml @@ -57,7 +57,7 @@ request: deny-receiver: "&#CCFFEEYou have successfully denied �FFDD%player%&#CCFFEE's trade request!" cant-trade-self: "&#CCFFEEYou can't send a trade request to yourself!" already-in-trade: "&#CCFFEEThe player is already trading with someone!" - already-sent: "&#CCFFEEYou have already sent a trade request to �FFDD%player%&#CCFFEE!" + already-sent: "&#CCFFEEYou have already sent a trade request to �FFDD%player% &#CCFFEErecently!" too-far: "&#CCFFEEYou are too far from �FFDD%player% &#CCFFEEto send a trade request!" not-accepting: "&#CCFFEEThis player is not accepting trades right now!" disallowed-gamemode: "&#CCFFEEEither you or the other player is in a disallowed gamemode!"