Minecraft Vanilla Warp Tools For Servers

minecraft-commandsminecraft-java-editionminecraft-java-edition-server

I'm making a server that has Warp Tools. Warp Tools are written books with a content inside saying "Throw book to warp to …" These books can be bought from my server shop. At first I made it so there's click event in the contents of the books so when a player click a text, it will teleport them to a location but found out it can't be done since certain players needs OP to do this.

My new idea is a player buys the books and a player can drop a book, then they get teleported to the location, plus getting rid of the book thrown on the ground and giving it back to the player so the player can use it unlimitedly.

My problem is, I don't know how to do this. Each book have different names and page contents. I have only tried testfor to test if a book with a specific name is dropped then say "Found Book!" and that's about it. I've thought about on how I'm going to this: testfor detects book on ground, gets player that dropped the book (gets player near the book), clear that specific book thrown on the ground, teleport player to a location, gives player back the book. I just do not know how to get the nearest player to the book that was thrown and clear the specific book that was thrown. I need to that part because multiple players could do this at the same time and can cause problems.

Best Answer

The only way I can think of is by using observer blocks. While this isn't the best way, it's the easiest way I can think of. Set some command blocks to teleport the player: /tp @p [insert coordinates] and you`re all set, only I don't know how to make it to test for an item.