mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancyholograms-v3: Add helper methods for trait handling
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user