From 326b7113b881ab8ac4f0feb5980b39e976b01857 Mon Sep 17 00:00:00 2001 From: BenceX100 <52270269+BenceX100@users.noreply.github.com> Date: Thu, 4 Apr 2024 21:00:52 +0200 Subject: [PATCH] Fixes --- .../java/com/artillexstudios/axtrade/request/Requests.java | 5 +++++ .../java/com/artillexstudios/axtrade/trade/TradeGui.java | 2 +- src/main/resources/lang.yml | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/artillexstudios/axtrade/request/Requests.java b/src/main/java/com/artillexstudios/axtrade/request/Requests.java index 6e9f239..0690a7c 100644 --- a/src/main/java/com/artillexstudios/axtrade/request/Requests.java +++ b/src/main/java/com/artillexstudios/axtrade/request/Requests.java @@ -16,6 +16,11 @@ public class Requests { private static final ArrayList requests = new ArrayList<>(); public static void addRequest(@NotNull Player sender, @NotNull Player receiver) { + if (sender.isDead() || receiver.isDead()) { + MESSAGEUTILS.sendLang(sender, "request.not-accepting", Map.of("%player%", receiver.getName())); + return; + } + if (sender.equals(receiver)) { MESSAGEUTILS.sendLang(sender, "request.cant-trade-self", Map.of("%player%", receiver.getName())); return; diff --git a/src/main/java/com/artillexstudios/axtrade/trade/TradeGui.java b/src/main/java/com/artillexstudios/axtrade/trade/TradeGui.java index 33cf339..8a17152 100644 --- a/src/main/java/com/artillexstudios/axtrade/trade/TradeGui.java +++ b/src/main/java/com/artillexstudios/axtrade/trade/TradeGui.java @@ -42,6 +42,7 @@ public class TradeGui extends GuiFrame { gui.setDefaultTopClickAction(event -> { player.cancel(); + Scheduler.get().run(scheduledTask -> trade.update()); if (!slots.contains(event.getSlot())) { event.setCancelled(true); if (event.getCursor() == null) return; @@ -49,7 +50,6 @@ public class TradeGui extends GuiFrame { event.getCursor().setAmount(0); return; } - Scheduler.get().run(scheduledTask -> trade.update()); }); gui.setDragAction(event -> { diff --git a/src/main/resources/lang.yml b/src/main/resources/lang.yml index 4c37911..6633073 100644 --- a/src/main/resources/lang.yml +++ b/src/main/resources/lang.yml @@ -38,6 +38,7 @@ request: already-in-trade: "&#CCFFEEThe player is already trading with someone!" already-sent: "&#CCFFEEYou have already sent a trade request to �FFDD%player%&#CCFFEE!" too-far: "&#CCFFEEYou are too far from �FFDD%player% &#CCFFEEto send a trade request!" + not-accepting: "&#CCFFEEThis player is not accepting trades right now!" # this must be 4 lines # note: currently the first line must be left empty