Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

feat: Export favorites via command #681

Merged
merged 5 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> 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;
}
}