Hi ! I didn't really know where to ask that question, so there you go. I was wondering if it was possible to restrict a teleport if the player has a certain item in the inventory / If one of these items has a certain enchantment example sharpness 6. If there is a plugin that already allows you to block this, I would appreciate a link to it.
It appears you’re looking for a certain plugin rather than needing help in creating one. The correct section for your thread Spigot Plugin Help. I’ve gone ahead and reported the thread so a moderator can move it accordingly
Either way, I'm fine with both. ^^ The plugin is an easy solution, but in case I'm told how to do it, even though I suppose it has to go through the same mechanics as a testfor, I'd be fine with it as well. Anyway, thank you ^^
Code (Java): private final Set<Predicate<Player>> teleportRestrictions; @EventHandler public void onTeleport(PlayerTeleportEvent event) { for (Predicate<Player> restriction : teleportRestrictions) { if (!restriction.test(player)) { event.setCancelled(true); return; } } } You can also have per player restrictions with a Map<UUID, Predicate<Player>>
Just in case. Thats how you add something to the set: Code (Java): teleportRestrictions.add((pl) -> { if (pl.getInventory().contains(Material.DIAMOND_BLOCK)) { return false; } return true; }); Spoiler: Same but shorter Code (Java): teleportRestrictions.add((pl) -> !pl.getInventory().contains(Material.DIAMOND_BLOCK)); Now he cant tp with a diamond block in its inv