Fixed inventory lookups not returning correct item for planted seeds

This commit is contained in:
Intelli 2022-02-24 20:52:30 -07:00
parent ddb804ce99
commit 900cad643f
4 changed files with 24 additions and 9 deletions

View File

@ -875,7 +875,7 @@ public class LookupCommand {
int amount = Integer.parseInt(data[10]); int amount = Integer.parseInt(data[10]);
String rbd = ((Integer.parseInt(data[8]) == 2 || Integer.parseInt(data[8]) == 3) ? Color.STRIKETHROUGH : ""); String rbd = ((Integer.parseInt(data[8]) == 2 || Integer.parseInt(data[8]) == 3) ? Color.STRIKETHROUGH : "");
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true); String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
Material blockType = Util.itemFilter(Util.getType(Integer.parseInt(dtype))); Material blockType = Util.itemFilter(Util.getType(Integer.parseInt(dtype)), (Integer.parseInt(data[13]) == 0));
String dname = Util.nameFilter(blockType.name().toLowerCase(Locale.ROOT), ddata); String dname = Util.nameFilter(blockType.name().toLowerCase(Locale.ROOT), ddata);
String selector = Selector.FIRST; String selector = Selector.FIRST;

View File

@ -234,11 +234,9 @@ public class Lookup extends Queue {
resultData = results.getInt("data"); resultData = results.getInt("data");
resultAmount = results.getInt("amount"); resultAmount = results.getInt("amount");
resultMeta = results.getBytes("metadata"); resultMeta = results.getBytes("metadata");
if (!lookup) {
resultTable = results.getInt("tbl"); resultTable = results.getInt("tbl");
hasTbl = true; hasTbl = true;
} }
}
else { else {
resultData = results.getInt("data"); resultData = results.getInt("data");
resultMeta = results.getBytes("meta"); resultMeta = results.getBytes("meta");

View File

@ -1053,7 +1053,7 @@ public class Rollback extends Queue {
int rolledBackInventory = Util.rolledBack((Integer) row[9], true); int rolledBackInventory = Util.rolledBack((Integer) row[9], true);
if (rowType != null) { if (rowType != null) {
if (inventoryRollback && ((rollbackType == 0 && rolledBackInventory == 0) || (rollbackType == 1 && rolledBackInventory == 1))) { if (inventoryRollback && ((rollbackType == 0 && rolledBackInventory == 0) || (rollbackType == 1 && rolledBackInventory == 1))) {
Material inventoryItem = Util.itemFilter(rowType); Material inventoryItem = Util.itemFilter(rowType, ((Integer) row[14] == 0));
int rowUserId = (Integer) row[2]; int rowUserId = (Integer) row[2];
String rowUser = ConfigHandler.playerIdCacheReversed.get(rowUserId); String rowUser = ConfigHandler.playerIdCacheReversed.get(rowUserId);
if (rowUser == null) { if (rowUser == null) {

View File

@ -1105,12 +1105,29 @@ public class Util extends Queue {
Chat.sendComponent(consoleSender, Color.RESET + "[CoreProtect] " + string + Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_POPUP + "| | " + Chat.COMPONENT_TAG_CLOSE); Chat.sendComponent(consoleSender, Color.RESET + "[CoreProtect] " + string + Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_POPUP + "| | " + Chat.COMPONENT_TAG_CLOSE);
} }
public static Material itemFilter(Material material) { // This filter is only used for a:inventory
if (material == null) { public static Material itemFilter(Material material, boolean blockTable) {
if (material == null || (!blockTable && material.isItem())) {
return material; return material;
} }
if (!material.isItem() && material.name().contains("WALL_")) { switch (material) {
case WHEAT:
material = Material.WHEAT_SEEDS;
break;
case PUMPKIN_STEM:
material = Material.PUMPKIN_SEEDS;
break;
case MELON_STEM:
material = Material.MELON_SEEDS;
break;
case BEETROOTS:
material = Material.BEETROOT_SEEDS;
break;
default:
}
if (material.name().contains("WALL_")) {
material = Material.valueOf(material.name().replace("WALL_", "")); material = Material.valueOf(material.name().replace("WALL_", ""));
} }