[ci skip] Cleanup events (#10202)

This commit is contained in:
Lulu13022002
2024-02-01 10:15:57 +01:00
parent d676979ea0
commit f7e469eb2e
187 changed files with 2415 additions and 2258 deletions

View File

@@ -32,18 +32,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <li>An Explorer/Treasure Map is activated.</li>
+ * <li>{@link World#locateNearestStructure(Location, StructureType, int, boolean)} is invoked.</li>
+ * </ul>
+ *
+ * @deprecated no longer used, see {@link StructuresLocateEvent}
+ */
+@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21")
+public class StructureLocateEvent extends WorldEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Location origin;
+ private Location result = null;
+ private StructureType type;
+ private int radius;
+ private boolean findUnexplored;
+ private boolean cancelled = false;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public StructureLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored) {
+ super(world);
+ this.origin = origin;
@@ -52,29 +57,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.findUnexplored = findUnexplored;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ /**
+ * Gets the location set as the structure location, if it was defined.
+ * <p>
+ * Returns {@code null} if it has not been set by {@link StructureLocateEvent#setResult(Location)}.
+ * Since this event fires <i>before</i> the search is done, the actual location is unknown at this point.
+ *
+ * @return The result location, if it has been set. null if it has not.
+ * @return The result location, if it has been set. {@code null} if it has not.
+ * @see World#locateNearestStructure(Location, StructureType, int, boolean)
+ */
+ @Nullable
+ public Location getResult() {
+ return result;
+ return this.result;
+ }
+
+ /**
@@ -93,7 +87,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */
+ @NotNull
+ public StructureType getType() {
+ return type;
+ return this.type;
+ }
+
+ /**
@@ -112,7 +106,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */
+ @NotNull
+ public Location getOrigin() {
+ return origin;
+ return this.origin;
+ }
+
+ /**
@@ -123,7 +117,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return the search radius.
+ */
+ public int getRadius() {
+ return radius;
+ return this.radius;
+ }
+
+ /**
@@ -145,7 +139,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return Whether to search for only unexplored structures.
+ */
+ public boolean shouldFindUnexplored() {
+ return findUnexplored;
+ return this.findUnexplored;
+ }
+
+ /**
@@ -161,13 +155,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ return this.cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+}
diff --git a/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java b/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java
new file mode 100644
@@ -190,6 +195,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.world.WorldEvent;
+import org.bukkit.generator.structure.Structure;
+import org.bukkit.generator.structure.StructureType;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.UnmodifiableView;
@@ -217,8 +223,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private List<ConfiguredStructure> legacy$structures;
+ private int radius;
+ private boolean findUnexplored;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public StructuresLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull List<Structure> structures, int radius, boolean findUnexplored) {
+ super(world);
+ this.origin = origin;
@@ -242,8 +250,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Returns {@code null} if it has not been set by {@link StructuresLocateEvent#setResult(Result)}.
+ * Since this event fires <i>before</i> the search is done, the actual result is unknown at this point.
+ *
+ * @return The result location and structure, if it has been set. null if it has not.
+ * @see World#locateNearestStructure(Location, org.bukkit.generator.structure.StructureType, int, boolean)
+ * @return The result location and structure, if it has been set. {@code null} if it has not.
+ * @see World#locateNearestStructure(Location, StructureType, int, boolean)
+ */
+ public @Nullable Result getResult() {
+ return this.result;