Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/patches/api/0440-Fix-PlayerSwapHandItemsEvent-throwing-exception-when.patch
Jake Potrebic 2f92d4e00e
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
01bb6ba7 PR-936: Add new PersistentDataContainer methods and clean up docs
bc145b90 PR-940: Create registry for banner pattern and cat type

CraftBukkit Changes:
cb2ea54de SPIGOT-7440, PR-1292: Fire EntityTeleportEvent for end gateways
4fea66e44 PR-1299: Add new PersistentDataContainer methods and clean up docs
b483a20db PR-1303: Create registry for banner pattern and cat type
4642dd526 SPIGOT-7535: Fix maps not having an ID and also call MapInitializeEvent in more places
2023-12-08 11:00:39 -08:00

48 Zeilen
1.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tamion <70228790+notTamion@users.noreply.github.com>
Date: Mon, 25 Sep 2023 19:55:51 +0200
Subject: [PATCH] Fix PlayerSwapHandItemsEvent throwing exception when mainhand
or offhand set to null
diff --git a/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java b/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java
index 9f592317c920589c22a5fb8e916c6ca58ebe5c59..39dd08de71b8b52fe3462c105ecdbfc1cd2cd9a3 100644
--- a/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java
@@ -31,7 +31,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable
*
* @return item in the main hand
*/
- @Nullable
+ @NotNull // Paper
public ItemStack getMainHandItem() {
return mainHandItem;
}
@@ -42,7 +42,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable
* @param mainHandItem new item in the main hand
*/
public void setMainHandItem(@Nullable ItemStack mainHandItem) {
- this.mainHandItem = mainHandItem;
+ this.mainHandItem = mainHandItem == null ? ItemStack.empty() : mainHandItem; // Paper
}
/**
@@ -50,7 +50,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable
*
* @return item in the off hand
*/
- @Nullable
+ @NotNull // Paper
public ItemStack getOffHandItem() {
return offHandItem;
}
@@ -61,7 +61,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable
* @param offHandItem new item in the off hand
*/
public void setOffHandItem(@Nullable ItemStack offHandItem) {
- this.offHandItem = offHandItem;
+ this.offHandItem = offHandItem == null ? ItemStack.empty() : offHandItem; // Paper
}
@Override