Fixed NotSerializableException when logging items containing attribute data
This commit is contained in:
parent
f729c8a126
commit
b3db65d07d
2 changed files with 12 additions and 5 deletions
|
|
@ -346,10 +346,17 @@ public class RollbackUtil extends Lookup {
|
||||||
List<Object> modifiers = (List<Object>) mapData.get("modifiers");
|
List<Object> modifiers = (List<Object>) mapData.get("modifiers");
|
||||||
|
|
||||||
for (Object item : modifiers) {
|
for (Object item : modifiers) {
|
||||||
Map<Attribute, Map<String, Object>> modifiersMap = (Map<Attribute, Map<String, Object>>) item;
|
Map<Object, Map<String, Object>> modifiersMap = (Map<Object, Map<String, Object>>) item;
|
||||||
for (Map.Entry<Attribute, Map<String, Object>> entry : modifiersMap.entrySet()) {
|
for (Map.Entry<Object, Map<String, Object>> entry : modifiersMap.entrySet()) {
|
||||||
try {
|
try {
|
||||||
Attribute attribute = entry.getKey();
|
Attribute attribute = null;
|
||||||
|
if (entry.getKey() instanceof Attribute) {
|
||||||
|
attribute = (Attribute) entry.getKey();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
attribute = (Attribute) BukkitAdapter.ADAPTER.getRegistryValue((String) entry.getKey(), Attribute.class);
|
||||||
|
}
|
||||||
|
|
||||||
AttributeModifier modifier = AttributeModifier.deserialize(entry.getValue());
|
AttributeModifier modifier = AttributeModifier.deserialize(entry.getValue());
|
||||||
itemMeta.addAttributeModifier(attribute, modifier);
|
itemMeta.addAttributeModifier(attribute, modifier);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,12 +125,12 @@ public class ItemMetaHandler {
|
||||||
|
|
||||||
if (itemMeta.hasAttributeModifiers()) {
|
if (itemMeta.hasAttributeModifiers()) {
|
||||||
for (Map.Entry<Attribute, AttributeModifier> entry : itemMeta.getAttributeModifiers().entries()) {
|
for (Map.Entry<Attribute, AttributeModifier> entry : itemMeta.getAttributeModifiers().entries()) {
|
||||||
Map<Attribute, Map<String, Object>> attributeList = new HashMap<>();
|
Map<Object, Map<String, Object>> attributeList = new HashMap<>();
|
||||||
Attribute attribute = entry.getKey();
|
Attribute attribute = entry.getKey();
|
||||||
AttributeModifier modifier = entry.getValue();
|
AttributeModifier modifier = entry.getValue();
|
||||||
|
|
||||||
itemMeta.removeAttributeModifier(attribute, modifier);
|
itemMeta.removeAttributeModifier(attribute, modifier);
|
||||||
attributeList.put(attribute, modifier.serialize());
|
attributeList.put(BukkitAdapter.ADAPTER.getRegistryKey(attribute), modifier.serialize());
|
||||||
modifiers.add(attributeList);
|
modifiers.add(attributeList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue