-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Improve WarPartyScreen structure, extract helper methods, a…
…nd fix NPE in right panel update
- Loading branch information
Showing
5 changed files
with
267 additions
and
338 deletions.
There are no files selected for viewing
56 changes: 0 additions & 56 deletions
56
common/src/main/java/dev/lotnest/sequoia/commands/PartyCommand.java
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
common/src/main/java/dev/lotnest/sequoia/commands/WarPartyCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.