feat: AxTradeCompletedEvent event

This commit is contained in:
Emmanuel Lampe 2024-12-19 19:42:04 +01:00
parent 73ac4398d2
commit 9c389c6892
No known key found for this signature in database
GPG Key ID: 2E080FC227CB0AE7

View File

@ -2,12 +2,14 @@ package com.artillexstudios.axtrade.trade;
import com.artillexstudios.axapi.scheduler.Scheduler;
import com.artillexstudios.axapi.utils.ContainerUtils;
import com.artillexstudios.axtrade.api.events.AxTradeCompletedEvent;
import com.artillexstudios.axtrade.currency.CurrencyProcessor;
import com.artillexstudios.axtrade.hooks.currency.CurrencyHook;
import com.artillexstudios.axtrade.utils.HistoryUtils;
import com.artillexstudios.axtrade.utils.NumberUtils;
import com.artillexstudios.axtrade.utils.SoundUtils;
import com.artillexstudios.axtrade.utils.Utils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.ArrayList;
@ -85,6 +87,17 @@ public class Trade {
}
}
AxTradeCompletedEvent event = new AxTradeCompletedEvent(
this.player1, this.player2
);
Bukkit.getPluginManager().callEvent(event);
if(event.isCancelled()) {
abort(true);
return;
}
CurrencyProcessor currencyProcessor1 = new CurrencyProcessor(player1.getPlayer(), player1.getCurrencies().entrySet());
currencyProcessor1.run().thenAccept(success1 -> {
if (!success1) {