mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2024-12-22 16:05:03 +00:00
Merge pull request #38 from ShadowRanger/master
Added 1.9 shield slot support
This commit is contained in:
commit
62f5d54676
3 changed files with 18 additions and 17 deletions
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
|||
<groupId>com.lishid</groupId>
|
||||
<artifactId>openinv</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>2.3.5</version>
|
||||
<version>2.3.6</version>
|
||||
<name>OpenInv</name>
|
||||
<url>http://dev.bukkit.org/bukkit-plugins/openinv/</url>
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import com.lishid.openinv.OpenInv;
|
|||
public class SpecialPlayerInventory extends PlayerInventory {
|
||||
|
||||
private final CraftInventory inventory = new CraftInventory(this);
|
||||
private final ItemStack[] extra = new ItemStack[5];
|
||||
private final ItemStack[] extra = new ItemStack[4];
|
||||
private final ItemStack[][] arrays;
|
||||
private final CraftPlayer owner;
|
||||
private boolean playerOnline;
|
||||
|
@ -41,32 +41,24 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
|||
super(((CraftPlayer) p).getHandle());
|
||||
this.owner = (CraftPlayer) p;
|
||||
reflectContents(getClass().getSuperclass(), player.inventory, this);
|
||||
this.arrays = new ItemStack[][] { this.items, this.armor, this.extra };
|
||||
this.arrays = new ItemStack[][] { this.items, this.armor, this.extraSlots, this.extra };
|
||||
this.playerOnline = online;
|
||||
OpenInv.inventories.put(owner.getUniqueId(), this);
|
||||
}
|
||||
|
||||
private void reflectContents(Class clazz, PlayerInventory src, PlayerInventory dest) {
|
||||
// Items
|
||||
try {
|
||||
Field itemsField = clazz.getDeclaredField("items");
|
||||
itemsField.setAccessible(true);
|
||||
itemsField.set(dest, src.items);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Armor
|
||||
try {
|
||||
Field armorField = clazz.getDeclaredField("armor");
|
||||
armorField.setAccessible(true);
|
||||
armorField.set(dest, src.armor);
|
||||
|
||||
Field extraSlotsField = clazz.getDeclaredField("extraSlots");
|
||||
extraSlotsField.setAccessible(true);
|
||||
extraSlotsField.set(dest, src.extraSlots);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
|
@ -120,12 +112,13 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
|||
ItemStack[] contents = new ItemStack[getSize()];
|
||||
System.arraycopy(this.items, 0, contents, 0, this.items.length);
|
||||
System.arraycopy(this.armor, 0, contents, this.items.length, this.armor.length);
|
||||
System.arraycopy(this.extraSlots, 0, contents, this.items.length + this.armor.length, this.extraSlots.length);
|
||||
return contents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return super.getSize() - this.extraSlots.length + 5;
|
||||
return super.getSize() + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -149,6 +142,8 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
|||
i = getReversedItemSlotNum(i);
|
||||
} else if (is == this.armor) {
|
||||
i = getReversedArmorSlotNum(i);
|
||||
} else if (is == this.extraSlots) {
|
||||
// Do nothing
|
||||
} else if (is == this.extra) {
|
||||
// Do nothing
|
||||
}
|
||||
|
@ -177,6 +172,8 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
|||
i = getReversedItemSlotNum(i);
|
||||
} else if (is == this.armor) {
|
||||
i = getReversedArmorSlotNum(i);
|
||||
} else if (is == this.extraSlots) {
|
||||
// Do nothing
|
||||
} else if (is == this.extra) {
|
||||
// Do nothing
|
||||
}
|
||||
|
@ -206,6 +203,8 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
|||
i = getReversedItemSlotNum(i);
|
||||
} else if (is == this.armor) {
|
||||
i = getReversedArmorSlotNum(i);
|
||||
} else if (is == this.extraSlots) {
|
||||
// Do nothing
|
||||
} else if (is == this.extra) {
|
||||
// Do nothing
|
||||
}
|
||||
|
@ -240,6 +239,8 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
|||
i = getReversedItemSlotNum(i);
|
||||
} else if (is == this.armor) {
|
||||
i = getReversedArmorSlotNum(i);
|
||||
} else if (is == this.extraSlots) {
|
||||
// Do nothing
|
||||
} else if (is == this.extra) {
|
||||
owner.getHandle().drop(itemStack, true);
|
||||
itemStack = null;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: OpenInv
|
||||
main: com.lishid.openinv.OpenInv
|
||||
version: 2.3.5
|
||||
version: 2.3.6
|
||||
author: lishid
|
||||
description: >
|
||||
This plugin allows you to open a player's inventory as a chest and interact with it in real time.
|
||||
|
|
Loading…
Reference in a new issue