// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/LastReplacer.java
// public class LastReplacer implements PlaceholderReplacer {
// 
//     private final Supplier<String> lastReplacer;
// 
//     public LastReplacer(Supplier<String> lastReplacer) {
//         this.lastReplacer = lastReplacer;
//     }
// 
//     @Override
//     public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
//         return lastReplacer.get();
//     }
// }
// 
// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/PlayerReplacer.java
// public class PlayerReplacer implements PlaceholderReplacer {
// 
//     private final Function<Player, String> playerReplacer;
// 
//     public PlayerReplacer(Function<Player, String> playerReplacer) {
//         this.playerReplacer = playerReplacer;
//     }
// 
//     @Override
//     public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
//         return playerReplacer.apply(event.getPlayer());
//     }
// }
// 
// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/RankReplacer.java
// public class RankReplacer implements PlaceholderReplacer {
// 
//     private final Function<Integer, String> rankReplacer;
//     private final int rank;
// 
//     public RankReplacer(Function<Integer, String> rankReplacer, int rank) {
//         this.rankReplacer = rankReplacer;
//         this.rank = rank;
//     }
// 
//     @Override
//     public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
//         return rankReplacer.apply(rank);
//     }
// }


import be.maximvdw.placeholderapi.PlaceholderAPI;
import net.novucs.ftop.hook.replacer.LastReplacer;
import net.novucs.ftop.hook.replacer.PlayerReplacer;
import net.novucs.ftop.hook.replacer.RankReplacer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
package net.novucs.ftop.hook;



public class MVdWPlaceholderAPIHook implements PlaceholderHook {

    private final Plugin plugin;
    private final Function<Player, String> playerReplacer;
    private final Function<Integer, String> rankReplacer;
    private final Supplier<String> lastReplacer;

    public MVdWPlaceholderAPIHook(Plugin plugin,
                                  Function<Player, String> playerReplacer,
                                  Function<Integer, String> rankReplacer,
                                  Supplier<String> lastReplacer) {
        this.plugin = plugin;
        this.playerReplacer = playerReplacer;
        this.rankReplacer = rankReplacer;
        this.lastReplacer = lastReplacer;
    }

    @Override
    public boolean initialize(List<Integer> enabledRanks) {
        LastReplacer lastReplacer = new LastReplacer(this.lastReplacer);
        boolean updated = PlaceholderAPI.registerPlaceholder(plugin, "factionstop_name:last", lastReplacer);

        for (int rank : enabledRanks) {
            RankReplacer replacer = new RankReplacer(rankReplacer, rank);
            if (PlaceholderAPI.registerPlaceholder(plugin, "factionstop_name:" + rank, replacer)) {
                updated = true;
            }
        }

// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/LastReplacer.java
// public class LastReplacer implements PlaceholderReplacer {
// 
//     private final Supplier<String> lastReplacer;
// 
//     public LastReplacer(Supplier<String> lastReplacer) {
//         this.lastReplacer = lastReplacer;
//     }
// 
//     @Override
//     public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
//         return lastReplacer.get();
//     }
// }
// 
// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/PlayerReplacer.java
// public class PlayerReplacer implements PlaceholderReplacer {
// 
//     private final Function<Player, String> playerReplacer;
// 
//     public PlayerReplacer(Function<Player, String> playerReplacer) {
//         this.playerReplacer = playerReplacer;
//     }
// 
//     @Override
//     public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
//         return playerReplacer.apply(event.getPlayer());
//     }
// }
// 
// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/RankReplacer.java
// public class RankReplacer implements PlaceholderReplacer {
// 
//     private final Function<Integer, String> rankReplacer;
//     private final int rank;
// 
//     public RankReplacer(Function<Integer, String> rankReplacer, int rank) {
//         this.rankReplacer = rankReplacer;
//         this.rank = rank;
//     }
// 
//     @Override
//     public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
//         return rankReplacer.apply(rank);
//     }
// }


// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/MVdWPlaceholderAPIHook.java
import be.maximvdw.placeholderapi.PlaceholderAPI;
import net.novucs.ftop.hook.replacer.LastReplacer;
import net.novucs.ftop.hook.replacer.PlayerReplacer;
import net.novucs.ftop.hook.replacer.RankReplacer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;

package net.novucs.ftop.hook;



public class MVdWPlaceholderAPIHook implements PlaceholderHook {

    private final Plugin plugin;
    private final Function<Player, String> playerReplacer;
    private final Function<Integer, String> rankReplacer;
    private final Supplier<String> lastReplacer;

    public MVdWPlaceholderAPIHook(Plugin plugin,
                                  Function<Player, String> playerReplacer,
                                  Function<Integer, String> rankReplacer,
                                  Supplier<String> lastReplacer) {
        this.plugin = plugin;
        this.playerReplacer = playerReplacer;
        this.rankReplacer = rankReplacer;
        this.lastReplacer = lastReplacer;
    }

    @Override
    public boolean initialize(List<Integer> enabledRanks) {
        LastReplacer lastReplacer = new LastReplacer(this.lastReplacer);
        boolean updated = PlaceholderAPI.registerPlaceholder(plugin, "factionstop_name:last", lastReplacer);

        for (int rank : enabledRanks) {
            RankReplacer replacer = new RankReplacer(rankReplacer, rank);
            if (PlaceholderAPI.registerPlaceholder(plugin, "factionstop_name:" + rank, replacer)) {
                updated = true;
            }
        }

        PlayerReplacer playerReplacer = new PlayerReplacer(this.playerReplacer);