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

Commit

Permalink
feat: Export favorites via command (#681)
Browse files Browse the repository at this point in the history
* chore: Remove broken quest book

* fix: Allow access to guides and lootruns

* feat: Export favorites via command

---------

Co-authored-by: Magnus Ihse Bursie <mag@icus.se>
  • Loading branch information
ryanzhoudev and magicus authored Jul 24, 2023
1 parent b0e0d5b commit 103a8b8
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
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;
}
}

0 comments on commit 103a8b8

Please sign in to comment.