mirror of
https://github.com/Artillex-Studios/AxTrade.git
synced 2025-01-04 18:47:51 +01:00
Fixed /trade deny
This commit is contained in:
parent
1989a20548
commit
fda0c823ee
@ -75,11 +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)) {
|
||||
if (request == null || request.getSender().equals(sender) || request.isDeclined()) {
|
||||
MESSAGEUTILS.sendLang(sender, "request.no-request", Map.of("%player%", other.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
request.decline();
|
||||
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");
|
||||
|
@ -6,6 +6,7 @@ public class Request {
|
||||
private final long time;
|
||||
private final Player sender;
|
||||
private final Player receiver;
|
||||
private boolean declined = false;
|
||||
|
||||
public Request(Player sender, Player receiver) {
|
||||
this.time = System.currentTimeMillis();
|
||||
@ -24,4 +25,12 @@ public class Request {
|
||||
public Player getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public boolean isDeclined() {
|
||||
return declined;
|
||||
}
|
||||
|
||||
public void decline() {
|
||||
declined = true;
|
||||
}
|
||||
}
|
||||
|
@ -58,16 +58,17 @@ public class Requests {
|
||||
return;
|
||||
}
|
||||
|
||||
var request = Requests.getRequest(sender, receiver);
|
||||
if (request != null && !request.getSender().equals(sender)) {
|
||||
Trades.addTrade(sender, receiver);
|
||||
requests.remove(request);
|
||||
return;
|
||||
}
|
||||
|
||||
if (request != null && System.currentTimeMillis() - request.getTime() < CONFIG.getInt("trade-request-expire-seconds", 60) * 1_000L) {
|
||||
MESSAGEUTILS.sendLang(sender, "request.already-sent", replacements);
|
||||
return;
|
||||
final Request request = Requests.getRequest(sender, receiver);
|
||||
if (request != null) {
|
||||
if (!request.getSender().equals(sender)) {
|
||||
Trades.addTrade(sender, receiver);
|
||||
requests.remove(request);
|
||||
return;
|
||||
}
|
||||
if (request.isDeclined() || System.currentTimeMillis() - request.getTime() < CONFIG.getInt("trade-request-expire-seconds", 60) * 1_000L) {
|
||||
MESSAGEUTILS.sendLang(sender, "request.already-sent", replacements);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final AxTradeRequestEvent apiEvent = new AxTradeRequestEvent(sender, receiver);
|
||||
|
Loading…
Reference in New Issue
Block a user