diff --git a/src/main/java/de/diddiz/LogBlock/QueryParams.java b/src/main/java/de/diddiz/LogBlock/QueryParams.java index 288e740..5e353d4 100644 --- a/src/main/java/de/diddiz/LogBlock/QueryParams.java +++ b/src/main/java/de/diddiz/LogBlock/QueryParams.java @@ -72,10 +72,8 @@ public final class QueryParams implements Cloneable { public CuboidRegion sel = null; public SummarizationMode sum = SummarizationMode.NONE; public List types = new ArrayList<>(); - public List> typeTags = new ArrayList<>(); - public List typeIds = new ArrayList<>(); + public List> typeTags = new ArrayList<>(); public List entityTypes = new ArrayList<>(); - public List entityTypeIds = new ArrayList<>(); public World world = null; public String match = null; public boolean needCount = false, needId = false, needDate = false, needType = false, needData = false, needPlayerId = false, needPlayer = false, needCoords = false, needChestAccess = false, needMessage = false, needKiller = false, needVictim = false, needWeapon = false; @@ -484,6 +482,7 @@ public final class QueryParams implements Cloneable { } } } else if (blockChangeType == BlockChangeType.ENTITIES || blockChangeType == BlockChangeType.ENTITIES_CREATED || blockChangeType == BlockChangeType.ENTITIES_KILLED) { + Set entityTypeIds = getEntityTypeIds(); if (!entityTypeIds.isEmpty()) { if (excludeBlocksEntitiesMode) { where.append("NOT "); @@ -502,6 +501,7 @@ public final class QueryParams implements Cloneable { where.append("action = " + EntityChange.EntityChangeType.KILL.ordinal() + " AND "); } } else { + Set typeIds = getTypeIds(); switch (blockChangeType) { case ALL: if (!typeIds.isEmpty()) { @@ -756,7 +756,6 @@ public final class QueryParams implements Cloneable { throw new IllegalArgumentException("No material matching: '" + weaponName + "'"); } types.add(mat); - typeIds.add(MaterialConverter.getOrAddMaterialId(mat)); } needWeapon = true; } else if (param.equals("block") || param.equals("type")) { @@ -777,9 +776,6 @@ public final class QueryParams implements Cloneable { throw new IllegalArgumentException("No block tag matching: '" + blockName + "'"); } } - for (Material mat : tag.getValues()) { - typeIds.add(MaterialConverter.getOrAddMaterialId(mat)); - } typeTags.add(tag); } else if (blockName.contains("*")) { StringBuilder sb = new StringBuilder(); @@ -807,7 +803,6 @@ public final class QueryParams implements Cloneable { } for (Material mat : matched) { types.add(mat); - typeIds.add(MaterialConverter.getOrAddMaterialId(mat)); } } else { final Material mat = Material.matchMaterial(blockName); @@ -815,7 +810,6 @@ public final class QueryParams implements Cloneable { throw new IllegalArgumentException("No material matching: '" + blockName + "'"); } types.add(mat); - typeIds.add(MaterialConverter.getOrAddMaterialId(mat)); } } } else if (param.equals("area")) { @@ -890,7 +884,6 @@ public final class QueryParams implements Cloneable { throw new IllegalArgumentException("No entity type matching: '" + entityTypeName + "'"); } entityTypes.add(entityType); - entityTypeIds.add(EntityTypeConverter.getOrAddEntityTypeId(entityType)); } } } else if (param.equals("all")) { @@ -1008,10 +1001,8 @@ public final class QueryParams implements Cloneable { params.players = new ArrayList<>(players); params.killers = new ArrayList<>(killers); params.victims = new ArrayList<>(victims); - params.typeIds = new ArrayList<>(typeIds); params.types = new ArrayList<>(types); params.typeTags = new ArrayList<>(typeTags); - params.entityTypeIds = new ArrayList<>(entityTypeIds); params.entityTypes = new ArrayList<>(entityTypes); params.loc = loc == null ? null : loc.clone(); params.sel = sel == null ? null : sel.clone(); @@ -1021,6 +1012,33 @@ public final class QueryParams implements Cloneable { } } + private Set getTypeIds() { + HashSet typeIds = new HashSet<>(); + for (Material type : types) { + if (type != null) { + typeIds.add(MaterialConverter.getOrAddMaterialId(type)); + } + } + for (Tag tag : typeTags) { + if (tag != null) { + for (Material type : tag.getValues()) { + typeIds.add(MaterialConverter.getOrAddMaterialId(type)); + } + } + } + return typeIds; + } + + private Set getEntityTypeIds() { + HashSet typeIds = new HashSet<>(); + for (EntityType type : entityTypes) { + if (type != null) { + typeIds.add(EntityTypeConverter.getOrAddEntityTypeId(type)); + } + } + return typeIds; + } + private static String[] getValues(List args, int offset, int minParams) { // The variable i will store the last value's index int i; @@ -1055,10 +1073,8 @@ public final class QueryParams implements Cloneable { killers.addAll(p.killers); victims.addAll(p.victims); excludePlayersMode = p.excludePlayersMode; - typeIds.addAll(p.typeIds); types.addAll(p.types); typeTags.addAll(p.typeTags); - entityTypeIds.addAll(p.entityTypeIds); entityTypes.addAll(p.entityTypes); loc = p.loc == null ? null : p.loc.clone(); radius = p.radius;