Skip to content

Commit

Permalink
roll back to use StringArgumentType
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyDynamic committed Oct 8, 2024
1 parent dff8c83 commit cd7a61a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.skydynamic.quickbackupmulti.command;

import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import io.github.skydynamic.quickbackupmulti.command.permission.PermissionManager;
import io.github.skydynamic.quickbackupmulti.command.permission.PermissionType;
Expand Down Expand Up @@ -40,13 +41,13 @@ public void run() {
public static LiteralArgumentBuilder<ServerCommandSource> makeCommand = literal("make")
.requires(it -> PermissionManager.hasPermission(it, 4, PermissionType.HELPER))
.executes(it -> makeSaveBackup(it.getSource(), dateFormat.format(System.currentTimeMillis()), ""))
.then(CommandManager.argument("name", MessageArgumentType.message())
.executes(it -> makeSaveBackup(it.getSource(), MessageArgumentType.getMessage(it, "name").getString(), ""))
.then(CommandManager.argument("desc", MessageArgumentType.message())
.then(CommandManager.argument("name", StringArgumentType.string())
.executes(it -> makeSaveBackup(it.getSource(), StringArgumentType.getString(it, "name"), ""))
.then(CommandManager.argument("desc", StringArgumentType.string())
.executes(it -> makeSaveBackup(
it.getSource(),
MessageArgumentType.getMessage(it, "name").getString(),
MessageArgumentType.getMessage(it, "desc").getString()
StringArgumentType.getString(it, "name"),
StringArgumentType.getString(it, "desc")
)))
);
// .then(CommandManager.argument("desc", StringArgumentType.string())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.github.skydynamic.quickbackupmulti.config.Config;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.command.argument.MessageArgumentType;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
Expand Down Expand Up @@ -54,14 +53,14 @@ public static void RegisterCommand(CommandDispatcher<ServerCommandSource> dispat
.executes(it -> listSaveBackups(it.getSource(), IntegerArgumentType.getInteger(it, "page")))))

.then(literal("search")
.then(CommandManager.argument("name", MessageArgumentType.message())
.executes(it -> searchSaveBackups(it.getSource(), MessageArgumentType.getMessage(it, "name").getString()))))
.then(CommandManager.argument("name", StringArgumentType.string())
.executes(it -> searchSaveBackups(it.getSource(), StringArgumentType.getString(it, "name")))))

.then(MakeCommand.makeCommand)

.then(literal("back").requires(it -> PermissionManager.hasPermission(it, 4, PermissionType.ADMIN))
.then(CommandManager.argument("name", MessageArgumentType.message())
.executes(it -> restoreSaveBackup(it.getSource(), MessageArgumentType.getMessage(it, "name").getString()))))
.then(CommandManager.argument("name", StringArgumentType.string())
.executes(it -> restoreSaveBackup(it.getSource(), StringArgumentType.getString(it, "name")))))

.then(literal("confirm").requires(it -> PermissionManager.hasPermission(it, 4, PermissionType.ADMIN))
.executes(it -> {
Expand All @@ -77,14 +76,14 @@ public static void RegisterCommand(CommandDispatcher<ServerCommandSource> dispat
.executes(it -> cancelRestore(it.getSource())))

.then(literal("delete").requires(it -> PermissionManager.hasPermission(it, 2, PermissionType.HELPER))
.then(CommandManager.argument("name", MessageArgumentType.message())
.executes(it -> deleteSaveBackup(it.getSource(), MessageArgumentType.getMessage(it, "name").getString()))))
.then(CommandManager.argument("name", StringArgumentType.string())
.executes(it -> deleteSaveBackup(it.getSource(), StringArgumentType.getString(it, "name")))))

.then(settingCommand)

.then(literal("show")
.then(CommandManager.argument("name", MessageArgumentType.message())
.executes(it -> showBackupDetail(it.getSource(), MessageArgumentType.getMessage(it, "name").getString()))))
.then(CommandManager.argument("name", StringArgumentType.string())
.executes(it -> showBackupDetail(it.getSource(), StringArgumentType.getString(it, "name")))))

.then(permissionCommand)
);
Expand Down

0 comments on commit cd7a61a

Please sign in to comment.