Patrick's suggestion of
docker is good. Any other virtualisation method would work well too (e.g.
Another option is to create another user (e.g.
minecraft) on your system just for running minecraft server. Give it it's own group (e.g.
minecraft) and make sure all minecraft files have RW access for group, then add your own user to the
minecraft group so your user has full read + write access to minecraft files.
You can also set up permissions on all minecraft files and directories so that the minecraft user doesn't have write access to most of its own files (only to the files that minecraft absolutely must be able to write). This would require that the minecraft user NOT be a member of the minecraft group (maybe have
nogroup as its primary gid).
Anyone who compromises the minecraft server will have access only to minecraft-owned files, and those that are read or write by everyone. - make sure your files don't have such lax permissions.