More param name fixes

This commit is contained in:
Nassim Jahnke
2024-12-20 12:45:19 +01:00
parent 42a2ccff55
commit f3c1eb3dc0
19 changed files with 68 additions and 86 deletions

View File

@@ -55,7 +55,7 @@
public Inventory(Player player) {
this.player = player;
}
@@ -50,10 +_,32 @@
@@ -50,10 +_,39 @@
private boolean hasRemainingSpaceForItem(ItemStack destination, ItemStack origin) {
return !destination.isEmpty()
@@ -68,24 +68,31 @@
+ }
+
+ // CraftBukkit start - Watch method above! :D
+ public int canHold(ItemStack itemstack) {
+ int remains = itemstack.getCount();
+ for (int i = 0; i < this.items.size(); ++i) {
+ ItemStack itemstack1 = this.getItem(i);
+ if (itemstack1.isEmpty()) return itemstack.getCount();
+
+ if (this.hasRemainingSpaceForItem(itemstack1, itemstack)) {
+ remains -= (itemstack1.getMaxStackSize() < this.getMaxStackSize() ? itemstack1.getMaxStackSize() : this.getMaxStackSize()) - itemstack1.getCount();
+ public int canHold(ItemStack itemStack) {
+ int remains = itemStack.getCount();
+ for (int slot = 0; slot < this.items.size(); ++slot) {
+ ItemStack itemInSlot = this.getItem(slot);
+ if (itemInSlot.isEmpty()) {
+ return itemStack.getCount();
+ }
+ if (remains <= 0) return itemstack.getCount();
+ }
+ ItemStack offhandItemStack = this.getItem(this.items.size() + this.armor.size());
+ if (this.hasRemainingSpaceForItem(offhandItemStack, itemstack)) {
+ remains -= (offhandItemStack.getMaxStackSize() < this.getMaxStackSize() ? offhandItemStack.getMaxStackSize() : this.getMaxStackSize()) - offhandItemStack.getCount();
+ }
+ if (remains <= 0) return itemstack.getCount();
+
+ return itemstack.getCount() - remains;
+ if (this.hasRemainingSpaceForItem(itemInSlot, itemStack)) {
+ remains -= (itemInSlot.getMaxStackSize() < this.getMaxStackSize() ? itemInSlot.getMaxStackSize() : this.getMaxStackSize()) - itemInSlot.getCount();
+ }
+ if (remains <= 0) {
+ return itemStack.getCount();
+ }
+ }
+
+ ItemStack itemInOffhand = this.getItem(this.items.size() + this.armor.size());
+ if (this.hasRemainingSpaceForItem(itemInOffhand, itemStack)) {
+ remains -= (itemInOffhand.getMaxStackSize() < this.getMaxStackSize() ? itemInOffhand.getMaxStackSize() : this.getMaxStackSize()) - itemInOffhand.getCount();
+ }
+ if (remains <= 0) {
+ return itemStack.getCount();
+ }
+
+ return itemStack.getCount() - remains;
+ }
+ // CraftBukkit end

View File

@@ -462,8 +462,8 @@
+ }
+
+ @Override
+ public void remove(Entity.RemovalReason entity_removalreason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
+ super.remove(entity_removalreason, cause);
+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
+ super.remove(reason, eventCause);
+ // CraftBukkit end
this.inventoryMenu.removed(this);
if (this.containerMenu != null && this.hasContainerOpen()) {