Merge pull request #2 from BisUmTo/master

Added "/flan addClaim" command
This commit is contained in:
Flemmli97 2020-09-03 08:01:37 +02:00 committed by GitHub
commit 123cd321c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);