Skip to content

Commit

Permalink
commands are so annoying.. but THIS is #101 for fabric 1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
HeatherComputer committed Dec 29, 2024
1 parent 2347bd9 commit 5cf343b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package computer.heather.advancedbackups;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.arguments.StringArgumentType;

import computer.heather.advancedbackups.core.CoreCommandSystem;
import net.minecraft.server.command.CommandManager;
Expand Down Expand Up @@ -35,9 +37,18 @@ public static void register(CommandDispatcher<ServerCommandSource> stack) {
.then(CommandManager.literal("snapshot").executes((runner) -> {
CoreCommandSystem.snapshot((response) -> {
runner.getSource().sendFeedback(Text.of(response), true);
});
}, "snapshot");
return 1;
}))
})

.then(CommandManager.argument("name", StringArgumentType.greedyString()).executes((runner) -> {
ParseResults<ServerCommandSource> parseResults = stack.parse(StringArgumentType.getString(runner, "name"), runner.getSource());
String snapshotName = parseResults.getReader().getString();
CoreCommandSystem.snapshot((response) -> {
runner.getSource().sendFeedback(Text.of(response), true);
}, snapshotName);
return 1;
})))

.then(CommandManager.literal("cancel").executes((runner) -> {
CoreCommandSystem.cancelBackup((response) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.time.Instant;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.arguments.StringArgumentType;

import computer.heather.advancedbackups.core.CoreCommandSystem;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
Expand Down Expand Up @@ -40,7 +42,15 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
Acknowledgment acknowledgment = MinecraftClient.getInstance().player.networkHandler.lastSeenMessagesCollector.collect().update();
MinecraftClient.getInstance().player.networkHandler.sendPacket(new CommandExecutionC2SPacket("backup snapshot", Instant.now(), 0L, ArgumentSignatureDataMap.EMPTY, acknowledgment));
return 1;
}))
})

.then(ClientCommandManager.argument("name", StringArgumentType.greedyString()).executes((runner) -> {
ParseResults<FabricClientCommandSource> parseResults = dispatcher.parse(StringArgumentType.getString(runner, "name"), runner.getSource());
String snapshotName = parseResults.getReader().getString();
Acknowledgment acknowledgment = MinecraftClient.getInstance().player.networkHandler.lastSeenMessagesCollector.collect().update();
MinecraftClient.getInstance().player.networkHandler.sendPacket(new CommandExecutionC2SPacket("backup snapshot " + snapshotName, Instant.now(), 0L, ArgumentSignatureDataMap.EMPTY, acknowledgment));
return 1;
})))

.then(ClientCommandManager.literal("cancel").executes((runner) -> {
Acknowledgment acknowledgment = MinecraftClient.getInstance().player.networkHandler.lastSeenMessagesCollector.collect().update();
Expand Down

0 comments on commit 5cf343b

Please sign in to comment.