mirror of
https://github.com/BentoBoxWorld/Limits.git
synced 2025-02-18 13:21:39 +01:00
Merge pull request #104 from weaondara/fixentitygroups
fix entity group limits not showing properly in limit panel
This commit is contained in:
commit
062574f0c5
@ -15,6 +15,7 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||||
@ -86,7 +87,7 @@ public class LimitTab implements Tab {
|
|||||||
result = new ArrayList<>();
|
result = new ArrayList<>();
|
||||||
addMaterialIcons(ibc, matLimits);
|
addMaterialIcons(ibc, matLimits);
|
||||||
addEntityLimits(ibc, island);
|
addEntityLimits(ibc, island);
|
||||||
addEntityGroupLimits(island);
|
addEntityGroupLimits(ibc, island);
|
||||||
// Sort
|
// Sort
|
||||||
switch (sortBy) {
|
switch (sortBy) {
|
||||||
default:
|
default:
|
||||||
@ -99,12 +100,15 @@ public class LimitTab implements Tab {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addEntityGroupLimits(Island island) {
|
private void addEntityGroupLimits(IslandBlockCount ibc, Island island) {
|
||||||
// Entity group limits
|
// Entity group limits
|
||||||
List<Settings.EntityGroup> groupmap = addon.getSettings().getGroupLimitDefinitions();
|
Map<EntityGroup, Integer> groupmap = addon.getSettings().getGroupLimitDefinitions().stream().collect(Collectors.toMap(e -> e, e -> e.getLimit()));
|
||||||
|
Map<String, EntityGroup> groupbyname = groupmap.keySet().stream().collect(Collectors.toMap(e -> e.getName(), e -> e));
|
||||||
// Merge in any permission-based limits
|
// Merge in any permission-based limits
|
||||||
// if (ibc != null) ibc.getEntityLimits().forEach(map::put);
|
if (ibc != null) ibc.getEntityGroupLimits().entrySet().stream()
|
||||||
groupmap.forEach(v -> {
|
.filter(e -> groupbyname.containsKey(e.getKey()))
|
||||||
|
.forEach(e -> groupmap.put(groupbyname.get(e.getKey()), e.getValue()));
|
||||||
|
groupmap.forEach((v, limit) -> {
|
||||||
PanelItemBuilder pib = new PanelItemBuilder();
|
PanelItemBuilder pib = new PanelItemBuilder();
|
||||||
EntityType k = v.getTypes().iterator().next();
|
EntityType k = v.getTypes().iterator().next();
|
||||||
pib.name(v.getName());
|
pib.name(v.getName());
|
||||||
@ -125,11 +129,11 @@ public class LimitTab implements Tab {
|
|||||||
}
|
}
|
||||||
pib.icon(m);
|
pib.icon(m);
|
||||||
long count = getCount(island, v);
|
long count = getCount(island, v);
|
||||||
String color = count >= v.getLimit() ? user.getTranslation("island.limits.max-color") : user.getTranslation("island.limits.regular-color");
|
String color = count >= limit ? user.getTranslation("island.limits.max-color") : user.getTranslation("island.limits.regular-color");
|
||||||
description += color
|
description += color
|
||||||
+ user.getTranslation("island.limits.block-limit-syntax",
|
+ user.getTranslation("island.limits.block-limit-syntax",
|
||||||
TextVariables.NUMBER, String.valueOf(count),
|
TextVariables.NUMBER, String.valueOf(count),
|
||||||
"[limit]", String.valueOf(v.getLimit()));
|
"[limit]", String.valueOf(limit));
|
||||||
pib.description(description);
|
pib.description(description);
|
||||||
result.add(pib.build());
|
result.add(pib.build());
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user