use of me.botsko.prism.database.IdMapQuery in project Prism-Bukkit by prism.
the class MaterialAliases method getIdsOf.
private Set<IntPair> getIdsOf(Material material) {
Set<IntPair> ids = allIdsCache.get(material);
if (ids != null) {
return ids;
}
IdMapQuery query = new SqlIdMapQuery(Prism.getPrismDataSource());
query.findAllIds(material.name().toLowerCase(Locale.ENGLISH), list -> allIdsCache.put(material, new HashSet<>(list)));
return allIdsCache.get(material);
}
use of me.botsko.prism.database.IdMapQuery in project Prism-Bukkit by prism.
the class MaterialAliases method partialBlockDataIds.
/**
* .
*
* @param material Material
* @param partialBlockData String
* @return Set of IntPair
* @throws IllegalArgumentException exception
*/
public Set<IntPair> partialBlockDataIds(Material material, String partialBlockData) throws IllegalArgumentException {
String fullBlockData = Utilities.dataString(Bukkit.createBlockData(material, partialBlockData));
String[] parts = fullBlockData.substring(1, fullBlockData.length() - 1).toLowerCase(Locale.ENGLISH).split(",");
StringBuilder likeString = new StringBuilder("%");
for (String string : parts) {
if (partialBlockData.contains(string)) {
likeString.append(string).append('%');
}
}
String stateLike = likeString.toString();
IdMapQuery query = new SqlIdMapQuery(Prism.getPrismDataSource());
Set<IntPair> ids = new HashSet<>();
query.findAllIdsPartial(material.name().toLowerCase(Locale.ENGLISH), stateLike, ids::addAll);
return ids;
}
Aggregations