Commits

Y2K_ authored and md_5 committed ea073278d25
#1088: Deprecate HumanEntity#open[Menu]; Add Server#createMerchant()
No tags

src/main/java/org/bukkit/entity/HumanEntity.java

Modified
4 4 import java.util.Set;
5 5 import org.bukkit.GameMode;
6 6 import org.bukkit.Location;
7 7 import org.bukkit.Material;
8 8 import org.bukkit.NamespacedKey;
9 9 import org.bukkit.inventory.Inventory;
10 10 import org.bukkit.inventory.InventoryHolder;
11 11 import org.bukkit.inventory.InventoryView;
12 12 import org.bukkit.inventory.ItemStack;
13 13 import org.bukkit.inventory.MainHand;
14 +import org.bukkit.inventory.MenuType;
14 15 import org.bukkit.inventory.Merchant;
15 16 import org.bukkit.inventory.PlayerInventory;
16 17 import org.bukkit.inventory.meta.FireworkMeta;
17 18 import org.jetbrains.annotations.NotNull;
18 19 import org.jetbrains.annotations.Nullable;
19 20
20 21 /**
21 22 * Represents a human entity, such as an NPC or a player
22 23 */
23 24 public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder {
111 112 /**
112 113 * Opens an empty workbench inventory window with the player's inventory
113 114 * on the bottom.
114 115 *
115 116 * @param location The location to attach it to. If null, the player's
116 117 * location is used.
117 118 * @param force If false, and there is no workbench block at the location,
118 119 * no inventory will be opened and null will be returned.
119 120 * @return The newly opened inventory view, or null if it could not be
120 121 * opened.
122 + * @deprecated This method should be replaced by {@link MenuType#CRAFTING}
123 + * see {@link MenuType.Typed#builder()} and its options for more information.
121 124 */
125 + @Deprecated(since = "1.21.4")
122 126 @Nullable
123 127 public InventoryView openWorkbench(@Nullable Location location, boolean force);
124 128
125 129 /**
126 130 * Opens an empty enchanting inventory window with the player's inventory
127 131 * on the bottom.
128 132 *
129 133 * @param location The location to attach it to. If null, the player's
130 134 * location is used.
131 135 * @param force If false, and there is no enchanting table at the
132 136 * location, no inventory will be opened and null will be returned.
133 137 * @return The newly opened inventory view, or null if it could not be
134 138 * opened.
139 + * @deprecated This method should be replaced by {@link MenuType#ENCHANTMENT}
140 + * see {@link MenuType.Typed#builder()} and its options for more information.
135 141 */
142 + @Deprecated(since = "1.21.4")
136 143 @Nullable
137 144 public InventoryView openEnchanting(@Nullable Location location, boolean force);
138 145
139 146 /**
140 147 * Opens an inventory window to the specified inventory view.
141 148 * <p>
142 149 * The player associated with the InventoryView must be the same as this
143 150 * instance of HumanEntity.
144 151 * <p>
145 152 * The player of the InventoryView can be checked using
152 159 /**
153 160 * Starts a trade between the player and the villager.
154 161 *
155 162 * Note that only one player may trade with a villager at once. You must use
156 163 * the force parameter for this.
157 164 *
158 165 * @param trader The merchant to trade with. Cannot be null.
159 166 * @param force whether to force the trade even if another player is trading
160 167 * @return The newly opened inventory view, or null if it could not be
161 168 * opened.
169 + * @deprecated This method can be replaced by using {@link MenuType#MERCHANT}
170 + * in conjunction with {@link #openInventory(InventoryView)}.
162 171 */
172 + @Deprecated(since = "1.21.4")
163 173 @Nullable
164 174 public InventoryView openMerchant(@NotNull Villager trader, boolean force);
165 175
166 176 /**
167 177 * Starts a trade between the player and the merchant.
168 178 *
169 179 * Note that only one player may trade with a merchant at once. You must use
170 180 * the force parameter for this.
171 181 *
172 182 * @param merchant The merchant to trade with. Cannot be null.
173 183 * @param force whether to force the trade even if another player is trading
174 184 * @return The newly opened inventory view, or null if it could not be
175 185 * opened.
186 + * @deprecated This method can be replaced by using {@link MenuType#MERCHANT}
187 + * in conjunction with {@link #openInventory(InventoryView)}.
176 188 */
189 + @Deprecated(since = "1.21.4")
177 190 @Nullable
178 191 public InventoryView openMerchant(@NotNull Merchant merchant, boolean force);
179 192
180 193 /**
181 194 * Force-closes the currently open inventory view for this player, if any.
182 195 */
183 196 public void closeInventory();
184 197
185 198 /**
186 199 * Returns the ItemStack currently in your hand, can be empty.

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut