mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-12-24 18:17:41 +01:00
Implement calculated value for blocks. (#260)
It is ~ value, as calculation formula cannot be applied per block. At least I think so. Part of #192
This commit is contained in:
parent
4948689fe8
commit
1914fc11e0
@ -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", "").
|
||||
|
@ -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: |-
|
||||
|
Loading…
Reference in New Issue
Block a user