Fix command permission requirements

- Commands glue, highlight, and replaceInCommandBlocks now require OP
level 2 instead of 0
This commit is contained in:
PepperBell 2021-09-05 21:14:41 -07:00
parent aa3d656445
commit 6800c24c58
6 changed files with 9 additions and 8 deletions

View file

@ -14,7 +14,7 @@ import net.minecraft.entity.player.PlayerEntity;
public class AllCommands {
public static Predicate<CommandSource> sourceIsPlayer = (cs) -> cs.getEntity() instanceof PlayerEntity;
public static final Predicate<CommandSource> SOURCE_IS_PLAYER = cs -> cs.getEntity() instanceof PlayerEntity;
public static void register(CommandDispatcher<CommandSource> dispatcher) {
@ -88,4 +88,5 @@ public class AllCommands {
}
return builder.build();
}
}

View file

@ -13,7 +13,7 @@ public class FabulousWarningCommand {
public static ArgumentBuilder<CommandSource, ?> register() {
return Commands.literal("dismissFabulousWarning")
.requires(AllCommands.sourceIsPlayer)
.requires(AllCommands.SOURCE_IS_PLAYER)
.executes(ctx -> {
ServerPlayerEntity player = ctx.getSource()
.getPlayerOrException();

View file

@ -13,7 +13,7 @@ import net.minecraft.world.server.ServerWorld;
public class GlueCommand {
public static ArgumentBuilder<CommandSource, ?> register() {
return Commands.literal("glue")
.requires(cs -> cs.hasPermission(0))
.requires(cs -> cs.hasPermission(2))
.then(Commands.argument("pos", BlockPosArgument.blockPos())
//.then(Commands.argument("direction", EnumArgument.enumArgument(Direction.class))
.executes(ctx -> {

View file

@ -28,7 +28,7 @@ public class HighlightCommand {
public static ArgumentBuilder<CommandSource, ?> register() {
return Commands.literal("highlight")
.requires(cs -> cs.hasPermission(0))
.requires(cs -> cs.hasPermission(2))
.then(Commands.argument("pos", BlockPosArgument.blockPos())
.then(Commands.argument("players", EntityArgument.players())
.executes(ctx -> {

View file

@ -24,12 +24,12 @@ public class HighlightPacket extends SimplePacketBase {
}
public HighlightPacket(PacketBuffer buffer) {
this.pos = BlockPos.of(buffer.readLong());
this.pos = buffer.readBlockPos();
}
@Override
public void write(PacketBuffer buffer) {
buffer.writeLong(pos.asLong());
buffer.writeBlockPos(pos);
}
@Override
@ -55,6 +55,6 @@ public class HighlightPacket extends SimplePacketBase {
.colored(0xEeEeEe)
// .colored(0x243B50)
.withFaceTexture(AllSpecialTextures.SELECTION);
}
}

View file

@ -21,7 +21,7 @@ public class ReplaceInCommandBlocksCommand {
public static ArgumentBuilder<CommandSource, ?> register() {
return Commands.literal("replaceInCommandBlocks")
.requires(cs -> cs.hasPermission(0))
.requires(cs -> cs.hasPermission(2))
.then(Commands.argument("begin", BlockPosArgument.blockPos())
.then(Commands.argument("end", BlockPosArgument.blockPos())
.then(Commands.argument("toReplace", StringArgumentType.string())