Using two variables to make a combined product (Minecraft Command Blocks)

Solution 1:

You can simply do this by using this command:

summon pig [x] [y] [z] {CustomName:"\"<name and level>\""}

This command will spawn a pig with the name and level you choose, although this will not change the pig itself, only its name, the pig will remain the same as it would be if you spawned it with a spawn egg. If you want to change the pigs health and other attributes you can do this with this command:

summon pig [x] [y] [z] {CustomName:"\"<name and level>\"",ActiveEffects:[{Id:21,Amplifier:<health amount>,Duration:999999}]}

This command simply adds an effect to the pig that boosts its health for an infinite amount of time where, {health amount} is the number put you can input to change the health, the number has to be between 1 and 255, you can also change the id to another effect or add one using this template, you just have to know the effect id, which you can easily find on the internet, or more simply use a command generator.

If you want to change the color of the pig's name and level just put this in the name slot:

[{"text":"<name/level>","color":"<color, red, blue, etc>"}]

If you want to change the name for both the name and level use this:

[{"text":"<level/name>","color":"<color>"},{"text":"<level/name>","color":"<color>"}]

Ex:

summon pig [x] [y] [z] {CustomName:"\"[{"text":"{Lvl:3}","color":"grey"},{"text":"Pig","color":"Red"}]\"",ActiveEffects [{Id:21,Amplifier:{health amount},Duration:999999}]}

Finally since you are on a server, you can add plugins that can do this for you, the plugins will have much more configurations for the mob, (such as showing the mobs current health).

Notice: I haven't yet tested if the color works, but if it doesn't you can just use the first and/or second command.

Hope this helps! If you have any questions feel free to ask me!

(Also this is my first time doing this)