Link custom nether world to portal

I want to let a plugin create a new overworld, nether and end world. This step is working already, but how to I link the worlds together when portals are getting created/entered?

Version 1.17.1