Package io.papermc.paper.event.world

# Class StructuresLocateEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.world.WorldEvent
io.papermc.paper.event.world.StructuresLocateEvent

All Implemented Interfaces:
  `Cancellable`

public class StructuresLocateEvent extends WorldEvent implements Cancellable
Called before a set of configured structures is located. This happens when:

- The /locate command is used.
- An Eye of Ender is used.
- An Explorer/Treasure Map is activated.
- A dolphin swims to a treasure location.
- A trade is done with a villager for a map.
- `World.locateNearestStructure(Location, org.bukkit.StructureType, int, boolean)` is invoked.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static final record`
`StructuresLocateEvent.Result`
Result for `StructuresLocateEvent`.

## Constructor Summary

Constructors
Constructor
Description
`StructuresLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull List<ConfiguredStructure> configuredStructures, int radius, boolean findUnexplored)`

## Method Summary

Modifier and Type
Method
Description
`@NotNull List<ConfiguredStructure>`
`getConfiguredStructures()`
Gets a mutable list of ConfiguredStructures that are valid targets for the search.
`static @NotNull HandlerList`
`getHandlerList()`
`@NotNull HandlerList`
`getHandlers()`
`@NotNull Location`
`getOrigin()`
Gets the `Location` from which the search is to be conducted.
`int`
`getRadius()`
Gets the search radius in which to attempt locating the structure.
`@Nullable StructuresLocateEvent.Result`
`getResult()`
Gets the `Location` and `ConfiguredStructure` set as the result, if it was defined.
`boolean`
`isCancelled()`
Gets the cancellation state of this event.
`void`
`setCancelled(boolean cancel)`
Sets the cancellation state of this event.
`void`
`setConfiguredStructures(@NotNull List<ConfiguredStructure> configuredStructures)`
Sets the list of ConfiguredStructures that are valid targets for the search.
`void`
`setFindUnexplored(boolean findUnexplored)`
Sets whether to search exclusively for unexplored structures.
`void`
`setRadius(int radius)`
Sets the search radius in which to attempt locating the structure.
`void`
`setResult(@Nullable StructuresLocateEvent.Result result)`
Sets the result `Location` and `ConfiguredStructure`.
`boolean`
`shouldFindUnexplored()`
Gets whether to search exclusively for unexplored structures.

### Methods inherited from class org.bukkit.event.world.WorldEvent

`getWorld`

### Methods inherited from class org.bukkit.event.Event

`callEvent, getEventName, isAsynchronous`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### StructuresLocateEvent

public StructuresLocateEvent(@NotNull @NotNull World world, @NotNull @NotNull Location origin, @NotNull @NotNull List<ConfiguredStructure> configuredStructures, int radius, boolean findUnexplored)

## Method Details

### getOrigin

@NotNull public @NotNull Location getOrigin()
Gets the `Location` from which the search is to be conducted.

Returns:
  `Location` where search begins

### getResult

@Nullable public @Nullable StructuresLocateEvent.Result getResult()
Gets the `Location` and `ConfiguredStructure` set as the result, if it was defined.

Returns `null` if it has not been set by `setResult(Result)`. Since this event fires before the search is done, the actual result is unknown at this point.

Returns:
  The result location and structure, if it has been set. null if it has not.
See Also:
  - `World.locateNearestStructure(Location, org.bukkit.StructureType, int, boolean)`

### setResult

public void setResult(@Nullable @Nullable StructuresLocateEvent.Result result)
Sets the result `Location` and `ConfiguredStructure`. This causes the search to be skipped, and the result object passed here to be used as the result.

Parameters:
  `result` - the `Location` and `ConfiguredStructure` of the search.

### getConfiguredStructures

@NotNull public @NotNull List<ConfiguredStructure> getConfiguredStructures()
Gets a mutable list of ConfiguredStructures that are valid targets for the search.

Returns:
  a mutable list of ConfiguredStructures

### setConfiguredStructures

public void setConfiguredStructures(@NotNull @NotNull List<ConfiguredStructure> configuredStructures)
Sets the list of ConfiguredStructures that are valid targets for the search.

Parameters:
  `configuredStructures` - a list of ConfiguredStructure targets

### getRadius

public int getRadius()
Gets the search radius in which to attempt locating the structure.

This radius may not always be obeyed during the structure search!

Returns:
  the search radius.

### setRadius

public void setRadius(int radius)
Sets the search radius in which to attempt locating the structure.

This radius may not always be obeyed during the structure search!

Parameters:
  `radius` - the search radius.

### shouldFindUnexplored

public boolean shouldFindUnexplored()
Gets whether to search exclusively for unexplored structures.

As with the search radius, this value is not always obeyed.

Returns:
  Whether to search for only unexplored structures.

### setFindUnexplored

public void setFindUnexplored(boolean findUnexplored)
Sets whether to search exclusively for unexplored structures.

As with the search radius, this value is not always obeyed.

Parameters:
  `findUnexplored` - Whether to search for only unexplored structures.

### isCancelled

public boolean isCancelled()
Description copied from interface: `Cancellable`
Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins

Specified by:
  `isCancelled` in interface `Cancellable`
Returns:
  true if this event is cancelled

### setCancelled

public void setCancelled(boolean cancel)
Description copied from interface: `Cancellable`
Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.

Specified by:
  `setCancelled` in interface `Cancellable`
Parameters:
  `cancel` - true if you wish to cancel this event

### getHandlers

@NotNull public @NotNull HandlerList getHandlers()

Specified by:
  `getHandlers` in class `Event`

### getHandlerList

@NotNull public static @NotNull HandlerList getHandlerList()