mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-31 04:02:06 -07:00
More more more more more more more more more work
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 13 Sep 2018 21:39:26 -0400
|
||||
Subject: [PATCH] Add ItemStackRecipeChoice Draft API
|
||||
|
||||
This is based on Spigots Draft API. This is subject to change
|
||||
|
||||
Allows creating recipes that must match isSimilar to full item stack.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/inventory/ItemStackRecipeChoice.java b/src/main/java/com/destroystokyo/paper/inventory/ItemStackRecipeChoice.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/inventory/ItemStackRecipeChoice.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package com.destroystokyo.paper.inventory;
|
||||
+
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.bukkit.inventory.RecipeChoice;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+
|
||||
+/**
|
||||
+ * Allows crafting Items that require full matching itemstacks to complete the recipe for custom items
|
||||
+ * @deprecated Draft API
|
||||
+ */
|
||||
+@Deprecated
|
||||
+public class ItemStackRecipeChoice implements RecipeChoice {
|
||||
+
|
||||
+ protected final List<ItemStack> choices = new ArrayList<>();
|
||||
+
|
||||
+ public ItemStackRecipeChoice(ItemStack choices) {
|
||||
+ this.choices.add(choices);
|
||||
+ }
|
||||
+
|
||||
+ public ItemStackRecipeChoice(List<ItemStack> choices) {
|
||||
+ this.choices.addAll(choices);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemStack getItemStack() {
|
||||
+ return choices.isEmpty() ? null : choices.get(0);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public RecipeChoice clone() {
|
||||
+ try {
|
||||
+ ItemStackRecipeChoice clone = (ItemStackRecipeChoice) super.clone();
|
||||
+ clone.choices.addAll(this.choices);
|
||||
+ return clone;
|
||||
+ } catch (CloneNotSupportedException ex) {
|
||||
+ throw new AssertionError(ex);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean test(ItemStack itemStack) {
|
||||
+ for (ItemStack stack : choices) {
|
||||
+ if (stack.isSimilar(itemStack)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
@@ -1,105 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 22 Sep 2018 00:32:53 -0500
|
||||
Subject: [PATCH] Add LivingEntity#getTargetEntity
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/entity/TargetEntityInfo.java b/src/main/java/com/destroystokyo/paper/entity/TargetEntityInfo.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/entity/TargetEntityInfo.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package com.destroystokyo.paper.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.util.Vector;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Represents information about a targeted entity
|
||||
+ */
|
||||
+public class TargetEntityInfo {
|
||||
+ private final Entity entity;
|
||||
+ private final Vector hitVec;
|
||||
+
|
||||
+ public TargetEntityInfo(@NotNull Entity entity, @NotNull Vector hitVec) {
|
||||
+ this.entity = entity;
|
||||
+ this.hitVec = hitVec;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the entity that is targeted
|
||||
+ *
|
||||
+ * @return Targeted entity
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Entity getEntity() {
|
||||
+ return entity;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the position the entity is targeted at
|
||||
+ *
|
||||
+ * @return Targeted position
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Vector getHitVector() {
|
||||
+ return hitVec;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
@@ -0,0 +0,0 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
|
||||
*/
|
||||
@Nullable
|
||||
public com.destroystokyo.paper.block.TargetBlockInfo getTargetBlockInfo(int maxDistance, @NotNull com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets information about the entity being targeted
|
||||
+ *
|
||||
+ * @param maxDistance this is the maximum distance to scan
|
||||
+ * @return entity being targeted, or null if no entity is targeted
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public default Entity getTargetEntity(int maxDistance) {
|
||||
+ return getTargetEntity(maxDistance, false);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets information about the entity being targeted
|
||||
+ *
|
||||
+ * @param maxDistance this is the maximum distance to scan
|
||||
+ * @param ignoreBlocks true to scan through blocks
|
||||
+ * @return entity being targeted, or null if no entity is targeted
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Entity getTargetEntity(int maxDistance, boolean ignoreBlocks);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets information about the entity being targeted
|
||||
+ *
|
||||
+ * @param maxDistance this is the maximum distance to scan
|
||||
+ * @return TargetEntityInfo about the entity being targeted,
|
||||
+ * or null if no entity is targeted
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public default com.destroystokyo.paper.entity.TargetEntityInfo getTargetEntityInfo(int maxDistance) {
|
||||
+ return getTargetEntityInfo(maxDistance, false);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets information about the entity being targeted
|
||||
+ *
|
||||
+ * @param maxDistance this is the maximum distance to scan
|
||||
+ * @param ignoreBlocks true to scan through blocks
|
||||
+ * @return TargetEntityInfo about the entity being targeted,
|
||||
+ * or null if no entity is targeted
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public com.destroystokyo.paper.entity.TargetEntityInfo getTargetEntityInfo(int maxDistance, boolean ignoreBlocks);
|
||||
// Paper end
|
||||
|
||||
/**
|
File diff suppressed because it is too large
Load Diff
@@ -1,319 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Vainomaa <mikroskeem@mikroskeem.eu>
|
||||
Date: Wed, 12 Sep 2018 18:53:35 +0300
|
||||
Subject: [PATCH] Add an API for CanPlaceOn and CanDestroy NBT values
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/Namespaced.java b/src/main/java/com/destroystokyo/paper/Namespaced.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/Namespaced.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package com.destroystokyo.paper;
|
||||
+
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a namespaced resource, see {@link org.bukkit.NamespacedKey} for single elements
|
||||
+ * or {@link com.destroystokyo.paper.NamespacedTag} for a collection of elements
|
||||
+ *
|
||||
+ * Namespaces may only contain lowercase alphanumeric characters, periods,
|
||||
+ * underscores, and hyphens.
|
||||
+ * <p>
|
||||
+ * Keys may only contain lowercase alphanumeric characters, periods,
|
||||
+ * underscores, hyphens, and forward slashes.
|
||||
+ * <p>
|
||||
+ * You should not be implementing this interface yourself, use {@link org.bukkit.NamespacedKey}
|
||||
+ * or {@link com.destroystokyo.paper.NamespacedTag} as needed instead.
|
||||
+ */
|
||||
+public interface Namespaced {
|
||||
+ /**
|
||||
+ * Gets the namespace this resource is a part of
|
||||
+ * <p>
|
||||
+ * This is contractually obligated to only contain lowercase alphanumeric characters,
|
||||
+ * periods, underscores, and hyphens.
|
||||
+ *
|
||||
+ * @return resource namespace
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ String getNamespace();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the key corresponding to this resource
|
||||
+ * <p>
|
||||
+ * This is contractually obligated to only contain lowercase alphanumeric characters,
|
||||
+ * periods, underscores, hyphens, and forward slashes.
|
||||
+ *
|
||||
+ * @return resource key
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ String getKey();
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/NamespacedTag.java b/src/main/java/com/destroystokyo/paper/NamespacedTag.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/NamespacedTag.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package com.destroystokyo.paper;
|
||||
+
|
||||
+import com.google.common.base.Preconditions;
|
||||
+import java.util.Locale;
|
||||
+import java.util.UUID;
|
||||
+import java.util.regex.Pattern;
|
||||
+import org.bukkit.plugin.Plugin;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a String based key pertaining to a tagged entry. Consists of two components - a namespace
|
||||
+ * and a key.
|
||||
+ * <p>
|
||||
+ * Namespaces may only contain lowercase alphanumeric characters, periods,
|
||||
+ * underscores, and hyphens.
|
||||
+ * <p>
|
||||
+ * Keys may only contain lowercase alphanumeric characters, periods,
|
||||
+ * underscores, hyphens, and forward slashes.
|
||||
+ *
|
||||
+ */
|
||||
+// Paper - entire class, based on org.bukkit.NamespacedKey
|
||||
+public final class NamespacedTag implements com.destroystokyo.paper.Namespaced {
|
||||
+
|
||||
+ /**
|
||||
+ * The namespace representing all inbuilt keys.
|
||||
+ */
|
||||
+ public static final String MINECRAFT = "minecraft";
|
||||
+ /**
|
||||
+ * The namespace representing all keys generated by Bukkit for backwards
|
||||
+ * compatibility measures.
|
||||
+ */
|
||||
+ public static final String BUKKIT = "bukkit";
|
||||
+ //
|
||||
+ private static final Pattern VALID_NAMESPACE = Pattern.compile("[a-z0-9._-]+");
|
||||
+ private static final Pattern VALID_KEY = Pattern.compile("[a-z0-9/._-]+");
|
||||
+ //
|
||||
+ private final String namespace;
|
||||
+ private final String key;
|
||||
+
|
||||
+ /**
|
||||
+ * Create a key in a specific namespace.
|
||||
+ *
|
||||
+ * @param namespace String representing a grouping of keys
|
||||
+ * @param key Name for this specific key
|
||||
+ * @deprecated should never be used by plugins, for internal use only!!
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ public NamespacedTag(@NotNull String namespace, @NotNull String key) {
|
||||
+ Preconditions.checkArgument(namespace != null && VALID_NAMESPACE.matcher(namespace).matches(), "Invalid namespace. Must be [a-z0-9._-]: %s", namespace);
|
||||
+ Preconditions.checkArgument(key != null && VALID_KEY.matcher(key).matches(), "Invalid key. Must be [a-z0-9/._-]: %s", key);
|
||||
+
|
||||
+ this.namespace = namespace;
|
||||
+ this.key = key;
|
||||
+
|
||||
+ String string = toString();
|
||||
+ Preconditions.checkArgument(string.length() < 256, "NamespacedTag must be less than 256 characters", string);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Create a key in the plugin's namespace.
|
||||
+ * <p>
|
||||
+ * Namespaces may only contain lowercase alphanumeric characters, periods,
|
||||
+ * underscores, and hyphens.
|
||||
+ * <p>
|
||||
+ * Keys may only contain lowercase alphanumeric characters, periods,
|
||||
+ * underscores, hyphens, and forward slashes.
|
||||
+ *
|
||||
+ * @param plugin the plugin to use for the namespace
|
||||
+ * @param key the key to create
|
||||
+ */
|
||||
+ public NamespacedTag(@NotNull Plugin plugin, @NotNull String key) {
|
||||
+ Preconditions.checkArgument(plugin != null, "Plugin cannot be null");
|
||||
+ Preconditions.checkArgument(key != null, "Key cannot be null");
|
||||
+
|
||||
+ this.namespace = plugin.getName().toLowerCase(Locale.ROOT);
|
||||
+ this.key = key.toLowerCase().toLowerCase(Locale.ROOT);
|
||||
+
|
||||
+ // Check validity after normalization
|
||||
+ Preconditions.checkArgument(VALID_NAMESPACE.matcher(this.namespace).matches(), "Invalid namespace. Must be [a-z0-9._-]: %s", this.namespace);
|
||||
+ Preconditions.checkArgument(VALID_KEY.matcher(this.key).matches(), "Invalid key. Must be [a-z0-9/._-]: %s", this.key);
|
||||
+
|
||||
+ String string = toString();
|
||||
+ Preconditions.checkArgument(string.length() < 256, "NamespacedTag must be less than 256 characters (%s)", string);
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public String getNamespace() {
|
||||
+ return namespace;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public String getKey() {
|
||||
+ return key;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int hashCode() {
|
||||
+ int hash = 7;
|
||||
+ hash = 47 * hash + this.namespace.hashCode();
|
||||
+ hash = 47 * hash + this.key.hashCode();
|
||||
+ return hash;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean equals(Object obj) {
|
||||
+ if (obj == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (getClass() != obj.getClass()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ final NamespacedTag other = (NamespacedTag) obj;
|
||||
+ return this.namespace.equals(other.namespace) && this.key.equals(other.key);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String toString() {
|
||||
+ return "#" + this.namespace + ":" + this.key;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Return a new random key in the {@link #BUKKIT} namespace.
|
||||
+ *
|
||||
+ * @return new key
|
||||
+ * @deprecated should never be used by plugins, for internal use only!!
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ public static NamespacedTag randomKey() {
|
||||
+ return new NamespacedTag(BUKKIT, UUID.randomUUID().toString());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get a key in the Minecraft namespace.
|
||||
+ *
|
||||
+ * @param key the key to use
|
||||
+ * @return new key in the Minecraft namespace
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public static NamespacedTag minecraft(@NotNull String key) {
|
||||
+ return new NamespacedTag(MINECRAFT, key);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/NamespacedKey.java b/src/main/java/org/bukkit/NamespacedKey.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/NamespacedKey.java
|
||||
+++ b/src/main/java/org/bukkit/NamespacedKey.java
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
|
||||
* underscores, hyphens, and forward slashes.
|
||||
*
|
||||
*/
|
||||
-public final class NamespacedKey implements net.kyori.adventure.key.Key { // Paper - implement Key
|
||||
+public final class NamespacedKey implements net.kyori.adventure.key.Key, com.destroystokyo.paper.Namespaced { // Paper - implement Key and Namespaced
|
||||
|
||||
/**
|
||||
* The namespace representing all inbuilt keys.
|
||||
@@ -0,0 +0,0 @@ public final class NamespacedKey implements net.kyori.adventure.key.Key { // Pap
|
||||
}
|
||||
|
||||
@NotNull
|
||||
+ @Override // Paper
|
||||
public String getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
+ @Override // Paper
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
|
||||
@@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
|
||||
@SuppressWarnings("javadoc")
|
||||
@NotNull
|
||||
ItemMeta clone();
|
||||
+
|
||||
+ // Paper start - Add an API for CanPlaceOn and CanDestroy NBT values
|
||||
+ /**
|
||||
+ * Gets set of materials what given item can destroy in {@link org.bukkit.GameMode#ADVENTURE}
|
||||
+ *
|
||||
+ * @return Set of materials
|
||||
+ * @deprecated Minecraft does not limit this to the material enum, Use {@link #getDestroyableKeys()} as a replacement
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ Set<org.bukkit.Material> getCanDestroy();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets set of materials what given item can destroy in {@link org.bukkit.GameMode#ADVENTURE}
|
||||
+ *
|
||||
+ * @param canDestroy Set of materials
|
||||
+ * @deprecated Minecraft does not limit this to the material enum, Use {@link #setDestroyableKeys(Collection)} as a replacement
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ void setCanDestroy(Set<org.bukkit.Material> canDestroy);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets set of materials where given item can be placed on in {@link org.bukkit.GameMode#ADVENTURE}
|
||||
+ *
|
||||
+ * @return Set of materials
|
||||
+ * @deprecated Minecraft does not limit this to the material enum, Use {@link #getPlaceableKeys()} as a replacement
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ Set<org.bukkit.Material> getCanPlaceOn();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets set of materials where given item can be placed on in {@link org.bukkit.GameMode#ADVENTURE}
|
||||
+ *
|
||||
+ * @param canPlaceOn Set of materials
|
||||
+ * @deprecated Minecraft does not limit this to the material enum, Use {@link #setPlaceableKeys(Collection)} as a replacement
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ void setCanPlaceOn(Set<org.bukkit.Material> canPlaceOn);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the collection of namespaced keys that the item can destroy in {@link org.bukkit.GameMode#ADVENTURE}
|
||||
+ *
|
||||
+ * @return Set of {@link com.destroystokyo.paper.Namespaced}
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ Set<com.destroystokyo.paper.Namespaced> getDestroyableKeys();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the collection of namespaced keys that the item can destroy in {@link org.bukkit.GameMode#ADVENTURE}
|
||||
+ *
|
||||
+ * @param canDestroy Collection of {@link com.destroystokyo.paper.Namespaced}
|
||||
+ */
|
||||
+ void setDestroyableKeys(@NotNull Collection<com.destroystokyo.paper.Namespaced> canDestroy);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the collection of namespaced keys that the item can be placed on in {@link org.bukkit.GameMode#ADVENTURE}
|
||||
+ *
|
||||
+ * @return Set of {@link com.destroystokyo.paper.Namespaced}
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ Set<com.destroystokyo.paper.Namespaced> getPlaceableKeys();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the set of namespaced keys that the item can be placed on in {@link org.bukkit.GameMode#ADVENTURE}
|
||||
+ *
|
||||
+ * @param canPlaceOn Collection of {@link com.destroystokyo.paper.Namespaced}
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ void setPlaceableKeys(@NotNull Collection<com.destroystokyo.paper.Namespaced> canPlaceOn);
|
||||
+
|
||||
+ /**
|
||||
+ * Checks for the existence of any keys that the item can be placed on
|
||||
+ *
|
||||
+ * @return true if this item has placeable keys
|
||||
+ */
|
||||
+ boolean hasPlaceableKeys();
|
||||
+
|
||||
+ /**
|
||||
+ * Checks for the existence of any keys that the item can destroy
|
||||
+ *
|
||||
+ * @return true if this item has destroyable keys
|
||||
+ */
|
||||
+ boolean hasDestroyableKeys();
|
||||
+ // Paper end
|
||||
}
|
@@ -1,141 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Caleb Bassham <caleb.bassham@gmail.com>
|
||||
Date: Fri, 28 Sep 2018 02:30:56 -0500
|
||||
Subject: [PATCH] Add spectator target events
|
||||
|
||||
- PlayerStartSpectatingEntityEvent
|
||||
- PlayerStopSpectatingEntityEvent
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerStartSpectatingEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerStartSpectatingEntityEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerStartSpectatingEntityEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package com.destroystokyo.paper.event.player;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Triggered when a player starts spectating an entity in spectator mode.
|
||||
+ */
|
||||
+public class PlayerStartSpectatingEntityEvent extends PlayerEvent implements Cancellable {
|
||||
+
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancelled;
|
||||
+ @NotNull private final Entity currentSpectatorTarget;
|
||||
+ @NotNull private final Entity newSpectatorTarget;
|
||||
+
|
||||
+ public PlayerStartSpectatingEntityEvent(@NotNull Player player, @NotNull Entity currentSpectatorTarget, @NotNull Entity newSpectatorTarget) {
|
||||
+ super(player);
|
||||
+ this.currentSpectatorTarget = currentSpectatorTarget;
|
||||
+ this.newSpectatorTarget = newSpectatorTarget;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the entity that the player is currently spectating or themselves if they weren't spectating anything
|
||||
+ *
|
||||
+ * @return The entity the player is currently spectating (before they start spectating the new target).
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Entity getCurrentSpectatorTarget() {
|
||||
+ return currentSpectatorTarget;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the new entity that the player will now be spectating
|
||||
+ *
|
||||
+ * @return The entity the player is now going to be spectating.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Entity getNewSpectatorTarget() {
|
||||
+ return newSpectatorTarget;
|
||||
+ }
|
||||
+
|
||||
+ @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;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerStopSpectatingEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerStopSpectatingEntityEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerStopSpectatingEntityEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package com.destroystokyo.paper.event.player;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Triggered when a player stops spectating an entity in spectator mode.
|
||||
+ */
|
||||
+public class PlayerStopSpectatingEntityEvent extends PlayerEvent implements Cancellable {
|
||||
+
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancelled;
|
||||
+ @NotNull private final Entity spectatorTarget;
|
||||
+
|
||||
+ public PlayerStopSpectatingEntityEvent(@NotNull Player player, @NotNull Entity spectatorTarget) {
|
||||
+ super(player);
|
||||
+ this.spectatorTarget = spectatorTarget;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the entity that the player is spectating
|
||||
+ *
|
||||
+ * @return The entity the player is currently spectating (before they will stop).
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Entity getSpectatorTarget() {
|
||||
+ return spectatorTarget;
|
||||
+ }
|
||||
+
|
||||
+ @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,45 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sun, 7 Oct 2018 00:54:15 -0500
|
||||
Subject: [PATCH] Add sun related API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -0,0 +0,0 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
||||
*/
|
||||
public void setFullTime(long time);
|
||||
|
||||
+ // Paper start
|
||||
+
|
||||
+ /**
|
||||
+ * Check if it is currently daytime in this world
|
||||
+ *
|
||||
+ * @return True if it is daytime
|
||||
+ */
|
||||
+ public boolean isDayTime();
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Gets the full in-game time on this world since the world generation
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Mob.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Mob.java
|
||||
@@ -0,0 +0,0 @@ public interface Mob extends LivingEntity, Lootable {
|
||||
*/
|
||||
@NotNull
|
||||
com.destroystokyo.paper.entity.Pathfinder getPathfinder();
|
||||
+
|
||||
+ /**
|
||||
+ * Check if this mob is exposed to daylight
|
||||
+ *
|
||||
+ * @return True if mob is exposed to daylight
|
||||
+ */
|
||||
+ boolean isInDaylight();
|
||||
// Paper end
|
||||
/**
|
||||
* Instructs this Mob to set the specified LivingEntity as its target.
|
@@ -1,42 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 12 Oct 2018 01:37:16 -0500
|
||||
Subject: [PATCH] Here's Johnny!
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Vindicator.java b/src/main/java/org/bukkit/entity/Vindicator.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Vindicator.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Vindicator.java
|
||||
@@ -0,0 +0,0 @@ package org.bukkit.entity;
|
||||
/**
|
||||
* Represents a Vindicator.
|
||||
*/
|
||||
-public interface Vindicator extends Illager { }
|
||||
+public interface Vindicator extends Illager {
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Check if this Vindicator is set to Johnny mode.
|
||||
+ * <p>
|
||||
+ * When in Johnny mode the Vindicator will be hostile to any kind of mob, except
|
||||
+ * for evokers, ghasts, illusioners and other vindicators. It will even be hostile
|
||||
+ * to vexes. All mobs, except for endermites, phantoms, guardians, slimes and
|
||||
+ * magma cubes, will try to attack the vindicator in return.
|
||||
+ *
|
||||
+ * @return True if in Johnny mode
|
||||
+ */
|
||||
+ boolean isJohnny();
|
||||
+
|
||||
+ /**
|
||||
+ * Set this Vindicator's Johnny mode.
|
||||
+ * <p>
|
||||
+ * When in Johnny mode the Vindicator will be hostile to any kind of mob, except
|
||||
+ * for evokers, ghasts, illusioners and other vindicators. It will even be hostile
|
||||
+ * to vexes. All mobs, except for endermites, phantoms, guardians, slimes and
|
||||
+ * magma cubes, will try to attack the vindicator in return.
|
||||
+ *
|
||||
+ * @param johnny True to enable Johnny mode
|
||||
+ */
|
||||
+ void setJohnny(boolean johnny);
|
||||
+ // Paper end
|
||||
+}
|
@@ -1,62 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tassu <git@tassu.me>
|
||||
Date: Thu, 13 Sep 2018 08:45:01 +0300
|
||||
Subject: [PATCH] Implement furnace cook speed multiplier API
|
||||
|
||||
Signed-off-by: Tassu <git@tassu.me>
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/block/Furnace.java b/src/main/java/org/bukkit/block/Furnace.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/block/Furnace.java
|
||||
+++ b/src/main/java/org/bukkit/block/Furnace.java
|
||||
@@ -0,0 +0,0 @@ public interface Furnace extends Container {
|
||||
*/
|
||||
public void setCookTimeTotal(int cookTimeTotal);
|
||||
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Gets the cook speed multiplier that this {@link Furnace} will cook
|
||||
+ * compared to vanilla.
|
||||
+ *
|
||||
+ * @return the multiplier, a value between 0 and 200
|
||||
+ */
|
||||
+ public double getCookSpeedMultiplier();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the speed multiplier that this {@link Furnace} will cook
|
||||
+ * compared to vanilla.
|
||||
+ *
|
||||
+ * @param multiplier the multiplier to set, a value between 0 and 200
|
||||
+ * @throws IllegalArgumentException if value is less than 0
|
||||
+ * @throws IllegalArgumentException if value is more than 200
|
||||
+ */
|
||||
+ public void setCookSpeedMultiplier(double multiplier);
|
||||
+ // Paper end
|
||||
+
|
||||
@NotNull
|
||||
@Override
|
||||
public FurnaceInventory getInventory();
|
||||
diff --git a/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java b/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java
|
||||
@@ -0,0 +0,0 @@ public class FurnaceStartSmeltEvent extends BlockEvent {
|
||||
private final CookingRecipe<?> recipe;
|
||||
private int totalCookTime;
|
||||
|
||||
+ @Deprecated // Paper - furnace cook speed multiplier
|
||||
public FurnaceStartSmeltEvent(@NotNull final Block furnace, @NotNull ItemStack source, @NotNull final CookingRecipe<?> recipe) {
|
||||
+ // Paper start - furnace cook speed multiplier
|
||||
+ this(furnace, source, recipe, recipe.getCookingTime());
|
||||
+ }
|
||||
+
|
||||
+ public FurnaceStartSmeltEvent(@NotNull final Block furnace, @NotNull ItemStack source, @NotNull CookingRecipe<?> recipe, int cookingTime) {
|
||||
+ // Paper end
|
||||
super(furnace);
|
||||
this.source = source;
|
||||
this.recipe = recipe;
|
||||
- this.totalCookTime = recipe.getCookingTime();
|
||||
+ this.totalCookTime = cookingTime; // Paper - furnace cook speed multiplier
|
||||
}
|
||||
|
||||
/**
|
@@ -1,41 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 6 Oct 2018 21:14:29 -0400
|
||||
Subject: [PATCH] Material API additions
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/Material.java
|
||||
+++ b/src/main/java/org/bukkit/Material.java
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* An enum of all material IDs accepted by the official server and client
|
||||
*/
|
||||
+@SuppressWarnings({"DeprecatedIsStillUsed", "deprecation"}) // Paper
|
||||
public enum Material implements Keyed {
|
||||
//<editor-fold desc="Materials" defaultstate="collapsed">
|
||||
AIR(9648, 0),
|
||||
@@ -0,0 +0,0 @@ public enum Material implements Keyed {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+
|
||||
+ /**
|
||||
+ * @return If the type is either AIR, CAVE_AIR or VOID_AIR
|
||||
+ */
|
||||
+ public boolean isEmpty() {
|
||||
+ switch (this) {
|
||||
+ case AIR:
|
||||
+ case CAVE_AIR:
|
||||
+ case VOID_AIR:
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Do not use for any reason.
|
||||
*
|
@@ -1,257 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 9 Sep 2018 12:39:06 -0400
|
||||
Subject: [PATCH] Mob Pathfinding API
|
||||
|
||||
Adds an API to allow plugins to instruct a Mob to Pathfind to a Location or Entity
|
||||
|
||||
This does not do anything to stop other AI rules from changing the location, so
|
||||
it is still up to the plugin to control that or override after another goal changed
|
||||
the location.
|
||||
|
||||
You can use EntityPathfindEvent to cancel new pathfinds from overriding your current.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java b/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package com.destroystokyo.paper.entity;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.LivingEntity;
|
||||
+import org.bukkit.entity.Mob;
|
||||
+
|
||||
+import java.util.List;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Handles pathfinding operations for an Entity
|
||||
+ */
|
||||
+public interface Pathfinder {
|
||||
+
|
||||
+ /**
|
||||
+ *
|
||||
+ * @return The entity that is controlled by this pathfinder
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ Mob getEntity();
|
||||
+
|
||||
+ /**
|
||||
+ * Instructs the Entity to stop trying to navigate to its current desired location
|
||||
+ */
|
||||
+ void stopPathfinding();
|
||||
+
|
||||
+ /**
|
||||
+ * If the entity is currently trying to navigate to a destination, this will return true
|
||||
+ * @return true if the entity is navigating to a destination
|
||||
+ */
|
||||
+ boolean hasPath();
|
||||
+
|
||||
+ /**
|
||||
+ * @return The location the entity is trying to navigate to, or null if there is no destination
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ PathResult getCurrentPath();
|
||||
+
|
||||
+ /**
|
||||
+ * Calculates a destination for the Entity to navigate to, but does not set it
|
||||
+ * as the current target. Useful for calculating what would happen before setting it.
|
||||
+ * @param loc Location to navigate to
|
||||
+ * @return The closest Location the Entity can get to for this navigation, or null if no path could be calculated
|
||||
+ */
|
||||
+ @Nullable PathResult findPath(@NotNull Location loc);
|
||||
+
|
||||
+ /**
|
||||
+ * Calculates a destination for the Entity to navigate to to reach the target entity,
|
||||
+ * but does not set it as the current target.
|
||||
+ * Useful for calculating what would happen before setting it.
|
||||
+ *
|
||||
+ * The behavior of this PathResult is subject to the games pathfinding rules, and may
|
||||
+ * result in the pathfinding automatically updating to follow the target Entity.
|
||||
+ *
|
||||
+ * However, this behavior is not guaranteed, and is subject to the games behavior.
|
||||
+ *
|
||||
+ * @param target the Entity to navigate to
|
||||
+ * @return The closest Location the Entity can get to for this navigation, or null if no path could be calculated
|
||||
+ */
|
||||
+ @Nullable PathResult findPath(@NotNull LivingEntity target);
|
||||
+
|
||||
+ /**
|
||||
+ * Calculates a destination for the Entity to navigate to, and sets it with default speed
|
||||
+ * as the current target.
|
||||
+ * @param loc Location to navigate to
|
||||
+ * @return If the pathfinding was successfully started
|
||||
+ */
|
||||
+ default boolean moveTo(@NotNull Location loc) {
|
||||
+ return moveTo(loc, 1);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Calculates a destination for the Entity to navigate to, with desired speed
|
||||
+ * as the current target.
|
||||
+ * @param loc Location to navigate to
|
||||
+ * @param speed Speed multiplier to navigate at, where 1 is 'normal'
|
||||
+ * @return If the pathfinding was successfully started
|
||||
+ */
|
||||
+ default boolean moveTo(@NotNull Location loc, double speed) {
|
||||
+ PathResult path = findPath(loc);
|
||||
+ return path != null && moveTo(path, speed);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Calculates a destination for the Entity to navigate to to reach the target entity,
|
||||
+ * and sets it with default speed.
|
||||
+ *
|
||||
+ * The behavior of this PathResult is subject to the games pathfinding rules, and may
|
||||
+ * result in the pathfinding automatically updating to follow the target Entity.
|
||||
+ *
|
||||
+ * However, this behavior is not guaranteed, and is subject to the games behavior.
|
||||
+ *
|
||||
+ * @param target the Entity to navigate to
|
||||
+ * @return If the pathfinding was successfully started
|
||||
+ */
|
||||
+ default boolean moveTo(@NotNull LivingEntity target) {
|
||||
+ return moveTo(target, 1);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Calculates a destination for the Entity to navigate to to reach the target entity,
|
||||
+ * and sets it with specified speed.
|
||||
+ *
|
||||
+ * The behavior of this PathResult is subject to the games pathfinding rules, and may
|
||||
+ * result in the pathfinding automatically updating to follow the target Entity.
|
||||
+ *
|
||||
+ * However, this behavior is not guaranteed, and is subject to the games behavior.
|
||||
+ *
|
||||
+ * @param target the Entity to navigate to
|
||||
+ * @param speed Speed multiplier to navigate at, where 1 is 'normal'
|
||||
+ * @return If the pathfinding was successfully started
|
||||
+ */
|
||||
+ default boolean moveTo(@NotNull LivingEntity target, double speed) {
|
||||
+ PathResult path = findPath(target);
|
||||
+ return path != null && moveTo(path, speed);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Takes the result of a previous pathfinding calculation and sets it
|
||||
+ * as the active pathfinding with default speed.
|
||||
+ *
|
||||
+ * @param path The Path to start following
|
||||
+ * @return If the pathfinding was successfully started
|
||||
+ */
|
||||
+ default boolean moveTo(@NotNull PathResult path) {
|
||||
+ return moveTo(path, 1);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Takes the result of a previous pathfinding calculation and sets it
|
||||
+ * as the active pathfinding,
|
||||
+ *
|
||||
+ * @param path The Path to start following
|
||||
+ * @param speed Speed multiplier to navigate at, where 1 is 'normal'
|
||||
+ * @return If the pathfinding was successfully started
|
||||
+ */
|
||||
+ boolean moveTo(@NotNull PathResult path, double speed);
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if this pathfinder allows passing through closed doors.
|
||||
+ *
|
||||
+ * @return if this pathfinder allows passing through closed doors
|
||||
+ */
|
||||
+ boolean canOpenDoors();
|
||||
+
|
||||
+ /**
|
||||
+ * Allows this pathfinder to pass through closed doors, or not
|
||||
+ *
|
||||
+ * @param canOpenDoors if the mob can pass through closed doors, or not
|
||||
+ */
|
||||
+ void setCanOpenDoors(boolean canOpenDoors);
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if this pathfinder allows passing through open doors.
|
||||
+ *
|
||||
+ * @return if this pathfinder allows passing through open doors
|
||||
+ */
|
||||
+ boolean canPassDoors();
|
||||
+
|
||||
+ /**
|
||||
+ * Allows this pathfinder to pass through open doors, or not
|
||||
+ *
|
||||
+ * @param canPassDoors if the mob can pass through open doors, or not
|
||||
+ */
|
||||
+ void setCanPassDoors(boolean canPassDoors);
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if this pathfinder assumes that the mob can float
|
||||
+ *
|
||||
+ * @return if this pathfinder assumes that the mob can float
|
||||
+ */
|
||||
+ boolean canFloat();
|
||||
+
|
||||
+ /**
|
||||
+ * Makes this pathfinder assume that the mob can float, or not
|
||||
+ *
|
||||
+ * @param canFloat if the mob can float, or not
|
||||
+ */
|
||||
+ void setCanFloat(boolean canFloat);
|
||||
+
|
||||
+ /**
|
||||
+ * Represents the result of a pathfinding calculation
|
||||
+ */
|
||||
+ interface PathResult {
|
||||
+
|
||||
+ /**
|
||||
+ * All currently calculated points to follow along the path to reach the destination location
|
||||
+ *
|
||||
+ * Will return points the entity has already moved past, see {@link #getNextPointIndex()}
|
||||
+ * @return List of points
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ List<Location> getPoints();
|
||||
+
|
||||
+ /**
|
||||
+ * @return Returns the index of the current point along the points returned in {@link #getPoints()} the entity
|
||||
+ * is trying to reach, or null if we are done with this pathfinding.
|
||||
+ */
|
||||
+ int getNextPointIndex();
|
||||
+
|
||||
+ /**
|
||||
+ * @return The next location in the path points the entity is trying to reach, or null if there is no next point
|
||||
+ */
|
||||
+ @Nullable Location getNextPoint();
|
||||
+
|
||||
+ /**
|
||||
+ * @return The closest point the path can get to the target location
|
||||
+ */
|
||||
+ @Nullable Location getFinalPoint();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Mob.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Mob.java
|
||||
@@ -0,0 +0,0 @@
|
||||
package org.bukkit.entity;
|
||||
|
||||
import org.bukkit.loot.Lootable;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -0,0 +0,0 @@ public interface Mob extends LivingEntity, Lootable {
|
||||
// Paper start
|
||||
@Override
|
||||
org.bukkit.inventory.@org.jetbrains.annotations.NotNull EntityEquipment getEquipment();
|
||||
+
|
||||
+ /**
|
||||
+ * Enables access to control the pathing of an Entity
|
||||
+ * @return Pathfinding Manager for this entity
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ com.destroystokyo.paper.entity.Pathfinder getPathfinder();
|
||||
// Paper end
|
||||
/**
|
||||
* Instructs this Mob to set the specified LivingEntity as its target.
|
@@ -1,113 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 13 Sep 2018 20:51:50 -0400
|
||||
Subject: [PATCH] Performance & Concurrency Improvements to Permissions
|
||||
|
||||
Modifying of permissions was only half protected, enabling concurrency
|
||||
issues to occur if permissions were modified async.
|
||||
|
||||
While no plugin really should be doing that, modifying operations
|
||||
are not heavily called, so they are safe to add synchronization to.
|
||||
|
||||
Now, all modification API's will be synchronized ensuring safety.
|
||||
|
||||
Additionally, hasPermission was victim to a common java newbie mistake
|
||||
of calling if (containsKey(k)) return get(k), resulting in 2 map lookups.
|
||||
|
||||
Optimized it to simply be a single get call cutting permission map
|
||||
lookups in half.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/permissions/PermissibleBase.java b/src/main/java/org/bukkit/permissions/PermissibleBase.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/permissions/PermissibleBase.java
|
||||
+++ b/src/main/java/org/bukkit/permissions/PermissibleBase.java
|
||||
@@ -0,0 +0,0 @@ public class PermissibleBase implements Permissible {
|
||||
|
||||
String name = inName.toLowerCase(java.util.Locale.ENGLISH);
|
||||
|
||||
- if (isPermissionSet(name)) {
|
||||
- return permissions.get(name).getValue();
|
||||
+ // Paper start
|
||||
+ PermissionAttachmentInfo info = permissions.get(name);
|
||||
+ if (info != null) {
|
||||
+ return info.getValue();
|
||||
+ // Paper end
|
||||
} else {
|
||||
Permission perm = Bukkit.getServer().getPluginManager().getPermission(name);
|
||||
|
||||
@@ -0,0 +0,0 @@ public class PermissibleBase implements Permissible {
|
||||
|
||||
String name = perm.getName().toLowerCase(java.util.Locale.ENGLISH);
|
||||
|
||||
- if (isPermissionSet(name)) {
|
||||
- return permissions.get(name).getValue();
|
||||
+ // Paper start
|
||||
+ PermissionAttachmentInfo info = permissions.get(name);
|
||||
+ if (info != null) {
|
||||
+ return info.getValue();
|
||||
}
|
||||
+ // Paper end
|
||||
return perm.getDefault().getValue(isOp());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
- public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) {
|
||||
+ public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) { // Paper - synchronized
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Permission name cannot be null");
|
||||
} else if (plugin == null) {
|
||||
@@ -0,0 +0,0 @@ public class PermissibleBase implements Permissible {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
- public PermissionAttachment addAttachment(@NotNull Plugin plugin) {
|
||||
+ public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin) { // Paper - synchronized
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
} else if (!plugin.isEnabled()) {
|
||||
@@ -0,0 +0,0 @@ public class PermissibleBase implements Permissible {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void removeAttachment(@NotNull PermissionAttachment attachment) {
|
||||
+ public synchronized void removeAttachment(@NotNull PermissionAttachment attachment) { // Paper - synchronized
|
||||
if (attachment == null) {
|
||||
throw new IllegalArgumentException("Attachment cannot be null");
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class PermissibleBase implements Permissible {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void recalculatePermissions() {
|
||||
+ public synchronized void recalculatePermissions() { // Paper - synchronized
|
||||
clearPermissions();
|
||||
Set<Permission> defaults = Bukkit.getServer().getPluginManager().getDefaultPermissions(isOp());
|
||||
Bukkit.getServer().getPluginManager().subscribeToDefaultPerms(isOp(), parent);
|
||||
@@ -0,0 +0,0 @@ public class PermissibleBase implements Permissible {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
- public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) {
|
||||
+ public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) { // Paper
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Permission name cannot be null");
|
||||
} else if (plugin == null) {
|
||||
@@ -0,0 +0,0 @@ public class PermissibleBase implements Permissible {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
- public PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) {
|
||||
+ public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) { // Paper - synchronized
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
} else if (!plugin.isEnabled()) {
|
||||
@@ -0,0 +0,0 @@ public class PermissibleBase implements Permissible {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
- public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
||||
+ public synchronized Set<PermissionAttachmentInfo> getEffectivePermissions() { // Paper - synchronized
|
||||
return new HashSet<PermissionAttachmentInfo>(permissions.values());
|
||||
}
|
||||
|
@@ -1,47 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Phoenix616 <mail@moep.tv>
|
||||
Date: Tue, 18 Sep 2018 23:50:10 +0100
|
||||
Subject: [PATCH] PreSpawnerSpawnEvent
|
||||
|
||||
This adds a separate event before an entity is spawned by a spawner
|
||||
which contains the location of the spawner too similarly to how the
|
||||
SpawnerSpawnEvent gets called instead of the CreatureSpawnEvent for
|
||||
spawners.
|
||||
|
||||
Dropped as it does not apply due to the earlier PreCreatureSpawnEvent patch not being applied
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package com.destroystokyo.paper.event.entity;
|
||||
+
|
||||
+
|
||||
+import com.google.common.base.Preconditions;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Called before an entity is spawned into a world by a spawner.
|
||||
+ *
|
||||
+ * This only includes the spawner's location and not the full BlockState snapshot for performance reasons.
|
||||
+ * If you really need it you have to get the spawner yourself.
|
||||
+ */
|
||||
+
|
||||
+public class PreSpawnerSpawnEvent extends PreCreatureSpawnEvent {
|
||||
+ @NotNull private final Location spawnerLocation;
|
||||
+
|
||||
+ public PreSpawnerSpawnEvent(@NotNull Location location, @NotNull EntityType type, @NotNull Location spawnerLocation) {
|
||||
+ super(location, type, CreatureSpawnEvent.SpawnReason.SPAWNER);
|
||||
+ this.spawnerLocation = Preconditions.checkNotNull(spawnerLocation, "Spawner location may not be null");
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public Location getSpawnerLocation() {
|
||||
+ return spawnerLocation;
|
||||
+ }
|
||||
+}
|
@@ -1,283 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 28 Sep 2018 17:08:09 -0500
|
||||
Subject: [PATCH] Turtle API
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package com.destroystokyo.paper.event.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Turtle;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Fired when a Turtle decides to go home
|
||||
+ */
|
||||
+public class TurtleGoHomeEvent extends EntityEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancelled = false;
|
||||
+
|
||||
+ public TurtleGoHomeEvent(@NotNull Turtle turtle) {
|
||||
+ super(turtle);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * The turtle going home
|
||||
+ *
|
||||
+ * @return The turtle
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Turtle getEntity() {
|
||||
+ return (Turtle) entity;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package com.destroystokyo.paper.event.entity;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.Turtle;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Fired when a Turtle lays eggs
|
||||
+ */
|
||||
+public class TurtleLayEggEvent extends EntityEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancelled = false;
|
||||
+ @NotNull
|
||||
+ private final Location location;
|
||||
+ private int eggCount;
|
||||
+
|
||||
+ public TurtleLayEggEvent(@NotNull Turtle turtle, @NotNull Location location, int eggCount) {
|
||||
+ super(turtle);
|
||||
+ this.location = location;
|
||||
+ this.eggCount = eggCount;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * The turtle laying the eggs
|
||||
+ *
|
||||
+ * @return The turtle
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Turtle getEntity() {
|
||||
+ return (Turtle) entity;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the location where the eggs are being laid
|
||||
+ *
|
||||
+ * @return Location of eggs
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Location getLocation() {
|
||||
+ return location;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the number of eggs being laid
|
||||
+ *
|
||||
+ * @return Number of eggs
|
||||
+ */
|
||||
+ public int getEggCount() {
|
||||
+ return eggCount;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Set the number of eggs being laid
|
||||
+ *
|
||||
+ * @param eggCount Number of eggs
|
||||
+ */
|
||||
+ public void setEggCount(int eggCount) {
|
||||
+ if (eggCount < 1) {
|
||||
+ cancelled = true;
|
||||
+ return;
|
||||
+ }
|
||||
+ eggCount = Math.min(eggCount, 4);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package com.destroystokyo.paper.event.entity;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.Turtle;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Fired when a Turtle starts digging to lay eggs
|
||||
+ */
|
||||
+public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancelled = false;
|
||||
+ @NotNull private final Location location;
|
||||
+
|
||||
+ public TurtleStartDiggingEvent(@NotNull Turtle turtle, @NotNull Location location) {
|
||||
+ super(turtle);
|
||||
+ this.location = location;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * The turtle digging
|
||||
+ *
|
||||
+ * @return The turtle
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Turtle getEntity() {
|
||||
+ return (Turtle) entity;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the location where the turtle is digging
|
||||
+ *
|
||||
+ * @return Location where digging
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Location getLocation() {
|
||||
+ return location;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Turtle.java b/src/main/java/org/bukkit/entity/Turtle.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Turtle.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Turtle.java
|
||||
@@ -0,0 +0,0 @@
|
||||
package org.bukkit.entity;
|
||||
|
||||
+import org.bukkit.Location;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
/**
|
||||
* Represents a turtle.
|
||||
*/
|
||||
-public interface Turtle extends Animals { }
|
||||
+public interface Turtle extends Animals {
|
||||
+ // Paper start
|
||||
+
|
||||
+ /**
|
||||
+ * Get the turtle's home location
|
||||
+ *
|
||||
+ * @return Home location
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ Location getHome();
|
||||
+
|
||||
+ /**
|
||||
+ * Set the turtle's home location
|
||||
+ *
|
||||
+ * @param location Home location
|
||||
+ */
|
||||
+ void setHome(@NotNull Location location);
|
||||
+
|
||||
+ /**
|
||||
+ * Check if turtle is currently pathfinding to it's home
|
||||
+ *
|
||||
+ * @return True if going home
|
||||
+ */
|
||||
+ boolean isGoingHome();
|
||||
+
|
||||
+ /**
|
||||
+ * Get if turtle is digging to lay eggs
|
||||
+ *
|
||||
+ * @return True if digging
|
||||
+ */
|
||||
+ boolean isDigging();
|
||||
+
|
||||
+ /**
|
||||
+ * Get if turtle is carrying egg
|
||||
+ *
|
||||
+ * @return True if carrying egg
|
||||
+ */
|
||||
+ boolean hasEgg();
|
||||
+
|
||||
+ /**
|
||||
+ * Set if turtle is carrying egg
|
||||
+ *
|
||||
+ * @param hasEgg True if carrying egg
|
||||
+ */
|
||||
+ void setHasEgg(boolean hasEgg);
|
||||
+ // Paper end
|
||||
+}
|
Reference in New Issue
Block a user