From 344b0a5b7cbf00d09e26b65959a4064fbdef4832 Mon Sep 17 00:00:00 2001 From: gnembon <41132274+gnembon@users.noreply.github.com> Date: Tue, 16 May 2023 21:03:59 +0200 Subject: [PATCH] /info command now requires gamemasters permissions to request info from unloaded chunks. --- src/main/java/carpet/commands/InfoCommand.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/carpet/commands/InfoCommand.java b/src/main/java/carpet/commands/InfoCommand.java index c3ab1c20..4e36964c 100644 --- a/src/main/java/carpet/commands/InfoCommand.java +++ b/src/main/java/carpet/commands/InfoCommand.java @@ -12,6 +12,7 @@ import java.util.regex.Pattern; import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; import net.minecraft.commands.arguments.coordinates.BlockPosArgument; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -67,6 +68,18 @@ public class InfoCommand private static int infoBlock(CommandSourceStack source, BlockPos pos, String grep) { + if (!source.hasPermission(Commands.LEVEL_GAMEMASTERS)) { + //check id pos is loaded + if (!source.getLevel().hasChunkAt(pos)) { + Messenger.m(source, "r Chunk is not loaded"); + return 0; + } + // verify it is in world bounds + if (!source.getLevel().isInWorldBounds(pos)) { + Messenger.m(source, "r Position is outside of world bounds"); + return 0; + } + } printBlock(BlockInfo.blockInfo(pos, source.getLevel()),source, grep); return 1; }