aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java b/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java
index 8efa0b7..7679b9c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java
@@ -1,18 +1,22 @@
package cc.polyfrost.oneconfig.config.gson;
+import cc.polyfrost.oneconfig.config.Config;
import cc.polyfrost.oneconfig.config.annotations.Exclude;
import cc.polyfrost.oneconfig.config.annotations.NonProfileSpecific;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
-public class NonProfileSpecificExclusionStrategy implements ExclusionStrategy {
+public class NonProfileSpecificExclusionStrategy extends ExclusionUtils implements ExclusionStrategy {
/**
* @param f the field object that is under test
* @return true if the field should be ignored; otherwise false
*/
@Override
public boolean shouldSkipField(FieldAttributes f) {
- return f.getAnnotation(NonProfileSpecific.class) == null || f.getAnnotation(Exclude.class) != null;
+ if (isSuperClassOf(f.getDeclaredClass(), Config.class)) return true;
+ if (f.getAnnotation(NonProfileSpecific.class) == null) return true;
+ Exclude exclude = f.getAnnotation(Exclude.class);
+ return exclude != null && exclude.type() != Exclude.ExcludeType.HUD;
}
/**
@@ -21,6 +25,7 @@ public class NonProfileSpecificExclusionStrategy implements ExclusionStrategy {
*/
@Override
public boolean shouldSkipClass(Class<?> clazz) {
- return clazz.getAnnotation(Exclude.class) != null;
+ Exclude exclude = clazz.getAnnotation(Exclude.class);
+ return exclude != null && exclude.type() != Exclude.ExcludeType.HUD;
}
}