chore: cleanup annotations in api adventure patch

This commit is contained in:
Riley Park 2023-03-23 09:49:24 -07:00
parent 92f872c146
commit 9087a644a3
67 changed files with 1427 additions and 1365 deletions

View file

@ -8,6 +8,7 @@ Subject: [PATCH] Test changes
- Ignore package-private methods for nullability annotations
- Add excludes for classes which don't pass
Co-authored-by: Riley Park <rileysebastianpark@gmail.com>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/build.gradle.kts b/build.gradle.kts
@ -143,10 +144,25 @@ index 0000000000000000000000000000000000000000..756acf231b1b076b08046d86992ba7ce
+
+}
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
index 4ac3dd977e75cd8464163351d306e037ee32cb48..8f35cda0d67ec66646c6096a5bf1c84891b8b0fd 100644
index 4ac3dd977e75cd8464163351d306e037ee32cb48..c26ea217927ba77611e6ae93f8df50a83bceb3dd 100644
--- a/src/test/java/org/bukkit/AnnotationTest.java
+++ b/src/test/java/org/bukkit/AnnotationTest.java
@@ -40,7 +40,17 @@ public class AnnotationTest {
@@ -29,7 +29,13 @@ public class AnnotationTest {
"Lorg/jetbrains/annotations/Nullable;",
"Lorg/jetbrains/annotations/NotNull;",
"Lorg/jetbrains/annotations/Contract;",
- "Lorg/bukkit/UndefinedNullability;"
+ "Lorg/bukkit/UndefinedNullability;",
+ // Paper start
+ "Lorg/checkerframework/checker/nullness/qual/MonotonicNonNull;",
+ "Lorg/checkerframework/checker/nullness/qual/NonNull;",
+ "Lorg/checkerframework/checker/nullness/qual/Nullable;",
+ "Lorg/checkerframework/checker/nullness/qual/PolyNull;",
+ // Paper end
};
private static final String[] EXCLUDED_CLASSES = {
@@ -40,7 +46,17 @@ public class AnnotationTest {
"org/bukkit/util/io/Wrapper",
"org/bukkit/plugin/java/PluginClassLoader",
// Generic functional interface
@ -165,7 +181,7 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..8f35cda0d67ec66646c6096a5bf1c848
};
@Test
@@ -67,14 +77,40 @@ public class AnnotationTest {
@@ -67,14 +83,40 @@ public class AnnotationTest {
}
if (mustBeAnnotated(Type.getReturnType(method.desc)) && !isWellAnnotated(method.invisibleAnnotations)) {
@ -176,7 +192,7 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..8f35cda0d67ec66646c6096a5bf1c848
+ } else if (method.invisibleTypeAnnotations != null) {
+ dance: for (final org.objectweb.asm.tree.TypeAnnotationNode invisibleTypeAnnotation : method.invisibleTypeAnnotations) {
+ final org.objectweb.asm.TypeReference ref = new org.objectweb.asm.TypeReference(invisibleTypeAnnotation.typeRef);
+ if (ref.getSort() == org.objectweb.asm.TypeReference.METHOD_RETURN && java.util.Arrays.binarySearch(ACCEPTED_ANNOTATIONS, invisibleTypeAnnotation.desc) >= 0) {
+ if (ref.getSort() == org.objectweb.asm.TypeReference.METHOD_RETURN && java.util.Arrays.asList(ACCEPTED_ANNOTATIONS).contains(invisibleTypeAnnotation.desc)) {
+ warn = false;
+ break dance; // cha cha real smooth
+ }
@ -197,7 +213,7 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..8f35cda0d67ec66646c6096a5bf1c848
+ if (method.invisibleTypeAnnotations != null) {
+ for (final org.objectweb.asm.tree.TypeAnnotationNode invisibleTypeAnnotation : method.invisibleTypeAnnotations) {
+ final org.objectweb.asm.TypeReference ref = new org.objectweb.asm.TypeReference(invisibleTypeAnnotation.typeRef);
+ if (ref.getSort() == org.objectweb.asm.TypeReference.METHOD_FORMAL_PARAMETER && ref.getTypeParameterIndex() == i && java.util.Arrays.binarySearch(ACCEPTED_ANNOTATIONS, invisibleTypeAnnotation.desc) >= 0) {
+ if (ref.getSort() == org.objectweb.asm.TypeReference.METHOD_FORMAL_PARAMETER && ref.getTypeParameterIndex() == i && java.util.Arrays.asList(ACCEPTED_ANNOTATIONS).contains(invisibleTypeAnnotation.desc)) {
+ continue dancing;
+ }
+ }
@ -206,7 +222,7 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..8f35cda0d67ec66646c6096a5bf1c848
ParameterNode paramNode = parameters == null ? null : parameters.get(i);
String paramName = paramNode == null ? null : paramNode.name;
@@ -91,13 +127,18 @@ public class AnnotationTest {
@@ -91,13 +133,18 @@ public class AnnotationTest {
Collections.sort(errors);
@ -229,7 +245,7 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..8f35cda0d67ec66646c6096a5bf1c848
}
private static void collectClasses(@NotNull File from, @NotNull Map<String, ClassNode> to) throws IOException {
@@ -140,6 +181,11 @@ public class AnnotationTest {
@@ -140,6 +187,11 @@ public class AnnotationTest {
// Exceptions are excluded
return false;
}
@ -241,7 +257,7 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..8f35cda0d67ec66646c6096a5bf1c848
for (String excludedClass : EXCLUDED_CLASSES) {
if (excludedClass.equals(clazz.name)) {
@@ -152,7 +198,7 @@ public class AnnotationTest {
@@ -152,7 +204,7 @@ public class AnnotationTest {
private static boolean isMethodIncluded(@NotNull ClassNode clazz, @NotNull MethodNode method, @NotNull Map<String, ClassNode> allClasses) {
// Exclude private, synthetic and deprecated methods
@ -250,7 +266,7 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..8f35cda0d67ec66646c6096a5bf1c848
return false;
}
@@ -170,11 +216,30 @@ public class AnnotationTest {
@@ -170,11 +222,30 @@ public class AnnotationTest {
if ("<init>".equals(method.name) && isAnonymous(clazz)) {
return false;
}
@ -272,12 +288,12 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..8f35cda0d67ec66646c6096a5bf1c848
+ return true;
+ }
+ }
+
- private static boolean isWellAnnotated(@Nullable List<AnnotationNode> annotations) {
+ return false;
+ }
+ // Paper end
- private static boolean isWellAnnotated(@Nullable List<AnnotationNode> annotations) {
+
+ private static boolean isWellAnnotated(@Nullable List<? extends AnnotationNode> annotations) { // Paper
if (annotations == null) {
return false;

File diff suppressed because it is too large Load diff

View file

@ -2194,7 +2194,7 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..302319acbc257a075adfb78d9f5c49fd
- javaPlugin.init(loader, loader.server, description, dataFolder, file, this);
+ javaPlugin.init(null, org.bukkit.Bukkit.getServer(), description, dataFolder, file, this); // Paper
+ }
}
+
+ // Paper start
+ @Override
@ -2219,7 +2219,7 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..302319acbc257a075adfb78d9f5c49fd
+ Class<? extends org.bukkit.configuration.serialization.ConfigurationSerializable> serializable = clazz.asSubclass(org.bukkit.configuration.serialization.ConfigurationSerializable.class);
+ org.bukkit.configuration.serialization.ConfigurationSerialization.unregisterClass(serializable);
+ }
}
+ }
+
+ @Override
+ public @Nullable io.papermc.paper.plugin.provider.classloader.PluginClassLoaderGroup getGroup() {

View file

@ -2791,7 +2791,7 @@ index 0000000000000000000000000000000000000000..5989ee21297935651b0edd44b8239e65
+ }
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 0084898567e8bb74fa271b65b56523a5c26d387c..e24589a4cb42b0163e4a1455b8b11d7130b5cd41 100644
index 16ec0cd908659d6d53e565281b8db9f81951277d..92b3c40959eac827ed8861fec8658e57f2910628 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -802,7 +802,6 @@ public final class Bukkit {
@ -2803,7 +2803,7 @@ index 0084898567e8bb74fa271b65b56523a5c26d387c..e24589a4cb42b0163e4a1455b8b11d71
/**
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 892e03189957b0072827be4fd485dd98352334e8..ac087402c90dad4b3c499fcf8507e50e9099cea5 100644
index 0a333c1439b3623d38029b88ce6d5ff159ae1ddd..bce277cd3a452769cd86dc017a2e548a170d6acc 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1768,6 +1768,26 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@ -2886,7 +2886,7 @@ index 0000000000000000000000000000000000000000..f9a00aecca5ec41b460bf41dfe1c6969
+ }
+}
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
index caa29be46e8541b69ec47c181eb3320d6515b544..6fd341482d5250ad814e870360e40b52427f799a 100644
index 75759131bd94b672bec4cd8e271ebff1ad391cba..5cfd88eec9bf02e83d77b6fce1a5c14b7687f48b 100644
--- a/src/main/java/org/bukkit/command/Command.java
+++ b/src/main/java/org/bukkit/command/Command.java
@@ -33,7 +33,8 @@ public abstract class Command {
@ -3392,7 +3392,7 @@ index 516d7fc7812aac343782861d0d567f54aa578c2a..00000000000000000000000000000000
- // Spigot end
-}
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index baf0887ec941533f8007f2c7f7ab78f16b45bd74..8d8a540c844e5365eed75a87db197a8fd4249bcd 100644
index fbf56bcc4540f7f1a8ced7cc2cd96e291c1ac273..8602b96bfc860ff1fea4c1c7a3655ce3a9516cf4 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -2077,7 +2077,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@ -3400,12 +3400,12 @@ index baf0887ec941533f8007f2c7f7ab78f16b45bd74..8d8a540c844e5365eed75a87db197a8f
public void sendMessage(@NotNull net.md_5.bungee.api.ChatMessageType position, @Nullable java.util.UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
throw new UnsupportedOperationException("Not supported yet.");
+
+ }
}
+
+ // Paper start
+ public int getPing() {
+ throw new UnsupportedOperationException( "Not supported yet." );
}
+ }
+ // Paper end
}
@ -3611,7 +3611,8 @@ index 44badfedcc3fdc26bdc293b85d8c781d6f659faa..123647bb10fc89508437d7a0bd3fd31d
public CustomTimingsHandler(@NotNull String name) {
- this(name, null);
- }
-
+ Timing timing;
- public CustomTimingsHandler(@NotNull String name, @Nullable CustomTimingsHandler parent) {
- this.name = name;
- this.parent = parent;
@ -3634,7 +3635,16 @@ index 44badfedcc3fdc26bdc293b85d8c781d6f659faa..123647bb10fc89508437d7a0bd3fd31d
- long avg = time / count;
-
- printStream.println(" " + timings.name + " Time: " + time + " Count: " + count + " Avg: " + avg + " Violations: " + timings.violations);
- }
+ new AuthorNagException("Deprecated use of CustomTimingsHandler. Please Switch to Timings.of ASAP").printStackTrace();
+ try {
+ final Method ofSafe = TimingsManager.class.getDeclaredMethod("getHandler", String.class, String.class, Timing.class);
+ ofSafe.setAccessible(true);
+ timing = (Timing) ofSafe.invoke(null,"Minecraft", "(Deprecated API) " + name, null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Bukkit.getLogger().log(Level.SEVERE, "This handler could not be registered");
+ timing = Timings.NULL_HANDLER;
}
- printStream.println("# Version " + Bukkit.getVersion());
- int entities = 0;
- int livingEntities = 0;
@ -3644,8 +3654,9 @@ index 44badfedcc3fdc26bdc293b85d8c781d6f659faa..123647bb10fc89508437d7a0bd3fd31d
- }
- printStream.println("# Entities " + entities);
- printStream.println("# LivingEntities " + livingEntities);
- }
-
+ handler = timing;
}
- /**
- * Resets all timings.
- */
@ -3657,7 +3668,9 @@ index 44badfedcc3fdc26bdc293b85d8c781d6f659faa..123647bb10fc89508437d7a0bd3fd31d
- }
- TimingsCommand.timingStart = System.nanoTime();
- }
-
+ public void startTiming() { handler.startTiming(); }
+ public void stopTiming() { handler.stopTiming(); }
- /**
- * Ticked every tick by CraftBukkit to count the number of times a timer
- * caused TPS loss.
@ -3673,8 +3686,7 @@ index 44badfedcc3fdc26bdc293b85d8c781d6f659faa..123647bb10fc89508437d7a0bd3fd31d
- }
- }
- }
+ Timing timing;
-
- /**
- * Starts timing to track a section of code.
- */
@ -3685,19 +3697,9 @@ index 44badfedcc3fdc26bdc293b85d8c781d6f659faa..123647bb10fc89508437d7a0bd3fd31d
- if (parent != null && ++parent.timingDepth == 1) {
- parent.start = start;
- }
+ new AuthorNagException("Deprecated use of CustomTimingsHandler. Please Switch to Timings.of ASAP").printStackTrace();
+ try {
+ final Method ofSafe = TimingsManager.class.getDeclaredMethod("getHandler", String.class, String.class, Timing.class);
+ ofSafe.setAccessible(true);
+ timing = (Timing) ofSafe.invoke(null,"Minecraft", "(Deprecated API) " + name, null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Bukkit.getLogger().log(Level.SEVERE, "This handler could not be registered");
+ timing = Timings.NULL_HANDLER;
}
+ handler = timing;
}
- }
- }
-
- /**
- * Stops timing a section of code.
- */
@ -3716,9 +3718,7 @@ index 44badfedcc3fdc26bdc293b85d8c781d6f659faa..123647bb10fc89508437d7a0bd3fd31d
- }
- }
- }
+ public void startTiming() { handler.startTiming(); }
+ public void stopTiming() { handler.stopTiming(); }
-
- /**
- * Reset this timer, setting all values to zero.
- */

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java
index 8feb6698f9630f099be99e52d1149cd6bc615197..d51d2ec1d04d9ea8a25a70d0d856f2355ebfcb4a 100644
--- a/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java
@@ -13,12 +13,31 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable
@@ -13,13 +13,32 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable
private boolean cancelled;
private double amount;
private final RegainReason regainReason;
@ -25,8 +25,8 @@ index 8feb6698f9630f099be99e52d1149cd6bc615197..d51d2ec1d04d9ea8a25a70d0d856f235
this.amount = amount;
this.regainReason = regainReason;
+ this.isFastRegen = isFastRegen; // Paper
+ }
+
}
+ // Paper start - Add getter for isFastRegen
+ /**
+ * Is this event a result of the fast regeneration mechanic
@ -35,8 +35,9 @@ index 8feb6698f9630f099be99e52d1149cd6bc615197..d51d2ec1d04d9ea8a25a70d0d856f235
+ */
+ public boolean isFastRegen() {
+ return isFastRegen;
}
+ }
+ // Paper end
+
/**
* Gets the amount of regained health
*

View file

@ -32,11 +32,11 @@ index af4a7ce37eb10bab06eadb6583c7894b3ec55ae6..159e5a908b35b84b7fabc36581e093d9
// Paper end
}
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
index 9da047582e9648d84875b6d3c136960bbb97b70e..87f7942082ad943a97058f58c09ea2fe9caf5bfe 100644
index 9d327f0832c40d4a8d212346284274f6cf78834f..09a36df6edce2a283df80c67d5ef62da7ff73555 100644
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
@@ -618,5 +618,20 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
public @NotNull net.kyori.adventure.text.Component displayName() {
public net.kyori.adventure.text.@NotNull Component displayName() {
return Bukkit.getServer().getItemFactory().displayName(this);
}
+

View file

@ -578,7 +578,7 @@ index 270e6d8ad4358baa256cee5f16cff281f063ce3b..4a3451af454295ac3e1b688e6665cad9
@Override
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
index 9825db30d42701aad5d9970bbb989fbff0142fb1..2cb81e6d253d70388da15c9d07b630277d486c70 100644
index c26ea217927ba77611e6ae93f8df50a83bceb3dd..06e96e5c98f1a7a68c8b4b5e527314c1aa774e38 100644
--- a/src/test/java/org/bukkit/AnnotationTest.java
+++ b/src/test/java/org/bukkit/AnnotationTest.java
@@ -48,6 +48,8 @@ public class AnnotationTest {

View file

@ -10,7 +10,7 @@ of giving the player experience points.
Both an API To standalone mend, and apply mending logic to .giveExp has been added.
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 2f2cce2a8b4b26fbe85da10f55f7313112b05435..af92443e50b66e526d382c820e1b2e27c6e1b461 100644
index dbe15267053cfd6bdac093f798dda1cb5aff02c4..95130fde38e7fcec4139fac97df25d82e0a79587 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -1128,12 +1128,33 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@ -18,21 +18,21 @@ index 2f2cce2a8b4b26fbe85da10f55f7313112b05435..af92443e50b66e526d382c820e1b2e27
public void resetPlayerWeather();
+ // Paper start
+ /**
+ * Gives the player the amount of experience specified.
+ *
+ * @param amount Exp amount to give
+ */
+ public default void giveExp(int amount) {
+ giveExp(amount, false);
+ }
/**
* Gives the player the amount of experience specified.
*
* @param amount Exp amount to give
+ * @param applyMending Mend players items with mending, with same behavior as picking up orbs. calls {@link #applyMending(int)}
*/
- public void giveExp(int amount);
+ public default void giveExp(int amount) {
+ giveExp(amount, false);
+ }
+ /**
+ * Gives the player the amount of experience specified.
+ *
+ * @param amount Exp amount to give
+ * @param applyMending Mend players items with mending, with same behavior as picking up orbs. calls {@link #applyMending(int)}
+ */
+ public void giveExp(int amount, boolean applyMending);
+
+ /**

View file

@ -18,7 +18,7 @@ index d4d7ad9c3c953680342c121f39ddaef476549047..719d0d878320c1903b44076053989ba9
+ public void setConsumeArrow(boolean consumeArrow) {
+ this.setConsumeItem(consumeArrow);
+ }
+
+ @Deprecated
+ public boolean getConsumeArrow() {
+ return this.shouldConsumeItem();
@ -33,7 +33,7 @@ index d4d7ad9c3c953680342c121f39ddaef476549047..719d0d878320c1903b44076053989ba9
+ public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Entity projectile, final float force) {
+ this(shooter, bow, new ItemStack(org.bukkit.Material.AIR), projectile, force);
+ }
+
+ @Deprecated
+ public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull ItemStack arrowItem, @NotNull final Entity projectile, final float force) {
+ this(shooter, bow, arrowItem, projectile, EquipmentSlot.HAND, force, true);

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/inventory/Inventory.java b/src/main/java/o
index 5576a6a8df8c95164bf2dde45d756ce8b7ec957a..f1a48eab1a357ae64545e1f1dc941c383cff8707 100644
--- a/src/main/java/org/bukkit/inventory/Inventory.java
+++ b/src/main/java/org/bukkit/inventory/Inventory.java
@@ -104,7 +104,9 @@ public interface Inventory extends Iterable<ItemStack> {
@@ -104,7 +104,37 @@ public interface Inventory extends Iterable<ItemStack> {
public HashMap<Integer, ItemStack> addItem(@NotNull ItemStack... items) throws IllegalArgumentException;
/**
@ -16,25 +16,6 @@ index 5576a6a8df8c95164bf2dde45d756ce8b7ec957a..f1a48eab1a357ae64545e1f1dc941c38
+ * Removes the given ItemStacks from the storage contents of the inventory.
+ * For removing ItemStacks from the inventories that have other content groups,
+ * like Player inventories, see {@link #removeItemAnySlot(ItemStack...)}.
* <p>
* It will try to remove 'as much as possible' from the types and amounts
* you give as arguments.
@@ -121,10 +123,39 @@ public interface Inventory extends Iterable<ItemStack> {
* @param items The ItemStacks to remove
* @return A HashMap containing items that couldn't be removed.
* @throws IllegalArgumentException if items is null
+ * @see #removeItemAnySlot(ItemStack...)
*/
@NotNull
public HashMap<Integer, ItemStack> removeItem(@NotNull ItemStack... items) throws IllegalArgumentException;
+ // Paper start
+ /**
+ * Searches all possible inventory slots in order to remove the given ItemStacks.
+ * <p>
+ * Similar to {@link Inventory#removeItem(ItemStack...)} in behavior, except this
+ * method will check all possible slots in the inventory, rather than just the main
+ * storage contents.
+ * <p>
+ * It will try to remove 'as much as possible' from the types and amounts
+ * you give as arguments.
@ -51,11 +32,28 @@ index 5576a6a8df8c95164bf2dde45d756ce8b7ec957a..f1a48eab1a357ae64545e1f1dc941c38
+ * @param items The ItemStacks to remove
+ * @return A HashMap containing items that couldn't be removed.
+ * @throws IllegalArgumentException if items is null
+ * @see #removeItemAnySlot(ItemStack...)
+ */
+ @NotNull
+ public HashMap<Integer, ItemStack> removeItem(@NotNull ItemStack... items) throws IllegalArgumentException;
+
+ // Paper start
+ /**
+ * Searches all possible inventory slots in order to remove the given ItemStacks.
+ * <p>
+ * Similar to {@link Inventory#removeItem(ItemStack...)} in behavior, except this
+ * method will check all possible slots in the inventory, rather than just the main
+ * storage contents.
* <p>
* It will try to remove 'as much as possible' from the types and amounts
* you give as arguments.
@@ -123,7 +153,8 @@ public interface Inventory extends Iterable<ItemStack> {
* @throws IllegalArgumentException if items is null
*/
@NotNull
- public HashMap<Integer, ItemStack> removeItem(@NotNull ItemStack... items) throws IllegalArgumentException;
+ public HashMap<Integer, ItemStack> removeItemAnySlot(@NotNull ItemStack... items) throws IllegalArgumentException;
+ // Paper end
+
/**
* Returns all ItemStacks from the inventory
*

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Expand world key API
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index ceb8d207843df5ddc852d44928286648a652eedb..197cf8cdd3d51c3e01ec737981601f37764315c6 100644
index 95a981218615b9ed167a317aaa5224e9613aa42a..244c836dd24cb49f6219634e3f323befcd68d9da 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -811,6 +811,18 @@ public final class Bukkit {
@ -56,7 +56,7 @@ index 2fa3de66107162ccaa158b369e2c4a926ecaff92..aa534b1a9a1fb84a2fbd4b372f313bb4
// Paper end
}
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 02b898d441c42771903d5839c3cde544b1a25778..1a3b4f20c7126caf8a34040028f735083bf47150 100644
index 3327810c2ae80b47f6ccbc5b2034b880a774879f..8390b1d4718a4c67d222e19609462d20c36506b7 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -671,6 +671,17 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@ -104,16 +104,20 @@ index cbe6b3a1ba7b04826d97c3558e8eb4e5ba11f92f..cbdcac688afb7c13dd7058fa522bbd2c
private final String name;
private long seed;
private World.Environment environment = World.Environment.NORMAL;
@@ -28,13 +29,80 @@ public class WorldCreator {
@@ -28,14 +29,81 @@ public class WorldCreator {
* @param name Name of the world that will be created
*/
public WorldCreator(@NotNull String name) {
- if (name == null) {
- throw new IllegalArgumentException("World name cannot be null");
- }
-
- this.name = name;
- this.seed = (new Random()).nextLong();
+ // Paper start
+ this(name, getWorldKey(name));
+ }
+
}
+ private static NamespacedKey getWorldKey(String name) {
+ final String mainLevelName = Bukkit.getUnsafe().getMainLevelName();
+ if (name.equals(mainLevelName)) {
@ -124,10 +128,9 @@ index cbe6b3a1ba7b04826d97c3558e8eb4e5ba11f92f..cbdcac688afb7c13dd7058fa522bbd2c
+ return NamespacedKey.minecraft("the_end");
+ } else {
+ return NamespacedKey.minecraft(name.toLowerCase(java.util.Locale.ENGLISH).replace(" ", "_"));
}
+ }
+ }
- this.name = name;
+
+ /**
+ * Creates an empty WorldCreator for the given world name and key
+ *
@ -139,7 +142,7 @@ index cbe6b3a1ba7b04826d97c3558e8eb4e5ba11f92f..cbdcac688afb7c13dd7058fa522bbd2c
+ throw new IllegalArgumentException("World name and key cannot be null");
+ }
+ this.name = levelName;
this.seed = (new Random()).nextLong();
+ this.seed = (new Random()).nextLong();
+ this.key = worldKey;
+ }
+
@ -183,8 +186,9 @@ index cbe6b3a1ba7b04826d97c3558e8eb4e5ba11f92f..cbdcac688afb7c13dd7058fa522bbd2c
+ @NotNull
+ public static WorldCreator ofKey(@NotNull NamespacedKey worldKey) {
+ return new WorldCreator(worldKey);
}
+ }
+ // Paper end
+
/**
* Copies the options from the specified world
*

View file

@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..e6a40c1fcea761bd66743b50e3da3d14
+ }
+}
diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java
index 0264c2f9a3977b6d47994b1e1b0240b312e5bf65..69a048eb4e48c92db70c3d6b6aa4ae96326b9705 100644
index 1b6f42ff632b1f3f5034c825e99b72f389a890b4..4cfe8501368f601fdd4203570f4e6a8f6f9685e6 100644
--- a/src/main/java/org/bukkit/enchantments/Enchantment.java
+++ b/src/main/java/org/bukkit/enchantments/Enchantment.java
@@ -273,11 +273,7 @@ public abstract class Enchantment implements Keyed, net.kyori.adventure.translat
@ -53,7 +53,7 @@ index 0264c2f9a3977b6d47994b1e1b0240b312e5bf65..69a048eb4e48c92db70c3d6b6aa4ae96
@@ -311,6 +307,46 @@ public abstract class Enchantment implements Keyed, net.kyori.adventure.translat
* @return the name of the enchantment with {@code level} applied
*/
public abstract @NotNull net.kyori.adventure.text.Component displayName(int level);
public abstract net.kyori.adventure.text.@NotNull Component displayName(int level);
+
+ /**
+ * Checks if this enchantment can be found in villager trades.

View file

@ -1,11 +1,11 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Riley Park <riley.park@meino.net>
From: Riley Park <rileysebastianpark@gmail.com>
Date: Sun, 23 May 2021 05:04:28 -0700
Subject: [PATCH] ItemStack#editMeta
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
index b731ac4f6cd82d8476e4040a2204f58b0f63a0d3..84ea952cdee1eaec5572641e09fdd85930ddeb47 100644
index ffde4d11d4d5e783afb77bc2e96cf71113b2eb25..c5579710f73e9b8d407d5b8d698d2543a25a752d 100644
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
@@ -547,6 +547,50 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat

View file

@ -5,13 +5,13 @@ Subject: [PATCH] Add PlayerKickEvent causes
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 6c4d148202c3378e361fd8068c00cc0b67d6dc1e..b834537b1fa7ee349d10fe1ac5aa7e7dca4e35f7 100644
index b49620af0edcf10e7f74d616dcb4fb775308308f..bf5eeaffb7983c6a849ee80df0b78230d3cce42b 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -249,6 +249,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* @param message kick message
*/
void kick(final @Nullable net.kyori.adventure.text.Component message);
void kick(final net.kyori.adventure.text.@Nullable Component message);
+
+ /**
+ * Kicks player with custom kick message and cause.
@ -19,12 +19,12 @@ index 6c4d148202c3378e361fd8068c00cc0b67d6dc1e..b834537b1fa7ee349d10fe1ac5aa7e7d
+ * @param message kick message
+ * @param cause kick cause
+ */
+ void kick(final @Nullable net.kyori.adventure.text.Component message, @NotNull org.bukkit.event.player.PlayerKickEvent.Cause cause);
+ void kick(final net.kyori.adventure.text.@Nullable Component message, org.bukkit.event.player.PlayerKickEvent.@NotNull Cause cause);
// Paper end
/**
diff --git a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
index efbf4b657c99ce3a5096d041d275af9ccaea7911..5c968a0867223925b7eb5d6e04dbc33c41b7be6b 100644
index 997b06c19a5277656521e0e298f2958c209f1da1..2eb13c049fa917d41fa9ad17fdec9ec4c33701a8 100644
--- a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
@@ -12,6 +12,7 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable {

View file

@ -194,8 +194,12 @@ index 17527c2f7bd5b8a5528388a53f2472bc1869c7f3..3f6b9e59c2ea38031ca74962e02d710f
+ * recipes.
*
- * This includes it's name, description and other visible tags.
- *
- * @return a AdvancementDisplay object, or null if not set.
+ * @return the display info
+ */
*/
- @Nullable
- AdvancementDisplay getDisplay();
+ @org.jetbrains.annotations.Nullable
+ io.papermc.paper.advancement.AdvancementDisplay getDisplay();
+
@ -205,13 +209,10 @@ index 17527c2f7bd5b8a5528388a53f2472bc1869c7f3..3f6b9e59c2ea38031ca74962e02d710f
+ * completes the advancement. Will return the same as
+ * {@link io.papermc.paper.advancement.AdvancementDisplay#displayName()} when an
+ * {@link io.papermc.paper.advancement.AdvancementDisplay} is present.
*
- * @return a AdvancementDisplay object, or null if not set.
+ *
+ * @return the display name
+ * @see io.papermc.paper.advancement.AdvancementDisplay#displayName()
*/
- @Nullable
- AdvancementDisplay getDisplay();
+ */
+ @NotNull net.kyori.adventure.text.Component displayName();
+
+ /**

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.jav
index 869bad7405ec7fa67728e90d8b9f2e11b542611f..7ce8f1a26c1b33dd0eb6e6435952fd73abf49879 100644
--- a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
@@ -11,15 +11,40 @@ import org.jetbrains.annotations.NotNull;
@@ -11,16 +11,41 @@ import org.jetbrains.annotations.NotNull;
public class EntityDamageByEntityEvent extends EntityDamageEvent {
private final Entity damager;
@ -32,8 +32,8 @@ index 869bad7405ec7fa67728e90d8b9f2e11b542611f..7ce8f1a26c1b33dd0eb6e6435952fd73
this.damager = damager;
+ // Paper start - add critical damage API
+ this.critical = critical;
+ }
+
}
+ /**
+ * Shows this damage instance was critical.
+ * The damage instance can be critical if the attacking player met the respective conditions.
@ -44,8 +44,9 @@ index 869bad7405ec7fa67728e90d8b9f2e11b542611f..7ce8f1a26c1b33dd0eb6e6435952fd73
+ */
+ public boolean isCritical() {
+ return this.critical;
}
+ }
+ // Paper end
+
/**
* Returns the entity that damaged the defender.
*

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java b/src/
index 67fb9d93e808e907fa980f3004d415ae5d0a53fc..97e36c7f6e09276fbae20eaeee0965566332ca46 100644
--- a/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java
@@ -15,15 +15,58 @@ import org.jetbrains.annotations.Nullable;
@@ -15,16 +15,59 @@ import org.jetbrains.annotations.Nullable;
public class EntityPortalEvent extends EntityTeleportEvent {
private static final HandlerList handlers = new HandlerList();
private int searchRadius = 128;
@ -23,8 +23,8 @@ index 67fb9d93e808e907fa980f3004d415ae5d0a53fc..97e36c7f6e09276fbae20eaeee096556
super(entity, from, to);
this.searchRadius = searchRadius;
+ this.type = org.bukkit.PortalType.CUSTOM; // Paper
+ }
+
}
+ // Paper start
+ public EntityPortalEvent(@NotNull Entity entity, @NotNull Location from, @Nullable Location to, int searchRadius, final @NotNull org.bukkit.PortalType portalType) {
+ super(entity, from, to);
@ -63,11 +63,12 @@ index 67fb9d93e808e907fa980f3004d415ae5d0a53fc..97e36c7f6e09276fbae20eaeee096556
+ @Override
+ public void setTo(@Nullable final Location to) {
+ super.setTo(to);
}
+ }
+ // Paper end
+
/**
* Set the Block radius to search in for available portals.
*
diff --git a/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java b/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java
index 57eeeafae84f83a939925820e827769749ff27ec..929a997671de8202efb9da97fbf9b4a0bf7c37e8 100644
--- a/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java