package com.hypixel.hytale.builtin.buildertools.commands; import com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin; import com.hypixel.hytale.builtin.buildertools.PrototypePlayerBuilderToolSettings; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.protocol.GameMode; import com.hypixel.hytale.server.core.Message; import com.hypixel.hytale.server.core.command.system.CommandContext; import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg; import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes; import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.prefab.selection.mask.BlockPattern; import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class FillCommand extends AbstractPlayerCommand { @Nonnull private final RequiredArg patternArg = this.withRequiredArg("pattern", "server.commands.fill.args.replacement.desc", ArgTypes.BLOCK_PATTERN); public FillCommand() { super("fillBlocks", "server.commands.fill.desc"); this.setPermissionGroup(GameMode.Creative); this.addAliases("fill"); } @Override protected void execute( @Nonnull CommandContext context, @Nonnull Store store, @Nonnull Ref ref, @Nonnull PlayerRef playerRef, @Nonnull World world ) { Player playerComponent = store.getComponent(ref, Player.getComponentType()); assert playerComponent != null; if (PrototypePlayerBuilderToolSettings.isOkayToDoCommandsOnSelection(ref, playerComponent, store)) { BlockPattern pattern = this.patternArg.get(context); if (pattern != null && !pattern.isEmpty()) { BuilderToolsPlugin.addToQueue(playerComponent, playerRef, (r, s, componentAccessor) -> s.fill(pattern, componentAccessor)); context.sendMessage(Message.translation("server.commands.fill.success").param("key", pattern.toString())); } else { context.sendMessage(Message.translation("server.builderTools.invalidBlockType").param("name", "").param("key", "")); } } } }