Command Block Tutorial Prison

Have you ever wanted to make a prison, and wanted to make it automatic? This tutorial will show you how. You must be owner to do the tutorial except for building the prison itself. If you want to see it in action, or see the command blocks yourself, view this: https://junon.io?e=vy9CWInxm064r.

## Building

Make your prison anyway you want, as long as you do not fill the entire map. Make sure there is a prisoner and a guard area. There should also be a way for prisoners to get weapons (Such as a black market dealer in the yard, and you smuggle potatoes to sell from the work area).

## Create a spawn and get role area

Build a spawn area, it is best placed in the corner of the map. Place a beacon, and set it for everybody to spawn there. Place a sign next to the beacon, and write how to get a role by stepping on each floor. (Because we cannot put multiple if commands, warn them that they cannot change their role. Soon Jmooroof will create a bonus section on how to make a change role, once command blocks add the option to create a sidebar with buttons.) (You may also credit Jmoorof) Place two sections of floor, and the area should look like this:

Next, either place a sign or use the /name command to tell players what stepping on the floors will do. To use the /name command, type /name set [id] [Text], and replace the items in the brackets with the id and the text you want. To get the id, click on a floor, and the id will show in a sidebar. When you are done, it should look like this:

Now it is time for creating the regions. Get the coordinates of the top-left floor and the bottom-right floor of the section of floor. Then type /region set [name] [top Left Coord1] [top Left Coord2] [bottom Right Coord1] [bottom Right Coord2]. Name the regions anything you want, but make sure to not use spaces. I recommend getPrisoner and getGuard as the names. When you are done, a blue box will cover the area you typed. Nobody but you will see this, so do not worry if it looks funny. Then, repeat the command again but for the second section of floor. It should look like this:

Create two roles, one for prisoners, and one for guards. Remember the names.

Now it is time to make the floors give roles when you step on them. Press "k" or the picture of a puzzle-piece and a menu will appear called "Command Blocks". Click "New Trigger" and add a region enter trigger. Click the plus sign next to "Actions" and add a "IfThenElse" action. In value1, type $region and in value2, type the region name for the prisoners. If you named it getPrisoner, just type getPrisoner in the box. Then click the plus sign next to Then and add the action "Commands" and type /role $player [roleName], and replace [roleName] with the role you named prisoner. Then click the plus sign next to else and add a command action. In the command action, add /role $player [roleName], and replace [roleName] with the guard role. When you are done, it should look like this:

You can also visit the prison test and open command blocks to see everything.

## Setting up the teleports

Before we can teleport players to a specific spot, you need to add spawns and a place to teleport players to. Place two beacons, one for prisoners, and one for guards. Set the one for prisoners for the role prisoners to spawn there and the one for guards set it for guards to spawn there. You can put multiple beacons for prisoners, so not all prisoners are in one cell. However, there currently is no way to randomly teleport prisoners to cells, so the only way for prisoners to occupy other cells is if they rejoin.

Get the coordinates for each beacon. Open command blocks. In the IfThenElse in Then, add /tp $player [coord1] [coord2] and replace the things in brackets with the coordinates of the prisoner beacon. Repeat it in else with the other beacon.

## Testing

It is time to test. If it does not work the way you want it to, visit the colony https://junon.io?e=vy9CWInxm064r and look at command blocks. Did you do everything right? Also, do not copy all of the commands exactly, replace the coordinates, roles, and regions with whatever you put.

Once you have done that, it is time to open up your colony to the public!