diff --git a/CHANGELOG.md b/CHANGELOG.md index df63fdd..b9d9ccf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ ### Added - Option to disallow teleports to different worlds -- Variable containing the distance between a player and waypoint for the cost formula (`distance`) +- Variable containing the distance between a player and waypoint for the cost formula (`distance`) +- Option to hide waypoints that are in different worlds as the player ## 4.5.3 diff --git a/waypoints/src/main/kotlin/de/md5lukas/waypoints/command/arguments/WaypointsSuggestionProvider.kt b/waypoints/src/main/kotlin/de/md5lukas/waypoints/command/arguments/WaypointsSuggestionProvider.kt index e1b27e0..9f81e47 100644 --- a/waypoints/src/main/kotlin/de/md5lukas/waypoints/command/arguments/WaypointsSuggestionProvider.kt +++ b/waypoints/src/main/kotlin/de/md5lukas/waypoints/command/arguments/WaypointsSuggestionProvider.kt @@ -87,6 +87,13 @@ class WaypointsSuggestionProvider( *getResolvers(sender as? Player))) } - private suspend fun shouldDiscard(sender: CommandSender, waypoint: Waypoint) = - waypoint.location.world === null || filter?.invoke(sender, waypoint) == false + private suspend fun shouldDiscard(sender: CommandSender, waypoint: Waypoint): Boolean { + if (waypoint.location.world === null) return true + if (sender is Player && plugin.waypointsConfig.general.hideWaypointsFromDifferentWorlds) { + if (sender.world != waypoint.location.world) { + return true + } + } + return filter?.invoke(sender, waypoint) == false + } } diff --git a/waypoints/src/main/kotlin/de/md5lukas/waypoints/config/general/GeneralConfiguration.kt b/waypoints/src/main/kotlin/de/md5lukas/waypoints/config/general/GeneralConfiguration.kt index 469b5b0..dc2a729 100644 --- a/waypoints/src/main/kotlin/de/md5lukas/waypoints/config/general/GeneralConfiguration.kt +++ b/waypoints/src/main/kotlin/de/md5lukas/waypoints/config/general/GeneralConfiguration.kt @@ -14,6 +14,9 @@ class GeneralConfiguration { var worldNotFound: WorldNotFoundAction = WorldNotFoundAction.SHOW private set + var hideWaypointsFromDifferentWorlds: Boolean = false + private set + val features = FeaturesConfiguration() val commands = CommandsConfiguration() diff --git a/waypoints/src/main/kotlin/de/md5lukas/waypoints/gui/pages/GUIFolderPage.kt b/waypoints/src/main/kotlin/de/md5lukas/waypoints/gui/pages/GUIFolderPage.kt index 73c5796..170a0e7 100644 --- a/waypoints/src/main/kotlin/de/md5lukas/waypoints/gui/pages/GUIFolderPage.kt +++ b/waypoints/src/main/kotlin/de/md5lukas/waypoints/gui/pages/GUIFolderPage.kt @@ -116,11 +116,16 @@ class GUIFolderPage(wpGUI: WaypointsGUI, private val guiFolder: GUIFolder) : val itr = content.iterator() while (itr.hasNext()) { val it = itr.next() - if (it is Waypoint && it.location.world === null) { - if (wpGUI.plugin.waypointsConfig.general.worldNotFound === WorldNotFoundAction.DELETE) { - it.delete() + if (it is Waypoint) { + if (it.location.world === null) { + if (wpGUI.plugin.waypointsConfig.general.worldNotFound === WorldNotFoundAction.DELETE) { + it.delete() + } + itr.remove() + } else if (wpGUI.plugin.waypointsConfig.general.hideWaypointsFromDifferentWorlds && + wpGUI.viewer.world != it.location.world) { + itr.remove() } - itr.remove() } } } diff --git a/waypoints/src/main/resources/config.yml b/waypoints/src/main/resources/config.yml index b81cc27..229cf05 100644 --- a/waypoints/src/main/resources/config.yml +++ b/waypoints/src/main/resources/config.yml @@ -46,6 +46,9 @@ general: # When set to a value greater than zero, the death waypoint will be automatically deselected after the set time autoDeselectAfter: 0s + # When this option is enabled players will only see waypoints that are in the same world as themselves. + hideWaypointsFromDifferentWorlds: false + # Specify in which worlds waypoints can be created # Players with the permission waypoints.modify.anywhere can place waypoints wherever they want. # Automatic waypoint-creation in disabled worlds will not occur