diff --git a/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java b/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java index 7ddb50dba..e9b134c3d 100644 --- a/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java +++ b/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java @@ -8,11 +8,11 @@ import com.wynntils.core.framework.instances.Module; import com.wynntils.core.framework.interfaces.annotations.ModuleInfo; import com.wynntils.modules.questbook.commands.CommandExportDiscoveries; +import com.wynntils.modules.questbook.commands.CommandExportFavorites; import com.wynntils.modules.questbook.configs.QuestBookConfig; import com.wynntils.modules.questbook.enums.Guides; import com.wynntils.modules.questbook.enums.QuestBookPages; import com.wynntils.modules.questbook.events.ClientEvents; -import com.wynntils.modules.questbook.managers.QuestManager; import com.wynntils.modules.questbook.overlays.hud.TrackedQuestOverlay; import net.minecraftforge.client.settings.KeyConflictContext; import org.lwjgl.input.Keyboard; @@ -31,6 +31,7 @@ public void onEnable() { registerOverlay(new TrackedQuestOverlay(), Priority.HIGHEST); registerCommand(new CommandExportDiscoveries()); + registerCommand(new CommandExportFavorites()); registerKeyBinding("Open Quest Book", Keyboard.KEY_K, "Wynntils", KeyConflictContext.IN_GAME, true, () -> QuestBookPages.QUESTS.getPage().open(true)); registerKeyBinding("Open Discoveries", Keyboard.KEY_U, "Wynntils", KeyConflictContext.IN_GAME, true, () -> QuestBookPages.DISCOVERIES.getPage().open(true)); diff --git a/src/main/java/com/wynntils/modules/questbook/commands/CommandExportFavorites.java b/src/main/java/com/wynntils/modules/questbook/commands/CommandExportFavorites.java new file mode 100644 index 000000000..79670cfc1 --- /dev/null +++ b/src/main/java/com/wynntils/modules/questbook/commands/CommandExportFavorites.java @@ -0,0 +1,60 @@ +/* + * * Copyright © Wynntils - 2022. + */ + +package com.wynntils.modules.questbook.commands; + +import com.wynntils.McIf; +import com.wynntils.core.utils.Utils; +import com.wynntils.modules.utilities.configs.UtilitiesConfig; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.event.ClickEvent; +import net.minecraftforge.client.IClientCommand; + +import java.util.ArrayList; +import java.util.List; + +public class CommandExportFavorites extends CommandBase implements IClientCommand { + + + @Override + public String getName() { + return "exportfavorites"; + } + + @Override + public boolean allowUsageWithoutPrefix(ICommandSender sender, String message) { + return false; + } + + @Override + public String getUsage(ICommandSender sender) { + return "exportfavorites"; + } + + @Override + public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + ITextComponent command = new TextComponentString("/exportfavorites"); + command.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/exportfavorites")); + + List combinedList = new ArrayList<>(); + combinedList.addAll(UtilitiesConfig.INSTANCE.favoriteItems); + combinedList.addAll(UtilitiesConfig.INSTANCE.favoriteIngredients); + combinedList.addAll(UtilitiesConfig.INSTANCE.favoritePowders); + combinedList.addAll(UtilitiesConfig.INSTANCE.favoriteEmeraldPouches); + + Utils.copyToClipboard("wynntilsFavorites," + String.join(",", combinedList)); + McIf.player().sendMessage(new TextComponentString(TextFormatting.GREEN + "Copied favorites to clipboard! Open the guide list and click the + button on Artemis to import them.")); + } + + @Override + public int getRequiredPermissionLevel() { + return 0; + } +}