Have you ever went through a Nether portal only to find when you return from the Nether that you end up in someone's house? The default game mechanic does not always bring you back through the portal you used. This plugin will force you to return to the portal that you originally walked through.
How Does It Work?
Lets say you build a Nether portal and you walk through it. This will create a entry in your history file that holds the source location and the destination location. So if you ever enter a portal that matches the destination location you will be teleported to the source location. This overrides the default game mechanic because you may not come back out the same portal you walked into. This history also covers multiple portals. So that each time you portal a history entry is created. Each time you walk back in a portal that you came out of all history entries below that will be dropped. Also, if you walk into a portal you walked into before all history entries after that entry will be dropped. This helps to keep the portal history files from growing and growing because of teleport such as /tpa and other teleports.
After a very very very long period of time a player's teleport history files may become slightly large. This can be fixed simply by deleting the files thus erasing the player's history. Do not worry though as this will take quite a bit of time to actually happen. Also each player has two files created which take a minimum of 8KB on most systems just for the two file allocations. However, the files will not actually grow until they exceeds 4KB.
I hope to one day eliminate the file per player and use a more complex format, but at the moment this is one of the best ways to keep the code simple and ensure that if a server crash does happen that the players can be fairly well assured that their portal history was saved.
The code actually checks locations using a 30 block spherical radius. This means that two portals next to each other will likely be considered the same portal. But, this is not a major problem or a problem at all for most players.
But, most servers have quite a large amount of disk space so do not be afraid. I may add in the ability for it to automatically delete a player's portal history after they have been inactive for quite some time and it could do this in the background with out effecting performance. Or, I may devise a better way to keep the portal history from growing and growing over a long period of time by possibly being able to detect if the portal even still exists.
The source code is contained in the JAR that you download. Just extract the JAR using a unzip utility. You are free to change, modify, or release the code as your own plugin. Or, if you like you can submit a patch to me and I can apply it, credit your name, and upload the new version.
- 7 comments