PaperMC/Remapped-Spigot-Server-Patches/0671-Merchant-getRecipes-should-return-an-immutable-list.patch
2021-06-11 13:56:17 +02:00

19 lines
1.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: jmp <jasonpenilla2@me.com>
Date: Wed, 10 Feb 2021 14:53:36 -0800
Subject: [PATCH] Merchant#getRecipes should return an immutable list
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java
index 3437ec2c7c1a84debb7d7b7c90283d7e25208604..b4bcbd6329c67ea3deeeb1bf38233ebd15e922b7 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java
@@ -24,7 +24,7 @@ public class CraftMerchant implements Merchant {
@Override
public List<MerchantRecipe> getRecipes() {
- return Collections.unmodifiableList(Lists.transform(merchant.getOffers(), new Function<net.minecraft.world.item.trading.MerchantOffer, MerchantRecipe>() {
+ return com.google.common.collect.ImmutableList.copyOf(Lists.transform(merchant.getOffers(), new Function<net.minecraft.world.item.trading.MerchantOffer, MerchantRecipe>() { // Paper - javadoc says 'an immutable list of trades' - not 'an unmodifiable view of a list of trades'. fixes issue with setRecipes(getRecipes())
@Override
public MerchantRecipe apply(net.minecraft.world.item.trading.MerchantOffer recipe) {
return recipe.asBukkit();