Added "/flan addClaim" command
This commit is contained in:
parent
22857cb544
commit
0a31f0fcf3
@ -23,6 +23,7 @@ import com.mojang.brigadier.context.CommandContext;
|
|||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import com.mojang.brigadier.suggestion.Suggestions;
|
import com.mojang.brigadier.suggestion.Suggestions;
|
||||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||||
|
import net.minecraft.command.argument.BlockPosArgumentType;
|
||||||
import net.minecraft.command.argument.GameProfileArgumentType;
|
import net.minecraft.command.argument.GameProfileArgumentType;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
@ -46,6 +47,7 @@ public class CommandClaim {
|
|||||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, boolean dedicated) {
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, boolean dedicated) {
|
||||||
dispatcher.register(addToMainCommand(CommandManager.literal("flan"),
|
dispatcher.register(addToMainCommand(CommandManager.literal("flan"),
|
||||||
CommandManager.literal("reload").executes(CommandClaim::reloadConfig),
|
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("menu").executes(CommandClaim::openMenu),
|
||||||
CommandManager.literal("claimInfo").executes(CommandClaim::claimInfo),
|
CommandManager.literal("claimInfo").executes(CommandClaim::claimInfo),
|
||||||
CommandManager.literal("delete").executes(CommandClaim::deleteClaim),
|
CommandManager.literal("delete").executes(CommandClaim::deleteClaim),
|
||||||
@ -99,6 +101,16 @@ public class CommandClaim {
|
|||||||
return Command.SINGLE_SUCCESS;
|
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 {
|
private static int openMenu(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||||
PlayerClaimData data = PlayerClaimData.get(player);
|
PlayerClaimData data = PlayerClaimData.get(player);
|
||||||
|
Loading…
Reference in New Issue
Block a user