Skip to content

Commit

Permalink
refactor: Improve WarPartyScreen structure, extract helper methods, a…
Browse files Browse the repository at this point in the history
…nd fix NPE in right panel update
  • Loading branch information
Lotnest committed Feb 12, 2025
1 parent c0894a1 commit 4098d8e
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 338 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright © sequoia-mod 2025.
* This file is released under LGPLv3. See LICENSE for full license details.
*/
package dev.lotnest.sequoia.commands;

import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.wynntils.core.components.Managers;
import dev.lotnest.sequoia.SequoiaMod;
import dev.lotnest.sequoia.core.components.Models;
import dev.lotnest.sequoia.core.consumers.command.Command;
import dev.lotnest.sequoia.mc.screens.WarPartyScreen;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;

public class WarPartyCommand extends Command {
@Override
public String getCommandName() {
return "warParty";
}

@Override
public List<String> getAliases() {
return List.of("wp");
}

@Override
public LiteralArgumentBuilder<CommandSourceStack> getCommandBuilder(
LiteralArgumentBuilder<CommandSourceStack> base) {
return base.executes(this::openWarPartyScreen);
}

private int openWarPartyScreen(CommandContext<CommandSourceStack> context) {
try {
Managers.TickScheduler.scheduleNextTick(
() -> Minecraft.getInstance().execute(() -> {
Models.War.mockWars();
Minecraft.getInstance().setScreen(new WarPartyScreen());
}));

} catch (Exception exception) {
SequoiaMod.error("Failed to open WarPartyScreen", exception);
context.getSource()
.sendFailure(
SequoiaMod.prefix(Component.translatable("sequoia.command.warParty.failedToOpenScreen")));
}

return 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import dev.lotnest.sequoia.commands.MeowCommand;
import dev.lotnest.sequoia.commands.OnlineMembersCommand;
import dev.lotnest.sequoia.commands.OuterVoidCommand;
import dev.lotnest.sequoia.commands.PartyCommand;
import dev.lotnest.sequoia.commands.PlayerDungeonsCommand;
import dev.lotnest.sequoia.commands.PlayerGuildCommand;
import dev.lotnest.sequoia.commands.PlayerRaidsCommand;
Expand All @@ -36,6 +35,7 @@
import dev.lotnest.sequoia.commands.TerritoryMenuCommand;
import dev.lotnest.sequoia.commands.TestCommand;
import dev.lotnest.sequoia.commands.VersionCommand;
import dev.lotnest.sequoia.commands.WarPartyCommand;
import dev.lotnest.sequoia.core.components.Manager;
import java.util.List;
import net.minecraft.ChatFormatting;
Expand Down Expand Up @@ -196,7 +196,7 @@ private void registerAllCommands() {
registerCommand(new SearchCommand());
registerCommand(new TerritoryMenuCommand());
registerCommand(new AuthCommand());
registerCommand(new PartyCommand());
registerCommand(new WarPartyCommand());

registerCommandWithCommandSet(new SequoiaCommand());
}
Expand Down
Loading

0 comments on commit 4098d8e

Please sign in to comment.