fancyholograms-v3: Add helper methods for trait handling

This commit is contained in:
Oliver
2025-05-18 00:35:09 +02:00
parent a358624a4a
commit 239c00b447
2 changed files with 29 additions and 1 deletions

View File

@@ -94,6 +94,26 @@ public abstract class HologramTrait {
throw new IllegalArgumentException("Trait class " + getClass() + " is not annotated with HologramTraitClass");
}
protected boolean isTraitAttached(Class<? extends HologramTrait> trait) {
for (HologramTrait hologramTrait : hologram.getTraitTrait().getTraits()) {
if (hologramTrait.getClass().equals(trait)) {
return true;
}
}
return false;
}
protected <T extends HologramTrait> T getTrait(Class<T> trait) {
for (HologramTrait hologramTrait : hologram.getTraitTrait().getTraits()) {
if (hologramTrait.getClass().equals(trait)) {
return (T) hologramTrait;
}
}
return null;
}
public Hologram getHologram() {
return hologram;
}

View File

@@ -138,7 +138,15 @@ public class HologramTraitTrait extends HologramTrait {
}
}
record Configuration(
public List<HologramTrait> getTraits() {
return traits;
}
public Configuration getConfiguration() {
return configuration;
}
public record Configuration(
List<String> traits
) {