Island score block limits

This commit is contained in:
WolfDW 2020-06-25 14:15:40 +00:00 committed by Fabrizio La Rosa
parent 62cd1ddbcb
commit ce85deb4e3
4 changed files with 748 additions and 7 deletions

View File

@ -78,8 +78,15 @@ public class IslandLevel {
if (current == null) continue;
long pointsRequired = current.getLong("Points", 0);
long blockAmount = entry.getValue();
if (pointsRequired != 0) pointsEarned = pointsEarned + (entry.getValue() * pointsRequired);
long materialLimit = current.getLong("Limit", -1);
long materialAmountCounted = Math.min(materialLimit, blockAmount);
if (materialLimit == -1)
materialAmountCounted = blockAmount;
if (pointsRequired != 0) pointsEarned = pointsEarned + (materialAmountCounted * pointsRequired);
}
@ -99,12 +106,17 @@ public class IslandLevel {
if (current == null) return 0;
Long boxedAmount = this.materials.get(material);
if (boxedAmount == null) return 0;
long materialLimit = current.getLong("Limit", -1);
long materialAmountCounted = Math.min(materialLimit, boxedAmount);
if (materialLimit == -1)
materialAmountCounted = boxedAmount;
long pointsRequired = current.getLong("Points");
return pointsRequired == 0 ? 0 : boxedAmount * pointsRequired;
return pointsRequired == 0 ? 0 : materialAmountCounted * pointsRequired;
}
public long getLevel() {

View File

@ -260,7 +260,14 @@ public class Levelling {
inventorySlot++;
long pointsEarned = materialAmount * pointsMultiplier;
long materialLimit = mainConfig.getFileConfiguration().getLong("Materials." + material + ".Limit", -1);
long materialAmountCounted = Math.min(materialLimit, materialAmount);
if (materialLimit == -1)
materialAmountCounted = materialAmount;
long pointsEarned = materialAmountCounted * pointsMultiplier;
String name = skyblock.getLocalizationManager().getLocalizationFor(CompatibleMaterial.class).getLocale(materials);
@ -271,11 +278,15 @@ public class Levelling {
is.setAmount(Math.min(Math.toIntExact(materialAmount), 64));
is.setType(CompatibleMaterial.getMaterial(is).getMaterial());
long finalMaterialAmountCounted = materialAmountCounted;
List<String> lore = configLoad.getStringList("Menu.Levelling.Item.Material.Lore");
lore.replaceAll(x -> x.replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned)).replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)).replace("%material", name));
lore.replaceAll(x -> x.replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned)).replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount))
.replace("%material", name).replace("%counted", NumberUtil.formatNumberByDecimal(finalMaterialAmountCounted)));
nInv.addItem(nInv.createItem(is, configLoad.getString("Menu.Levelling.Item.Material.Displayname").replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned))
.replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)).replace("%material", name), lore, null, null, null), inventorySlot);
.replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)).replace("%material", name).replace("%counted", NumberUtil.formatNumberByDecimal(finalMaterialAmountCounted))
,lore, null, null, null), inventorySlot);
}
}

View File

@ -2307,7 +2307,7 @@ Menu:
Material:
Displayname: '&7%material &8(&e+%points Points&8)'
Lore:
- '&8(&e%blocks Blocks&8)'
- '&8(&e%blocks Blocks&8, &e%counted Counted&8)'
Title: '&8Island Levelling'
ControlPanel:
Item:

File diff suppressed because it is too large Load Diff