Skip to content

Commit

Permalink
WIP fix some bugs - still more to fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Sep 7, 2021
1 parent 05a8a0e commit 390814b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/main/java/world/bentobox/limits/commands/LimitTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ private void addEntityGroupLimits(IslandBlockCount ibc, Island island) {
Map<String, EntityGroup> groupbyname = groupmap.keySet().stream().collect(Collectors.toMap(e -> e.getName(), e -> e));
// Merge in any permission-based limits
if (ibc != null) ibc.getEntityGroupLimits().entrySet().stream()
.filter(e -> groupbyname.containsKey(e.getKey()))
.forEach(e -> groupmap.put(groupbyname.get(e.getKey()), e.getValue()));
.filter(e -> groupbyname.containsKey(e.getKey()))
.forEach(e -> groupmap.put(groupbyname.get(e.getKey()), e.getValue()));
ibc.getEntityGroupLimitsOffset().entrySet().forEach(o ->
groupmap.put(groupbyname.get(o.getKey()), (groupmap.getOrDefault(o.getKey(), 0) + o.getValue())));
groupmap.forEach((v, limit) -> {
PanelItemBuilder pib = new PanelItemBuilder();
EntityType k = v.getTypes().iterator().next();
Expand Down Expand Up @@ -142,7 +144,11 @@ private void addEntityLimits(IslandBlockCount ibc, Island island) {
// Entity limits
Map<EntityType, Integer> map = new HashMap<>(addon.getSettings().getLimits());
// Merge in any permission-based limits
if (ibc != null) ibc.getEntityLimits().forEach(map::put);
if (ibc != null) {
ibc.getEntityLimits().forEach(map::put);
ibc.getEntityLimitsOffset().forEach((k,v) -> map.put(k, map.getOrDefault(k, 0) + v));
}

map.forEach((k,v) -> {
PanelItemBuilder pib = new PanelItemBuilder();
pib.name(Util.prettifyText(k.toString()));
Expand Down Expand Up @@ -180,11 +186,12 @@ private void addMaterialIcons(IslandBlockCount ibc, Map<Material, Integer> matLi
pib.icon(B2M.getOrDefault(en.getKey(), en.getKey()));

int count = ibc == null ? 0 : ibc.getBlockCounts().getOrDefault(en.getKey(), 0);
String color = count >= en.getValue() ? user.getTranslation("island.limits.max-color") : user.getTranslation("island.limits.regular-color");
int value = en.getValue() + ibc.getBlockLimitsOffset().getOrDefault(en.getKey(), 0);
String color = count >= value ? user.getTranslation("island.limits.max-color") : user.getTranslation("island.limits.regular-color");
pib.description(color
+ user.getTranslation("island.limits.block-limit-syntax",
TextVariables.NUMBER, String.valueOf(count),
"[limit]", String.valueOf(en.getValue())));
"[limit]", String.valueOf(value)));
result.add(pib.build());
}
}
Expand Down

0 comments on commit 390814b

Please sign in to comment.