Fixed ClassCastException when rolling back banner inventory transactions

This commit is contained in:
Intelli 2022-02-22 21:41:11 -07:00
parent 4445c3c4a7
commit 3b93046731

View File

@ -1689,9 +1689,24 @@ public class Rollback extends Queue {
*/ */
Material rowType = itemstack.getType(); Material rowType = itemstack.getType();
List<Object> metaList = (List<Object>) list;
if (!(metaList.get(0) instanceof List<?>)) {
if (rowType.name().endsWith("_BANNER")) {
BannerMeta meta = (BannerMeta) itemstack.getItemMeta();
for (Object value : metaList) {
if (value instanceof Map) {
Pattern pattern = new Pattern((Map<String, Object>) value);
meta.addPattern(pattern);
}
}
itemstack.setItemMeta(meta);
}
return new Object[] { slot, faceData, itemstack };
}
int itemCount = 0; int itemCount = 0;
Builder effectBuilder = FireworkEffect.builder(); Builder effectBuilder = FireworkEffect.builder();
for (List<Map<String, Object>> map : (List<List<Map<String, Object>>>) list) { for (List<Map<String, Object>> map : (List<List<Map<String, Object>>>) list) {
if (map.size() == 0) { if (map.size() == 0) {
if (itemCount == 3 && (rowType == Material.FIREWORK_ROCKET || rowType == Material.FIREWORK_STAR)) { if (itemCount == 3 && (rowType == Material.FIREWORK_ROCKET || rowType == Material.FIREWORK_STAR)) {