diff --git a/src/main/java/world/bentobox/level/panels/DetailsPanel.java b/src/main/java/world/bentobox/level/panels/DetailsPanel.java index deac18b..bbffd57 100644 --- a/src/main/java/world/bentobox/level/panels/DetailsPanel.java +++ b/src/main/java/world/bentobox/level/panels/DetailsPanel.java @@ -180,8 +180,16 @@ public class DetailsPanel { sorter = (o1, o2) -> { - int o1Value = this.addon.getBlockConfig().getBlockValues().getOrDefault(o1.getKey(), 0); - int o2Value = this.addon.getBlockConfig().getBlockValues().getOrDefault(o2.getKey(), 0); + int blockLimit = this.addon.getBlockConfig().getBlockLimits().getOrDefault(o1.getKey(), 0); + int o1Count = blockLimit > 0 ? Math.min(o1.getValue(), blockLimit) : o1.getValue(); + + blockLimit = this.addon.getBlockConfig().getBlockLimits().getOrDefault(o2.getKey(), 0); + int o2Count = blockLimit > 0 ? Math.min(o2.getValue(), blockLimit) : o2.getValue(); + + long o1Value = (long) o1Count * + this.addon.getBlockConfig().getBlockValues().getOrDefault(o1.getKey(), 0); + long o2Value = (long) o2Count * + this.addon.getBlockConfig().getBlockValues().getOrDefault(o2.getKey(), 0); if (o1Value == o2Value) { @@ -192,7 +200,7 @@ public class DetailsPanel } else { - return Integer.compare(o2Value, o1Value); + return Long.compare(o2Value, o1Value); } }; } @@ -659,12 +667,17 @@ public class DetailsPanel String count = this.user.getTranslationOrNothing(reference + "count", "[number]", String.valueOf(materialCount.getValue())); + long calculatedValue = (long) Math.min(blockLimit > 0 ? blockLimit : Integer.MAX_VALUE, materialCount.getValue()) * blockValue; + String valueText = calculatedValue > 0 ? this.user.getTranslationOrNothing(reference + "calculated", + "[number]", String.valueOf(calculatedValue)) : ""; + if (template.description() != null) { builder.description(this.user.getTranslation(this.world, template.description(), "[description]", description, "[id]", blockId, "[value]", value, + "[calculated]", valueText, "[limit]", limit, "[count]", count). replaceAll("(?m)^[ \\t]*\\r?\\n", ""). diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index f7eeb7a..dd2e73b 100755 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -96,12 +96,14 @@ level: [description] [count] [value] + [calculated] [limit] [id] id: "&7 Block id: &e [id]" value: "&7 Block value: &e [number]" limit: "&7 Block limit: &e [number]" count: "&7 Number of blocks: &e [number]" + calculated: "&7 Calculated value: &e [number]" all_blocks: name: "&f&l All Blocks" description: |-