mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-23 08:46:44 +01:00
Reapplying changes lost with our new system in CraftInventory and CraftInventoryPlayer.
This commit is contained in:
parent
ddfa284be7
commit
2fd3f8d299
2 changed files with 15 additions and 15 deletions
|
@ -26,16 +26,16 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
|
||||||
return getInventory().getName();
|
return getInventory().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftItemStack getItem(int index) {
|
public ItemStack getItem(int index) {
|
||||||
return new CraftItemStack(getInventory().getItem(index));
|
return new CraftItemStack(getInventory().getItem(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftItemStack[] getContents() {
|
public ItemStack[] getContents() {
|
||||||
CraftItemStack[] items = new CraftItemStack[getSize()];
|
ItemStack[] items = new ItemStack[getSize()];
|
||||||
net.minecraft.server.ItemStack[] mcItems = getInventory().getContents();
|
net.minecraft.server.ItemStack[] mcItems = getInventory().getContents();
|
||||||
|
|
||||||
for (int i = 0; i < mcItems.length; i++ ) {
|
for (int i = 0; i < mcItems.length; i++ ) {
|
||||||
items[i] = new CraftItemStack(mcItems[i]);
|
items[i] = mcItems[i] == null ? null : new CraftItemStack(mcItems[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
|
@ -64,7 +64,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
|
||||||
|
|
||||||
public boolean contains(int materialId) {
|
public boolean contains(int materialId) {
|
||||||
for (ItemStack item: getContents()) {
|
for (ItemStack item: getContents()) {
|
||||||
if (item.getTypeId() == materialId) {
|
if (item != null && item.getTypeId() == materialId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,11 +90,11 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
|
||||||
public boolean contains(int materialId, int amount) {
|
public boolean contains(int materialId, int amount) {
|
||||||
int amt = 0;
|
int amt = 0;
|
||||||
for (ItemStack item: getContents()) {
|
for (ItemStack item: getContents()) {
|
||||||
if (item.getTypeId() == materialId && item.getAmount() >= amount) {
|
if (item != null && item.getTypeId() == materialId) {
|
||||||
return true;
|
amt += item.getAmount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return amt >= amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Material material, int amount) {
|
public boolean contains(Material material, int amount) {
|
||||||
|
@ -107,11 +107,11 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
|
||||||
}
|
}
|
||||||
int amt = 0;
|
int amt = 0;
|
||||||
for (ItemStack i: getContents()) {
|
for (ItemStack i: getContents()) {
|
||||||
if (item.equals(i) && item.getAmount() >= amount) {
|
if (item.equals(i)) {
|
||||||
return true;
|
amt += item.getAmount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return amt >= amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Integer, ItemStack> all(int materialId) {
|
public HashMap<Integer, ItemStack> all(int materialId) {
|
||||||
|
|
|
@ -30,19 +30,19 @@ public class CraftInventoryPlayer extends CraftInventory implements PlayerInvent
|
||||||
return getInventory().itemInHandIndex;
|
return getInventory().itemInHandIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftItemStack getHelmet() {
|
public ItemStack getHelmet() {
|
||||||
return getItem( getSize() + 3 );
|
return getItem( getSize() + 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftItemStack getChestplate() {
|
public ItemStack getChestplate() {
|
||||||
return getItem( getSize() + 2 );
|
return getItem( getSize() + 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftItemStack getLeggings() {
|
public ItemStack getLeggings() {
|
||||||
return getItem( getSize() + 1 );
|
return getItem( getSize() + 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftItemStack getBoots() {
|
public ItemStack getBoots() {
|
||||||
return getItem( getSize() + 0 );
|
return getItem( getSize() + 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue