use of net.silentchaos512.gear.api.traits.TraitInstance in project Silent-Gear by SilentChaos512.
the class TraitsCommand method getMaterialsWithTrait.
private static String getMaterialsWithTrait(ITrait trait) {
StringBuilder str = new StringBuilder();
boolean foundAny = false;
for (IMaterial material : MaterialManager.getValues(false)) {
MaterialInstance instance = MaterialInstance.of(material);
Collection<PartType> typesWithTrait = new ArrayList<>();
for (PartType partType : PartType.getValues()) {
Collection<TraitInstance> traits = instance.getTraits(partType);
for (TraitInstance inst : traits) {
if (inst.getTrait().equals(trait) && material.isVisible(partType)) {
typesWithTrait.add(partType);
break;
}
}
}
if (!typesWithTrait.isEmpty()) {
if (foundAny) {
str.append(", ");
}
foundAny = true;
str.append("**").append(instance.getDisplayName(PartType.MAIN).getString()).append("**").append(" _(").append(typesWithTrait.stream().map(pt -> pt.getDisplayName(0).getString()).collect(Collectors.joining(", "))).append(")_");
}
}
return str.toString();
}
use of net.silentchaos512.gear.api.traits.TraitInstance in project Silent-Gear by SilentChaos512.
the class TraitsCommand method getPartsWithTrait.
private static String getPartsWithTrait(ITrait trait) {
StringBuilder str = new StringBuilder();
boolean foundAny = false;
for (IGearPart part : PartManager.getValues()) {
PartData partData = PartData.of(part);
for (TraitInstance inst : partData.getTraits()) {
if (inst.getTrait().equals(trait) && part.isVisible()) {
if (foundAny) {
str.append(", ");
}
foundAny = true;
str.append("**").append(partData.getDisplayName(ItemStack.EMPTY).getString()).append("**");
}
}
}
return str.toString();
}
Aggregations