This answer is for 1.12 or before. Refer to this answer by pppery for 1.13 and later.
You can set up some simple commands with command blocks, and let players click the button of each command block so that they receive the enchanted items.
You can use the following command to give players enchanted items (in this example, 1 diamond sword with Smite 2 and Knockback 30)
/give @p diamond_sword 1 0 {ench:[{id:17,lvl:2},{id:19,lvl:30}]}
This is the general command:
/give @p <ID> <amount> 0 {ench:[{id:<0-62>,lvl:<1-32767>},{id:<0-62>,lvl:<1-32767>},...]}
You put all enchantment tags between [ ]
, each with both id
and lvl
tags wrapped together by curly braces { }
.
You can also add in the clear inventory command to ensure they don't get kits twice.
/clear @p
Remember the highest level for the enchantment is level 32767.
You can stack enchants as many times as you want such as:
/give @p diamond_sword 1 0 {ench:[{id:17,lvl:32767},{id:17,lvl:32767}]}
After setting up the command blocks, put buttons and the players can choose by clicking them.
You can also put enchantments onto things that normally cannot be enchanted or have that specific enchantment. For example, you can do the command stated above to give you enchanted blocks. But, enchantments will NOT affect how the thing works normally. For example, enchanting Thorns on a dirt block will not hurt players when they come into contact with the enchanted block.
You should use a dummy variable and target selector arguments.
Run once
Have a dummy score, call it healthDif
.
/scoreboard objectives add healthDif dummy
Run every tick, in order
Set each players healthDif
score to their own health score:
/execute @a ~ ~ ~ scoreboard players operation @a[c=1] healthDif = @a[c=1] health
Subtract the other player's healthDif
score from your own:
/execute @a ~ ~ ~ scoreboard players operation @a[c=1] healthDif -= @a[rm=0] health
Now players with a positive healthDif
score will have more health than the other player. Target with @a[score_healthDif=1]
Note this will only work for two players. In order for it to work with more, you have to take a few extra steps.
Run once
First you'll need a dummy variable to store miscellaneous variables. Call it vars
. Note: If you already have a variable for this (you likely do), you can skip this step.
/scoreboard objectives add vars dummy
Run every tick, in order
Put these between the two commands from before.
First, set the #nplayers
to 0:
/scoreboard players set #nplayers vars -1
Now, have each player increment #nplayers
:
/execute @a ~ ~ ~ scoreboard players add #nplayers vars 1
Finally, multiply each players healthDif
score by this number
/scoreboard players operation @a healthDif *= #nplayers vars
This way, you can have any amount of players, and the system automatically adapts!
Best Answer
If you don't mind using a server, the WorldGuard plugin can be used. To create a server with plugin support, this is a good tutorial:
Stop the server and delete "world", "world_nether" and "world_the_end". Copy the world to "world".
Download WorldGuard and add it into the server's "plugins" folder.
Start the server back up.
Set
gamemode
toadventure
.Give yourself cheats (
/op <player>
).For a guide on how to use WorldGuard here's another tutorial (I just can't be bothered to write the whole thing):
The flag used to prevent block-trampling is "block-trampling" (not too surprisingly). It does not affect operators.
Unfortunately, to distribute the map you need to distribute the whole server folder (excluding "cache", for copyright reasons).
Sorry if this wasn't the most ideal solution.