Added type chevrons

This commit is contained in:
tastybento 2020-06-26 16:22:18 -07:00
parent 598ccf383c
commit b9ea6ecddd
2 changed files with 13 additions and 14 deletions

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@ -68,7 +67,7 @@ public class Settings {
}
addon.log("Entity limits:");
limits.entrySet().stream().map(e -> "Limit " + e.getKey().toString() + " to " + e.getValue()).forEach(addon::log);
//group limits
el = addon.getConfig().getConfigurationSection("entitygrouplimits");
if (el != null) {
@ -91,13 +90,13 @@ public class Settings {
continue;
EntityGroup group = new EntityGroup(name, entities, limit);
entities.forEach(e -> {
List<EntityGroup> groups = groupLimits.getOrDefault(e, new ArrayList());
List<EntityGroup> groups = groupLimits.getOrDefault(e, new ArrayList<>());
groups.add(group);
groupLimits.put(e, groups);
});
}
}
addon.log("Entity group limits:");
getGroupLimitDefinitions().stream().map(e -> "Limit " + e.getName() + " (" + e.getTypes().stream().map(x -> x.name()).collect(Collectors.joining(", ")) + ") to " + e.getLimit()).forEach(addon::log);
}
@ -119,7 +118,7 @@ public class Settings {
public Map<EntityType, List<EntityGroup>> getGroupLimits() {
return groupLimits;
}
/**
* @return the group limit definitions
*/
@ -144,7 +143,7 @@ public class Settings {
this.types = types;
this.limit = limit;
}
public boolean contains(EntityType type) {
return types.contains(type);
}

View File

@ -198,7 +198,7 @@ public class EntityLimitListener implements Listener {
Map<Settings.EntityGroup, Integer> groupsLimits = new HashMap<>();
if (addon.getBlockLimitListener().getIsland(island.getUniqueId()) != null) {
limitAmount = addon.getBlockLimitListener().getIsland(island.getUniqueId()).getEntityLimit(ent.getType());
List<Settings.EntityGroup> groupdefs = addon.getSettings().getGroupLimits().getOrDefault(ent.getType(), new ArrayList());
List<Settings.EntityGroup> groupdefs = addon.getSettings().getGroupLimits().getOrDefault(ent.getType(), new ArrayList<>());
groupdefs.forEach(def -> {
int limit = addon.getBlockLimitListener().getIsland(island.getUniqueId()).getEntityGroupLimit(def.getName());
if (limit >= 0)
@ -211,11 +211,11 @@ public class EntityLimitListener implements Listener {
}
if (addon.getSettings().getGroupLimits().containsKey(ent.getType())) {
addon.getSettings().getGroupLimits().getOrDefault(ent.getType(), new ArrayList<>()).stream()
.filter(group -> !groupsLimits.containsKey(group) || groupsLimits.get(group) > group.getLimit())
.forEach(group -> groupsLimits.put(group, group.getLimit()));
.filter(group -> !groupsLimits.containsKey(group) || groupsLimits.get(group) > group.getLimit())
.forEach(group -> groupsLimits.put(group, group.getLimit()));
}
if (limitAmount < 0 && groupsLimits.isEmpty()) return new AtLimitResult();
// We have to count the entities
if (limitAmount >= 0)
{
@ -225,7 +225,7 @@ public class EntityLimitListener implements Listener {
if (count >= limitAmount)
return new AtLimitResult(ent.getType(), limitAmount);
}
// Now do the group limits
for (Map.Entry<Settings.EntityGroup, Integer> group : groupsLimits.entrySet()) { //do not use lambda
if (group.getValue() < 0)
@ -238,13 +238,13 @@ public class EntityLimitListener implements Listener {
}
return new AtLimitResult();
}
private class AtLimitResult {
private Map.Entry<EntityType, Integer> typelimit;
private Map.Entry<EntityGroup, Integer> grouplimit;
public AtLimitResult() {}
public AtLimitResult(EntityType type, int limit) {
typelimit = new AbstractMap.SimpleEntry<>(type, limit);
}
@ -252,7 +252,7 @@ public class EntityLimitListener implements Listener {
public AtLimitResult(EntityGroup type, int limit) {
grouplimit = new AbstractMap.SimpleEntry<>(type, limit);
}
public boolean hit() {
return typelimit != null || grouplimit != null;
}