mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-17 06:25:02 +00:00
Annotate all the things
This commit is contained in:
63 files changed
+623
-369
No files matched your search
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2022 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice, this permission notice and the word "SNEED"
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.falsepattern.lib.internal;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
public class ReflectionUtil {
|
||||
private static final Field f_modifiers;
|
||||
|
||||
static {
|
||||
try {
|
||||
f_modifiers = Field.class.getDeclaredField("modifiers");
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
f_modifiers.setAccessible(true);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static void jailBreak(Field field) {
|
||||
field.setAccessible(true);
|
||||
f_modifiers.set(field, field.getModifiers() & ~Modifier.FINAL);
|
||||
}
|
||||
|
||||
public static void jailBreak(Method method) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.falsepattern.lib.internal.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
import com.falsepattern.lib.internal.Tags;
|
||||
|
||||
@@ -44,9 +45,13 @@ public class LibraryConfig {
|
||||
@Config.DefaultEnum("Log")
|
||||
public static ValidationLogging CONFIG_ERROR_LOUDNESS;
|
||||
|
||||
@StableAPI(since = "__INTERNAL__")
|
||||
public enum ValidationLogging {
|
||||
@StableAPI.Expose
|
||||
None,
|
||||
@StableAPI.Expose
|
||||
Log,
|
||||
@StableAPI.Expose
|
||||
LogAndToast
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class LibraryGuiConfig extends SimpleGuiConfig {
|
||||
public LibraryGuiConfig(GuiScreen parent) throws ConfigException {
|
||||
super(parent, new Class[]{LibraryConfig.class, ToastConfig.class}, Tags.MODID, Tags.MODNAME);
|
||||
super(parent, Tags.MODID, Tags.MODNAME, LibraryConfig.class, ToastConfig.class);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.falsepattern.lib.internal.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.config.SimpleGuiFactory;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -27,6 +28,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "__INTERNAL__")
|
||||
public class LibraryGuiFactory implements SimpleGuiFactory {
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.falsepattern.lib.internal.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
import com.falsepattern.lib.internal.Tags;
|
||||
|
||||
@@ -53,8 +54,11 @@ public class ToastConfig {
|
||||
return ALIGN == Side.Left;
|
||||
}
|
||||
|
||||
@StableAPI(since = "__INTERNAL__")
|
||||
public enum Side {
|
||||
@StableAPI.Expose
|
||||
Left,
|
||||
@StableAPI.Expose
|
||||
Right
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@ import com.falsepattern.lib.config.Config;
|
||||
import com.falsepattern.lib.config.ConfigException;
|
||||
import com.falsepattern.lib.internal.impl.config.fields.AConfigField;
|
||||
import com.falsepattern.lib.internal.impl.config.fields.BooleanConfigField;
|
||||
import com.falsepattern.lib.internal.impl.config.fields.BooleanListConfigField;
|
||||
import com.falsepattern.lib.internal.impl.config.fields.DoubleConfigField;
|
||||
import com.falsepattern.lib.internal.impl.config.fields.DoubleListConfigField;
|
||||
import com.falsepattern.lib.internal.impl.config.fields.EnumConfigField;
|
||||
import com.falsepattern.lib.internal.impl.config.fields.FloatConfigField;
|
||||
@@ -31,7 +33,7 @@ import com.falsepattern.lib.internal.impl.config.fields.IntConfigField;
|
||||
import com.falsepattern.lib.internal.impl.config.fields.IntListConfigField;
|
||||
import com.falsepattern.lib.internal.impl.config.fields.StringConfigField;
|
||||
import com.falsepattern.lib.internal.impl.config.fields.StringListConfigField;
|
||||
import com.falsepattern.lib.util.ReflectionUtil;
|
||||
import com.falsepattern.lib.internal.ReflectionUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.val;
|
||||
@@ -175,12 +177,14 @@ public class ParsedConfiguration {
|
||||
} else if (fieldClass.equals(Float.class) || fieldClass.equals(float.class)) {
|
||||
//noinspection deprecation
|
||||
fields.put(name, new FloatConfigField(field, rawConfig, category));
|
||||
} else if (fieldClass.equals(Double.class) || fieldClass.equals(double.class)) {
|
||||
fields.put(name, new DoubleConfigField(field, rawConfig, category));
|
||||
} else if (fieldClass.equals(String.class)) {
|
||||
fields.put(name, new StringConfigField(field, rawConfig, category));
|
||||
} else if (fieldClass.isEnum()) {
|
||||
fields.put(name, new EnumConfigField<>(field, rawConfig, category));
|
||||
} else if (fieldClass.isArray() && fieldClass.getComponentType().equals(boolean.class)) {
|
||||
fields.put(name, new StringListConfigField(field, rawConfig, category));
|
||||
fields.put(name, new BooleanListConfigField(field, rawConfig, category));
|
||||
} else if (fieldClass.isArray() && fieldClass.getComponentType().equals(int.class)) {
|
||||
fields.put(name, new IntListConfigField(field, rawConfig, category));
|
||||
} else if (fieldClass.isArray() && fieldClass.getComponentType().equals(double.class)) {
|
||||
|
||||
@@ -40,7 +40,7 @@ public abstract class AConfigField<T> {
|
||||
protected final String langKey;
|
||||
protected final Property.Type type;
|
||||
protected final Property property;
|
||||
protected String comment;
|
||||
protected final String comment;
|
||||
|
||||
protected AConfigField(Field field, Configuration configuration, String category, Property.Type type) {
|
||||
this(field, configuration, category, type, false);
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ import java.util.Optional;
|
||||
public class BooleanListConfigField extends AListConfigField<boolean[]> {
|
||||
private final boolean[] defaultValue;
|
||||
|
||||
protected BooleanListConfigField(Field field, Configuration configuration, String category) throws ConfigException {
|
||||
public BooleanListConfigField(Field field, Configuration configuration, String category) throws ConfigException {
|
||||
super(field, configuration, category, Property.Type.BOOLEAN);
|
||||
defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultBooleanList.class))
|
||||
.map(Config.DefaultBooleanList::value)
|
||||
|
||||
Reference in new issue
Block a user