mirror of
https://github.com/tomasff/BeesPlus.git
synced 2025-01-09 01:07:54 +01:00
Add support to hives with variable capacity
This commit is contained in:
parent
c73fcba252
commit
3ba2c17c6a
@ -52,14 +52,6 @@ public class BeeHiveInfo extends Gui {
|
||||
}
|
||||
}
|
||||
|
||||
private int getBeehivePopulation(Beehive beehive) {
|
||||
return beehive.getEntityCount();
|
||||
}
|
||||
|
||||
private int getBeehiveMaxPopulation(Beehive beehive) {
|
||||
return beehive.getMaxEntities();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildIcons() {
|
||||
org.bukkit.block.data.type.Beehive beehiveData = (org.bukkit.block.data.type.Beehive) beehive.getBlockData();
|
||||
@ -78,7 +70,7 @@ public class BeeHiveInfo extends Gui {
|
||||
|
||||
ItemStack beeCapacity = new ItemBuilder(Material.BEE_NEST)
|
||||
.setName(Localization.get(Localization.BEEHIVE_INFO_GUI_BEE_CAPACITY))
|
||||
.setLore(Localization.get(Localization.BEEHIVE_INFO_GUI_BEE_CAPACITY_DESC, getBeehivePopulation(beehive), getBeehiveMaxPopulation(beehive)),
|
||||
.setLore(Localization.get(Localization.BEEHIVE_INFO_GUI_BEE_CAPACITY_DESC, beehive.getEntityCount(), beehive.getMaxEntities()),
|
||||
isSedated)
|
||||
.build();
|
||||
|
||||
@ -100,7 +92,8 @@ public class BeeHiveInfo extends Gui {
|
||||
Icon flowerIcon = new Icon(flower, null);
|
||||
setIcon(flowerIcon, 37);
|
||||
|
||||
HoneyLevelIndicators honeyLevelIndicator = HoneyLevelIndicators.getFromLevel(beehiveData.getHoneyLevel());
|
||||
HoneyLevelIndicators honeyLevelIndicator = HoneyLevelIndicators.getFromLevel(beehiveData.getHoneyLevel(),
|
||||
beehiveData.getMaximumHoneyLevel());
|
||||
setHoneyLevelSlots(honeyLevelIndicator);
|
||||
|
||||
ItemStack filler = new ItemBuilder(Material.WHITE_STAINED_GLASS_PANE)
|
||||
|
@ -28,11 +28,16 @@ public enum HoneyLevelIndicators {
|
||||
this.slots = slots;
|
||||
}
|
||||
|
||||
public static HoneyLevelIndicators getFromLevel(int level) {
|
||||
return Arrays.stream(values())
|
||||
.filter((levelIndicator) -> levelIndicator.level == level)
|
||||
.findFirst()
|
||||
.orElse(VERY_HIGH);
|
||||
public static HoneyLevelIndicators getFromLevel(int currentHoneyLvl, int maxHoneyLvl) {
|
||||
float ratio = (float) currentHoneyLvl / (float) maxHoneyLvl;
|
||||
|
||||
if (ratio == 0) return EMPTY;
|
||||
if (ratio <= 0.25) return LOW;
|
||||
if (ratio <= 0.50) return MEDIUM;
|
||||
if (ratio <= 0.75) return HIGH;
|
||||
if (ratio <= 1) return VERY_HIGH;
|
||||
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
|
Loading…
Reference in New Issue
Block a user