You got taken advantage of, which is a sad and very common occurence in nearly every gym I have ever been in. A friend of mine was 15 when they let him "spar" with a 20-0 pro and he was ko'd. Years later he was 3-0 as a pro and they- his management- tried to put him in with Clyde Gray, who had just gone 15 for a world title.
Practically, and to quote Jake LaMotta, "keep your hands up and your ....rear..off the floor"
A big part of taking a punch is being loose. Tension is your enemy when getting hit. Ride with shots. Don't resist them.