mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Fix trader merchants NPE when interacting with a merchant with non-active trades
This commit is contained in:
parent
df42b6f60c
commit
55c371884e
1 changed files with 16 additions and 11 deletions
|
@ -180,6 +180,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
MerchantOffer merchantOffer = this.slots.getActiveOffer();
|
MerchantOffer merchantOffer = this.slots.getActiveOffer();
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ io.papermc.paper.event.player.PlayerPurchaseEvent event = null;
|
+ io.papermc.paper.event.player.PlayerPurchaseEvent event = null;
|
||||||
|
+ if (merchantOffer != null) {
|
||||||
+ if (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager && this.merchant.getTradingPlayer().getBukkitEntity() instanceof org.bukkit.entity.Player) {
|
+ if (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager && this.merchant.getTradingPlayer().getBukkitEntity() instanceof org.bukkit.entity.Player) {
|
||||||
+ event = new io.papermc.paper.event.player.PlayerTradeEvent((org.bukkit.entity.Player) this.merchant.getTradingPlayer().getBukkitEntity(), (org.bukkit.entity.AbstractVillager) ((net.minecraft.world.entity.npc.AbstractVillager) this.merchant).getBukkitEntity(), merchantOffer.asBukkit(), true, true);
|
+ event = new io.papermc.paper.event.player.PlayerTradeEvent((org.bukkit.entity.Player) this.merchant.getTradingPlayer().getBukkitEntity(), (org.bukkit.entity.AbstractVillager) ((net.minecraft.world.entity.npc.AbstractVillager) this.merchant).getBukkitEntity(), merchantOffer.asBukkit(), true, true);
|
||||||
+ } else if (this.merchant instanceof org.bukkit.craftbukkit.inventory.CraftMerchantCustom.MinecraftMerchant && this.merchant.getTradingPlayer().getBukkitEntity() instanceof org.bukkit.entity.Player) {
|
+ } else if (this.merchant instanceof org.bukkit.craftbukkit.inventory.CraftMerchantCustom.MinecraftMerchant && this.merchant.getTradingPlayer().getBukkitEntity() instanceof org.bukkit.entity.Player) {
|
||||||
|
@ -192,8 +193,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ merchantOffer = org.bukkit.craftbukkit.inventory.CraftMerchantRecipe.fromBukkit(event.getTrade()).toMinecraft();
|
+ merchantOffer = org.bukkit.craftbukkit.inventory.CraftMerchantRecipe.fromBukkit(event.getTrade()).toMinecraft();
|
||||||
|
+ } else {
|
||||||
|
+ // TODO: Check this, I don't see how this would be hit and the logic below should be fired, warn for missing cases?
|
||||||
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ this.checkTakeAchievements(stack);
|
+ this.checkTakeAchievements(stack);
|
||||||
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
if (merchantOffer != null) {
|
if (merchantOffer != null) {
|
||||||
ItemStack itemStack = this.slots.getItem(0);
|
ItemStack itemStack = this.slots.getItem(0);
|
||||||
|
|
Loading…
Reference in a new issue