add amount of npcs imported to import command

This commit is contained in:
Pyrbu 2023-06-18 23:14:05 +02:00
parent 35e08097d5
commit 1925eb0e95

@ -5,10 +5,12 @@ import lol.pyr.director.adventure.command.CommandHandler;
import lol.pyr.director.common.command.CommandExecutionException; import lol.pyr.director.common.command.CommandExecutionException;
import lol.pyr.znpcsplus.conversion.DataImporter; import lol.pyr.znpcsplus.conversion.DataImporter;
import lol.pyr.znpcsplus.conversion.DataImporterRegistry; import lol.pyr.znpcsplus.conversion.DataImporterRegistry;
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
import lol.pyr.znpcsplus.npc.NpcRegistryImpl; import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -37,8 +39,9 @@ public class ImportCommand implements CommandHandler {
return; return;
} }
try { try {
npcRegistry.registerAll(importer.importData()); Collection<NpcEntryImpl> entries = importer.importData();
context.send(Component.text("All NPCs from " + id + " have been loaded.", NamedTextColor.GREEN)); npcRegistry.registerAll(entries);
context.send(Component.text(entries.size() + " npcs have been loaded from " + id, NamedTextColor.GREEN));
} catch (Exception exception) { } catch (Exception exception) {
context.send(Component.text("Importing failed! Please check the console for more details.", NamedTextColor.RED)); context.send(Component.text("Importing failed! Please check the console for more details.", NamedTextColor.RED));
exception.printStackTrace(); exception.printStackTrace();