use of com.palmergames.bukkit.towny.event.LoadedMetadataEvent in project Towny by TownyAdvanced.
the class MetadataLoader method runDeserialization.
private void runDeserialization() {
if (storedMetadata.isEmpty())
return;
List<CustomDataField<?>> deserializedFields = new ArrayList<>();
for (TownyObject tObj : storedMetadata) {
// Convert all RawDataFields to actual CustomDataField classes.
for (CustomDataField<?> cdf : tObj.getMetadata()) {
if (!(cdf instanceof RawDataField))
continue;
CustomDataField<?> convertedCDF = convertRawMetadata((RawDataField) cdf);
if (convertedCDF == null || convertedCDF instanceof RawDataField)
continue;
deserializedFields.add(convertedCDF);
}
if (!deserializedFields.isEmpty()) {
for (CustomDataField<?> cdf : deserializedFields) {
// Will override the metadata
tObj.addMetaData(cdf, false);
}
deserializedFields.clear();
}
}
storedMetadata.clear();
// Reduce memory alloc after load.
storedMetadata.trimToSize();
// Call event
Bukkit.getPluginManager().callEvent(new LoadedMetadataEvent());
}
Aggregations