Merge pull request #2 from BisUmTo/master
Added "/flan addClaim" command
This commit is contained in:
commit
123cd321c2
@ -23,6 +23,7 @@ import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import net.minecraft.command.argument.BlockPosArgumentType;
|
||||
import net.minecraft.command.argument.GameProfileArgumentType;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
@ -46,6 +47,7 @@ public class CommandClaim {
|
||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, boolean dedicated) {
|
||||
dispatcher.register(addToMainCommand(CommandManager.literal("flan"),
|
||||
CommandManager.literal("reload").executes(CommandClaim::reloadConfig),
|
||||
CommandManager.literal("addClaim").then(CommandManager.argument("from", BlockPosArgumentType.blockPos()).then(CommandManager.argument("to", BlockPosArgumentType.blockPos()).executes(CommandClaim::addClaim))),
|
||||
CommandManager.literal("menu").executes(CommandClaim::openMenu),
|
||||
CommandManager.literal("claimInfo").executes(CommandClaim::claimInfo),
|
||||
CommandManager.literal("delete").executes(CommandClaim::deleteClaim),
|
||||
@ -99,6 +101,16 @@ public class CommandClaim {
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
private static int addClaim(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||
ClaimStorage storage = ClaimStorage.get(player.getServerWorld());
|
||||
BlockPos from = BlockPosArgumentType.getLoadedBlockPos(context, "from");
|
||||
BlockPos to = BlockPosArgumentType.getLoadedBlockPos(context, "to");
|
||||
|
||||
storage.createClaim(from, to, player);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
private static int openMenu(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||
PlayerClaimData data = PlayerClaimData.get(player);
|
||||
|
Loading…
Reference in New Issue
Block a user