// Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionEconomyEvent.java
// public class FactionEconomyEvent extends EconomyEvent {
// 
//     private static final HandlerList handlers = new HandlerList();
//     private final String factionId;
// 
//     public FactionEconomyEvent(String factionId, double oldBalance, double newBalance) {
//         super(oldBalance, newBalance);
//         this.factionId = factionId;
//     }
// 
//     public String getFactionId() {
//         return factionId;
//     }
// 
//     @Override
//     public HandlerList getHandlers() {
//         return handlers;
//     }
// 
//     public static HandlerList getHandlerList() {
//         return handlers;
//     }
// }
// 
// Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/PlayerEconomyEvent.java
// public class PlayerEconomyEvent extends EconomyEvent {
// 
//     private static final HandlerList handlers = new HandlerList();
//     private final Player player;
// 
//     public PlayerEconomyEvent(Player player, double oldBalance, double newBalance) {
//         super(oldBalance, newBalance);
//         this.player = player;
//     }
// 
//     public Player getPlayer() {
//         return player;
//     }
// 
//     @Override
//     public HandlerList getHandlers() {
//         return handlers;
//     }
// 
//     public static HandlerList getHandlerList() {
//         return handlers;
//     }
// }


import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.api.UserDoesNotExistException;
import net.ess3.api.Economy;
import net.ess3.api.events.UserBalanceUpdateEvent;
import net.novucs.ftop.hook.event.FactionEconomyEvent;
import net.novucs.ftop.hook.event.PlayerEconomyEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import java.util.List;
import java.util.UUID;
    }

    @Override
    public double getTotalBalance(List<UUID> playerIds) {
        double balance = 0;
        for (UUID playerId : playerIds) {
            balance += getBalance(playerId);
        }
        return balance;
    }

    @Override
    public double getFactionBalance(String factionId) {
        try {
            return Economy.getMoneyExact("faction_" + factionId.replace("-", "_")).doubleValue();
        } catch (UserDoesNotExistException e) {
            return 0;
        }
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onEconomyEvent(UserBalanceUpdateEvent event) {
        double oldBalance = event.getOldBalance().doubleValue();
        double newBalance = event.getNewBalance().doubleValue();

        Player player = event.getPlayer();
        if (!player.isOnline() && player.getName().startsWith("faction_")) {
            String factionId = player.getName().substring(8).replace("_", "-");
            if (factionsHook.isFaction(factionId)) {
                if (factionEnabled) {
// Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionEconomyEvent.java
// public class FactionEconomyEvent extends EconomyEvent {
// 
//     private static final HandlerList handlers = new HandlerList();
//     private final String factionId;
// 
//     public FactionEconomyEvent(String factionId, double oldBalance, double newBalance) {
//         super(oldBalance, newBalance);
//         this.factionId = factionId;
//     }
// 
//     public String getFactionId() {
//         return factionId;
//     }
// 
//     @Override
//     public HandlerList getHandlers() {
//         return handlers;
//     }
// 
//     public static HandlerList getHandlerList() {
//         return handlers;
//     }
// }
// 
// Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/PlayerEconomyEvent.java
// public class PlayerEconomyEvent extends EconomyEvent {
// 
//     private static final HandlerList handlers = new HandlerList();
//     private final Player player;
// 
//     public PlayerEconomyEvent(Player player, double oldBalance, double newBalance) {
//         super(oldBalance, newBalance);
//         this.player = player;
//     }
// 
//     public Player getPlayer() {
//         return player;
//     }
// 
//     @Override
//     public HandlerList getHandlers() {
//         return handlers;
//     }
// 
//     public static HandlerList getHandlerList() {
//         return handlers;
//     }
// }


// Path: hook/essentials/src/main/java/net/novucs/ftop/hook/EssentialsEconomyHook.java
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.api.UserDoesNotExistException;
import net.ess3.api.Economy;
import net.ess3.api.events.UserBalanceUpdateEvent;
import net.novucs.ftop.hook.event.FactionEconomyEvent;
import net.novucs.ftop.hook.event.PlayerEconomyEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import java.util.List;
import java.util.UUID;

    }

    @Override
    public double getTotalBalance(List<UUID> playerIds) {
        double balance = 0;
        for (UUID playerId : playerIds) {
            balance += getBalance(playerId);
        }
        return balance;
    }

    @Override
    public double getFactionBalance(String factionId) {
        try {
            return Economy.getMoneyExact("faction_" + factionId.replace("-", "_")).doubleValue();
        } catch (UserDoesNotExistException e) {
            return 0;
        }
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onEconomyEvent(UserBalanceUpdateEvent event) {
        double oldBalance = event.getOldBalance().doubleValue();
        double newBalance = event.getNewBalance().doubleValue();

        Player player = event.getPlayer();
        if (!player.isOnline() && player.getName().startsWith("faction_")) {
            String factionId = player.getName().substring(8).replace("_", "-");
            if (factionsHook.isFaction(factionId)) {
                if (factionEnabled) {
                    callEvent(new FactionEconomyEvent(factionId, oldBalance, newBalance));