Hey!
Sorry to hear about this!
If you don't want this to happen, you can whitelist your server by going to console (or in game if you are OP) and typing in "/whitelist on"
After that, you can type "/whitelist add <name>" to add someone to the whitelist. If someone is not whitelisted they will not be able to join your server!
If you want to have a public server that won't get griefed, consider installing world edit and world guard. You can find a tutorial on this by clicking here.
Please leave a like on this post if i helped!