Allow for logging of item data greater than 256. Fixes #96, #235

This change involves refactoring many instances of "byte" to "short and altering a few ItemStack calls to use the int,int,short form instead of int,int,0,byte
Significantly it also involves altering the MaterialName system to allow shorts instead of bytes, and altering the rawdata() function to return the durability of an ItemStack rather than the data value of its Material.

One side effect of this is that tool durability is now logged, which will make for more accurate rollbacks.
This commit is contained in:
Philip Cass
2013-12-04 11:29:02 +00:00
parent d50c48f79d
commit c0b983e8e8
9 changed files with 51 additions and 23 deletions
@@ -242,7 +242,7 @@ public class BukkitUtils
for (final ItemStack item : items)
if (item != null) {
final int type = item.getTypeId();
final byte data = rawData(item);
final short data = rawData(item);
boolean found = false;
for (final ItemStack item2 : compressed)
if (type == item2.getTypeId() && data == rawData(item2)) {
@@ -251,7 +251,7 @@ public class BukkitUtils
break;
}
if (!found)
compressed.add(new ItemStack(type, item.getAmount(), (short)0, data));
compressed.add(new ItemStack(type, item.getAmount(), data));
}
Collections.sort(compressed, new ItemStackComparator());
return compressed.toArray(new ItemStack[compressed.size()]);
@@ -322,8 +322,8 @@ public class BukkitUtils
}
}
public static byte rawData(ItemStack item) {
return item.getType() != null ? item.getData() != null ? item.getData().getData() : 0 : 0;
public static short rawData(ItemStack item) {
return item.getType() != null ? item.getData() != null ? item.getDurability() : 0 : 0;
}
public static int saveSpawnHeight(Location loc) {
@@ -381,7 +381,7 @@ public class BukkitUtils
return -1;
if (aType > bType)
return 1;
final byte aData = rawData(a), bData = rawData(b);
final short aData = rawData(a), bData = rawData(b);
if (aData < bData)
return -1;
if (aData > bData)