/*
 * This file is part of Nucleus, licensed under the MIT License (MIT). See the LICENSE.txt file
 * at the root of this project for more details.
 */
package io.github.nucleuspowered.nucleus.modules.playerinfo.listeners;

import io.github.nucleuspowered.nucleus.Nucleus;
import io.github.nucleuspowered.nucleus.internal.ListenerBase;
import io.github.nucleuspowered.nucleus.internal.annotations.ConditionalListener;
import io.github.nucleuspowered.nucleus.modules.playerinfo.PlayerInfoModule;
import io.github.nucleuspowered.nucleus.modules.playerinfo.config.PlayerInfoConfigAdapter;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.command.SendCommandEvent;
import org.spongepowered.api.event.filter.Getter;
import org.spongepowered.api.event.filter.cause.Root;
import uk.co.drnaylor.quickstart.exceptions.IncorrectAdapterTypeException;
import uk.co.drnaylor.quickstart.exceptions.NoModuleException;

import java.util.function.Predicate;

@ConditionalListener(CommandListener.Condition.class)
public class CommandListener extends ListenerBase {

    @Listener
    public void onCommandPreProcess(SendCommandEvent event, @Root ConsoleSource source, @Getter("getCommand") String command) {
        if (command.equalsIgnoreCase("list")) {
            event.setCommand("minecraft:list");
            Sponge.getScheduler().createSyncExecutor(plugin).submit(() ->
                source.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("list.listener.multicraftcompat")));
        }
    }

    public static class Condition implements Predicate<Nucleus> {

        @Override public boolean test(Nucleus nucleus) {
            try {
                return nucleus.getModuleContainer().getConfigAdapterForModule(PlayerInfoModule.ID, PlayerInfoConfigAdapter.class)
                    .getNodeOrDefault().getList().isMulticraftCompatibility();
            } catch (NoModuleException | IncorrectAdapterTypeException e) {
                if (nucleus.isDebugMode()) {
                    e.printStackTrace();
                }

                return false;
            }
        }
    }
}

@@ -1165,24 +1165,67 @@
 enerBase %7B%0A%0A
+    private boolean messageShown = false;%0A%0A
     @Listene
@@ -1226,16 +1226,16 @@
 istener%0A
-
     publ
@@ -1450,16 +1450,90 @@
 list%22);%0A
+            if (!messageShown) %7B%0A                messageShown = true;%0A    
         
@@ -1598,16 +1598,20 @@
 t(() -%3E%0A
+    
         
@@ -1727,16 +1727,30 @@
 at%22)));%0A
+            %7D%0A
         

Stop showing the Multicraft list warning message everytime.