Back to Guides
Server ManagementIntermediate

Command Block Configuration Guide

Complete guide to enabling, configuring, and securing command blocks for automation and custom server features.

Blockhead Support Team
12 minutes
Command blocks are powerful tools for automation, mini-games, and custom server features. Proper configuration is essential for security and functionality.
1

Enable Command Blocks

Configure server to allow command block usage:

server.properties Configuration:

# Enable command blocks enable-command-block=true # Function permission level (1-4) function-permission-level=2 # Operator permission level op-permission-level=4

Security Considerations:

  • Restricted access: Only trusted players should place them
  • Permission levels: Control what commands can run
  • Regular audits: Review existing command blocks
  • Backup before use: Command blocks can break things
Command blocks can execute any server command. Only enable them if you trust your operators and understand the security implications.
2

Types of Command Blocks

Understand the different command block variants:

Command Block Types:

  • Impulse (Orange): Runs once when activated
  • Chain (Green): Runs after previous command block
  • Repeat (Purple): Runs continuously when powered

Activation Modes:

  • Needs Redstone: Requires redstone signal
  • Always Active: Runs without redstone
  • Conditional: Only runs if previous succeeded
  • Unconditional: Always attempts to run
3

Basic Command Block Usage

Learn fundamental command block operations:

Getting Command Blocks:

# Give yourself command blocks /give @s command_block /give @s chain_command_block /give @s repeating_command_block # Give to another player /give PlayerName command_block 1

Basic Commands:

# Teleport player to spawn /tp @p 0 64 0 # Give items to nearest player /give @p diamond 1 # Set time to day /time set day # Send message to all players /say Welcome to the server!
4

Target Selectors

Use advanced targeting for precise command execution:

Basic Selectors:

  • @p: Nearest player
  • @a: All players
  • @r: Random player
  • @e: All entities
  • @s: Self (command block)

Selector Arguments:

# Target by distance @p[distance=..10] # Within 10 blocks @a[distance=5..15] # Between 5-15 blocks # Target by gamemode @a[gamemode=creative] # Creative mode players @a[gamemode=!survival] # Not in survival # Target by level @p[level=30..] # Level 30 or higher @a[level=..5] # Level 5 or lower # Target by coordinates @e[x=0,y=64,z=0,distance=..5] # Entities near coordinates
5

Create Automation Systems

Build automated server functions:

Auto-Announcements:

# Repeating command block (Always Active) /tellraw @a {"text":"Remember to read /rules!","color":"yellow"} # Chain command block (Always Active, Conditional) /playsound minecraft:block.note_block.pling master @a ~ ~ ~ 1 1

Player Welcome System:

# Impulse command block /tag @a[tag=!welcomed] add new_player # Chain command block /tellraw @a[tag=new_player] {"text":"Welcome to our server!","color":"green"} # Chain command block /give @a[tag=new_player] bread 16 # Chain command block /tag @a[tag=new_player] add welcomed /tag @a[tag=new_player] remove new_player
6

Mini-Game Creation

Build interactive games and challenges:

Simple Parkour Timer:

# Start trigger (Impulse) /scoreboard objectives add parkour_time dummy /scoreboard players set @p parkour_time 0 /tellraw @p {"text":"Parkour started! Go!","color":"green"} # Timer (Repeating, Always Active) /scoreboard players add @a[x=start_x,y=start_y,z=start_z,distance=..2] parkour_time 1 # Finish trigger (Impulse) /tellraw @p[scores={parkour_time=1..}] [{"text":"Finished in "},{"score":{"name":"@p","objective":"parkour_time"}},{"text":" ticks!"}] /scoreboard players reset @p parkour_time

Random Teleporter:

# Main teleporter (Impulse) /execute as @p at @s run spreadplayers ~ ~ 0 1000 false @s # Safety check (Chain, Conditional) /execute as @p at @s if block ~ ~-1 ~ water run tp @s ~ ~10 ~ /execute as @p at @s if block ~ ~-1 ~ lava run tp @s ~ ~10 ~
7

Advanced Features

Implement complex command block systems:

Scoreboard Operations:

# Create objectives /scoreboard objectives add deaths deathCount /scoreboard objectives add health health /scoreboard objectives add money dummy # Mathematical operations /scoreboard players add @p money 100 /scoreboard players remove @p money 50 /scoreboard players set @p health 20 # Conditional execution based on scores /execute if entity @p[scores={money=100..}] run give @p diamond 1

Data Storage:

# Store data /data merge storage myserver:data {player_count:0} # Retrieve and use data /execute store result storage myserver:data player_count int 1 run list # Use stored data in commands /execute store result score @p temp run data get storage myserver:data player_count
8

Security and Monitoring

Secure your command block systems:

Security Best Practices:

  • Limit access: Only trusted staff can place/edit
  • Regular audits: Check all command blocks periodically
  • Log commands: Monitor command block execution
  • Test in creative: Verify commands before deployment
  • Backup worlds: Before major command block projects

Finding Command Blocks:

# Locate command blocks /execute as @a at @s run fill ~-50 ~-50 ~-50 ~50 ~50 ~50 air replace command_block # Find specific types /execute as @a at @s run fill ~-50 ~-50 ~-50 ~50 ~50 ~50 air replace repeating_command_block # Count command blocks in area /execute as @a at @s run clone ~-50 ~-50 ~-50 ~50 ~50 ~50 ~ ~1000 ~ filtered command_block
9

Troubleshooting

Debug common command block issues:

  • Commands not running: Check redstone power and block settings
  • Syntax errors: Verify command syntax with /help
  • Permission denied: Ensure function-permission-level is correct
  • Lag issues: Limit repeating command blocks
  • Chain failures: Check conditional settings
  • Target not found: Verify selector arguments
  • Performance impact: Monitor server TPS with complex systems
Command blocks are now configured and ready for use! Remember to test thoroughly and monitor for any performance impact on your server.

Need More Help?

Our support team is available 24/7 to help with any Minecraft server issues.