Check for empty when sending equipment changes (#12008)

This commit is contained in:
Creeam 2025-01-25 11:04:47 -08:00 committed by GitHub
parent 88bbead13b
commit 336ea9dfeb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -1063,7 +1063,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* *
* @param entity the entity whose equipment to change * @param entity the entity whose equipment to change
* @param items the slots to change, where the values are the items to which * @param items the slots to change, where the values are the items to which
* the slot should be changed. null values will set the slot to air * the slot should be changed. null values will set the slot to air, empty map is not allowed
*/ */
public void sendEquipmentChange(@NotNull LivingEntity entity, @NotNull Map<EquipmentSlot, ItemStack> items); public void sendEquipmentChange(@NotNull LivingEntity entity, @NotNull Map<EquipmentSlot, ItemStack> items);

View File

@ -1161,6 +1161,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void sendEquipmentChange(LivingEntity entity, Map<EquipmentSlot, ItemStack> items) { public void sendEquipmentChange(LivingEntity entity, Map<EquipmentSlot, ItemStack> items) {
Preconditions.checkArgument(entity != null, "Entity cannot be null"); Preconditions.checkArgument(entity != null, "Entity cannot be null");
Preconditions.checkArgument(items != null, "items cannot be null"); Preconditions.checkArgument(items != null, "items cannot be null");
Preconditions.checkArgument(!items.isEmpty(), "items cannot be empty");
if (this.getHandle().connection == null) { if (this.getHandle().connection == null) {
return; return;