Skip to content

Commit 8c98524

Browse files
fancyholograms v3: Mark methods as final in HologramTrait for immutability
1 parent d2f222b commit 8c98524

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

  • plugins/fancyholograms/fh-api/src/main/java/de/oliver/fancyholograms/api/trait

plugins/fancyholograms/fh-api/src/main/java/de/oliver/fancyholograms/api/trait/HologramTrait.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public abstract class HologramTrait {
3030
protected Hologram hologram;
3131
protected JDB storage;
3232

33-
public void attachHologram(Hologram hologram) {
33+
@ApiStatus.Internal
34+
public final void attachHologram(Hologram hologram) {
3435
if (this.hologram != null) {
3536
throw new IllegalStateException("Trait is already attached to a hologram");
3637
}
@@ -98,15 +99,15 @@ public void load() {
9899
public void save() {
99100
}
100101

101-
public String getName() {
102+
public final String getName() {
102103
if (getClass().isAnnotationPresent(HologramTraitClass.class)) {
103104
return getClass().getAnnotation(HologramTraitClass.class).traitName();
104105
}
105106

106107
throw new IllegalArgumentException("Trait class " + getClass() + " is not annotated with HologramTraitClass");
107108
}
108109

109-
protected boolean isTraitAttached(Class<? extends HologramTrait> trait) {
110+
protected final boolean isTraitAttached(Class<? extends HologramTrait> trait) {
110111
for (HologramTrait hologramTrait : hologram.getTraitTrait().getTraits()) {
111112
if (hologramTrait.getClass().equals(trait)) {
112113
return true;
@@ -116,7 +117,7 @@ protected boolean isTraitAttached(Class<? extends HologramTrait> trait) {
116117
return false;
117118
}
118119

119-
protected <T extends HologramTrait> T getTrait(Class<T> trait) {
120+
protected final <T extends HologramTrait> T getTrait(Class<T> trait) {
120121
for (HologramTrait hologramTrait : hologram.getTraitTrait().getTraits()) {
121122
if (hologramTrait.getClass().equals(trait)) {
122123
return (T) hologramTrait;
@@ -126,7 +127,7 @@ protected <T extends HologramTrait> T getTrait(Class<T> trait) {
126127
return null;
127128
}
128129

129-
public Hologram getHologram() {
130+
public final Hologram getHologram() {
130131
return hologram;
131132
}
132133
}

0 commit comments

Comments
 (0)