Skip to content

Commit

Permalink
initial commit for party commands and melody solver
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamKracker committed Dec 23, 2024
1 parent b03064a commit 0423b1d
Show file tree
Hide file tree
Showing 24 changed files with 616 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,12 @@ private void addDungeonConfig(CookiesTranslationBuilder translationBuilder) {
translationBuilder.addConfig(CONFIG_DUNGEON_GLOW_CLASS_COLOR,
"Class based glow color",//"Glow teammates by class colors",
"Overrides the default hypixel glowing by rank to glow by class color.");
translationBuilder.addConfig(CONFIG_DUNGEON_ANNOUNCE_LEAPS,
"Announce leaps",
"Announce who you leap to and their coords when you leap to a player using the custom leap ui.");
translationBuilder.addConfig(CONFIG_DUNGEON_ANNOUNCE_LEAP_COORDS,
"Announce coords",
"Announce the coords of the player you leap to as well.");
translationBuilder.addConfig(CONFIG_DUNGEON_CLASS_COLOR,
"Class colors",
"The colors used for every class");
Expand Down Expand Up @@ -667,6 +673,9 @@ private void addDungeonConfig(CookiesTranslationBuilder translationBuilder) {
translationBuilder.addConfig(CONFIG_DUNGEON_TERMINAL_STARTS_WITH_TERMINAL,
"Starts with",
"Enables the starts with solver.");
translationBuilder.addConfig(CONFIG_DUNGEON_TERMINAL_MELODY_NOTIFIER,
"Melody notifier",
"Enables chat messages that are sent when you begin melody, when you complete each row, and when you finish.");
translationBuilder.addConfig(CONFIG_DUNGEON_PUZZLE, "Puzzles", "All settings related to puzzles.");
translationBuilder.addConfig(CONFIG_DUNGEON_PUZZLE_CREEPER_BEAMS_SOLVER,
"Creeper Beams",
Expand All @@ -688,5 +697,24 @@ private void addDungeonConfig(CookiesTranslationBuilder translationBuilder) {
Furthermore thank you to drek1984, Jade and bonsai
which where helping Desco1 with the original
and as well skytils for parts of the original solver.""");

translationBuilder.addConfig(CONFIG_DUNGEON_PARTY_CHAT_COMMANDS, "Chat Commands", "All of the party chat commands.");
translationBuilder.addConfig(CONFIG_DUNGEON_PARTY_CHAT_COMMANDS_PT_ME,
"Party Transfer",
"Enables the !ptme command that transfers the party to the player that ran the command.");
translationBuilder.addConfig(CONFIG_DUNGEON_PARTY_CHAT_COMMANDS_WARP,
"Party Warp",
"Enables the !warp command, running /p warp.");
translationBuilder.addConfig(CONFIG_DUNGEON_PARTY_CHAT_COMMANDS_JOIN_INSTANCE,
"Join Instance",
"""
Enables the joininstance command, which is run using !f/!m or !t, followed by the floor/kuudra tier number. ex: !f7.
Runs /joininstance based on the provided floor/kuudra tier, if you are not in an existing instance.""");
translationBuilder.addConfig(CONFIG_DUNGEON_PARTY_CHAT_COMMANDS_DOWN_TIME,
"Downtime",
"Enables the !dt command, allowing players to request downtime at the end of a run.");
translationBuilder.addConfig(CONFIG_DUNGEON_PARTY_CHAT_COMMANDS_COIN_FLIP,
"Coin flip",
"Enables the !cf command, allowing players to flip a coin, sends heads or tails to party chat.");
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21.3 2024-12-11T11:17:47.4766913 cookies-mod/Language (en_us)
b8e506abeadfabc1b260c9088e803802d2607fc9 assets\cookies-mod\lang\en_us.json
// 1.21.3 2024-12-23T13:05:01.4950796 cookies-mod/Language (en_us)
221fcc1e2c7a96aab55552e72cd228815baa08ea assets\cookies-mod\lang\en_us.json
20 changes: 19 additions & 1 deletion src/main/generated/assets/cookies-mod/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,23 @@
"cookies.config.dev.show_plot_price_breakdown.name": "Plot price breakdown",
"cookies.config.dev.show_plot_price_breakdown.tooltip": "Shows a breakdown of how much compost you need to unlock all plots.",
"cookies.config.dev.tooltip": "Development related config entries.",
"cookies.config.dungeon.announce_leap_coords.name": "Announce coords",
"cookies.config.dungeon.announce_leap_coords.tooltip": "Announce the coords of the player you leap to as well.",
"cookies.config.dungeon.announce_leaps.name": "Announce leaps",
"cookies.config.dungeon.announce_leaps.tooltip": "Announce who you leap to and their coords when you leap to a player using the custom leap ui.",
"cookies.config.dungeon.name": "Dungeon Config",
"cookies.config.dungeon.party_chat_commands.coin_flip.name": "Coin flip",
"cookies.config.dungeon.party_chat_commands.coin_flip.tooltip": "Enables the !cf command, allowing players to flip a coin, sends heads or tails to party chat.",
"cookies.config.dungeon.party_chat_commands.down_time.name": "Downtime",
"cookies.config.dungeon.party_chat_commands.down_time.tooltip": "Enables the !dt command, allowing players to request downtime at the end of a run.",
"cookies.config.dungeon.party_chat_commands.join_instance.name": "Join Instance",
"cookies.config.dungeon.party_chat_commands.join_instance.tooltip": "Enables the joininstance command, which is run using !f/!m or !t, followed by the floor/kuudra tier number. ex: !f7.\nRuns /joininstance based on the provided floor/kuudra tier, if you are not in an existing instance.",
"cookies.config.dungeon.party_chat_commands.name": "Chat Commands",
"cookies.config.dungeon.party_chat_commands.pt_me.name": "Party Transfer",
"cookies.config.dungeon.party_chat_commands.pt_me.tooltip": "Enables the !ptme command that transfers the party to the player that ran the command.",
"cookies.config.dungeon.party_chat_commands.tooltip": "All of the party chat commands.",
"cookies.config.dungeon.party_chat_commands.warp.name": "Party Warp",
"cookies.config.dungeon.party_chat_commands.warp.tooltip": "Enables the !warp command, running /p warp.",
"cookies.config.dungeon.player_glow_by_class_color.name": "Class based glow color",
"cookies.config.dungeon.player_glow_by_class_color.tooltip": "Overrides the default hypixel glowing by rank to glow by class color.",
"cookies.config.dungeon.puzzle.creeper_beams.name": "Creeper Beams",
Expand Down Expand Up @@ -173,6 +189,8 @@
"cookies.config.dungeon.terminal.click_in_order.tooltip": "Enables the click in order solver.",
"cookies.config.dungeon.terminal.correct_all_panes.name": "Correct all panes",
"cookies.config.dungeon.terminal.correct_all_panes.tooltip": "Enables the correct all panes solver.",
"cookies.config.dungeon.terminal.melody_notifier.name": "Melody notifier",
"cookies.config.dungeon.terminal.melody_notifier.tooltip": "Enables chat messages that are sent when you begin melody, when you complete each row, and when you finish.",
"cookies.config.dungeon.terminal.name": "Terminals",
"cookies.config.dungeon.terminal.prevent_miss_clicks.name": "Prevent Missclicks",
"cookies.config.dungeon.terminal.prevent_miss_clicks.tooltip": "Prevents you from clicking wrong options.",
Expand Down Expand Up @@ -480,4 +498,4 @@
"cookies.unexpected_error": "An unexpected error occurred while executing the command!",
"cookies.update_available": "Your version of the mod isn't up-to-date!",
"cookies.update_modrinth": "(Click here to open modrinth)"
}
}
21 changes: 19 additions & 2 deletions src/main/java/codes/cookies/mod/CookiesMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
public class CookiesMod implements ClientModInitializer {
public static KeyBinding chestSearch;
private static KeyBinding useGardenKeybinds;
public static KeyBinding pasteCommandFromClipboard;
@Getter
private static final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(4);

Expand All @@ -72,7 +73,11 @@ public static void openScreen(Screen screen) {
MinecraftClient.getInstance().send(() -> MinecraftClient.getInstance().setScreen(screen));
}

@Override
public static void pasteCommand() {

}

@Override
public void onInitializeClient() {
CommandManager.initialize();
CookieDataManager.load();
Expand All @@ -85,7 +90,8 @@ public void onInitializeClient() {
Features.load();
CommandManager.addCommands(new OpenConfigCommand(), new DevCommand(), new CookieCommand(), new ViewForgeRecipeCommand());
CommandManager.addCommands(RepositoryConstants.warps.getWarps().entrySet().stream().map(WarpCommand::new).toArray(WarpCommand[]::new));
UpdateChecker.init();

UpdateChecker.init();
PlayerListUtils.init();
HudManager.load();
CrystalStatusService.register();
Expand All @@ -102,6 +108,10 @@ private void registerKeyBindings() {
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_K,
"cookies.mod.keybinds"));
pasteCommandFromClipboard = KeyBindingHelper.registerKeyBinding(new KeyBinding("cookies.mod.paste_command",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_UNKNOWN,
"cookies.mod.keybinds"));

ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (chestSearch.isPressed()) {
Expand All @@ -115,6 +125,13 @@ private void registerKeyBindings() {
}
CookiesUtils.sendMessage(Text.translatable("cookies.mod.garden.keybinds." + (GardenKeybindPredicate.keyBindToggle ? "enabled" : "disabled")), false);
}
while (pasteCommandFromClipboard.wasPressed()) {
var message = client.keyboard.getClipboard();

if (message != null && message.startsWith("/")) {
CookiesUtils.getPlayer().map(player -> player.networkHandler.sendCommand(message.substring(1)));
}
}
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package codes.cookies.mod.config.categories;

import codes.cookies.mod.config.system.HudSetting;
import codes.cookies.mod.config.system.Option;
import codes.cookies.mod.config.system.Parent;
import codes.cookies.mod.features.dungeons.map.DungeonMapHud;
import codes.cookies.mod.render.hud.HudEditScreen;
import codes.cookies.mod.utils.cookies.Constants;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import codes.cookies.mod.CookiesMod;
import codes.cookies.mod.config.ConfigManager;
Expand Down Expand Up @@ -46,6 +52,7 @@ public DungeonConfig() {
public PuzzleFoldable puzzleFoldable = new PuzzleFoldable();
public ClassColorFoldable classColorFoldable = new ClassColorFoldable();
public BooleanOption glowClassColor = new BooleanOption(CONFIG_DUNGEON_GLOW_CLASS_COLOR, true);
public PartyChatCommandsFoldable partyChatCommandsFoldable = new PartyChatCommandsFoldable();

public TextDisplayOption render = new TextDisplayOption(CONFIG_DUNGEON_RENDER);
public ButtonOption repositionMap = new ButtonOption(CONFIG_DUNGEON_RENDER_MAP_REPOSITION,
Expand Down Expand Up @@ -110,6 +117,8 @@ public String getName() {
public static class SpiritLeapFoldable extends Foldable {

public BooleanOption colorInClassColor = new BooleanOption(CONFIG_DUNGEON_SPIRIT_LEAP_USE_CLASS_COLOR, false);
public BooleanOption announceLeaps = new BooleanOption(CONFIG_DUNGEON_ANNOUNCE_LEAPS, true);
public BooleanOption announceLeapCoords = new BooleanOption(CONFIG_DUNGEON_ANNOUNCE_LEAP_COORDS, false).onlyIf(announceLeaps);

@Parent
public TextDisplayOption vanillaUi = new TextDisplayOption(CONFIG_DUNGEON_SPIRIT_LEAP_VANILLA);
Expand Down Expand Up @@ -158,11 +167,27 @@ public static class TerminalFoldable extends Foldable {
new BooleanOption(CONFIG_DUNGEON_TERMINAL_SELECT_ALL_COLORS, true);
public BooleanOption startsWithTerminal = new BooleanOption(CONFIG_DUNGEON_TERMINAL_STARTS_WITH_TERMINAL,
true);
public BooleanOption melodyNotifier = new BooleanOption(CONFIG_DUNGEON_TERMINAL_MELODY_NOTIFIER, true);


@Override
public String getName() {
return CONFIG_DUNGEON_TERMINAL;
}
}

public static class PartyChatCommandsFoldable extends Foldable {
public BooleanOption ptMe = new BooleanOption(CONFIG_DUNGEON_PARTY_CHAT_COMMANDS_PT_ME, true);
public BooleanOption warp = new BooleanOption(CONFIG_DUNGEON_PARTY_CHAT_COMMANDS_WARP, true);
public BooleanOption joinInstance = new BooleanOption(CONFIG_DUNGEON_PARTY_CHAT_COMMANDS_JOIN_INSTANCE, true);
public BooleanOption downTime = new BooleanOption(CONFIG_DUNGEON_PARTY_CHAT_COMMANDS_DOWN_TIME, true);
public BooleanOption coinFlip = new BooleanOption(CONFIG_DUNGEON_PARTY_CHAT_COMMANDS_COIN_FLIP, true);

public Map<String, BooleanOption> partyChatCommands = Map.of("ptme", ptMe, "warp", warp, "joininstance", joinInstance, "dt", downTime, "cf", coinFlip);

@Override
public String getName() {
return CONFIG_DUNGEON_PARTY_CHAT_COMMANDS;
}
}
}
1 change: 0 additions & 1 deletion src/main/java/codes/cookies/mod/events/ChatListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ public static void lookForProfileIdMessage(Text text, boolean overlay) {
}
}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package codes.cookies.mod.features.dungeons;

import codes.cookies.mod.features.dungeons.map.DungeonMapHud;
import codes.cookies.mod.features.dungeons.solver.terminals.MelodyTerminalSolver;
import codes.cookies.mod.render.hud.HudManager;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
Expand Down Expand Up @@ -73,7 +74,9 @@ public DungeonFeatures() {
new ClickInOrderTerminalSolver();
new CorrectAllThePanesTerminalSolver();
new ChangeAllToSameColorTerminalSolver();
new MelodyTerminalSolver();
SpiritLeapOverlay.init(this);

HudManager.register(DungeonMapHud.getInstance());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.OptionalInt;

import codes.cookies.mod.features.dungeons.map.DungeonMapHud;
import codes.cookies.mod.utils.skyblock.ChatUtils;
import com.google.common.base.Predicates;
import codes.cookies.mod.config.categories.DungeonConfig;
import codes.cookies.mod.events.InventoryEvents;
Expand Down Expand Up @@ -273,7 +274,7 @@ private boolean mouseClicked(Screen screen, double mouseX, double mouseY, int bu
player.location.y,
player.location.width,
player.location.height)) {
clickedPlayer(player.slot);
clickedPlayer(player.slot, player.dungeonPlayer());
break;
}
}
Expand Down Expand Up @@ -381,13 +382,22 @@ private void setPlayers() {
}
}

public void clickedPlayer(Slot slot) {
public void clickedPlayer(Slot slot, @Nullable DungeonPlayer player) {
MinecraftClient.getInstance().interactionManager.clickSlot(
this.handledScreen.getScreenHandler().syncId,
slot.id,
0,
SlotActionType.PICKUP,
MinecraftClient.getInstance().player);
if (player != null && DungeonConfig.getInstance().spiritLeapFoldable.announceLeaps.getValue()) {
StringBuilder message = new StringBuilder("Leaped to ");
message.append(player.getName());
if (player.getPlayer() != null && DungeonConfig.getInstance().spiritLeapFoldable.announceLeapCoords.getValue()) {
message.append(" at coords ").append(player.getPlayer().getBlockPos().toCenterPos().toString());
}
message.append("!");
ChatUtils.sendPartyMessage(message.toString());
}
}

private boolean modifyNormalIfAvailable() {
Expand Down Expand Up @@ -430,7 +440,7 @@ private Result<Runnable, String> setClass(
handledScreen.close();
CookiesUtils.sendFailedMessage("Can't leap to yourself!");
} else {
clickedPlayer(leapPlayer.slot);
clickedPlayer(leapPlayer.slot, dungeonPlayer);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ChangeAllToSameColorTerminalSolver extends TerminalSolver {

public ChangeAllToSameColorTerminalSolver() {
InventoryEvents.beforeInit("Change all to same color!",
super.getFloorPredicate().or(super.getDebugPredicate()),
getFloorPredicate().or(getDebugPredicate()),
this::modify);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ClickInOrderTerminalSolver extends TerminalSolver {

public ClickInOrderTerminalSolver() {
InventoryEvents.beforeInit("Click in order!",
super.getFloorPredicate().or(super.getDebugPredicate()),
getFloorPredicate().or(getDebugPredicate()),
this::modify);
}

Expand Down Expand Up @@ -67,7 +67,7 @@ private void update(int slot, ItemStack stack) {
return;
}

if (!(stack.getItem() == Items.RED_STAINED_GLASS_PANE)) {
if (stack.getItem() != Items.RED_STAINED_GLASS_PANE) {
stack.set(MiscDataComponentTypes.TERMINAL_SOLVER_MODIFIED, this.doneItem);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class CorrectAllThePanesTerminalSolver extends TerminalSolver {

public CorrectAllThePanesTerminalSolver() {
InventoryEvents.beforeInit("Correct all the panes!",
super.getFloorPredicate().or(super.getDebugPredicate()),
getFloorPredicate().or(getDebugPredicate()),
this::modify);
}

Expand All @@ -36,6 +36,7 @@ private void update(int slot, ItemStack stack) {
this.items.clear();
}
this.items.add(stack);

if (slot == 44) {
stack.set(MiscDataComponentTypes.TERMINAL_SOLVER_TOGGLE, Unit.INSTANCE);
if (this.localToggle) {
Expand Down
Loading

0 comments on commit 0423b1d

Please sign in to comment.