Skip to content

Commit

Permalink
Actually allow for offhand modification, whoops.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jikoo committed Mar 4, 2016
1 parent 5b3ba79 commit d761b6b
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
CraftPlayer owner;
public boolean playerOnline = false;
private final ItemStack[] extra = new ItemStack[5];
private final ItemStack[] extra = new ItemStack[4];
private final CraftInventory inventory = new CraftInventory(this);

public SpecialPlayerInventory(Player p, Boolean online) {
Expand All @@ -59,6 +59,7 @@ private void setItemArrays(PlayerInventory inventory, ItemStack[] items, ItemSta
field.set(inventory, armor);
field = inventory.getClass().getField("extraSlots");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, extraSlots);
} catch (NoSuchFieldException e) {
// Unable to set final fields to item arrays, we're screwed. Noisily fail.
e.printStackTrace();
Expand All @@ -69,15 +70,18 @@ private void setItemArrays(PlayerInventory inventory, ItemStack[] items, ItemSta
}
}

@Override
public Inventory getBukkitInventory() {
return inventory;
}

@Override
public boolean inventoryRemovalCheck() {
owner.saveData();
return transaction.isEmpty() && !playerOnline;
}

@Override
public void setPlayerOnline(Player player) {
if (!playerOnline) {
CraftPlayer p = (CraftPlayer) player;
Expand All @@ -87,6 +91,7 @@ public void setPlayerOnline(Player player) {
}
}

@Override
public boolean setPlayerOffline() {
playerOnline = false;
return this.inventoryRemovalCheck();
Expand All @@ -103,6 +108,7 @@ public ItemStack[] getContents() {
ItemStack[] C = new ItemStack[getSize()];
System.arraycopy(items, 0, C, 0, items.length);
System.arraycopy(armor, 0, C, items.length, armor.length);
System.arraycopy(extraSlots, 0, C, items.length + armor.length, extraSlots.length);
return C;
}

Expand Down

0 comments on commit d761b6b

Please sign in to comment.