forked from LogBlock/LogBlock
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user