Add StructuresLocateEvent as replacement for StructureLocateEvent (#7524)
Dieser Commit ist enthalten in:
Ursprung
753bf2c103
Commit
15b6b3db2c
112
patches/api/0256-Add-PaperRegistry.patch
Normale Datei
112
patches/api/0256-Add-PaperRegistry.patch
Normale Datei
@ -0,0 +1,112 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 2 Mar 2022 13:36:21 -0800
|
||||
Subject: [PATCH] Add PaperRegistry
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/registry/Reference.java b/src/main/java/io/papermc/paper/registry/Reference.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d880810cbf05bc45051fe29515054211572e33b4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/Reference.java
|
||||
@@ -0,0 +1,43 @@
|
||||
+package io.papermc.paper.registry;
|
||||
+
|
||||
+import org.bukkit.Keyed;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.Registry;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a reference to a server-backed registry value that may
|
||||
+ * change.
|
||||
+ *
|
||||
+ * @param <T> type of the value
|
||||
+ */
|
||||
+public interface Reference<T extends Keyed> extends Keyed {
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the value from the registry with the key.
|
||||
+ *
|
||||
+ * @return the value
|
||||
+ * @throws java.util.NoSuchElementException if there is no value with this key
|
||||
+ */
|
||||
+ @NotNull T value();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the value from the registry with the key.
|
||||
+ *
|
||||
+ * @return the value or null if it doesn't exist
|
||||
+ */
|
||||
+ @Nullable T valueOrNull();
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a reference to a registered value.
|
||||
+ *
|
||||
+ * @param registry the registry the value is located in
|
||||
+ * @param key the key to the value
|
||||
+ * @param <T> the type of the value
|
||||
+ * @return a reference
|
||||
+ */
|
||||
+ static <T extends Keyed> @NotNull Reference<T> create(@NotNull Registry<T> registry, @NotNull NamespacedKey key) {
|
||||
+ return new ReferenceImpl<>(registry, key);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/registry/ReferenceImpl.java b/src/main/java/io/papermc/paper/registry/ReferenceImpl.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f29e76a6b66ddfec12ddf8db6dcb2df6083b5982
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/ReferenceImpl.java
|
||||
@@ -0,0 +1,31 @@
|
||||
+package io.papermc.paper.registry;
|
||||
+
|
||||
+import org.bukkit.Keyed;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.Registry;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.util.NoSuchElementException;
|
||||
+
|
||||
+record ReferenceImpl<T extends Keyed>(@NotNull Registry<T> registry, @NotNull NamespacedKey key) implements Reference<T> {
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull T value() {
|
||||
+ final T value = this.registry.get(this.key);
|
||||
+ if (value == null) {
|
||||
+ throw new NoSuchElementException("No such value with key " + this.key);
|
||||
+ }
|
||||
+ return value;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @Nullable T valueOrNull() {
|
||||
+ return this.registry.get(this.key);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull NamespacedKey getKey() {
|
||||
+ return this.key;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index b24439b379be1a90dde4e6f4dbe5ca3fdd8face4..0697214210a6e87f690b9454d9651d06ca57a524 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -147,5 +147,15 @@ public interface UnsafeValues {
|
||||
* Use this when sending custom packets, so that there are no collisions on the client or server.
|
||||
*/
|
||||
public int nextEntityId();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the server-backed registry for a type.
|
||||
+ *
|
||||
+ * @param classOfT type
|
||||
+ * @param <T> type
|
||||
+ * @return the server-backed registry
|
||||
+ * @throws IllegalArgumentException if there isn't a registry for that type
|
||||
+ */
|
||||
+ <T extends Keyed> @org.jetbrains.annotations.NotNull Registry<T> registryFor(Class<T> classOfT);
|
||||
// Paper end
|
||||
}
|
@ -1,167 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: dfsek <dfsek@protonmail.com>
|
||||
Date: Tue, 15 Sep 2020 21:59:16 -0700
|
||||
Subject: [PATCH] Add StructureLocateEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/world/StructureLocateEvent.java b/src/main/java/io/papermc/paper/event/world/StructureLocateEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..45b6694fc5741831e2df638b1f760a3ca28a4907
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/world/StructureLocateEvent.java
|
||||
@@ -0,0 +1,155 @@
|
||||
+package io.papermc.paper.event.world;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.StructureType;
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.world.WorldEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Called <b>before</b> a structure/feature is located.
|
||||
+ * This happens when:
|
||||
+ * <ul>
|
||||
+ * <li>The /locate command is used.<br></li>
|
||||
+ * <li>An Eye of Ender is used.</li>
|
||||
+ * <li>An Explorer/Treasure Map is activated.</li>
|
||||
+ * <li>{@link World#locateNearestStructure(Location, StructureType, int, boolean)} is invoked.</li>
|
||||
+ * </ul>
|
||||
+ */
|
||||
+public class StructureLocateEvent extends WorldEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final Location origin;
|
||||
+ private Location result = null;
|
||||
+ private StructureType type;
|
||||
+ private int radius;
|
||||
+ private boolean findUnexplored;
|
||||
+ private boolean cancelled = false;
|
||||
+
|
||||
+ public StructureLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored) {
|
||||
+ super(world);
|
||||
+ this.origin = origin;
|
||||
+ this.type = structureType;
|
||||
+ this.radius = radius;
|
||||
+ 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.
|
||||
+ * @see World#locateNearestStructure(Location, StructureType, int, boolean)
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Location getResult() {
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the result {@link Location}. This causes the search to be skipped, and the location passed here to be used as the result.
|
||||
+ *
|
||||
+ * @param result the {@link Location} of the structure.
|
||||
+ */
|
||||
+ public void setResult(@Nullable Location result) {
|
||||
+ this.result = result;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link StructureType} that is to be located.
|
||||
+ *
|
||||
+ * @return the structure type.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public StructureType getType() {
|
||||
+ return type;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the {@link StructureType} that is to be located.
|
||||
+ *
|
||||
+ * @param type the structure type.
|
||||
+ */
|
||||
+ public void setType(@NotNull StructureType type) {
|
||||
+ this.type = type;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link Location} from which the search is to be conducted.
|
||||
+ *
|
||||
+ * @return {@link Location} where search begins
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Location getOrigin() {
|
||||
+ return origin;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the search radius in which to attempt locating the structure.
|
||||
+ * <p>
|
||||
+ * This radius may not always be obeyed during the structure search!
|
||||
+ *
|
||||
+ * @return the search radius.
|
||||
+ */
|
||||
+ public int getRadius() {
|
||||
+ return radius;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the search radius in which to attempt locating the structure.
|
||||
+ * <p>
|
||||
+ * This radius may not always be obeyed during the structure search!
|
||||
+ *
|
||||
+ * @param radius the search radius.
|
||||
+ */
|
||||
+ public void setRadius(int radius) {
|
||||
+ this.radius = radius;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets whether to search exclusively for unexplored structures.
|
||||
+ * <p>
|
||||
+ * As with the search radius, this value is not always obeyed.
|
||||
+ *
|
||||
+ * @return Whether to search for only unexplored structures.
|
||||
+ */
|
||||
+ public boolean shouldFindUnexplored() {
|
||||
+ return findUnexplored;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets whether to search exclusively for unexplored structures.
|
||||
+ * <p>
|
||||
+ * As with the search radius, this value is not always obeyed.
|
||||
+ *
|
||||
+ * @param findUnexplored Whether to search for only unexplored structures.
|
||||
+ */
|
||||
+ public void setFindUnexplored(boolean findUnexplored) {
|
||||
+ this.findUnexplored = findUnexplored;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+}
|
461
patches/api/0257-Add-StructuresLocateEvent.patch
Normale Datei
461
patches/api/0257-Add-StructuresLocateEvent.patch
Normale Datei
@ -0,0 +1,461 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: dfsek <dfsek@protonmail.com>
|
||||
Date: Tue, 15 Sep 2020 21:59:16 -0700
|
||||
Subject: [PATCH] Add StructuresLocateEvent
|
||||
|
||||
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/world/StructureLocateEvent.java b/src/main/java/io/papermc/paper/event/world/StructureLocateEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0c83a02059d65672ff191c42932d850950e9ea00
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/world/StructureLocateEvent.java
|
||||
@@ -0,0 +1,157 @@
|
||||
+package io.papermc.paper.event.world;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.StructureType;
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.world.WorldEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Called <b>before</b> a structure/feature is located.
|
||||
+ * This happens when:
|
||||
+ * <ul>
|
||||
+ * <li>The /locate command is used.<br></li>
|
||||
+ * <li>An Eye of Ender is used.</li>
|
||||
+ * <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)
|
||||
+public class StructureLocateEvent extends WorldEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final Location origin;
|
||||
+ private Location result = null;
|
||||
+ private StructureType type;
|
||||
+ private int radius;
|
||||
+ private boolean findUnexplored;
|
||||
+ private boolean cancelled = false;
|
||||
+
|
||||
+ public StructureLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored) {
|
||||
+ super(world);
|
||||
+ this.origin = origin;
|
||||
+ this.type = structureType;
|
||||
+ this.radius = radius;
|
||||
+ 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.
|
||||
+ * @see World#locateNearestStructure(Location, StructureType, int, boolean)
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Location getResult() {
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the result {@link Location}. This causes the search to be skipped, and the location passed here to be used as the result.
|
||||
+ *
|
||||
+ * @param result the {@link Location} of the structure.
|
||||
+ */
|
||||
+ public void setResult(@Nullable Location result) {
|
||||
+ this.result = result;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link StructureType} that is to be located.
|
||||
+ *
|
||||
+ * @return the structure type.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public StructureType getType() {
|
||||
+ return type;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the {@link StructureType} that is to be located.
|
||||
+ *
|
||||
+ * @param type the structure type.
|
||||
+ */
|
||||
+ public void setType(@NotNull StructureType type) {
|
||||
+ this.type = type;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link Location} from which the search is to be conducted.
|
||||
+ *
|
||||
+ * @return {@link Location} where search begins
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Location getOrigin() {
|
||||
+ return origin;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the search radius in which to attempt locating the structure.
|
||||
+ * <p>
|
||||
+ * This radius may not always be obeyed during the structure search!
|
||||
+ *
|
||||
+ * @return the search radius.
|
||||
+ */
|
||||
+ public int getRadius() {
|
||||
+ return radius;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the search radius in which to attempt locating the structure.
|
||||
+ * <p>
|
||||
+ * This radius may not always be obeyed during the structure search!
|
||||
+ *
|
||||
+ * @param radius the search radius.
|
||||
+ */
|
||||
+ public void setRadius(int radius) {
|
||||
+ this.radius = radius;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets whether to search exclusively for unexplored structures.
|
||||
+ * <p>
|
||||
+ * As with the search radius, this value is not always obeyed.
|
||||
+ *
|
||||
+ * @return Whether to search for only unexplored structures.
|
||||
+ */
|
||||
+ public boolean shouldFindUnexplored() {
|
||||
+ return findUnexplored;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets whether to search exclusively for unexplored structures.
|
||||
+ * <p>
|
||||
+ * As with the search radius, this value is not always obeyed.
|
||||
+ *
|
||||
+ * @param findUnexplored Whether to search for only unexplored structures.
|
||||
+ */
|
||||
+ public void setFindUnexplored(boolean findUnexplored) {
|
||||
+ this.findUnexplored = findUnexplored;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+}
|
||||
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
|
||||
index 0000000000000000000000000000000000000000..566f9df8f615142e14330965f3491f4e83846783
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java
|
||||
@@ -0,0 +1,164 @@
|
||||
+package io.papermc.paper.event.world;
|
||||
+
|
||||
+import io.papermc.paper.world.structure.ConfiguredStructure;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.world.WorldEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+
|
||||
+/**
|
||||
+ * Called <b>before</b> a set of configured structures is located.
|
||||
+ * This happens when:
|
||||
+ * <ul>
|
||||
+ * <li>The /locate command is used.<br></li>
|
||||
+ * <li>An Eye of Ender is used.</li>
|
||||
+ * <li>An Explorer/Treasure Map is activated.</li>
|
||||
+ * <li>A dolphin swims to a treasure location.</li>
|
||||
+ * <li>A trade is done with a villager for a map.</li>
|
||||
+ * <li>{@link World#locateNearestStructure(Location, org.bukkit.StructureType, int, boolean)} is invoked.</li>
|
||||
+ * </ul>
|
||||
+ */
|
||||
+public class StructuresLocateEvent extends WorldEvent implements Cancellable {
|
||||
+
|
||||
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
+
|
||||
+ private final Location origin;
|
||||
+ private Result result;
|
||||
+ private List<ConfiguredStructure> configuredStructures;
|
||||
+ private int radius;
|
||||
+ private boolean findUnexplored;
|
||||
+ private boolean cancelled;
|
||||
+
|
||||
+ public StructuresLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull List<ConfiguredStructure> configuredStructures, int radius, boolean findUnexplored) {
|
||||
+ super(world);
|
||||
+ this.origin = origin;
|
||||
+ this.configuredStructures = configuredStructures;
|
||||
+ this.radius = radius;
|
||||
+ this.findUnexplored = findUnexplored;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link Location} from which the search is to be conducted.
|
||||
+ *
|
||||
+ * @return {@link Location} where search begins
|
||||
+ */
|
||||
+ public @NotNull Location getOrigin() {
|
||||
+ return this.origin;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link Location} and {@link ConfiguredStructure} set as the result, if it was defined.
|
||||
+ * <p>
|
||||
+ * 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.StructureType, int, boolean)
|
||||
+ */
|
||||
+ public @Nullable Result getResult() {
|
||||
+ return this.result;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the result {@link Location} and {@link ConfiguredStructure}. This causes the search to be
|
||||
+ * skipped, and the result object passed here to be used as the result.
|
||||
+ *
|
||||
+ * @param result the {@link Location} and {@link ConfiguredStructure} of the search.
|
||||
+ */
|
||||
+ public void setResult(@Nullable Result result) {
|
||||
+ this.result = result;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets a mutable list of ConfiguredStructures that are valid targets for the search.
|
||||
+ *
|
||||
+ * @return a mutable list of ConfiguredStructures
|
||||
+ */
|
||||
+ public @NotNull List<ConfiguredStructure> getConfiguredStructures() {
|
||||
+ return this.configuredStructures;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the list of ConfiguredStructures that are valid targets for the search.
|
||||
+ *
|
||||
+ * @param configuredStructures a list of ConfiguredStructure targets
|
||||
+ */
|
||||
+ public void setConfiguredStructures(@NotNull List<ConfiguredStructure> configuredStructures) {
|
||||
+ this.configuredStructures = new ArrayList<>(configuredStructures);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the search radius in which to attempt locating the structure.
|
||||
+ * <p>
|
||||
+ * This radius may not always be obeyed during the structure search!
|
||||
+ *
|
||||
+ * @return the search radius.
|
||||
+ */
|
||||
+ public int getRadius() {
|
||||
+ return this.radius;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the search radius in which to attempt locating the structure.
|
||||
+ * <p>
|
||||
+ * This radius may not always be obeyed during the structure search!
|
||||
+ *
|
||||
+ * @param radius the search radius.
|
||||
+ */
|
||||
+ public void setRadius(int radius) {
|
||||
+ this.radius = radius;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets whether to search exclusively for unexplored structures.
|
||||
+ * <p>
|
||||
+ * As with the search radius, this value is not always obeyed.
|
||||
+ *
|
||||
+ * @return Whether to search for only unexplored structures.
|
||||
+ */
|
||||
+ public boolean shouldFindUnexplored() {
|
||||
+ return this.findUnexplored;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets whether to search exclusively for unexplored structures.
|
||||
+ * <p>
|
||||
+ * As with the search radius, this value is not always obeyed.
|
||||
+ *
|
||||
+ * @param findUnexplored Whether to search for only unexplored structures.
|
||||
+ */
|
||||
+ public void setFindUnexplored(boolean findUnexplored) {
|
||||
+ this.findUnexplored = findUnexplored;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return this.cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+
|
||||
+ public static @NotNull HandlerList getHandlerList() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Result for {@link StructuresLocateEvent}.
|
||||
+ */
|
||||
+ public record Result(@NotNull Location position, @NotNull ConfiguredStructure configuredStructure) {
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/world/structure/ConfiguredStructure.java b/src/main/java/io/papermc/paper/world/structure/ConfiguredStructure.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..280febf7482418734558c50c22688248ac2b14f3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/world/structure/ConfiguredStructure.java
|
||||
@@ -0,0 +1,97 @@
|
||||
+package io.papermc.paper.world.structure;
|
||||
+
|
||||
+import io.papermc.paper.registry.Reference;
|
||||
+import org.bukkit.Keyed;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.Registry;
|
||||
+import org.bukkit.StructureType;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.Objects;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a configured structure each with a
|
||||
+ * {@link StructureType}. Multiple ConfiguredStructures can have
|
||||
+ * the same {@link StructureType}.
|
||||
+ */
|
||||
+public final class ConfiguredStructure implements Keyed {
|
||||
+
|
||||
+ public static final Reference<ConfiguredStructure> PILLAGER_OUTPOST = create("pillager_outpost");
|
||||
+ public static final Reference<ConfiguredStructure> MINESHAFT = create("mineshaft");
|
||||
+ public static final Reference<ConfiguredStructure> MINESHAFT_MESA = create("mineshaft_mesa");
|
||||
+ public static final Reference<ConfiguredStructure> WOODLAND_MANSION = create("mansion");
|
||||
+ public static final Reference<ConfiguredStructure> JUNGLE_TEMPLE = create("jungle_pyramid");
|
||||
+ public static final Reference<ConfiguredStructure> DESERT_PYRAMID = create("desert_pyramid");
|
||||
+ public static final Reference<ConfiguredStructure> IGLOO = create("igloo");
|
||||
+ public static final Reference<ConfiguredStructure> SHIPWRECK = create("shipwreck");
|
||||
+ public static final Reference<ConfiguredStructure> SHIPWRECK_BEACHED = create("shipwreck_beached");
|
||||
+ public static final Reference<ConfiguredStructure> SWAMP_HUT = create("swamp_hut");
|
||||
+ public static final Reference<ConfiguredStructure> STRONGHOLD = create("stronghold");
|
||||
+ public static final Reference<ConfiguredStructure> OCEAN_MONUMENT = create("monument");
|
||||
+ public static final Reference<ConfiguredStructure> OCEAN_RUIN_COLD = create("ocean_ruin_cold");
|
||||
+ public static final Reference<ConfiguredStructure> OCEAN_RUIN_WARM = create("ocean_ruin_warm");
|
||||
+ public static final Reference<ConfiguredStructure> FORTRESS = create("fortress");
|
||||
+ public static final Reference<ConfiguredStructure> NETHER_FOSSIL = create("nether_fossil");
|
||||
+ public static final Reference<ConfiguredStructure> END_CITY = create("end_city");
|
||||
+ public static final Reference<ConfiguredStructure> BURIED_TREASURE = create("buried_treasure");
|
||||
+ public static final Reference<ConfiguredStructure> BASTION_REMNANT = create("bastion_remnant");
|
||||
+ public static final Reference<ConfiguredStructure> VILLAGE_PLAINS = create("village_plains");
|
||||
+ public static final Reference<ConfiguredStructure> VILLAGE_DESERT = create("village_desert");
|
||||
+ public static final Reference<ConfiguredStructure> VILLAGE_SAVANNA = create("village_savanna");
|
||||
+ public static final Reference<ConfiguredStructure> VILLAGE_SNOWY = create("village_snowy");
|
||||
+ public static final Reference<ConfiguredStructure> VILLAGE_TAIGA = create("village_taiga");
|
||||
+ public static final Reference<ConfiguredStructure> RUINED_PORTAL_STANDARD = create("ruined_portal");
|
||||
+ public static final Reference<ConfiguredStructure> RUINED_PORTAL_DESERT = create("ruined_portal_desert");
|
||||
+ public static final Reference<ConfiguredStructure> RUINED_PORTAL_JUNGLE = create("ruined_portal_jungle");
|
||||
+ public static final Reference<ConfiguredStructure> RUINED_PORTAL_SWAMP = create("ruined_portal_swamp");
|
||||
+ public static final Reference<ConfiguredStructure> RUINED_PORTAL_MOUNTAIN = create("ruined_portal_mountain");
|
||||
+ public static final Reference<ConfiguredStructure> RUINED_PORTAL_OCEAN = create("ruined_portal_ocean");
|
||||
+ public static final Reference<ConfiguredStructure> RUINED_PORTAL_NETHER = create("ruined_portal_nether");
|
||||
+
|
||||
+ private final NamespacedKey key;
|
||||
+ private final StructureType structureType;
|
||||
+
|
||||
+ ConfiguredStructure(@NotNull NamespacedKey key, @NotNull StructureType structureType) {
|
||||
+ this.key = key;
|
||||
+ this.structureType = structureType;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull NamespacedKey getKey() {
|
||||
+ return this.key;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the structure type for this configure structure.
|
||||
+ *
|
||||
+ * @return the structure type
|
||||
+ */
|
||||
+ public @NotNull StructureType getStructureType() {
|
||||
+ return this.structureType;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean equals(Object o) {
|
||||
+ if (this == o) return true;
|
||||
+ if (o == null || getClass() != o.getClass()) return false;
|
||||
+ ConfiguredStructure structure = (ConfiguredStructure) o;
|
||||
+ return this.key.equals(structure.key) && this.structureType.equals(structure.structureType);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int hashCode() {
|
||||
+ return Objects.hash(this.key, this.structureType);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String toString() {
|
||||
+ return "ConfiguredStructure{" +
|
||||
+ "key=" + this.key +
|
||||
+ ", structureType=" + this.structureType +
|
||||
+ '}';
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Reference<ConfiguredStructure> create(@NotNull String name) {
|
||||
+ return Reference.create(Registry.CONFIGURED_STRUCTURE, NamespacedKey.minecraft(name));
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
|
||||
index a696fcaffa03af9e6c92e2ef3e12b38eb59e5db4..bfe0d98e6032c7633d6bb97382426f94fb437430 100644
|
||||
--- a/src/main/java/org/bukkit/Registry.java
|
||||
+++ b/src/main/java/org/bukkit/Registry.java
|
||||
@@ -189,6 +189,13 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
return GameEvent.getByKey(key);
|
||||
}
|
||||
};
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Configured structures.
|
||||
+ * @see io.papermc.paper.world.structure.ConfiguredStructure
|
||||
+ */
|
||||
+ Registry<io.papermc.paper.world.structure.ConfiguredStructure> CONFIGURED_STRUCTURE = Bukkit.getUnsafe().registryFor(io.papermc.paper.world.structure.ConfiguredStructure.class);
|
||||
+ // Paper end
|
||||
|
||||
/**
|
||||
* Get the object by its key.
|
@ -50,7 +50,7 @@ index b1cfea011efa985f644328486196edf5c73e72cd..67c6443c5639beafade19bc39932f30b
|
||||
* Gets the map from the given item ID.
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index 85c1f5b33e933b23946cad3c5ad37cc350ee5d3c..a17b0f540f1b0a85d16ca3e07da2fc495349a699 100644
|
||||
index 37f0acb893f886ac0605838eb03b4a935b96f85b..47b9b8b476cbc7a4ef329dbd7629195851c8f4ea 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -43,7 +43,7 @@ import org.jetbrains.annotations.Nullable;
|
@ -61,13 +61,13 @@ index 9f0048888a2fe40316154613a722d1c709fd3856..709ae1eaabd81ee712d7d6f353c4983f
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index b24439b379be1a90dde4e6f4dbe5ca3fdd8face4..4b01c6f82d172b55268fe670c1106b5038ff6eee 100644
|
||||
index 0697214210a6e87f690b9454d9651d06ca57a524..8cbd493f695229a7dad46916087aeb3159328bfe 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -147,5 +147,22 @@ public interface UnsafeValues {
|
||||
* Use this when sending custom packets, so that there are no collisions on the client or server.
|
||||
@@ -157,5 +157,22 @@ public interface UnsafeValues {
|
||||
* @throws IllegalArgumentException if there isn't a registry for that type
|
||||
*/
|
||||
public int nextEntityId();
|
||||
<T extends Keyed> @org.jetbrains.annotations.NotNull Registry<T> registryFor(Class<T> classOfT);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the item rarity of a material. The material <b>MUST</b> be an item.
|
@ -5,10 +5,10 @@ Subject: [PATCH] Expose protocol version
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 4b01c6f82d172b55268fe670c1106b5038ff6eee..2708718e0391960f9e784f38e5753d95e71de2fc 100644
|
||||
index 8cbd493f695229a7dad46916087aeb3159328bfe..45a5e148ae5582a805e350b526cfb3ad87f6f945 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -164,5 +164,12 @@ public interface UnsafeValues {
|
||||
@@ -174,5 +174,12 @@ public interface UnsafeValues {
|
||||
* @return the itemstack rarity
|
||||
*/
|
||||
public io.papermc.paper.inventory.ItemRarity getItemStackRarity(ItemStack itemStack);
|
@ -5,7 +5,7 @@ Subject: [PATCH] More World API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index a17b0f540f1b0a85d16ca3e07da2fc495349a699..b29b313dfe6342460d5f1ff085a0a61b4604d5ea 100644
|
||||
index 47b9b8b476cbc7a4ef329dbd7629195851c8f4ea..def9f0f9803e71cbe57abcffeb9114a5ab462e54 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -3645,6 +3645,114 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
@ -5,10 +5,10 @@ Subject: [PATCH] ItemStack repair check API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 2708718e0391960f9e784f38e5753d95e71de2fc..93d139cd498d0c9f616c077ce1c25e3f8e9f55b5 100644
|
||||
index 45a5e148ae5582a805e350b526cfb3ad87f6f945..d712a2c7a8ec02d3abbbcb8e616e002e5cdf1afe 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -165,6 +165,16 @@ public interface UnsafeValues {
|
||||
@@ -175,6 +175,16 @@ public interface UnsafeValues {
|
||||
*/
|
||||
public io.papermc.paper.inventory.ItemRarity getItemStackRarity(ItemStack itemStack);
|
||||
|
@ -31,10 +31,10 @@ index 709ae1eaabd81ee712d7d6f353c4983f20f6dc4f..fb8758970a76ee263fc85aaccbafb0bf
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 93d139cd498d0c9f616c077ce1c25e3f8e9f55b5..eeac5e445dba5e1eace52e908d5146c079269c17 100644
|
||||
index d712a2c7a8ec02d3abbbcb8e616e002e5cdf1afe..2141396d252cb78630181785d5ae0c17f8f7df10 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -175,6 +175,18 @@ public interface UnsafeValues {
|
||||
@@ -185,6 +185,18 @@ public interface UnsafeValues {
|
||||
*/
|
||||
public boolean isValidRepairItemStack(@org.jetbrains.annotations.NotNull ItemStack itemToBeRepaired, @org.jetbrains.annotations.NotNull ItemStack repairMaterial);
|
||||
|
@ -5,7 +5,7 @@ Subject: [PATCH] Add PlayerKickEvent causes
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 71de9f4c7f07c4c0b1155df14794de3ba8e28d69..c7d02e196d57f41c35d37e9a16d8e079a5c176ae 100644
|
||||
index d881ae7fb0c17242998c0a495ccd81802611410a..35be51b2b57acfc5dc165b22e16f499fac906e34 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -236,6 +236,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
@ -5,7 +5,7 @@ Subject: [PATCH] Add more line of sight methods
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index b29b313dfe6342460d5f1ff085a0a61b4604d5ea..abce27d50ef62f14948220272a2452874ae69836 100644
|
||||
index def9f0f9803e71cbe57abcffeb9114a5ab462e54..d149dd1d3d2703a428006e0c3ab5f9251e560882 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -76,6 +76,14 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
@ -48,7 +48,7 @@ index 0000000000000000000000000000000000000000..909617079db61b675cc7b60b44ef96b3
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 0ecff0322c3ff4e6e3c6fcaf72d0ab786ba423fa..c88eb8946d5ce145fc1cd27795826daeb7f27bff 100644
|
||||
index 7732d26277ca8b845898cb01c7623a2f175f0aaa..2af2a948dc9c0d4ad28fccb1c9a2b28d5db99203 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -53,6 +53,7 @@ import org.bukkit.util.CachedServerIcon;
|
@ -5,7 +5,7 @@ Subject: [PATCH] Add methods to find targets for lightning strikes
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index abce27d50ef62f14948220272a2452874ae69836..268d77210e47d5247ac9b82c344fac323b16a0c4 100644
|
||||
index d149dd1d3d2703a428006e0c3ab5f9251e560882..22191f733bbda0710ffae425fda1861e3c2ec87f 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -759,6 +759,37 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
@ -5,10 +5,10 @@ Subject: [PATCH] Get entity default attributes
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index eeac5e445dba5e1eace52e908d5146c079269c17..2e1ec0aa44836ab5be944cf2dbd4601dfb43aed6 100644
|
||||
index 2141396d252cb78630181785d5ae0c17f8f7df10..b78d18fc09cee98f0eac907409188c35b3c137fc 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -193,5 +193,22 @@ public interface UnsafeValues {
|
||||
@@ -203,5 +203,22 @@ public interface UnsafeValues {
|
||||
* @return the server's protocol version
|
||||
*/
|
||||
int getProtocolVersion();
|
@ -26,10 +26,10 @@ index fb8758970a76ee263fc85aaccbafb0bf1745afb8..ef7054fec75d91082be27fdd2a06469f
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 2e1ec0aa44836ab5be944cf2dbd4601dfb43aed6..329612597a2cdf556f5ca970f5409e1c77a5d911 100644
|
||||
index b78d18fc09cee98f0eac907409188c35b3c137fc..54b0fe21d3b6379e6550a3b1dc81c2a44e7699da 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -210,5 +210,14 @@ public interface UnsafeValues {
|
||||
@@ -220,5 +220,14 @@ public interface UnsafeValues {
|
||||
* @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultEntityAttributes(NamespacedKey)} first)
|
||||
*/
|
||||
@org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey);
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
In neuem Issue referenzieren
Einen Benutzer sperren