use of com.palmergames.bukkit.towny.object.TownyObject in project Towny by TownyAdvanced.
the class TownyCommand method getMostResidents.
public List<String> getMostResidents(List<ResidentList> list) {
final int maxListing = TownySettings.getTownyTopSize();
List<String> output = new ArrayList<>();
list.sort(Comparator.comparingInt(residentList -> residentList.getResidents().size()));
Collections.reverse(list);
int n = 0;
for (ResidentList residentList : list) {
n++;
if (maxListing != -1 && n > maxListing)
break;
output.add(String.format(Colors.Blue + "%30s " + Colors.Gold + "|" + Colors.LightGray + " %10d", ((TownyObject) residentList).getFormattedName(), residentList.getResidents().size()));
}
return output;
}
use of com.palmergames.bukkit.towny.object.TownyObject 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