loottracker: replace getTotalPrice with stream
This commit is contained in:
@@ -1131,26 +1131,18 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getTotalPrice(Collection<ItemStack> items)
|
|
||||||
{
|
|
||||||
long totalPrice = 0;
|
|
||||||
|
|
||||||
for (final ItemStack itemStack : items)
|
|
||||||
{
|
|
||||||
totalPrice += (long) itemManager.getItemPrice(itemStack.getId()) * itemStack.getQuantity();
|
|
||||||
}
|
|
||||||
|
|
||||||
return totalPrice;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void lootReceivedChatMessage(final Collection<ItemStack> items, final String name)
|
private void lootReceivedChatMessage(final Collection<ItemStack> items, final String name)
|
||||||
{
|
{
|
||||||
|
long totalPrice = items.stream()
|
||||||
|
.mapToLong(is -> (long) itemManager.getItemPrice(is.getId()) * is.getQuantity())
|
||||||
|
.sum();
|
||||||
|
|
||||||
final String message = new ChatMessageBuilder()
|
final String message = new ChatMessageBuilder()
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append("You've killed ")
|
.append("You've killed ")
|
||||||
.append(name)
|
.append(name)
|
||||||
.append(" for ")
|
.append(" for ")
|
||||||
.append(QuantityFormatter.quantityToStackSize(getTotalPrice(items)))
|
.append(QuantityFormatter.quantityToStackSize(totalPrice))
|
||||||
.append(" loot.")
|
.append(" loot.")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user