Skip to content

Commit

Permalink
Add option to hide waypoints that are in different worlds as the player
Browse files Browse the repository at this point in the history
  • Loading branch information
Sytm committed Aug 7, 2024
1 parent ebe37b1 commit c5f139e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions waypoints/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c5f139e

Please sign in to comment.