Update TradeListeners.java

Fix trade cancellation bug by adding a delay check to prevent immediate trade abort when the sender moves during trade acceptance.
This commit is contained in:
Sneyzi 2024-11-23 10:41:06 +02:00 committed by GitHub
parent 993b9a01cd
commit 0ae334ea66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -74,6 +74,7 @@ public class TradeListeners implements Listener {
final Player player = event.getPlayer();
final Trade trade = Trades.getTrade(player);
if (trade == null) return;
if (System.currentTimeMillis() - trade.getPrepTime() < 1_000L) return;
if (event.getFrom().distanceSquared(event.getTo()) == 0) return;
trade.abort();
}