more patches done
This commit is contained in:
parent
c4ef2add48
commit
4664528315
27 changed files with 111 additions and 123 deletions
|
@ -1,81 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Fri, 19 Mar 2021 23:39:21 -0400
|
||||
Subject: [PATCH] Add ElderGuardianAppearanceEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/entity/ElderGuardianAppearanceEvent.java b/src/main/java/io/papermc/paper/event/entity/ElderGuardianAppearanceEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4cd551c8311ff8f7321ed2dc6a4efc87162dadfe
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/entity/ElderGuardianAppearanceEvent.java
|
||||
@@ -0,0 +1,69 @@
|
||||
+package io.papermc.paper.event.entity;
|
||||
+
|
||||
+import org.bukkit.entity.ElderGuardian;
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+
|
||||
+/**
|
||||
+ * Is called when an {@link org.bukkit.entity.ElderGuardian} appears in front of a {@link org.bukkit.entity.Player}.
|
||||
+ */
|
||||
+public class ElderGuardianAppearanceEvent extends EntityEvent implements Cancellable {
|
||||
+
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ private boolean cancelled;
|
||||
+ private final Player affectedPlayer;
|
||||
+
|
||||
+ public ElderGuardianAppearanceEvent(@NotNull Entity what, @NotNull Player affectedPlayer) {
|
||||
+ super(what);
|
||||
+ this.affectedPlayer = affectedPlayer;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the player affected by the guardian appearance.
|
||||
+ *
|
||||
+ * @return Player affected by the appearance
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Player getAffectedPlayer() {
|
||||
+ return affectedPlayer;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * The elder guardian playing the effect.
|
||||
+ *
|
||||
+ * @return The elder guardian
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public ElderGuardian getEntity() {
|
||||
+ return (ElderGuardian) entity;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
|
@ -1,49 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: TwoLeggedCat <80929284+TwoLeggedCat@users.noreply.github.com>
|
||||
Date: Sat, 29 May 2021 14:33:18 -0500
|
||||
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 34a9b8248409c0d077049944e40b710d97455723..77577de113b1413ed1474850b4ef8e7fd0c07dd6 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -74,6 +74,14 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
||||
*/
|
||||
@NotNull
|
||||
io.papermc.paper.world.MoonPhase getMoonPhase();
|
||||
+
|
||||
+ /**
|
||||
+ * Tell whether a line of sight exists between the given locations
|
||||
+ * @param from Location to start at
|
||||
+ * @param to target Location
|
||||
+ * @return whether a line of sight exists between {@code from} and {@code to}
|
||||
+ */
|
||||
+ public boolean lineOfSightExists(@NotNull Location from, @NotNull Location to);
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
index 330eab77547ae059f716418f71ad1d3391a57a9b..cda05df6784dd4d6a09710a416dcb71c016dabfc 100644
|
||||
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
@@ -483,6 +483,19 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
|
||||
*/
|
||||
public boolean hasLineOfSight(@NotNull Entity other);
|
||||
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Checks whether the living entity has block line of sight to the given block.
|
||||
+ * <p>
|
||||
+ * This uses the same algorithm that hostile mobs use to find the closest
|
||||
+ * player.
|
||||
+ *
|
||||
+ * @param location the location to determine line of sight to
|
||||
+ * @return true if there is a line of sight, false if not
|
||||
+ */
|
||||
+ public boolean hasLineOfSight(@NotNull Location location);
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Returns if the living entity despawns when away from players or not.
|
||||
* <p>
|
|
@ -1,511 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: dfsek <dfsek@protonmail.com>
|
||||
Date: Sat, 19 Jun 2021 20:15:29 -0700
|
||||
Subject: [PATCH] Add more LimitedRegion API
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/world/generation/ProtoWorld.java b/src/main/java/io/papermc/paper/world/generation/ProtoWorld.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..edf8d0ae398f123ab25cb7954df07f6020454dd4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/world/generation/ProtoWorld.java
|
||||
@@ -0,0 +1,319 @@
|
||||
+package io.papermc.paper.world.generation;
|
||||
+
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.block.data.BlockData;
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.generator.LimitedRegion;
|
||||
+import org.bukkit.generator.WorldInfo;
|
||||
+import org.bukkit.util.Vector;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.util.Random;
|
||||
+import java.util.function.Consumer;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a small grid of chunks in a {@link World}
|
||||
+ * with rudimentary block and entity access, for use during world generation.
|
||||
+ * <p>
|
||||
+ * A ProtoWorld is guaranteed read/write access to a 3x3 grid of chunks,
|
||||
+ * but may have access to a grid as large as 17x17. It is safest to assume
|
||||
+ * that there is only read/write access to 3x3 chunks. Some chunks outside
|
||||
+ * of the 3x3 area may be readable but not writable.
|
||||
+ * <p>
|
||||
+ * ProtoWorlds should not be stored! After they are used during
|
||||
+ * chunk generation they should be disposed of.
|
||||
+ *
|
||||
+ * @see org.bukkit.generator.BlockPopulator#populate(WorldInfo, Random, int, int, LimitedRegion)
|
||||
+ * @deprecated see {@link org.bukkit.RegionAccessor} and {@link org.bukkit.generator.LimitedRegion}
|
||||
+ */
|
||||
+@Deprecated(forRemoval = true)
|
||||
+public interface ProtoWorld {
|
||||
+ /**
|
||||
+ * Sets the block at (x, y, z) to the provided {@link BlockData}.
|
||||
+ *
|
||||
+ * @param x X coordinate in this ProtoWorld
|
||||
+ * @param y Y coordinate in this ProtoWorld
|
||||
+ * @param z Z coordinate in this ProtoWorld
|
||||
+ * @param data {@link BlockData} to set the block at the provided coordinates to.
|
||||
+ */
|
||||
+ void setBlockData(int x, int y, int z, @NotNull BlockData data);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the block at a vector location to the provided {@link BlockData}.
|
||||
+ *
|
||||
+ * @param vector {@link Vector} representing the position of the block to set.
|
||||
+ * @param data {@link BlockData} to set the block at the provided coordinates to.
|
||||
+ */
|
||||
+ default void setBlockData(@NotNull Vector vector, @NotNull BlockData data) {
|
||||
+ setBlockData(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ(), data);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the {@link BlockState} at a location.
|
||||
+ *
|
||||
+ * @param x X coordinate.
|
||||
+ * @param y Y coordinate.
|
||||
+ * @param z Z coordinate.
|
||||
+ * @param state The block state.
|
||||
+ */
|
||||
+ void setBlockState(int x, int y, int z, @NotNull BlockState state);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the {@link BlockState} at a location.
|
||||
+ *
|
||||
+ * @param location Location to set block state.
|
||||
+ * @param state The block state.
|
||||
+ */
|
||||
+ default void setBlockState(@NotNull Vector location, @NotNull BlockState state) {
|
||||
+ setBlockState(location.getBlockX(), location.getBlockY(), location.getBlockZ(), state);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link BlockState} at a location.
|
||||
+ *
|
||||
+ * @param x X coordinate.
|
||||
+ * @param y Y coordinate.
|
||||
+ * @param z Z coordinate.
|
||||
+ * @return The block state.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ BlockState getBlockState(int x, int y, int z);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link BlockState} at a location.
|
||||
+ *
|
||||
+ * @param location Location to get block state from.
|
||||
+ * @return The block state.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ default BlockState getBlockState(@NotNull Vector location) {
|
||||
+ return getBlockState(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Schedule a block update at (x, y, z).
|
||||
+ *
|
||||
+ * @param x X coordinate in this ProtoWorld
|
||||
+ * @param y Y coordinate in this ProtoWorld
|
||||
+ * @param z Z coordinate in this ProtoWorld
|
||||
+ */
|
||||
+ void scheduleBlockUpdate(int x, int y, int z);
|
||||
+
|
||||
+ /**
|
||||
+ * Schedule a block update at a vector location
|
||||
+ *
|
||||
+ * @param location {@link Vector} representing the position of the block to update.
|
||||
+ */
|
||||
+ default void scheduleBlockUpdate(@NotNull Vector location) {
|
||||
+ scheduleBlockUpdate(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Schedule a fluid update at (x, y, z).
|
||||
+ *
|
||||
+ * @param x X coordinate in this ProtoWorld
|
||||
+ * @param y Y coordinate in this ProtoWorld
|
||||
+ * @param z Z coordinate in this ProtoWorld
|
||||
+ */
|
||||
+ void scheduleFluidUpdate(int x, int y, int z);
|
||||
+
|
||||
+ /**
|
||||
+ * Schedule a fluid update at a vector location
|
||||
+ *
|
||||
+ * @param location {@link Vector} representing the position of the block to update.
|
||||
+ */
|
||||
+ default void scheduleFluidUpdate(@NotNull Vector location) {
|
||||
+ scheduleFluidUpdate(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the {@link World} object this ProtoWorld represents.
|
||||
+ * <p>
|
||||
+ * Do <b>not</b> attempt to read from/write to this world! Doing so during generation <b>will cause a deadlock!</b>
|
||||
+ *
|
||||
+ * @return The {@link World} object that this ProtoWorld represents.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ World getWorld();
|
||||
+
|
||||
+
|
||||
+ /**
|
||||
+ * Get the {@link BlockData} of the block at the provided coordinates.
|
||||
+ *
|
||||
+ * @param x X coordinate in this ProtoWorld
|
||||
+ * @param y Y coordinate in this ProtoWorld
|
||||
+ * @param z Z coordinate in this ProtoWorld
|
||||
+ * @return {@link BlockData} at the coordinates
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ BlockData getBlockData(int x, int y, int z);
|
||||
+
|
||||
+ /**
|
||||
+ * Get the {@link BlockData} of the block at the provided coordinates.
|
||||
+ *
|
||||
+ * @param vector {@link Vector} representing the position of the block to get.
|
||||
+ * @return {@link BlockData} at the coordinates
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ default BlockData getBlockData(@NotNull Vector vector) {
|
||||
+ return getBlockData(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the X-coordinate of the chunk in the center of this ProtoWorld
|
||||
+ *
|
||||
+ * @return The center chunk's X coordinate.
|
||||
+ */
|
||||
+ int getCenterChunkX();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the X-coordinate of the block in the center of this {@link ProtoWorld}
|
||||
+ *
|
||||
+ * @return The center chunk's X coordinate.
|
||||
+ */
|
||||
+ default int getCenterBlockX() {
|
||||
+ return getCenterChunkX() << 4;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the Z-coordinate of the chunk in the center of this {@link ProtoWorld}
|
||||
+ *
|
||||
+ * @return The center chunk's Z coordinate.
|
||||
+ */
|
||||
+ int getCenterChunkZ();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the Z-coordinate of the block in the center of this {@link ProtoWorld}
|
||||
+ *
|
||||
+ * @return The center chunk's Z coordinate.
|
||||
+ */
|
||||
+ default int getCenterBlockZ() {
|
||||
+ return getCenterChunkZ() << 4;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates an entity at the location represented by the given {@link Vector}
|
||||
+ *
|
||||
+ * @param loc The {@link Vector} representing the location to spawn the entity
|
||||
+ * @param type The entity to spawn
|
||||
+ * @return Resulting Entity of this method
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ default Entity spawnEntity(@NotNull Vector loc, @NotNull EntityType type) {
|
||||
+ return spawn(loc, type.getEntityClass(), CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Spawn an entity of a specific class at location represented by the given {@link Vector}
|
||||
+ *
|
||||
+ * @param location The {@link Vector} representing the location to spawn the entity at
|
||||
+ * @param clazz The class of the {@link Entity} to spawn
|
||||
+ * @param <T> The class of the {@link Entity} to spawn
|
||||
+ * @return An instance of the spawned {@link Entity}
|
||||
+ * @throws IllegalArgumentException if either parameter is null or the
|
||||
+ * {@link Entity} requested cannot be spawned
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ default <T extends Entity> T spawn(@NotNull Vector location, @NotNull Class<T> clazz) throws IllegalArgumentException {
|
||||
+ return spawn(location, clazz, CreatureSpawnEvent.SpawnReason.DEFAULT, null);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Spawn an entity of a specific class at location represented by the given {@link Vector}
|
||||
+ *
|
||||
+ * @param location The {@link Vector} representing the location to spawn the entity at
|
||||
+ * @param clazz The class of the {@link Entity} to spawn
|
||||
+ * @param <T> The class of the {@link Entity} to spawn
|
||||
+ * @param reason The reason for the entity's spawn.
|
||||
+ * @return An instance of the spawned {@link Entity}
|
||||
+ * @throws IllegalArgumentException if either parameter is null or the
|
||||
+ * {@link Entity} requested cannot be spawned
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ default <T extends Entity> T spawn(@NotNull Vector location, @NotNull Class<T> clazz, @NotNull CreatureSpawnEvent.SpawnReason reason) throws IllegalArgumentException {
|
||||
+ return spawn(location, clazz, reason, null);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Spawn an entity of a specific class at the location represented by the given {@link Vector}, with
|
||||
+ * the supplied function run before the entity is added to the world.
|
||||
+ * <br>
|
||||
+ * Note that when the function is run, the entity will not be actually in
|
||||
+ * the world. Any operation involving such as teleporting the entity is undefined
|
||||
+ * until after this function returns.
|
||||
+ *
|
||||
+ * @param location The {@link Vector} representing the location to spawn the entity at
|
||||
+ * @param clazz The class of the {@link Entity} to spawn
|
||||
+ * @param function The function to be run before the entity is spawned.
|
||||
+ * @param <T> The class of the {@link Entity} to spawn
|
||||
+ * @return An instance of the spawned {@link Entity}
|
||||
+ * @throws IllegalArgumentException if either parameter is null or the
|
||||
+ * {@link Entity} requested cannot be spawned
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ default <T extends Entity> T spawn(@NotNull Vector location, @NotNull Class<T> clazz, @Nullable Consumer<T> function) throws IllegalArgumentException {
|
||||
+ return spawn(location, clazz, CreatureSpawnEvent.SpawnReason.CUSTOM, function);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Spawn an entity of a specific class at the location represented by the given {@link Vector}, with
|
||||
+ * the supplied function run before the entity is added to the world.
|
||||
+ * <br>
|
||||
+ * Note that when the function is run, the entity will not be actually in
|
||||
+ * the world. Any operation involving such as teleporting the entity is undefined
|
||||
+ * until after this function returns.
|
||||
+ *
|
||||
+ * @param location The {@link Vector} representing the location to spawn the entity at
|
||||
+ * @param clazz The class of the {@link Entity} to spawn
|
||||
+ * @param reason The reason for the entity's spawn.
|
||||
+ * @param function The function to be run before the entity is spawned.
|
||||
+ * @param <T> The class of the {@link Entity} to spawn
|
||||
+ * @return An instance of the spawned {@link Entity}
|
||||
+ * @throws IllegalArgumentException if either parameter is null or the
|
||||
+ * {@link Entity} requested cannot be spawned
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ default <T extends Entity> T spawn(@NotNull Vector location, @NotNull Class<T> clazz, @NotNull CreatureSpawnEvent.SpawnReason reason, @Nullable Consumer<T> function) throws IllegalArgumentException {
|
||||
+ return spawn(location, clazz, function, reason);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates an entity at the location represented by the given {@link Vector}
|
||||
+ *
|
||||
+ * @param loc The {@link Vector} representing the location to spawn the entity
|
||||
+ * @param type The entity to spawn
|
||||
+ * @param reason The reason for the entity's spawn.
|
||||
+ * @return Resulting Entity of this method
|
||||
+ */
|
||||
+ @SuppressWarnings("unchecked")
|
||||
+ @NotNull
|
||||
+ default Entity spawnEntity(@NotNull Vector loc, @NotNull EntityType type, @NotNull CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ return spawn(loc, (Class<Entity>) type.getEntityClass(), reason, null);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates an entity at the location represented by the given {@link Vector}, with
|
||||
+ * the supplied function run before the entity is added to the world.
|
||||
+ * <br>
|
||||
+ * Note that when the function is run, the entity will not be actually in
|
||||
+ * the world. Any operation involving such as teleporting the entity is undefined
|
||||
+ * until after this function returns.
|
||||
+ *
|
||||
+ * @param loc The {@link Vector} representing the location to spawn the entity
|
||||
+ * @param type The entity to spawn
|
||||
+ * @param reason The reason for the entity's spawn.
|
||||
+ * @param function The function to be run before the entity is spawned.
|
||||
+ * @return Resulting Entity of this method
|
||||
+ */
|
||||
+ @SuppressWarnings("unchecked")
|
||||
+ @NotNull
|
||||
+ default Entity spawnEntity(@NotNull Vector loc, @NotNull EntityType type, @NotNull CreatureSpawnEvent.SpawnReason reason, @Nullable Consumer<Entity> function) {
|
||||
+ return spawn(loc, (Class<Entity>) type.getEntityClass(), reason, function);
|
||||
+ }
|
||||
+
|
||||
+ @NotNull <T extends Entity> T spawn(@NotNull Vector location, @NotNull Class<T> clazz, @Nullable Consumer<T> function, @NotNull CreatureSpawnEvent.SpawnReason reason) throws IllegalArgumentException;
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/generator/ChunkGenerator.java b/src/main/java/org/bukkit/generator/ChunkGenerator.java
|
||||
index 0667315e2bd10254aef59c2a6bcceee9d927b6d5..e96d8877f73de12a56a2b36e32381a0b48bce297 100644
|
||||
--- a/src/main/java/org/bukkit/generator/ChunkGenerator.java
|
||||
+++ b/src/main/java/org/bukkit/generator/ChunkGenerator.java
|
||||
@@ -343,6 +343,20 @@ public abstract class ChunkGenerator {
|
||||
return new ArrayList<BlockPopulator>();
|
||||
}
|
||||
|
||||
+
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Generate decorations in a chunk, with quick access to its neighbors.
|
||||
+ *
|
||||
+ * @param world ProtoWorld to generate decorations with.
|
||||
+ * @deprecated use and override {@link BlockPopulator#populate(WorldInfo, Random, int, int, LimitedRegion)}
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ public void generateDecorations(@NotNull io.papermc.paper.world.generation.ProtoWorld world) {
|
||||
+ // Do nothing by default to maintain compatibility with existing generators.
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Gets a fixed spawn location to use for a given world.
|
||||
* <p>
|
||||
diff --git a/src/main/java/org/bukkit/generator/LimitedRegion.java b/src/main/java/org/bukkit/generator/LimitedRegion.java
|
||||
index 85faeeeef908243aa5f172284784e7e67995ebfb..e0b249d328f7671894cea94bc00d54ab54aacd36 100644
|
||||
--- a/src/main/java/org/bukkit/generator/LimitedRegion.java
|
||||
+++ b/src/main/java/org/bukkit/generator/LimitedRegion.java
|
||||
@@ -4,6 +4,12 @@ import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.RegionAccessor;
|
||||
import org.bukkit.block.BlockState;
|
||||
+// Paper start
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.block.data.BlockData;
|
||||
+import org.bukkit.util.Vector;
|
||||
+// Paper end
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -53,4 +59,137 @@ public interface LimitedRegion extends RegionAccessor {
|
||||
*/
|
||||
@NotNull
|
||||
List<BlockState> getTileEntities();
|
||||
+
|
||||
+
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Sets the block at a vector location to the provided {@link BlockData}.
|
||||
+ *
|
||||
+ * @param vector {@link Vector} representing the position of the block to set.
|
||||
+ * @param data {@link BlockData} to set the block at the provided coordinates to.
|
||||
+ */
|
||||
+ default void setBlockData(@NotNull Vector vector, @NotNull BlockData data) {
|
||||
+ setBlockData(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ(), data);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the {@link BlockState} at a location.
|
||||
+ *
|
||||
+ * @param x X coordinate.
|
||||
+ * @param y Y coordinate.
|
||||
+ * @param z Z coordinate.
|
||||
+ * @param state The block state.
|
||||
+ */
|
||||
+ void setBlockState(int x, int y, int z, @NotNull BlockState state);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the {@link BlockState} at a location.
|
||||
+ *
|
||||
+ * @param location Location to set block state.
|
||||
+ * @param state The block state.
|
||||
+ */
|
||||
+ default void setBlockState(@NotNull Vector location, @NotNull BlockState state) {
|
||||
+ setBlockState(location.getBlockX(), location.getBlockY(), location.getBlockZ(), state);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link BlockState} at a location.
|
||||
+ *
|
||||
+ * @param location Location to get block state from.
|
||||
+ * @return The block state.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ default BlockState getBlockState(@NotNull Vector location) {
|
||||
+ return getBlockState(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Schedules a block update at (x, y, z).
|
||||
+ *
|
||||
+ * @param x X coordinate
|
||||
+ * @param y Y coordinate
|
||||
+ * @param z Z coordinate
|
||||
+ */
|
||||
+ void scheduleBlockUpdate(int x, int y, int z);
|
||||
+
|
||||
+ /**
|
||||
+ * Schedules a block update at a vector location.
|
||||
+ *
|
||||
+ * @param location {@link Vector} representing the position of the block to update.
|
||||
+ */
|
||||
+ default void scheduleBlockUpdate(@NotNull Vector location) {
|
||||
+ scheduleBlockUpdate(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Schedules a fluid update at (x, y, z).
|
||||
+ *
|
||||
+ * @param x X coordinate
|
||||
+ * @param y Y coordinate
|
||||
+ * @param z Z coordinate
|
||||
+ */
|
||||
+ void scheduleFluidUpdate(int x, int y, int z);
|
||||
+
|
||||
+ /**
|
||||
+ * Schedules a fluid update at a vector location.
|
||||
+ *
|
||||
+ * @param location {@link Vector} representing the position of the block to update.
|
||||
+ */
|
||||
+ default void scheduleFluidUpdate(@NotNull Vector location) {
|
||||
+ scheduleFluidUpdate(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link World} object this region represents.
|
||||
+ * <p>
|
||||
+ * Do <b>not</b> attempt to read from/write to this world! Doing so during generation <b>will cause a deadlock!</b>
|
||||
+ *
|
||||
+ * @return The {@link World} object that this region represents.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ World getWorld();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link BlockData} of the block at the provided coordinates.
|
||||
+ *
|
||||
+ * @param vector {@link Vector} representing the position of the block to get.
|
||||
+ * @return {@link BlockData} at the coordinates
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ default BlockData getBlockData(@NotNull Vector vector) {
|
||||
+ return getBlockData(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the X-coordinate of the chunk in the center of the region.
|
||||
+ *
|
||||
+ * @return The center chunk's X coordinate.
|
||||
+ */
|
||||
+ int getCenterChunkX();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the X-coordinate of the block in the center of the region.
|
||||
+ *
|
||||
+ * @return The center chunk's X coordinate.
|
||||
+ */
|
||||
+ default int getCenterBlockX() {
|
||||
+ return getCenterChunkX() << 4;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the Z-coordinate of the chunk in the center of the region.
|
||||
+ *
|
||||
+ * @return The center chunk's Z coordinate.
|
||||
+ */
|
||||
+ int getCenterChunkZ();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the Z-coordinate of the block in the center of the region.
|
||||
+ *
|
||||
+ * @return The center chunk's Z coordinate.
|
||||
+ */
|
||||
+ default int getCenterBlockZ() {
|
||||
+ return getCenterChunkZ() << 4;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,173 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Fri, 28 May 2021 21:06:59 -0400
|
||||
Subject: [PATCH] Missing Entity Behavior API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/AbstractHorse.java b/src/main/java/org/bukkit/entity/AbstractHorse.java
|
||||
index 2bbf1d074b7d46e176f2589db7abe5e3ef47871c..e023ed37963177e35bfe78105768ca6b2af6c2a1 100644
|
||||
--- a/src/main/java/org/bukkit/entity/AbstractHorse.java
|
||||
+++ b/src/main/java/org/bukkit/entity/AbstractHorse.java
|
||||
@@ -105,4 +105,54 @@ public interface AbstractHorse extends Vehicle, InventoryHolder, Tameable {
|
||||
@NotNull
|
||||
@Override
|
||||
public AbstractHorseInventory getInventory();
|
||||
+
|
||||
+ // Paper start - Horse API
|
||||
+ /**
|
||||
+ * Gets if a horse is in their eating grass animation.
|
||||
+ *
|
||||
+ * @return eating grass animation is active
|
||||
+ */
|
||||
+ public boolean isEatingGrass();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets if a horse is in their eating grass animation.
|
||||
+ *
|
||||
+ * <p>When true, the horse will lower its neck.</p>
|
||||
+ *
|
||||
+ * @param eating eating grass animation is active
|
||||
+ */
|
||||
+ public void setEatingGrass(boolean eating);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets if a horse is in their rearing animation.
|
||||
+ *
|
||||
+ * @return rearing animation is active
|
||||
+ */
|
||||
+ public boolean isRearing();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets if a horse is in their rearing animation.
|
||||
+ *
|
||||
+ * <p>When true, the horse will stand on its hind legs.</p>
|
||||
+ *
|
||||
+ * @param rearing rearing animation is active
|
||||
+ */
|
||||
+ public void setRearing(boolean rearing);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets if a horse is in their eating animation.
|
||||
+ *
|
||||
+ * @return eating animation is active
|
||||
+ */
|
||||
+ public boolean isEating();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets if a horse is in their eating animation.
|
||||
+ *
|
||||
+ * <p>When true, the horse will bob its head.</p>
|
||||
+ *
|
||||
+ * @param eating eating animation is active
|
||||
+ */
|
||||
+ public void setEating(boolean eating);
|
||||
+ // Paper end - Horse API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Cat.java b/src/main/java/org/bukkit/entity/Cat.java
|
||||
index c2a566b864c82ffb094b7334d9e6e25a1bfc87d1..c340fecb61bac66baf0f44189d21bc85289b1269 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Cat.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Cat.java
|
||||
@@ -54,4 +54,36 @@ public interface Cat extends Tameable, Sittable {
|
||||
JELLIE,
|
||||
ALL_BLACK;
|
||||
}
|
||||
+
|
||||
+ // Paper Start - More cat api
|
||||
+ /**
|
||||
+ * Sets if the cat is lying down.
|
||||
+ * This is visual and does not affect the behaviour of the cat.
|
||||
+ *
|
||||
+ * @param lyingDown whether the cat should lie down
|
||||
+ */
|
||||
+ public void setLyingDown(boolean lyingDown);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets if the cat is lying down.
|
||||
+ *
|
||||
+ * @return whether the cat is lying down
|
||||
+ */
|
||||
+ public boolean isLyingDown();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets if the cat has its head up.
|
||||
+ * This is visual and does not affect the behaviour of the cat.
|
||||
+ *
|
||||
+ * @param headUp head is up
|
||||
+ */
|
||||
+ public void setHeadUp(boolean headUp);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets if the cat has its head up.
|
||||
+ *
|
||||
+ * @return head is up
|
||||
+ */
|
||||
+ public boolean isHeadUp();
|
||||
+ // Paper End - More cat api
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Fox.java b/src/main/java/org/bukkit/entity/Fox.java
|
||||
index 498e182846b81d50b3a594254e8b341fb23e8763..3826363a1954afcddaadec7f96ac18300f8e89e9 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Fox.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Fox.java
|
||||
@@ -85,4 +85,62 @@ public interface Fox extends Animals, Sittable {
|
||||
RED,
|
||||
SNOW;
|
||||
}
|
||||
+
|
||||
+ // Paper start - Add more fox behavior API
|
||||
+ /**
|
||||
+ * Sets if the fox is interested.
|
||||
+ *
|
||||
+ * @param interested is interested
|
||||
+ */
|
||||
+ public void setInterested(boolean interested);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets if the fox is interested.
|
||||
+ *
|
||||
+ * @return fox is interested
|
||||
+ */
|
||||
+ public boolean isInterested();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets if the fox is leaping.
|
||||
+ *
|
||||
+ * @param leaping is leaping
|
||||
+ */
|
||||
+ public void setLeaping(boolean leaping);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets if the fox is leaping.
|
||||
+ *
|
||||
+ * @return fox is leaping
|
||||
+ */
|
||||
+ public boolean isLeaping();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets if the fox is defending.
|
||||
+ *
|
||||
+ * @param defending is defending
|
||||
+ */
|
||||
+ public void setDefending(boolean defending);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets if the fox is defending.
|
||||
+ *
|
||||
+ * @return fox is defending
|
||||
+ */
|
||||
+ public boolean isDefending();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets if the fox face planted.
|
||||
+ *
|
||||
+ * @param faceplanted face planted
|
||||
+ */
|
||||
+ public void setFaceplanted(boolean faceplanted);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets if the fox face planted.
|
||||
+ *
|
||||
+ * @return fox face planted
|
||||
+ */
|
||||
+ public boolean isFaceplanted();
|
||||
+ // Paper end - Add more fox behavior API
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Professor Bloodstone <git@bloodstone.dev>
|
||||
Date: Sun, 20 Jun 2021 01:48:31 +0200
|
||||
Subject: [PATCH] Add Git information to version command/on startup
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/JarManifests.java b/src/main/java/io/papermc/paper/util/JarManifests.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..02ad04c41b9c3ec68b1dcdc22c538340d8d3455b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/util/JarManifests.java
|
||||
@@ -0,0 +1,93 @@
|
||||
+/*
|
||||
+Copyright (c) 2012-2017, jcabi.com
|
||||
+All rights reserved.
|
||||
+
|
||||
+Redistribution and use in source and binary forms, with or without
|
||||
+modification, are permitted provided that the following conditions
|
||||
+are met: 1) Redistributions of source code must retain the above
|
||||
+copyright notice, this list of conditions and the following
|
||||
+disclaimer. 2) Redistributions in binary form must reproduce the above
|
||||
+copyright notice, this list of conditions and the following
|
||||
+disclaimer in the documentation and/or other materials provided
|
||||
+with the distribution. 3) Neither the name of the jcabi.com nor
|
||||
+the names of its contributors may be used to endorse or promote
|
||||
+products derived from this software without specific prior written
|
||||
+permission.
|
||||
+
|
||||
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
|
||||
+NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
+THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
+OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+*/
|
||||
+package io.papermc.paper.util;
|
||||
+
|
||||
+import java.io.IOException;
|
||||
+import java.io.InputStream;
|
||||
+import java.net.URL;
|
||||
+import java.util.*;
|
||||
+import java.util.jar.Manifest;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Modified version of jcabi-manifests
|
||||
+ *
|
||||
+ */
|
||||
+public final class JarManifests {
|
||||
+
|
||||
+ public static final JarManifests JAR_MANIFESTS = new JarManifests();
|
||||
+ public static final Map<String, String> MANIFEST_MAP;
|
||||
+
|
||||
+ static {
|
||||
+ try {
|
||||
+ MANIFEST_MAP = Collections.unmodifiableMap(JAR_MANIFESTS.getManifestMap());
|
||||
+ } catch (final IOException ex) {
|
||||
+ throw new RuntimeException(ex);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private JarManifests() {}
|
||||
+
|
||||
+ // Based on:
|
||||
+ // https://github.com/jcabi/jcabi-manifests/blob/c4e1dd22bb6099769b8d279ebe3737e5b638b278/src/main/java/com/jcabi/manifests/ClasspathMfs.java#L49-L58
|
||||
+
|
||||
+ /**
|
||||
+ * Get collection containing all META-INF/MANIFEST.MF streams
|
||||
+ *
|
||||
+ * @throws IOException if unable to get resources from classloader
|
||||
+ */
|
||||
+ public @NotNull Collection<@NotNull InputStream> getManifestStreams() throws IOException {
|
||||
+ final Enumeration<URL> resources = getClass().getClassLoader().getResources("META-INF/MANIFEST.MF");
|
||||
+ final Collection<InputStream> streams = new ArrayList<>(1);
|
||||
+ while (resources.hasMoreElements()) {
|
||||
+ streams.add(resources.nextElement().openStream());
|
||||
+ }
|
||||
+ return streams;
|
||||
+ }
|
||||
+
|
||||
+ // Based on:
|
||||
+ // https://github.com/jcabi/jcabi-manifests/blob/c4e1dd22bb6099769b8d279ebe3737e5b638b278/src/main/java/com/jcabi/manifests/Manifests.java#L209-L225
|
||||
+ // https://github.com/jcabi/jcabi-manifests/blob/c4e1dd22bb6099769b8d279ebe3737e5b638b278/src/main/java/com/jcabi/manifests/Manifests.java#L381-L388
|
||||
+
|
||||
+ /**
|
||||
+ * Get map containing entries from all manifests
|
||||
+ *
|
||||
+ * @throws IOException if unable to get manifest streams
|
||||
+ */
|
||||
+ public @NotNull Map<@NotNull String, @NotNull String> getManifestMap() throws IOException {
|
||||
+ final HashMap<String, String> attribs = new HashMap<>();
|
||||
+ for (final InputStream stream : getManifestStreams()) {
|
||||
+ for (final Map.Entry<Object, Object> attr: new Manifest(stream).getMainAttributes().entrySet()) {
|
||||
+ attribs.put(attr.getKey().toString(), attr.getValue().toString());
|
||||
+ }
|
||||
+ }
|
||||
+ return attribs;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 5ec72f013c6c94a6590e78e87d2f97e57176c6a1..a4fd6f6e51c478efa9b125d3878c246b5f762999 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -51,6 +51,7 @@ import org.bukkit.util.CachedServerIcon;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
+import io.papermc.paper.util.JarManifests; // Paper
|
||||
|
||||
/**
|
||||
* Represents the Bukkit core, for version and Server singleton handling
|
||||
@@ -86,7 +87,25 @@ public final class Bukkit {
|
||||
}
|
||||
|
||||
Bukkit.server = server;
|
||||
- server.getLogger().info("This server is running " + getName() + " version " + getVersion() + " (Implementing API version " + getBukkitVersion() + ")");
|
||||
+ // Paper start - add git information
|
||||
+ server.getLogger().info(getVersionMessage());
|
||||
+ }
|
||||
+ /**
|
||||
+ * Gets message describing the version server is running.
|
||||
+ *
|
||||
+ * @return message describing the version server is running
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public static String getVersionMessage() {
|
||||
+ Map<String, String> attributes = JarManifests.MANIFEST_MAP;
|
||||
+ @NotNull String gitBranch = attributes.get("Git-Branch");
|
||||
+ @NotNull String gitCommit = attributes.get("Git-Commit");
|
||||
+ @NotNull String branchMsg = " on " + gitBranch;
|
||||
+ if ("master".equals(gitBranch) || "main".equals(gitBranch)) {
|
||||
+ branchMsg = ""; // Don't show branch on main/master
|
||||
+ }
|
||||
+ return "This server is running " + getName() + " version " + getVersion() + " (Implementing API version " + getBukkitVersion() + ") (Git: " + gitCommit + branchMsg + ")";
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
index 4c2ddc722a9dc4011906ad9530b13fa9be1d3ff9..57a21495843f3a144cd73473cdc8781d6129b7ca 100644
|
||||
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
@@ -241,7 +241,7 @@ public class VersionCommand extends BukkitCommand {
|
||||
private void setVersionMessage(final @NotNull Component msg) {
|
||||
lastCheck = System.currentTimeMillis();
|
||||
final Component message = net.kyori.adventure.text.TextComponent.ofChildren(
|
||||
- Component.text("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")", net.kyori.adventure.text.format.NamedTextColor.WHITE),
|
||||
+ Component.text(Bukkit.getVersionMessage(), net.kyori.adventure.text.format.NamedTextColor.WHITE),
|
||||
Component.newline(),
|
||||
msg
|
||||
);
|
|
@ -1,71 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 12 Mar 2021 19:20:03 -0800
|
||||
Subject: [PATCH] Adds PlayerArmSwingEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1a4550a73e89f9cf92d2831d21bcfb46f92fd189
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java
|
||||
@@ -0,0 +1,27 @@
|
||||
+package io.papermc.paper.event.player;
|
||||
+
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
+import org.bukkit.event.player.PlayerAnimationType;
|
||||
+import org.bukkit.inventory.EquipmentSlot;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+public class PlayerArmSwingEvent extends PlayerAnimationEvent {
|
||||
+
|
||||
+ private final EquipmentSlot equipmentSlot;
|
||||
+
|
||||
+ public PlayerArmSwingEvent(@NotNull Player player, @NotNull EquipmentSlot equipmentSlot) {
|
||||
+ super(player, PlayerAnimationType.ARM_SWING);
|
||||
+ this.equipmentSlot = equipmentSlot;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the hand of the arm swing.
|
||||
+ *
|
||||
+ * @return the hand
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public EquipmentSlot getHand() {
|
||||
+ return this.equipmentSlot;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java b/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java
|
||||
index 6cd236cd1fa10ec37e6e0228c7bbd4415b39399d..4d18b0f2984b301bb2d909c9c362de4cbd4366fe 100644
|
||||
--- a/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java
|
||||
@@ -7,6 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a player animation event
|
||||
+ * <br>Use {@link io.papermc.paper.event.player.PlayerArmSwingEvent} for determining which arm was swung.
|
||||
*/
|
||||
public class PlayerAnimationEvent extends PlayerEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
@@ -18,12 +19,19 @@ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable {
|
||||
*
|
||||
* @param player The player instance
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
public PlayerAnimationEvent(@NotNull final Player player) {
|
||||
super(player);
|
||||
|
||||
// Only supported animation type for now:
|
||||
animationType = PlayerAnimationType.ARM_SWING;
|
||||
}
|
||||
+ // Paper start
|
||||
+ public PlayerAnimationEvent(@NotNull final Player player, @NotNull PlayerAnimationType animationType) {
|
||||
+ super(player);
|
||||
+ this.animationType = animationType;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
/**
|
||||
* Get the type of this animation event
|
|
@ -1,46 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 9 Jul 2021 17:44:33 -0700
|
||||
Subject: [PATCH] Add PlayerSignCommandPreprocessEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerSignCommandPreprocessEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerSignCommandPreprocessEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a51a2288bf812e7d8845a6ec70274d625ff793b6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/player/PlayerSignCommandPreprocessEvent.java
|
||||
@@ -0,0 +1,34 @@
|
||||
+package io.papermc.paper.event.player;
|
||||
+
|
||||
+import org.bukkit.block.Sign;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.Set;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a {@link Player} clicks a sign that causes a command to run.
|
||||
+ * <p>
|
||||
+ * This command is run with elevated permissions which allows players to access commands on signs they wouldn't
|
||||
+ * normally be able to run.
|
||||
+ */
|
||||
+public class PlayerSignCommandPreprocessEvent extends PlayerCommandPreprocessEvent {
|
||||
+
|
||||
+ private final Sign sign;
|
||||
+
|
||||
+ public PlayerSignCommandPreprocessEvent(@NotNull Player player, @NotNull String message, @NotNull Set<Player> recipients, @NotNull Sign sign) {
|
||||
+ super(player, message, recipients);
|
||||
+ this.sign = sign;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the sign that the command originated from.
|
||||
+ *
|
||||
+ * @return the sign
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Sign getSign() {
|
||||
+ return sign;
|
||||
+ }
|
||||
+}
|
Loading…
Add table
Add a link
Reference in a new issue