mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-15 14:54:45 +00:00
cleanup code
This commit is contained in:
51 files changed
+637
-373
No files matched your search
@@ -34,6 +34,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
@StableAPI(since = "0.10.0")
|
||||
public @interface DeprecationDetails {
|
||||
@StableAPI.Expose String deprecatedSince();
|
||||
|
||||
@StableAPI.Expose(since = "0.11.0") String replacement() default "";
|
||||
|
||||
/**
|
||||
|
||||
@@ -85,6 +85,5 @@ public @interface StableAPI {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
|
||||
@StableAPI(since = "0.10.0")
|
||||
@interface Internal {
|
||||
}
|
||||
@interface Internal {}
|
||||
}
|
||||
@@ -63,12 +63,16 @@ public class ASMUtil {
|
||||
public static FieldNode findFieldFromMCP(ClassNode cn, String fieldName, boolean optional) {
|
||||
val classMapping = discoverClassMappingType(cn);
|
||||
if (classMapping == null) {
|
||||
throw new AsmClassNotFoundException("The class " + cn + " is not from Minecraft, or the mapping manager" +
|
||||
"doesn't have it, cannot use findFieldFromMCP! Use findFieldStandard instead!");
|
||||
throw new AsmClassNotFoundException("The class "
|
||||
+ cn
|
||||
+ " is not from Minecraft, or the mapping manager"
|
||||
+ "doesn't have it, cannot use findFieldFromMCP! Use findFieldStandard instead!");
|
||||
}
|
||||
return findFieldStandard(cn, MappingManager.classForName(NameType.Internal, classMapping, cn.name)
|
||||
.getField(MappingType.MCP, fieldName)
|
||||
.getName(classMapping), optional);
|
||||
return findFieldStandard(cn,
|
||||
MappingManager.classForName(NameType.Internal, classMapping, cn.name)
|
||||
.getField(MappingType.MCP, fieldName)
|
||||
.getName(classMapping),
|
||||
optional);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
@@ -106,8 +110,10 @@ public class ASMUtil {
|
||||
public static MethodNode findMethodFromMCP(ClassNode cn, String mcpName, String mcpDescriptor, boolean optional) {
|
||||
val classMapping = discoverClassMappingType(cn);
|
||||
if (classMapping == null) {
|
||||
throw new AsmClassNotFoundException("The class " + cn + " is not from Minecraft, or the mapping manager" +
|
||||
"doesn't have it, cannot use findMethodFromMCP! Use findFieldStandard instead!");
|
||||
throw new AsmClassNotFoundException("The class "
|
||||
+ cn
|
||||
+ " is not from Minecraft, or the mapping manager"
|
||||
+ "doesn't have it, cannot use findMethodFromMCP! Use findFieldStandard instead!");
|
||||
}
|
||||
val method = MappingManager.classForName(NameType.Internal, classMapping, cn.name)
|
||||
.getMethod(MappingType.MCP, mcpName, mcpDescriptor);
|
||||
|
||||
@@ -115,9 +115,12 @@ public class BlockPos extends Vec3i {
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static Iterable<BlockPos> getAllInBox(@NonNull BlockPos from, @NonNull BlockPos to) {
|
||||
return getAllInBox(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()),
|
||||
Math.min(from.getZ(), to.getZ()), Math.max(from.getX(), to.getX()),
|
||||
Math.max(from.getY(), to.getY()), Math.max(from.getZ(), to.getZ()));
|
||||
return getAllInBox(Math.min(from.getX(), to.getX()),
|
||||
Math.min(from.getY(), to.getY()),
|
||||
Math.min(from.getZ(), to.getZ()),
|
||||
Math.max(from.getX(), to.getX()),
|
||||
Math.max(from.getY(), to.getY()),
|
||||
Math.max(from.getZ(), to.getZ()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,9 +195,12 @@ public class BlockPos extends Vec3i {
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static Iterable<BlockPos.MutableBlockPos> getAllInBoxMutable(@NonNull BlockPos from, @NonNull BlockPos to) {
|
||||
return getAllInBoxMutable(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()),
|
||||
Math.min(from.getZ(), to.getZ()), Math.max(from.getX(), to.getX()),
|
||||
Math.max(from.getY(), to.getY()), Math.max(from.getZ(), to.getZ()));
|
||||
return getAllInBoxMutable(Math.min(from.getX(), to.getX()),
|
||||
Math.min(from.getY(), to.getY()),
|
||||
Math.min(from.getZ(), to.getZ()),
|
||||
Math.max(from.getX(), to.getX()),
|
||||
Math.max(from.getY(), to.getY()),
|
||||
Math.max(from.getZ(), to.getZ()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,7 +310,8 @@ public class BlockPos extends Vec3i {
|
||||
if (blocks == 0) {
|
||||
return this;
|
||||
}
|
||||
return new BlockPos(x + facing.getFrontOffsetX() * blocks, y + facing.getFrontOffsetY() * blocks,
|
||||
return new BlockPos(x + facing.getFrontOffsetX() * blocks,
|
||||
y + facing.getFrontOffsetY() * blocks,
|
||||
z + facing.getFrontOffsetZ() * blocks);
|
||||
}
|
||||
|
||||
@@ -380,7 +387,8 @@ public class BlockPos extends Vec3i {
|
||||
|
||||
@Override
|
||||
public BlockPos crossProduct(@NonNull Vec3i vec) {
|
||||
return new BlockPos(y * vec.getZ() - z * vec.getY(), z * vec.getX() - x * vec.getZ(),
|
||||
return new BlockPos(y * vec.getZ() - z * vec.getY(),
|
||||
z * vec.getX() - x * vec.getZ(),
|
||||
x * vec.getY() - y * vec.getX());
|
||||
}
|
||||
|
||||
@@ -479,7 +487,8 @@ public class BlockPos extends Vec3i {
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos.MutableBlockPos move(@NonNull EnumFacing facing, int blocks) {
|
||||
return this.setPos(x + facing.getFrontOffsetX() * blocks, y + facing.getFrontOffsetY() * blocks,
|
||||
return this.setPos(x + facing.getFrontOffsetX() * blocks,
|
||||
y + facing.getFrontOffsetY() * blocks,
|
||||
z + facing.getFrontOffsetZ() * blocks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,8 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public Vec3i crossProduct(@NonNull Vec3i vec) {
|
||||
return new Vec3i(y * vec.getZ() - z * vec.getY(), z * vec.getX() - x * vec.getZ(),
|
||||
return new Vec3i(y * vec.getZ() - z * vec.getY(),
|
||||
z * vec.getX() - x * vec.getZ(),
|
||||
x * vec.getY() - y * vec.getX());
|
||||
}
|
||||
|
||||
|
||||
@@ -80,8 +80,7 @@ public @interface Config {
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface Ignore {
|
||||
}
|
||||
@interface Ignore {}
|
||||
|
||||
/**
|
||||
* The default value for a boolean field. Not having a default is deprecated since 0.10, and will be strongly
|
||||
@@ -253,8 +252,7 @@ public @interface Config {
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface ListFixedLength {
|
||||
}
|
||||
@interface ListFixedLength {}
|
||||
|
||||
/**
|
||||
* This annotation limits the maximum number of elements present in an array configuration. Only effective if
|
||||
@@ -290,8 +288,7 @@ public @interface Config {
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@interface RequiresMcRestart {
|
||||
}
|
||||
@interface RequiresMcRestart {}
|
||||
|
||||
/**
|
||||
* Whether the specific configuration needs a world/server rejoin to be applied.
|
||||
@@ -300,8 +297,7 @@ public @interface Config {
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@interface RequiresWorldRestart {
|
||||
}
|
||||
@interface RequiresWorldRestart {}
|
||||
|
||||
/**
|
||||
* Signals that this configuration class should be synchronized between the client and the server when
|
||||
@@ -314,8 +310,7 @@ public @interface Config {
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@interface Synchronize {
|
||||
}
|
||||
@interface Synchronize {}
|
||||
|
||||
/**
|
||||
* Use this to mark config fields you don't want to synchronize in a class marked with {@link Synchronize}.
|
||||
@@ -324,6 +319,5 @@ public @interface Config {
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface NoSync {
|
||||
}
|
||||
@interface NoSync {}
|
||||
}
|
||||
@@ -40,7 +40,12 @@ public class SimpleGuiConfig extends GuiConfig {
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
public SimpleGuiConfig(GuiScreen parent, String modID, String modName, Class<?>... configClasses)
|
||||
throws ConfigException {
|
||||
super(parent, ConfigurationManager.getConfigElementsMulti(configClasses), modID, false, false,
|
||||
modName + " Configuration", I18n.format("falsepatternlib.gui.config.description"));
|
||||
super(parent,
|
||||
ConfigurationManager.getConfigElementsMulti(configClasses),
|
||||
modID,
|
||||
false,
|
||||
false,
|
||||
modName + " Configuration",
|
||||
I18n.format("falsepatternlib.gui.config.description"));
|
||||
}
|
||||
}
|
||||
@@ -63,23 +63,34 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
public static void postNumericRangeOutOfBounds(Field field, int listIndex, String value, String min, String max) {
|
||||
FMLCommonHandler.instance()
|
||||
.bus()
|
||||
.post(new NumericRangeOutOfBounds(field.getDeclaringClass(), field.getName(), listIndex, value,
|
||||
min, max));
|
||||
.post(new NumericRangeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
listIndex,
|
||||
value,
|
||||
min,
|
||||
max));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postSize(Field field, int requestedSize, boolean fixedSize, int maxSize, int defaultSize) {
|
||||
FMLCommonHandler.instance()
|
||||
.bus()
|
||||
.post(new ListSizeOutOfBounds(field.getDeclaringClass(), field.getName(), requestedSize,
|
||||
fixedSize, maxSize, defaultSize));
|
||||
.post(new ListSizeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
requestedSize,
|
||||
fixedSize,
|
||||
maxSize,
|
||||
defaultSize));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postStringSizeOutOfBounds(Field field, int listIndex, String text, int maxSize) {
|
||||
FMLCommonHandler.instance()
|
||||
.bus()
|
||||
.post(new StringSizeOutOfBounds(field.getDeclaringClass(), field.getName(), listIndex, text,
|
||||
.post(new StringSizeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
listIndex,
|
||||
text,
|
||||
maxSize));
|
||||
}
|
||||
|
||||
@@ -92,7 +103,10 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
public static void postStringPatternMismatch(Field field, int listIndex, String text, String pattern) {
|
||||
FMLCommonHandler.instance()
|
||||
.bus()
|
||||
.post(new StringPatternMismatch(field.getDeclaringClass(), field.getName(), listIndex, text,
|
||||
.post(new StringPatternMismatch(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
listIndex,
|
||||
text,
|
||||
pattern));
|
||||
}
|
||||
|
||||
@@ -100,11 +114,13 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
@StableAPI.Internal
|
||||
public void toast() {
|
||||
val ann = configClass.getAnnotation(Config.class);
|
||||
val toast = new SimpleToast(ToastBG.TOAST_DARK, null,
|
||||
val toast = new SimpleToast(ToastBG.TOAST_DARK,
|
||||
null,
|
||||
FormattedText.parse(EnumChatFormatting.RED + "Config validation failed")
|
||||
.toChatText()
|
||||
.get(0),
|
||||
FormattedText.parse(ann.modid() + ":" + ann.category()).toChatText().get(0), false,
|
||||
FormattedText.parse(ann.modid() + ":" + ann.category()).toChatText().get(0),
|
||||
false,
|
||||
2000);
|
||||
GuiToast.add(toast);
|
||||
}
|
||||
@@ -122,7 +138,7 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
errorString.append("\nArray index: ").append(listIndex);
|
||||
}
|
||||
customText(errorString);
|
||||
for (val line: errorString.toString().split("\n")) {
|
||||
for (val line : errorString.toString().split("\n")) {
|
||||
Share.LOG.error(line);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,16 +130,35 @@ public class Library {
|
||||
|
||||
@StableAPI.Expose
|
||||
public Library build() {
|
||||
return new Library(loadingModId, groupId, artifactId, minVersion, maxVersion, preferredVersion,
|
||||
regularSuffix, devSuffix);
|
||||
return new Library(loadingModId,
|
||||
groupId,
|
||||
artifactId,
|
||||
minVersion,
|
||||
maxVersion,
|
||||
preferredVersion,
|
||||
regularSuffix,
|
||||
devSuffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Library.LibraryBuilder(loadingModId=" + this.loadingModId + ", groupId=" + this.groupId +
|
||||
", artifactId=" + this.artifactId + ", minVersion=" + this.minVersion + ", maxVersion=" +
|
||||
this.maxVersion + ", preferredVersion=" + this.preferredVersion + ", regularSuffix=" +
|
||||
this.regularSuffix + ", devSuffix=" + this.devSuffix + ")";
|
||||
return "Library.LibraryBuilder(loadingModId="
|
||||
+ this.loadingModId
|
||||
+ ", groupId="
|
||||
+ this.groupId
|
||||
+ ", artifactId="
|
||||
+ this.artifactId
|
||||
+ ", minVersion="
|
||||
+ this.minVersion
|
||||
+ ", maxVersion="
|
||||
+ this.maxVersion
|
||||
+ ", preferredVersion="
|
||||
+ this.preferredVersion
|
||||
+ ", regularSuffix="
|
||||
+ this.regularSuffix
|
||||
+ ", devSuffix="
|
||||
+ this.devSuffix
|
||||
+ ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,9 +111,11 @@ public class SemanticVersion extends Version {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// @formatter:off
|
||||
return majorVersion + (minorVersion < 0 ? "" : "." + minorVersion) +
|
||||
(patchVersion < 0 ? "" : "." + patchVersion) + (preRelease == null ? "" : "-" + preRelease) +
|
||||
(build == null ? "" : "+" + build);
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
@@ -165,9 +167,17 @@ public class SemanticVersion extends Version {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SemanticVersion.SemanticVersionBuilder(majorVersion=" + this.majorVersion + ", minorVersion=" +
|
||||
this.minorVersion + ", patchVersion=" + this.patchVersion + ", preRelease=" + this.preRelease +
|
||||
", build=" + this.build + ")";
|
||||
return "SemanticVersion.SemanticVersionBuilder(majorVersion="
|
||||
+ this.majorVersion
|
||||
+ ", minorVersion="
|
||||
+ this.minorVersion
|
||||
+ ", patchVersion="
|
||||
+ this.patchVersion
|
||||
+ ", preRelease="
|
||||
+ this.preRelease
|
||||
+ ", build="
|
||||
+ this.build
|
||||
+ ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ import java.util.function.Consumer;
|
||||
|
||||
public class Internet {
|
||||
private static final Map<String, String> NO_HEADERS = Collections.emptyMap();
|
||||
|
||||
public static void connect(URL URL, Consumer<Exception> onError, Consumer<InputStream> onSuccess) {
|
||||
connect(URL, NO_HEADERS, onError, onSuccess);
|
||||
}
|
||||
@@ -64,9 +65,13 @@ public class Internet {
|
||||
val connection = (HttpURLConnection) URL.openConnection();
|
||||
connection.setConnectTimeout(3500);
|
||||
connection.setReadTimeout(5000);
|
||||
connection.setRequestProperty("User-Agent", Tags.MODNAME + " " + Tags.VERSION + " Internet Connector" +
|
||||
" (https://github.com/FalsePattern/FalsePatternLib)");
|
||||
for (val header: headers.entrySet()) {
|
||||
connection.setRequestProperty("User-Agent",
|
||||
Tags.MODNAME
|
||||
+ " "
|
||||
+ Tags.VERSION
|
||||
+ " Internet Connector"
|
||||
+ " (https://github.com/FalsePattern/FalsePatternLib)");
|
||||
for (val header : headers.entrySet()) {
|
||||
val key = header.getKey();
|
||||
val value = header.getValue();
|
||||
if (key == null || value == null) {
|
||||
@@ -87,8 +92,9 @@ public class Internet {
|
||||
//Check if NonUpdate is present
|
||||
try {
|
||||
if (Launch.classLoader.getClassBytes("moe.mickey.forge.nonupdate.NonUpdate") != null) {
|
||||
e.addSuppressed(new Exception("NonUpdate is present, it's possible that it's blocking a library download." +
|
||||
" Please disable it for a single run to allow mod dependencies to download."));
|
||||
e.addSuppressed(new Exception(
|
||||
"NonUpdate is present, it's possible that it's blocking a library download."
|
||||
+ " Please disable it for a single run to allow mod dependencies to download."));
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
e.addSuppressed(ex);
|
||||
@@ -111,7 +117,9 @@ public class Internet {
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
});
|
||||
if (success.get()) return result.toByteArray();
|
||||
if (success.get()) {
|
||||
return result.toByteArray();
|
||||
}
|
||||
}
|
||||
throw new CompletionException(caught.get());
|
||||
});
|
||||
@@ -131,7 +139,9 @@ public class Internet {
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
});
|
||||
if (success.get()) return;
|
||||
if (success.get()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new CompletionException(caught.get());
|
||||
});
|
||||
|
||||
@@ -39,12 +39,10 @@ public class ReflectionUtil {
|
||||
}
|
||||
|
||||
// ref: https://github.com/prestodb/presto/pull/15240/files#diff-8bf996e5c1d4fb088b84ae0528bc42686b0724bcf5a2692a1e7b5eff32c90cce
|
||||
private static Field getModifiersField() throws NoSuchFieldException
|
||||
{
|
||||
private static Field getModifiersField() throws NoSuchFieldException {
|
||||
try {
|
||||
return Field.class.getDeclaredField("modifiers");
|
||||
}
|
||||
catch (NoSuchFieldException e) {
|
||||
} catch (NoSuchFieldException e) {
|
||||
try {
|
||||
Method getDeclaredFields0 = Class.class.getDeclaredMethod("getDeclaredFields0", boolean.class);
|
||||
getDeclaredFields0.setAccessible(true);
|
||||
@@ -54,8 +52,7 @@ public class ReflectionUtil {
|
||||
return field;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ReflectiveOperationException ex) {
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
e.addSuppressed(ex);
|
||||
}
|
||||
throw e;
|
||||
|
||||
@@ -116,15 +116,20 @@ public class CoreLoadingPlugin implements IFMLLoadingPlugin {
|
||||
public static void validateGasStation() {
|
||||
Share.LOG.info("Got any gas?");
|
||||
//Make sure everything is loaded correctly, crash if gasstation is bugged
|
||||
if (!isClassPresentSafe("com.falsepattern.gasstation.core.GasStationCore") || //Validate core class
|
||||
!isClassPresentSafe("makamys.mixingasm.api.TransformerInclusions") || //Validate the mixingasm compat
|
||||
!isClassPresentSafe("ru.timeconqueror.spongemixins.core.SpongeMixinsCore") || //Validate the spongemixins compat
|
||||
!isClassPresentSafe("io.github.tox1cozz.mixinbooterlegacy.MixinBooterLegacyPlugin") || //Validate the MBL compat
|
||||
(!isClassPresentSafe("org.spongepowered.asm.lib.Opcodes") || isClassPresentSafe("org.spongepowered.libraries.org.objectweb.asm.Opcodes")) //Validate correct mixins class
|
||||
// @formatter:off
|
||||
if (!isClassPresentSafe("com.falsepattern.gasstation.core.GasStationCore") //Validate core class
|
||||
|| !isClassPresentSafe("makamys.mixingasm.api.TransformerInclusions") //Validate the mixingasm compat
|
||||
|| !isClassPresentSafe("ru.timeconqueror.spongemixins.core.SpongeMixinsCore") //Validate the spongemixins compat
|
||||
|| !isClassPresentSafe("io.github.tox1cozz.mixinbooterlegacy.MixinBooterLegacyPlugin") //Validate the MBL compat
|
||||
|| !isClassPresentSafe("org.spongepowered.asm.lib.Opcodes") //Validate correct mixins class
|
||||
|| isClassPresentSafe("org.spongepowered.libraries.org.objectweb.asm.Opcodes")
|
||||
) {
|
||||
Share.LOG.fatal("Somebody put diesel in my gas tank!");
|
||||
throw new Error("Failed to validate your GasStation mixin plugin installation. Please make sure you have the latest GasStation installed from the official source: https://github.com/FalsePattern/GasStation");
|
||||
throw new Error("Failed to validate your GasStation mixin plugin installation. "
|
||||
+ "Please make sure you have the latest GasStation installed from the official source: "
|
||||
+ "https://github.com/FalsePattern/GasStation");
|
||||
}
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-5
@@ -33,6 +33,7 @@ public class ConfigOrderTransformer implements IClassNodeTransformer {
|
||||
private static final String DESC_CONFIG = Type.getDescriptor(Config.class);
|
||||
private static final String DESC_CONFIG_IGNORE = Type.getDescriptor(Config.Ignore.class);
|
||||
private static final String DESC_ORDER = Type.getDescriptor(DeclOrderInternal.class);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ConfigOrderTransformer";
|
||||
@@ -54,11 +55,11 @@ public class ConfigOrderTransformer implements IClassNodeTransformer {
|
||||
public void transform(ClassNode cn, String transformedName, boolean obfuscated) {
|
||||
int order = 0;
|
||||
outer:
|
||||
for (val field: cn.fields) {
|
||||
if ((field.access & Opcodes.ACC_PUBLIC) == 0 ||
|
||||
(field.access & Opcodes.ACC_STATIC) == 0 ||
|
||||
(field.access & Opcodes.ACC_FINAL) != 0) {
|
||||
continue;
|
||||
for (val field : cn.fields) {
|
||||
if ((field.access & Opcodes.ACC_PUBLIC) == 0
|
||||
|| (field.access & Opcodes.ACC_STATIC) == 0
|
||||
|| (field.access & Opcodes.ACC_FINAL) != 0) {
|
||||
continue;
|
||||
} else if (field.visibleAnnotations != null) {
|
||||
for (val ann : field.visibleAnnotations) {
|
||||
if (DESC_CONFIG_IGNORE.equals(ann.desc)) {
|
||||
|
||||
+8
-7
@@ -61,10 +61,11 @@ public class IMixinPluginTransformer implements IClassNodeTransformer {
|
||||
|
||||
@Override
|
||||
public boolean shouldTransform(ClassNode cn, String transformedName, boolean obfuscated) {
|
||||
return IMIXINPLUGIN.equals(transformedName) ||
|
||||
IMIXINCONFIGPLUGIN.equals(transformedName) ||
|
||||
cn.interfaces.stream().anyMatch((i) -> IMIXINPLUGIN_INTERNAL.equals(i) ||
|
||||
IMIXINCONFIGPLUGIN_INTERNAL.equals(i));
|
||||
return IMIXINPLUGIN.equals(transformedName)
|
||||
|| IMIXINCONFIGPLUGIN.equals(transformedName)
|
||||
|| cn.interfaces.stream()
|
||||
.anyMatch((i) -> IMIXINPLUGIN_INTERNAL.equals(i)
|
||||
|| IMIXINCONFIGPLUGIN_INTERNAL.equals(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +90,7 @@ public class IMixinPluginTransformer implements IClassNodeTransformer {
|
||||
continue;
|
||||
}
|
||||
if (CLASSNODE_REAL != null) {
|
||||
for (val local: method.localVariables) {
|
||||
for (val local : method.localVariables) {
|
||||
if (local.desc.contains("ClassNode;")) {
|
||||
local.desc = local.desc.replaceAll("L[a-zA-Z/$]+[a-zA-Z$]+/ClassNode;", CLASSNODE_REAL);
|
||||
}
|
||||
@@ -119,10 +120,10 @@ public class IMixinPluginTransformer implements IClassNodeTransformer {
|
||||
}
|
||||
|
||||
private static String extractMethodWithReflection(String m) {
|
||||
for (val method: IMixinConfigPlugin.class.getDeclaredMethods()) {
|
||||
for (val method : IMixinConfigPlugin.class.getDeclaredMethods()) {
|
||||
if (method.getName().equals(m)) {
|
||||
StringBuilder b = new StringBuilder("(");
|
||||
for (val param: method.getParameterTypes()) {
|
||||
for (val param : method.getParameterTypes()) {
|
||||
if (param.getName().contains("ClassNode")) {
|
||||
CLASSNODE_REAL = "L" + param.getName().replace('.', '/') + ";";
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class ITypeDiscovererTransformer implements IClassNodeTransformer {
|
||||
|
||||
@Override
|
||||
public void transform(ClassNode cn, String transformedName, boolean obfuscated) {
|
||||
for (val method: cn.methods) {
|
||||
for (val method : cn.methods) {
|
||||
if (!method.name.equals("<clinit>")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,10 @@ public class LibraryConfig {
|
||||
static {
|
||||
ConfigurationManager.selfInit();
|
||||
}
|
||||
|
||||
@Config.Comment({"Used to control whether FalsePatternLib should check for outdated mods.",
|
||||
"If you're building a public modpack, you should turn this off so that your users don't " +
|
||||
"get nagged about outdated mods."})
|
||||
"If you're building a public modpack, you should turn this off so that your users don't "
|
||||
+ "get nagged about outdated mods."})
|
||||
@Config.LangKey("config.falsepatternlib.updatecheck")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean ENABLE_UPDATE_CHECKER;
|
||||
|
||||
@@ -35,6 +35,7 @@ public class ToastConfig {
|
||||
static {
|
||||
ConfigurationManager.selfInit();
|
||||
}
|
||||
|
||||
@Config.Comment("The maximum amount of toasts to show on the screen")
|
||||
@Config.LangKey("config.falsepatternlib.maxtoasts")
|
||||
@Config.DefaultInt(5)
|
||||
|
||||
+4
-7
@@ -171,23 +171,20 @@ public final class ConfigurationManagerImpl {
|
||||
val opt = serializedNames.keySet().stream().filter((key) -> key.equals(serializedName)).findFirst();
|
||||
if (!opt.isPresent()) {
|
||||
input.skipBytes(dataSize);
|
||||
Share.LOG
|
||||
.warn("Server tried to sync config not registered on our side: " + serializedName);
|
||||
Share.LOG.warn("Server tried to sync config not registered on our side: " + serializedName);
|
||||
continue;
|
||||
}
|
||||
val clazz = serializedNames.get(opt.get());
|
||||
val config = parsedConfigMap.get(clazz);
|
||||
if (!config.sync) {
|
||||
input.skipBytes(dataSize);
|
||||
Share.LOG
|
||||
.warn("Server tried to sync config without @Synchronize annotation on our side: " +
|
||||
serializedName);
|
||||
Share.LOG.warn("Server tried to sync config without @Synchronize annotation on our side: "
|
||||
+ serializedName);
|
||||
continue;
|
||||
}
|
||||
if (!ConfigSyncEvent.postStart(clazz)) {
|
||||
input.skipBytes(dataSize);
|
||||
Share.LOG.warn(
|
||||
"Config synchronization was cancelled by event for: " + serializedName);
|
||||
Share.LOG.warn("Config synchronization was cancelled by event for: " + serializedName);
|
||||
continue;
|
||||
}
|
||||
val bytes = new byte[dataSize];
|
||||
|
||||
@@ -82,14 +82,19 @@ public class ParsedConfiguration {
|
||||
|
||||
public static ParsedConfiguration parseConfig(Class<?> configClass) throws ConfigException {
|
||||
val cfg = Optional.ofNullable(configClass.getAnnotation(Config.class))
|
||||
.orElseThrow(() -> new ConfigException(
|
||||
"Class " + configClass.getName() + " does not have a @Config annotation!"));
|
||||
.orElseThrow(() -> new ConfigException("Class "
|
||||
+ configClass.getName()
|
||||
+ " does not have a @Config annotation!"));
|
||||
val category = Optional.of(cfg.category().trim())
|
||||
.map((cat) -> cat.length() == 0 ? null : cat)
|
||||
.orElseThrow(() -> new ConfigException(
|
||||
"Config class " + configClass.getName() + " has an empty category!"));
|
||||
.orElseThrow(() -> new ConfigException("Config class "
|
||||
+ configClass.getName()
|
||||
+ " has an empty category!"));
|
||||
val rawConfig = ConfigurationManagerImpl.getForgeConfig(cfg.modid());
|
||||
val parsedConfig = new ParsedConfiguration(configClass, cfg.modid(), category, rawConfig,
|
||||
val parsedConfig = new ParsedConfiguration(configClass,
|
||||
cfg.modid(),
|
||||
category,
|
||||
rawConfig,
|
||||
configClass.isAnnotationPresent(Config.Synchronize.class));
|
||||
try {
|
||||
parsedConfig.reloadFields();
|
||||
@@ -133,8 +138,10 @@ public class ParsedConfiguration {
|
||||
val fieldName =
|
||||
StringConfigField.receiveString(input, maxFieldNameLength, "field name", configClass.getName());
|
||||
if (!syncFields.containsKey(fieldName)) {
|
||||
throw new IOException("Invalid sync field name received: " + fieldName + " for config class " +
|
||||
configClass.getName());
|
||||
throw new IOException("Invalid sync field name received: "
|
||||
+ fieldName
|
||||
+ " for config class "
|
||||
+ configClass.getName());
|
||||
}
|
||||
syncFields.remove(fieldName).receive(input);
|
||||
}
|
||||
@@ -180,9 +187,13 @@ public class ParsedConfiguration {
|
||||
} else if (fieldClass.isEnum()) {
|
||||
fields.put(name, configField = new EnumConfigField<>(field, rawConfig, category));
|
||||
} else {
|
||||
throw new ConfigException("Illegal config field: " + field.getName() + " in " + configClass.getName() +
|
||||
": Unsupported type " + fieldClass.getName() +
|
||||
"! Did you forget an @Ignore annotation?");
|
||||
throw new ConfigException("Illegal config field: "
|
||||
+ field.getName()
|
||||
+ " in "
|
||||
+ configClass.getName()
|
||||
+ ": Unsupported type "
|
||||
+ fieldClass.getName()
|
||||
+ "! Did you forget an @Ignore annotation?");
|
||||
}
|
||||
if (field.isAnnotationPresent(Config.RequiresMcRestart.class)) {
|
||||
cat.setRequiresMcRestart(true);
|
||||
@@ -196,7 +207,8 @@ public class ParsedConfiguration {
|
||||
save();
|
||||
}));
|
||||
}
|
||||
rawConfig.setCategoryPropertyOrder(category, fieldsSorted().map((prop) -> prop.name).collect(Collectors.toList()));
|
||||
rawConfig.setCategoryPropertyOrder(category,
|
||||
fieldsSorted().map((prop) -> prop.name).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private Stream<AConfigField<?>> fieldsSorted() {
|
||||
|
||||
+8
-4
@@ -61,19 +61,23 @@ public class ClientEventHandlerPre {
|
||||
public void onConfigSyncFinished(ConfigSyncEvent.End e) {
|
||||
val cfg = e.configClass.getAnnotation(Config.class);
|
||||
if (e.successful) {
|
||||
GuiToast.add(new SimpleToast(ToastBG.TOAST_DARK, null,
|
||||
GuiToast.add(new SimpleToast(ToastBG.TOAST_DARK,
|
||||
null,
|
||||
FormattedText.parse(EnumChatFormatting.GREEN + "Synced config")
|
||||
.toChatText()
|
||||
.get(0),
|
||||
FormattedText.parse(cfg.modid() + ":" + cfg.category()).toChatText().get(0),
|
||||
false, 5000));
|
||||
false,
|
||||
5000));
|
||||
} else {
|
||||
GuiToast.add(new SimpleToast(ToastBG.TOAST_DARK, null,
|
||||
GuiToast.add(new SimpleToast(ToastBG.TOAST_DARK,
|
||||
null,
|
||||
FormattedText.parse(EnumChatFormatting.RED + "Failed to sync config")
|
||||
.toChatText()
|
||||
.get(0),
|
||||
FormattedText.parse(cfg.modid() + ":" + cfg.category()).toChatText().get(0),
|
||||
false, 5000));
|
||||
false,
|
||||
5000));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,9 @@ public abstract class AConfigField<T> {
|
||||
}
|
||||
property.setLanguageKey(langKey);
|
||||
noSync = field.isAnnotationPresent(Config.NoSync.class);
|
||||
order = Optional.ofNullable(field.getAnnotation(DeclOrderInternal.class)).map(DeclOrderInternal::value).orElse(-1);
|
||||
order = Optional.ofNullable(field.getAnnotation(DeclOrderInternal.class))
|
||||
.map(DeclOrderInternal::value)
|
||||
.orElse(-1);
|
||||
}
|
||||
|
||||
protected abstract T getField();
|
||||
|
||||
+11
-5
@@ -47,9 +47,11 @@ public abstract class AListConfigField<T> extends AConfigField<T> {
|
||||
.map(Config.ListMaxLength::value)
|
||||
.orElse(256);
|
||||
if (maxLength < 0) {
|
||||
throw new ConfigException(
|
||||
"Negative length list configurations are not supported!\n" + "Field name: " + field.getName() +
|
||||
", class: " + field.getDeclaringClass().getName());
|
||||
throw new ConfigException("Negative length list configurations are not supported!\n"
|
||||
+ "Field name: "
|
||||
+ field.getName()
|
||||
+ ", class: "
|
||||
+ field.getDeclaringClass().getName());
|
||||
}
|
||||
property.setIsListLengthFixed(fixedLength);
|
||||
property.setMaxListLength(maxLength);
|
||||
@@ -105,8 +107,12 @@ public abstract class AListConfigField<T> extends AConfigField<T> {
|
||||
public void receive(DataInput input) throws IOException {
|
||||
int length = input.readInt();
|
||||
if (length > maxLength || fixedLength && length(getDefault()) != length) {
|
||||
throw new IOException("Error while retrieving config value for field " + field.getName() + " in class " +
|
||||
field.getDeclaringClass().getName() + ":\n" + "Illegal array length received!");
|
||||
throw new IOException("Error while retrieving config value for field "
|
||||
+ field.getName()
|
||||
+ " in class "
|
||||
+ field.getDeclaringClass().getName()
|
||||
+ ":\n"
|
||||
+ "Illegal array length received!");
|
||||
}
|
||||
val arr = createArray(length);
|
||||
receiveElements(input, arr);
|
||||
|
||||
+5
-4
@@ -44,10 +44,11 @@ public class BooleanConfigField extends AConfigField<Boolean> {
|
||||
defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultBoolean.class))
|
||||
.map(Config.DefaultBoolean::value)
|
||||
.orElseGet(() -> {
|
||||
Share.LOG
|
||||
.warn("The field " + field.getName() + " in class " +
|
||||
field.getDeclaringClass().getName() +
|
||||
" has no DefaultBoolean annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
Share.LOG.warn("The field "
|
||||
+ field.getName()
|
||||
+ " in class "
|
||||
+ field.getDeclaringClass().getName()
|
||||
+ " has no DefaultBoolean annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
try {
|
||||
return field.getType().isPrimitive() ? field.getBoolean(null)
|
||||
: (Boolean) field.get(null);
|
||||
|
||||
+5
-4
@@ -43,10 +43,11 @@ public class BooleanListConfigField extends AListConfigField<boolean[]> {
|
||||
defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultBooleanList.class))
|
||||
.map(Config.DefaultBooleanList::value)
|
||||
.orElseGet(() -> {
|
||||
Share.LOG
|
||||
.warn("The field " + field.getName() + " in class " +
|
||||
field.getDeclaringClass().getName() +
|
||||
" has no DefaultBooleanList annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
Share.LOG.warn("The field "
|
||||
+ field.getName()
|
||||
+ " in class "
|
||||
+ field.getDeclaringClass().getName()
|
||||
+ " has no DefaultBooleanList annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
try {
|
||||
return (boolean[]) field.get(null);
|
||||
} catch (IllegalAccessException e) {
|
||||
|
||||
+10
-6
@@ -50,10 +50,11 @@ public class DoubleConfigField extends AConfigField<Double> {
|
||||
defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultDouble.class))
|
||||
.map(Config.DefaultDouble::value)
|
||||
.orElseGet(() -> {
|
||||
Share.LOG
|
||||
.warn("The field " + field.getName() + " in class " +
|
||||
field.getDeclaringClass().getName() +
|
||||
" has no DefaultDouble annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
Share.LOG.warn("The field "
|
||||
+ field.getName()
|
||||
+ " in class "
|
||||
+ field.getDeclaringClass().getName()
|
||||
+ " has no DefaultDouble annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
try {
|
||||
return field.getType().isPrimitive() ? field.getInt(null)
|
||||
: (Double) field.get(null);
|
||||
@@ -112,8 +113,11 @@ public class DoubleConfigField extends AConfigField<Double> {
|
||||
if (value >= min && value <= max) {
|
||||
return true;
|
||||
}
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, -1, Double.toString(value),
|
||||
Double.toString(min), Double.toString(max));
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field,
|
||||
-1,
|
||||
Double.toString(value),
|
||||
Double.toString(min),
|
||||
Double.toString(max));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -49,10 +49,11 @@ public class DoubleListConfigField extends AListConfigField<double[]> {
|
||||
defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultDoubleList.class))
|
||||
.map(Config.DefaultDoubleList::value)
|
||||
.orElseGet(() -> {
|
||||
Share.LOG
|
||||
.warn("The field " + field.getName() + " in class " +
|
||||
field.getDeclaringClass().getName() +
|
||||
" has no DefaultDoubleList annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
Share.LOG.warn("The field "
|
||||
+ field.getName()
|
||||
+ " in class "
|
||||
+ field.getDeclaringClass().getName()
|
||||
+ " has no DefaultDoubleList annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
try {
|
||||
return (double[]) field.get(null);
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -107,8 +108,11 @@ public class DoubleListConfigField extends AListConfigField<double[]> {
|
||||
for (int j = 0; j < doubles.length; j++) {
|
||||
double d = doubles[j];
|
||||
if (d < min || d > max) {
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, j, Double.toString(d),
|
||||
Double.toString(min), Double.toString(max));
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field,
|
||||
j,
|
||||
Double.toString(d),
|
||||
Double.toString(min),
|
||||
Double.toString(max));
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
+32
-16
@@ -58,13 +58,16 @@ public class EnumConfigField<T extends Enum<T>> extends AConfigField<T> {
|
||||
.filter((e) -> e.name().equals(defName))
|
||||
.findAny()
|
||||
.orElseThrow(() -> new IllegalArgumentException(
|
||||
"Default value \"" + defName +
|
||||
"\" was not found in enum " + enumClass.getName())))
|
||||
"Default value \""
|
||||
+ defName
|
||||
+ "\" was not found in enum "
|
||||
+ enumClass.getName())))
|
||||
.orElseGet(() -> {
|
||||
Share.LOG
|
||||
.warn("The field " + field.getName() + " in class " +
|
||||
field.getDeclaringClass().getName() +
|
||||
" has no DefaultEnum annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
Share.LOG.warn("The field "
|
||||
+ field.getName()
|
||||
+ " in class "
|
||||
+ field.getDeclaringClass().getName()
|
||||
+ " has no DefaultEnum annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
try {
|
||||
return enumClass.cast(field.get(null));
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -77,8 +80,12 @@ public class EnumConfigField<T extends Enum<T>> extends AConfigField<T> {
|
||||
if (!enumNameMap.containsValue(getConfig())) {
|
||||
setToDefault();
|
||||
}
|
||||
property.comment += "\n[default: " + defaultValue + ", possible values: " +
|
||||
Arrays.toString(enumNameMap.keySet().toArray(new String[0])) + "]";
|
||||
property.comment += "\n[default: "
|
||||
+ defaultValue
|
||||
+ ", possible values: "
|
||||
+ Arrays.toString(enumNameMap.keySet()
|
||||
.toArray(new String[0]))
|
||||
+ "]";
|
||||
}
|
||||
|
||||
public static void transmitString(DataOutput output, String value) throws IOException {
|
||||
@@ -90,9 +97,12 @@ public class EnumConfigField<T extends Enum<T>> extends AConfigField<T> {
|
||||
throws IOException {
|
||||
val length = input.readInt();
|
||||
if (length > maxLength || length < 0) {
|
||||
throw new IOException(
|
||||
"Error while retrieving config value for field " + fieldName + " in class " + className + ":\n" +
|
||||
"Illegal string length received!");
|
||||
throw new IOException("Error while retrieving config value for field "
|
||||
+ fieldName
|
||||
+ " in class "
|
||||
+ className
|
||||
+ ":\n"
|
||||
+ "Illegal string length received!");
|
||||
}
|
||||
val arr = new char[length];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
@@ -103,11 +113,17 @@ public class EnumConfigField<T extends Enum<T>> extends AConfigField<T> {
|
||||
|
||||
private T getEnumByName(String name) {
|
||||
if (!enumNameMap.containsKey(name)) {
|
||||
Share.LOG
|
||||
.warn("Invalid value " + name + " for enum configuration field " + field.getName() +
|
||||
" of type " + enumClass.getName() + " in config class " +
|
||||
field.getDeclaringClass().getName() + "! Using default value of " +
|
||||
defaultValue.name() + "!");
|
||||
Share.LOG.warn("Invalid value "
|
||||
+ name
|
||||
+ " for enum configuration field "
|
||||
+ field.getName()
|
||||
+ " of type "
|
||||
+ enumClass.getName()
|
||||
+ " in config class "
|
||||
+ field.getDeclaringClass().getName()
|
||||
+ "! Using default value of "
|
||||
+ defaultValue.name()
|
||||
+ "!");
|
||||
return defaultValue;
|
||||
}
|
||||
return enumNameMap.get(name);
|
||||
|
||||
@@ -50,10 +50,11 @@ public class IntConfigField extends AConfigField<Integer> {
|
||||
defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultInt.class))
|
||||
.map(Config.DefaultInt::value)
|
||||
.orElseGet(() -> {
|
||||
Share.LOG
|
||||
.warn("The field " + field.getName() + " in class " +
|
||||
field.getDeclaringClass().getName() +
|
||||
" has no DefaultInt annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
Share.LOG.warn("The field "
|
||||
+ field.getName()
|
||||
+ " in class "
|
||||
+ field.getDeclaringClass().getName()
|
||||
+ " has no DefaultInt annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
try {
|
||||
return field.getType().isPrimitive() ? field.getInt(null)
|
||||
: (Integer) field.get(null);
|
||||
@@ -112,8 +113,11 @@ public class IntConfigField extends AConfigField<Integer> {
|
||||
if (value >= min && value <= max) {
|
||||
return true;
|
||||
}
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, -1, Integer.toString(value),
|
||||
Integer.toString(min), Integer.toString(max));
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field,
|
||||
-1,
|
||||
Integer.toString(value),
|
||||
Integer.toString(min),
|
||||
Integer.toString(max));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -49,10 +49,11 @@ public class IntListConfigField extends AListConfigField<int[]> {
|
||||
defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultIntList.class))
|
||||
.map(Config.DefaultIntList::value)
|
||||
.orElseGet(() -> {
|
||||
Share.LOG
|
||||
.warn("The field " + field.getName() + " in class " +
|
||||
field.getDeclaringClass().getName() +
|
||||
" has no DefaultIntList annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
Share.LOG.warn("The field "
|
||||
+ field.getName()
|
||||
+ " in class "
|
||||
+ field.getDeclaringClass().getName()
|
||||
+ " has no DefaultIntList annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
try {
|
||||
return (int[]) field.get(null);
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -107,8 +108,11 @@ public class IntListConfigField extends AListConfigField<int[]> {
|
||||
for (int j = 0; j < ints.length; j++) {
|
||||
int i = ints[j];
|
||||
if (i < min || i > max) {
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, j, Integer.toString(i),
|
||||
Integer.toString(min), Integer.toString(max));
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field,
|
||||
j,
|
||||
Integer.toString(i),
|
||||
Integer.toString(min),
|
||||
Integer.toString(max));
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
+17
-9
@@ -49,10 +49,11 @@ public class StringConfigField extends AConfigField<String> {
|
||||
defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultString.class))
|
||||
.map(Config.DefaultString::value)
|
||||
.orElseGet(() -> {
|
||||
Share.LOG
|
||||
.warn("The field " + field.getName() + " in class " +
|
||||
field.getDeclaringClass().getName() +
|
||||
" has no DefaultString annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
Share.LOG.warn("The field "
|
||||
+ field.getName()
|
||||
+ " in class "
|
||||
+ field.getDeclaringClass().getName()
|
||||
+ " has no DefaultString annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
try {
|
||||
return (String) field.get(null);
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -63,9 +64,12 @@ public class StringConfigField extends AConfigField<String> {
|
||||
.map(Config.StringMaxLength::value)
|
||||
.orElse(256);
|
||||
property.setDefaultValue(defaultValue);
|
||||
property.comment +=
|
||||
"\n[max length: " + maxLength + (pattern != null ? ", pattern: \"" + pattern.pattern() + "\"" : "") +
|
||||
", default: \"" + defaultValue + "\"]";
|
||||
property.comment += "\n[max length: "
|
||||
+ maxLength
|
||||
+ (pattern != null ? ", pattern: \"" + pattern.pattern() + "\"" : "")
|
||||
+ ", default: \""
|
||||
+ defaultValue
|
||||
+ "\"]";
|
||||
}
|
||||
|
||||
public static boolean validateString(String value, int maxLength, Pattern pattern, Field field, int listIndex) {
|
||||
@@ -93,8 +97,12 @@ public class StringConfigField extends AConfigField<String> {
|
||||
throws IOException {
|
||||
val length = input.readInt();
|
||||
if (length > maxLength || length < 0) {
|
||||
throw new IOException("Error while retrieving value for " + valueName + " in class " + className + ":\n" +
|
||||
"Illegal string length received!");
|
||||
throw new IOException("Error while retrieving value for "
|
||||
+ valueName
|
||||
+ " in class "
|
||||
+ className
|
||||
+ ":\n"
|
||||
+ "Illegal string length received!");
|
||||
}
|
||||
val arr = new char[length];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
|
||||
+15
-8
@@ -49,10 +49,11 @@ public class StringListConfigField extends AListConfigField<String[]> {
|
||||
defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultStringList.class))
|
||||
.map(Config.DefaultStringList::value)
|
||||
.orElseGet(() -> {
|
||||
Share.LOG
|
||||
.warn("The field " + field.getName() + " in class " +
|
||||
field.getDeclaringClass().getName() +
|
||||
" has no DefaultStringList annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
Share.LOG.warn("The field "
|
||||
+ field.getName()
|
||||
+ " in class "
|
||||
+ field.getDeclaringClass().getName()
|
||||
+ " has no DefaultStringList annotation!\nThis will be a crash in FalsePatternLib 0.11, update your code!");
|
||||
try {
|
||||
return (String[]) field.get(null);
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -66,9 +67,13 @@ public class StringListConfigField extends AListConfigField<String[]> {
|
||||
if (!property.isList()) {
|
||||
setToDefault();
|
||||
}
|
||||
property.comment += "\n[max string length: " + maxLength +
|
||||
(pattern != null ? ", pattern: \"" + pattern.pattern() + "\"" : "") + ", default: \"" +
|
||||
stringify(defaultValue) + "\"]";
|
||||
property.comment +=
|
||||
"\n[max string length: "
|
||||
+ maxLength
|
||||
+ (pattern != null ? ", pattern: \"" + pattern.pattern() + "\"" : "")
|
||||
+ ", default: \""
|
||||
+ stringify(defaultValue)
|
||||
+ "\"]";
|
||||
}
|
||||
|
||||
private static String stringify(String[] arr) {
|
||||
@@ -102,7 +107,9 @@ public class StringListConfigField extends AListConfigField<String[]> {
|
||||
@Override
|
||||
protected void receiveElements(DataInput input, String[] arr) throws IOException {
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
arr[i] = StringConfigField.receiveString(input, maxStringLength, field.getName(),
|
||||
arr[i] = StringConfigField.receiveString(input,
|
||||
maxStringLength,
|
||||
field.getName(),
|
||||
field.getDeclaringClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
+158
-95
@@ -115,12 +115,17 @@ public class DependencyLoaderImpl {
|
||||
}
|
||||
}
|
||||
if (oldLibDir.exists()) {
|
||||
LOG.info("Migrating old library folder. From: " + oldLibDir.getAbsolutePath() + ", To: " + libDir.getAbsolutePath());
|
||||
LOG.info("Migrating old library folder. From: "
|
||||
+ oldLibDir.getAbsolutePath()
|
||||
+ ", To: "
|
||||
+ libDir.getAbsolutePath());
|
||||
val oldFiles = oldLibDir.listFiles();
|
||||
if (oldFiles != null) {
|
||||
for (val file: oldFiles) {
|
||||
for (val file : oldFiles) {
|
||||
try {
|
||||
Files.move(file.toPath(), libDir.toPath().resolve(oldLibDir.toPath().relativize(file.toPath())), StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.move(file.toPath(),
|
||||
libDir.toPath().resolve(oldLibDir.toPath().relativize(file.toPath())),
|
||||
StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (IOException e) {
|
||||
LOG.warn("Failed to move file " + file.getName() + " to new dir! Deleting instead.");
|
||||
try {
|
||||
@@ -214,9 +219,14 @@ public class DependencyLoaderImpl {
|
||||
public static CompletableFuture<Void> loadLibrariesAsync(Library... libraries) {
|
||||
val futures = new ArrayList<CompletableFuture<Void>>();
|
||||
for (val library : libraries) {
|
||||
val task = new DependencyLoadTask(library.loadingModId, library.groupId, library.artifactId,
|
||||
library.minVersion, library.maxVersion, library.preferredVersion,
|
||||
library.regularSuffix, library.devSuffix);
|
||||
val task = new DependencyLoadTask(library.loadingModId,
|
||||
library.groupId,
|
||||
library.artifactId,
|
||||
library.minVersion,
|
||||
library.maxVersion,
|
||||
library.preferredVersion,
|
||||
library.regularSuffix,
|
||||
library.devSuffix);
|
||||
futures.add(CompletableFuture.runAsync(task::load, executor));
|
||||
}
|
||||
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||
@@ -230,7 +240,8 @@ public class DependencyLoaderImpl {
|
||||
boolean found = false;
|
||||
if (fileName.endsWith(".jar")) {
|
||||
//Scan jar file for json in META-INF, add them to the list
|
||||
try (val inputStream = new BufferedInputStream(source.openStream(), 65536); val jarFile = new JarInputStream(inputStream)) {
|
||||
try (val inputStream = new BufferedInputStream(source.openStream(), 65536);
|
||||
val jarFile = new JarInputStream(inputStream)) {
|
||||
ZipEntry entry;
|
||||
while ((entry = jarFile.getNextEntry()) != null) {
|
||||
if (!entry.getName().startsWith("META-INF") || !entry.getName().endsWith(".json")) {
|
||||
@@ -301,11 +312,12 @@ public class DependencyLoaderImpl {
|
||||
return mapper.apply(pair.b).map(b -> new Pair<>(a, b));
|
||||
}
|
||||
|
||||
private static final Pattern VERSION_PATTERN = Pattern.compile(""
|
||||
+ "(0|[1-9]\\d*)(?:\\.(0|[1-9]\\d*))?(?:\\.(0|[1-9]\\d*))?"
|
||||
+ "(?:-((?:(?:[0-9]+[a-zA-Z-][\\w-]*)|(?:[a-zA-Z][\\w-]*)|(?:[1-9]\\d*)|0)"
|
||||
+ "(?:\\.(?:(?:[0-9]+[a-zA-Z-][\\w-]*)|(?:[a-zA-Z][\\w-]*)|(?:[1-9]\\d*)|0))*))?"
|
||||
+ "(?:\\+([\\w-]+(\\.[\\w-]+)*))?");
|
||||
private static final Pattern VERSION_PATTERN =
|
||||
Pattern.compile("(0|[1-9]\\d*)(?:\\.(0|[1-9]\\d*))?(?:\\.(0|[1-9]\\d*))?"
|
||||
+ "(?:-((?:(?:[0-9]+[a-zA-Z-][\\w-]*)|(?:[a-zA-Z][\\w-]*)|(?:[1-9]\\d*)|0)"
|
||||
+ "(?:\\.(?:(?:[0-9]+[a-zA-Z-][\\w-]*)|(?:[a-zA-Z][\\w-]*)|(?:[1-9]\\d*)|0))*))?"
|
||||
+ "(?:\\+([\\w-]+(\\.[\\w-]+)*))?");
|
||||
|
||||
public static void scanDeps() {
|
||||
LOG.debug("Discovering dependency source candidates...");
|
||||
val modsDir = new File(FileUtil.getMinecraftHome(), "mods");
|
||||
@@ -327,48 +339,43 @@ public class DependencyLoaderImpl {
|
||||
.filter((url) -> !urlsWithoutDeps.contains(url.toString()))
|
||||
.collect(Collectors.toList());
|
||||
val urls = new ArrayList<URL>();
|
||||
for (val candidate: candidates) {
|
||||
for (val candidate : candidates) {
|
||||
if (!scanForDepSpecs(candidate, urls)) {
|
||||
urlsWithoutDeps.add(candidate.toString());
|
||||
}
|
||||
}
|
||||
try (val out = Files.newBufferedWriter(depCache.toPath())) {
|
||||
for (val noDep: urlsWithoutDeps) {
|
||||
for (val noDep : urlsWithoutDeps) {
|
||||
out.append(noDep).append(System.lineSeparator());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.error("Could not write dependency scanner cache", e);
|
||||
}
|
||||
val dependencySpecs = urls.stream()
|
||||
.map((source) -> {
|
||||
//Convert source to GSON json
|
||||
try (val is = new BufferedInputStream(source.openStream())) {
|
||||
val jsonRaw = new JsonParser().parse(new InputStreamReader(is));
|
||||
if (!jsonRaw.isJsonObject()) {
|
||||
return null;
|
||||
}
|
||||
val json = jsonRaw.getAsJsonObject();
|
||||
if (!(json.has("identifier") &&
|
||||
json.get("identifier")
|
||||
val dependencySpecs = urls.stream().map((source) -> {
|
||||
//Convert source to GSON json
|
||||
try (val is = new BufferedInputStream(source.openStream())) {
|
||||
val jsonRaw = new JsonParser().parse(new InputStreamReader(is));
|
||||
if (!jsonRaw.isJsonObject()) {
|
||||
return null;
|
||||
}
|
||||
val json = jsonRaw.getAsJsonObject();
|
||||
if (!(json.has("identifier") && json.get("identifier")
|
||||
.getAsString()
|
||||
.equals("falsepatternlib_dependencies")
|
||||
)) {
|
||||
return null;
|
||||
}
|
||||
val builder = new GsonBuilder();
|
||||
builder.excludeFieldsWithoutExposeAnnotation();
|
||||
val gson = builder.create();
|
||||
json.remove("identifier");
|
||||
val root = gson.fromJson(json, DepRoot.class);
|
||||
root.source(source.toString());
|
||||
return root;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to read json from source {}: {}", source, e);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
.equals("falsepatternlib_dependencies"))) {
|
||||
return null;
|
||||
}
|
||||
val builder = new GsonBuilder();
|
||||
builder.excludeFieldsWithoutExposeAnnotation();
|
||||
val gson = builder.create();
|
||||
json.remove("identifier");
|
||||
val root = gson.fromJson(json, DepRoot.class);
|
||||
root.source(source.toString());
|
||||
return root;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to read json from source {}: {}", source, e);
|
||||
return null;
|
||||
}
|
||||
}).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
long end = System.currentTimeMillis();
|
||||
LOG.debug("Discovered {} dependency source candidates in {}ms", dependencySpecs.size(), end - start);
|
||||
mavenRepositories.addAll(dependencySpecs.stream()
|
||||
@@ -376,11 +383,16 @@ public class DependencyLoaderImpl {
|
||||
.collect(Collectors.toSet()));
|
||||
val artifacts = dependencySpecs.stream()
|
||||
.map((root) -> new Pair<>(root.source(), root.dependencies()))
|
||||
.flatMap(pair -> flatMap(pair, (dep) -> Stream.of(dep.always(), Share.DEV_ENV ? dep.dev() : dep.obf())))
|
||||
.flatMap(pair -> flatMap(pair, (dep) -> Stream.concat(dep.common().stream(),
|
||||
FMLLaunchHandler.side().isClient() ?
|
||||
dep.client().stream() :
|
||||
dep.server().stream())))
|
||||
.flatMap(pair -> flatMap(pair,
|
||||
(dep) -> Stream.of(dep.always(),
|
||||
Share.DEV_ENV ? dep.dev()
|
||||
: dep.obf())))
|
||||
.flatMap(pair -> flatMap(pair,
|
||||
(dep) -> Stream.concat(dep.common().stream(),
|
||||
FMLLaunchHandler.side()
|
||||
.isClient()
|
||||
? dep.client().stream()
|
||||
: dep.server().stream())))
|
||||
.map((pair) -> {
|
||||
val source = pair.a;
|
||||
val dep = pair.b;
|
||||
@@ -398,38 +410,57 @@ public class DependencyLoaderImpl {
|
||||
throw new IllegalArgumentException("Invalid version: " + parts[2]);
|
||||
}
|
||||
val major = Integer.parseInt(matcher.group(1));
|
||||
val minor = matcher.group(2) == null ? -1 : Integer.parseInt(matcher.group(2));
|
||||
val patch = matcher.group(3) == null ? -1 : Integer.parseInt(matcher.group(3));
|
||||
val minor = matcher.group(2) == null ? -1
|
||||
: Integer.parseInt(matcher.group(2));
|
||||
val patch = matcher.group(3) == null ? -1
|
||||
: Integer.parseInt(matcher.group(3));
|
||||
val preRelease = matcher.group(4);
|
||||
val build = matcher.group(5);
|
||||
version = new SemanticVersion(major, minor, patch, preRelease, build);
|
||||
} catch (IllegalArgumentException e) {
|
||||
LOG.warn("Unparseable dependency version {}:{}:{} from {}", groupId, artifactId, parts[2], source);
|
||||
LOG.warn("Unparseable dependency version {}:{}:{} from {}",
|
||||
groupId,
|
||||
artifactId,
|
||||
parts[2],
|
||||
source);
|
||||
version = new RawVersion(parts[2]);
|
||||
}
|
||||
final String classifier = parts.length > 3 ? parts[3] : null;
|
||||
if (classifier != null) {
|
||||
LOG.info("Found dependency: {}:{}:{}:{} from {}", groupId, artifactId,
|
||||
version, classifier, source);
|
||||
LOG.info("Found dependency: {}:{}:{}:{} from {}",
|
||||
groupId,
|
||||
artifactId,
|
||||
version,
|
||||
classifier,
|
||||
source);
|
||||
} else {
|
||||
LOG.info("Found dependency: {}:{}:{} from {}", groupId, artifactId,
|
||||
version, source);
|
||||
LOG.info("Found dependency: {}:{}:{} from {}",
|
||||
groupId,
|
||||
artifactId,
|
||||
version,
|
||||
source);
|
||||
}
|
||||
return new DependencyLoadTask(source, groupId, artifactId,
|
||||
version, null, version,
|
||||
classifier, classifier);
|
||||
return new DependencyLoadTask(source,
|
||||
groupId,
|
||||
artifactId,
|
||||
version,
|
||||
null,
|
||||
version,
|
||||
classifier,
|
||||
classifier);
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
val artifactMap = new HashMap<String, DependencyLoadTask>();
|
||||
for (val artifact: artifacts) {
|
||||
for (val artifact : artifacts) {
|
||||
val id = artifact.getGroupArtifact();
|
||||
if (artifactMap.containsKey(id)) {
|
||||
val otherArtifact = artifactMap.get(id);
|
||||
//TODO: Check for conflicts
|
||||
if (artifact.preferredVersion.compareTo(otherArtifact.preferredVersion) > 0) {
|
||||
LOG.info("Replacing dependency {}:{} from {} with version {} from {}",
|
||||
otherArtifact.getGroupArtifact(), otherArtifact.preferredVersion,
|
||||
otherArtifact.getGroupArtifact(),
|
||||
otherArtifact.preferredVersion,
|
||||
otherArtifact.loadingModId,
|
||||
artifact.preferredVersion,
|
||||
artifact.loadingModId);
|
||||
@@ -495,16 +526,18 @@ public class DependencyLoaderImpl {
|
||||
}
|
||||
|
||||
private void crashCouldNotDownload() {
|
||||
val errorMessage = "Failed to download library " + groupId + ":" + artifactId + ":" + preferredVersion +
|
||||
((suffix != null) ? ":" + suffix : "") + " from any repository! Requested by mod: " +
|
||||
loadingModId;
|
||||
val errorMessage = "Failed to download library " + groupId + ":" + artifactId + ":" + preferredVersion + (
|
||||
(suffix != null) ? ":" + suffix : "") + " from any repository! Requested by mod: " + loadingModId;
|
||||
LOG.fatal(errorMessage);
|
||||
throw new IllegalStateException(errorMessage);
|
||||
}
|
||||
|
||||
private void setupLibraryNames() {
|
||||
suffix = Share.DEV_ENV ? devSuffix : regularSuffix;
|
||||
artifactLogName = String.format("%s:%s:%s%s", groupId, artifactId, preferredVersion,
|
||||
artifactLogName = String.format("%s:%s:%s%s",
|
||||
groupId,
|
||||
artifactId,
|
||||
preferredVersion,
|
||||
suffix != null ? "-" + suffix : "");
|
||||
LOG.info("Adding library {}, requested by mod {}", artifactLogName, loadingModId);
|
||||
artifact = groupId + ":" + artifactId + ":" + suffix;
|
||||
@@ -520,19 +553,31 @@ public class DependencyLoaderImpl {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
LOG.fatal("ALERT VVVVVVVVVVVV ALERT");
|
||||
}
|
||||
LOG.fatal("Library {}:{}{} already loaded with version {}, " +
|
||||
"but a version in the range {} was requested! Thing may go horribly wrong! " +
|
||||
"Requested by mod: {}, previously loaded by mod: {}", groupId, artifactId,
|
||||
suffix != null ? ":" + suffix : "", currentVer, rangeString, loadingModId,
|
||||
LOG.fatal("Library {}:{}{} already loaded with version {}, "
|
||||
+ "but a version in the range {} was requested! Thing may go horribly wrong! "
|
||||
+ "Requested by mod: {}, previously loaded by mod: {}",
|
||||
groupId,
|
||||
artifactId,
|
||||
suffix != null ? ":" + suffix : "",
|
||||
currentVer,
|
||||
rangeString,
|
||||
loadingModId,
|
||||
loadedLibraryMods.get(artifact));
|
||||
for (int i = 0; i < 16; i++) {
|
||||
LOG.fatal("ALERT ^^^^^^^^^^^^ ALERT");
|
||||
}
|
||||
} else {
|
||||
LOG.info("Attempted loading of library {}:{}{} with preferred version {}, " +
|
||||
"but version {} was already loaded, which matched the range {}. This is not an " + "error. " +
|
||||
"Requested by mod: {}, previously loaded by mod: {}", groupId, artifactId,
|
||||
suffix != null ? ":" + suffix : "", preferredVersion, currentVer, rangeString, loadingModId,
|
||||
LOG.info("Attempted loading of library {}:{}{} with preferred version {}, "
|
||||
+ "but version {} was already loaded, which matched the range {}. This is not an "
|
||||
+ "error. "
|
||||
+ "Requested by mod: {}, previously loaded by mod: {}",
|
||||
groupId,
|
||||
artifactId,
|
||||
suffix != null ? ":" + suffix : "",
|
||||
preferredVersion,
|
||||
currentVer,
|
||||
rangeString,
|
||||
loadingModId,
|
||||
loadedLibraryMods.get(artifact));
|
||||
}
|
||||
}
|
||||
@@ -553,8 +598,8 @@ public class DependencyLoaderImpl {
|
||||
if (status == ChecksumStatus.FAILED) {
|
||||
return false;
|
||||
} else if (status == ChecksumStatus.MISSING) {
|
||||
LOG.debug("Library {} is missing checksum data! Either it was manually deleted, " +
|
||||
"or the source repo didn't have it in the first place", artifactLogName);
|
||||
LOG.debug("Library {} is missing checksum data! Either it was manually deleted, "
|
||||
+ "or the source repo didn't have it in the first place", artifactLogName);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.error("Failed to execute validation check for " + artifactLogName, e);
|
||||
@@ -575,10 +620,18 @@ public class DependencyLoaderImpl {
|
||||
|
||||
private void validateDownloadsAllowed() {
|
||||
if (!LibraryConfig.ENABLE_LIBRARY_DOWNLOADS) {
|
||||
val errorMessage = "Failed to load library " + groupId + ":" + artifactId + ":" + preferredVersion +
|
||||
((suffix != null) ? ":" + suffix : "") + ": " + Tags.MODNAME +
|
||||
" library downloading has been disabled in the config, and the library is not present " +
|
||||
"on disk! Requested by mod: " + loadingModId;
|
||||
val errorMessage = "Failed to load library "
|
||||
+ groupId
|
||||
+ ":"
|
||||
+ artifactId
|
||||
+ ":"
|
||||
+ preferredVersion
|
||||
+ ((suffix != null) ? ":" + suffix : "")
|
||||
+ ": "
|
||||
+ Tags.MODNAME
|
||||
+ " library downloading has been disabled in the config, and the library is not present "
|
||||
+ "on disk! Requested by mod: "
|
||||
+ loadingModId;
|
||||
LOG.fatal(errorMessage);
|
||||
throw new IllegalStateException(errorMessage);
|
||||
}
|
||||
@@ -589,7 +642,11 @@ public class DependencyLoaderImpl {
|
||||
if (!repo.endsWith("/")) {
|
||||
repo = repo + "/";
|
||||
}
|
||||
val url = String.format("%s%s/%s/%s/%s", repo, groupId.replace('.', '/'), artifactId, preferredVersion,
|
||||
val url = String.format("%s%s/%s/%s/%s",
|
||||
repo,
|
||||
groupId.replace('.', '/'),
|
||||
artifactId,
|
||||
preferredVersion,
|
||||
mavenJarName);
|
||||
String finalRepo = repo;
|
||||
int retryCount = 0;
|
||||
@@ -601,12 +658,15 @@ public class DependencyLoaderImpl {
|
||||
val success = new AtomicBoolean(false);
|
||||
Internet.connect(new URL(url),
|
||||
(ex) -> LOG.debug("Artifact {} could not be downloaded from repo {}: {}",
|
||||
artifactLogName, finalRepo, ex.getMessage()), (input) -> {
|
||||
LOG.debug("Downloading {} from {}", artifactLogName, finalRepo);
|
||||
download(input, file);
|
||||
LOG.debug("Downloaded {} from {}", artifactLogName, finalRepo);
|
||||
success.set(true);
|
||||
});
|
||||
artifactLogName,
|
||||
finalRepo,
|
||||
ex.getMessage()),
|
||||
(input) -> {
|
||||
LOG.debug("Downloading {} from {}", artifactLogName, finalRepo);
|
||||
download(input, file);
|
||||
LOG.debug("Downloaded {} from {}", artifactLogName, finalRepo);
|
||||
success.set(true);
|
||||
});
|
||||
if (success.get()) {
|
||||
LOG.debug("Validating checksum for {}", artifactLogName);
|
||||
val hadChecksum = validateChecksum(url);
|
||||
@@ -616,9 +676,9 @@ public class DependencyLoaderImpl {
|
||||
case OK:
|
||||
break;
|
||||
case MISSING:
|
||||
LOG.warn("The library {} had no checksum available on the repository.\n" +
|
||||
"There's a chance it might have gotten corrupted during download,\n" +
|
||||
"but we're loading it anyways.", artifactLogName);
|
||||
LOG.warn("The library {} had no checksum available on the repository.\n"
|
||||
+ "There's a chance it might have gotten corrupted during download,\n"
|
||||
+ "but we're loading it anyways.", artifactLogName);
|
||||
}
|
||||
loadedLibraries.put(artifact, preferredVersion);
|
||||
loadedLibraryMods.put(artifact, loadingModId);
|
||||
@@ -638,13 +698,16 @@ public class DependencyLoaderImpl {
|
||||
LOG.debug("Attempting to get {} checksum...", checksumType);
|
||||
val success = new AtomicBoolean(false);
|
||||
Internet.connect(new URL(checksumURL),
|
||||
(ex) -> LOG.debug("Could not get {} checksum for {}: {}", checksumType,
|
||||
artifactLogName, ex.getMessage()), (input) -> {
|
||||
LOG.debug("Downloading {} checksum for {}", checksumType, artifactLogName);
|
||||
download(input, checksumFile);
|
||||
LOG.debug("Downloaded {} checksum for {}", checksumType, artifactLogName);
|
||||
success.set(true);
|
||||
});
|
||||
(ex) -> LOG.debug("Could not get {} checksum for {}: {}",
|
||||
checksumType,
|
||||
artifactLogName,
|
||||
ex.getMessage()),
|
||||
(input) -> {
|
||||
LOG.debug("Downloading {} checksum for {}", checksumType, artifactLogName);
|
||||
download(input, checksumFile);
|
||||
LOG.debug("Downloaded {} checksum for {}", checksumType, artifactLogName);
|
||||
success.set(true);
|
||||
});
|
||||
if (success.get()) {
|
||||
return getChecksumStatus(file, checksumType, checksumFile);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RawVersion extends Version {
|
||||
public final String versionString;
|
||||
|
||||
public RawVersion(String versionString) {
|
||||
this.versionString = versionString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull Version o) {
|
||||
if (o instanceof RawVersion) {
|
||||
|
||||
@@ -99,8 +99,9 @@ public class GuiToastImpl extends Gui {
|
||||
@Nullable
|
||||
public <T extends IToast> T getToast(Class<? extends T> toastClass, Object type) {
|
||||
for (val toast : this.visible) {
|
||||
if (toast != null && toastClass.isAssignableFrom(toast.getToast().getClass()) &&
|
||||
toast.getToast().getType().equals(type)) {
|
||||
if (toast != null && toastClass.isAssignableFrom(toast.getToast().getClass()) && toast.getToast()
|
||||
.getType()
|
||||
.equals(type)) {
|
||||
return toastClass.cast(toast);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,30 +100,33 @@ public final class UpdateCheckerImpl {
|
||||
continue;
|
||||
}
|
||||
val latest = parsedVersions.get(0).getAsJsonObject();
|
||||
result.add(new ModUpdateInfo(modid, currentVersion, latest.get("version").getAsString(), latest.get("url").getAsString()));
|
||||
result.add(new ModUpdateInfo(modid,
|
||||
currentVersion,
|
||||
latest.get("version").getAsString(),
|
||||
latest.get("url").getAsString()));
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
throw new UpdateCheckException("Failed to check for updates!", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<IChatComponent> updateListToChatMessages(String initiator, List<ModUpdateInfo> updates) {
|
||||
if (updates == null || updates.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
val updateText = new ArrayList<IChatComponent>(
|
||||
FormattedText.parse(I18n.format("falsepatternlib.chat.updatesavailable", initiator)).toChatText());
|
||||
val updateText = new ArrayList<IChatComponent>(FormattedText.parse(I18n.format(
|
||||
"falsepatternlib.chat.updatesavailable",
|
||||
initiator)).toChatText());
|
||||
val mods = Loader.instance().getIndexedModList();
|
||||
for (val update : updates) {
|
||||
val mod = mods.get(update.modID);
|
||||
updateText.addAll(
|
||||
FormattedText.parse(I18n.format("falsepatternlib.chat.modname", mod.getName())).toChatText());
|
||||
updateText.addAll(
|
||||
FormattedText.parse(I18n.format("falsepatternlib.chat.currentversion", update.currentVersion))
|
||||
.toChatText());
|
||||
updateText.addAll(
|
||||
FormattedText.parse(I18n.format("falsepatternlib.chat.latestversion", update.latestVersion))
|
||||
.toChatText());
|
||||
updateText.addAll(FormattedText.parse(I18n.format("falsepatternlib.chat.modname", mod.getName()))
|
||||
.toChatText());
|
||||
updateText.addAll(FormattedText.parse(I18n.format("falsepatternlib.chat.currentversion",
|
||||
update.currentVersion)).toChatText());
|
||||
updateText.addAll(FormattedText.parse(I18n.format("falsepatternlib.chat.latestversion",
|
||||
update.latestVersion)).toChatText());
|
||||
if (!update.updateURL.isEmpty()) {
|
||||
val pre = FormattedText.parse(I18n.format("falsepatternlib.chat.updateurlpre")).toChatText();
|
||||
val link = FormattedText.parse(I18n.format("falsepatternlib.chat.updateurl")).toChatText();
|
||||
@@ -184,7 +187,7 @@ public final class UpdateCheckerImpl {
|
||||
private static CompletableFuture<JsonArray> parseVersionSpecs(JsonArray versions) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
val result = new JsonArray();
|
||||
for (val entry: versions) {
|
||||
for (val entry : versions) {
|
||||
if (!entry.isJsonObject()) {
|
||||
continue;
|
||||
}
|
||||
@@ -238,17 +241,20 @@ public final class UpdateCheckerImpl {
|
||||
val response = new AtomicReference<JsonObject>();
|
||||
val result = new JsonObject();
|
||||
Internet.connect(new URL("https://api.github.com/repos/" + owner + "/" + name + "/releases/latest"),
|
||||
Internet.constructHeaders("Accept", "application/vnd.github+json",
|
||||
"X-GitHub-Api-Version", "2022-11-28"),
|
||||
(e) -> {throw new CompletionException(e);
|
||||
Internet.constructHeaders("Accept",
|
||||
"application/vnd.github+json",
|
||||
"X-GitHub-Api-Version",
|
||||
"2022-11-28"),
|
||||
(e) -> {
|
||||
throw new CompletionException(e);
|
||||
},
|
||||
(stream) -> {
|
||||
val parser = new JsonParser();
|
||||
val json = parser.parse(new InputStreamReader(stream));
|
||||
if (!json.isJsonObject()) {
|
||||
return;
|
||||
}
|
||||
response.set(json.getAsJsonObject());
|
||||
val parser = new JsonParser();
|
||||
val json = parser.parse(new InputStreamReader(stream));
|
||||
if (!json.isJsonObject()) {
|
||||
return;
|
||||
}
|
||||
response.set(json.getAsJsonObject());
|
||||
});
|
||||
if (response.get() == null) {
|
||||
return null;
|
||||
@@ -306,11 +312,10 @@ public final class UpdateCheckerImpl {
|
||||
if (latestVersions.contains(currentVersion)) {
|
||||
continue;
|
||||
}
|
||||
val updateURL = obj.has("updateURL") &&
|
||||
obj.get("updateURL").isJsonPrimitive() &&
|
||||
obj.get("updateURL").getAsJsonPrimitive().isString()
|
||||
? obj.get("updateURL").getAsString()
|
||||
: "";
|
||||
val updateURL = obj.has("updateURL") && obj.get("updateURL").isJsonPrimitive() && obj.get("updateURL")
|
||||
.getAsJsonPrimitive()
|
||||
.isString()
|
||||
? obj.get("updateURL").getAsString() : "";
|
||||
result.add(new ModUpdateInfo(modid, currentVersion, latestVersions.get(0), updateURL));
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -45,6 +45,7 @@ public class MappingManager {
|
||||
private static final Map<String, String> stringPool = new HashMap<>();
|
||||
private static boolean initialized = false;
|
||||
private static final Object MUTEX = new Object();
|
||||
|
||||
@SneakyThrows
|
||||
public static void initialize() {
|
||||
synchronized (MUTEX) {
|
||||
@@ -53,20 +54,23 @@ public class MappingManager {
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
val classMappings = new String(ResourceUtil.getResourceBytesFromJar("/classes.csv", CoreLoadingPlugin.class)).split("\n");
|
||||
val classMappings =
|
||||
new String(ResourceUtil.getResourceBytesFromJar("/classes.csv", CoreLoadingPlugin.class)).split("\n");
|
||||
for (int i = 1; i < classMappings.length; i++) {
|
||||
val line = classMappings[i].split(",");
|
||||
val clazz = new UniversalClass(line, stringPool);
|
||||
internalLookup.unwrap(clazz.internalName, clazz);
|
||||
regularLookup.unwrap(clazz.regularName, clazz);
|
||||
}
|
||||
var fieldMappings = new String(ResourceUtil.getResourceBytesFromJar("/fields.csv", CoreLoadingPlugin.class)).split("\n");
|
||||
var fieldMappings =
|
||||
new String(ResourceUtil.getResourceBytesFromJar("/fields.csv", CoreLoadingPlugin.class)).split("\n");
|
||||
for (int i = 1; i < fieldMappings.length; i++) {
|
||||
val line = fieldMappings[i].split(",");
|
||||
val clazz = internalLookup.get(MappingType.Notch, line[0].substring(0, line[0].lastIndexOf('/')));
|
||||
UniversalField.createAndAddToParent(clazz, line, stringPool);
|
||||
}
|
||||
val methodMappings = new String(ResourceUtil.getResourceBytesFromJar("/methods.csv", CoreLoadingPlugin.class)).split("\n");
|
||||
val methodMappings =
|
||||
new String(ResourceUtil.getResourceBytesFromJar("/methods.csv", CoreLoadingPlugin.class)).split("\n");
|
||||
for (int i = 1; i < methodMappings.length; i++) {
|
||||
val line = methodMappings[i].split(",");
|
||||
val clazz = internalLookup.get(MappingType.Notch, line[0].substring(0, line[0].lastIndexOf('/')));
|
||||
@@ -88,9 +92,14 @@ public class MappingManager {
|
||||
throw new IllegalArgumentException("Invalid enum value " + nameType);
|
||||
}
|
||||
} catch (Lookup.LookupException e) {
|
||||
throw new ClassNotFoundException(
|
||||
"Could not find class \"" + className + "\" with " + nameType.name().toLowerCase() +
|
||||
" name in the " + mappingType.name() + " mapping.");
|
||||
throw new ClassNotFoundException("Could not find class \""
|
||||
+ className
|
||||
+ "\" with "
|
||||
+ nameType.name()
|
||||
.toLowerCase()
|
||||
+ " name in the "
|
||||
+ mappingType.name()
|
||||
+ " mapping.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,8 +125,9 @@ public class MappingManager {
|
||||
return classForName(NameType.Internal, MappingType.MCP, instruction.owner).getField(MappingType.MCP,
|
||||
instruction.name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new ClassNotFoundException("Could not find the class " + instruction.owner +
|
||||
" in the MCP mappings. Are you sure it's a Minecraft class? (we're in dev, cannot use SRG or Notch here).");
|
||||
throw new ClassNotFoundException("Could not find the class "
|
||||
+ instruction.owner
|
||||
+ " in the MCP mappings. Are you sure it's a Minecraft class? (we're in dev, cannot use SRG or Notch here).");
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
@@ -125,11 +135,13 @@ public class MappingManager {
|
||||
instruction.name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
try {
|
||||
return classForName(NameType.Internal, MappingType.Notch, instruction.owner).getField(
|
||||
MappingType.Notch, instruction.name);
|
||||
return classForName(NameType.Internal,
|
||||
MappingType.Notch,
|
||||
instruction.owner).getField(MappingType.Notch, instruction.name);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
throw new ClassNotFoundException("Could not find the class " + instruction.owner +
|
||||
" neither in the SRG nor in the Notch mappings. Are you sure it's a Minecraft class? (we're in obf, cannot use MCP here)");
|
||||
throw new ClassNotFoundException("Could not find the class "
|
||||
+ instruction.owner
|
||||
+ " neither in the SRG nor in the Notch mappings. Are you sure it's a Minecraft class? (we're in obf, cannot use MCP here)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,8 +157,9 @@ public class MappingManager {
|
||||
instruction.name,
|
||||
instruction.desc);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new ClassNotFoundException("Could not find the class " + instruction.owner +
|
||||
" in the MCP mappings. Are you sure it's a Minecraft class? (we're in dev, cannot use SRG or Notch here).");
|
||||
throw new ClassNotFoundException("Could not find the class "
|
||||
+ instruction.owner
|
||||
+ " in the MCP mappings. Are you sure it's a Minecraft class? (we're in dev, cannot use SRG or Notch here).");
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
@@ -155,11 +168,15 @@ public class MappingManager {
|
||||
instruction.desc);
|
||||
} catch (ClassNotFoundException e) {
|
||||
try {
|
||||
return classForName(NameType.Internal, MappingType.Notch, instruction.owner).getMethod(
|
||||
MappingType.Notch, instruction.name, instruction.desc);
|
||||
return classForName(NameType.Internal,
|
||||
MappingType.Notch,
|
||||
instruction.owner).getMethod(MappingType.Notch,
|
||||
instruction.name,
|
||||
instruction.desc);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
throw new ClassNotFoundException("Could not find the class " + instruction.owner +
|
||||
" neither in the SRG nor in the Notch mappings. Are you sure it's a Minecraft class? (we're in obf, cannot use MCP here)");
|
||||
throw new ClassNotFoundException("Could not find the class "
|
||||
+ instruction.owner
|
||||
+ " neither in the SRG nor in the Notch mappings. Are you sure it's a Minecraft class? (we're in obf, cannot use MCP here)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,8 +150,8 @@ public class UniversalMethod {
|
||||
return javaMethodCache;
|
||||
}
|
||||
val parentClass = parent.asJavaClass();
|
||||
javaMethodCache = parentClass.getDeclaredMethod(getName(parent.realClassMapping()), decodeMethodDescriptor(
|
||||
getDescriptor(parent.realClassMapping())));
|
||||
javaMethodCache = parentClass.getDeclaredMethod(getName(parent.realClassMapping()),
|
||||
decodeMethodDescriptor(getDescriptor(parent.realClassMapping())));
|
||||
ReflectionUtil.jailBreak(javaMethodCache);
|
||||
return javaMethodCache;
|
||||
}
|
||||
@@ -175,7 +175,10 @@ public class UniversalMethod {
|
||||
|
||||
@StableAPI.Expose
|
||||
public MethodInsnNode asInstruction(int opcode, MappingType mapping, boolean itf) {
|
||||
return new MethodInsnNode(opcode, parent.getName(NameType.Internal, mapping), getName(mapping),
|
||||
getDescriptor(mapping), itf);
|
||||
return new MethodInsnNode(opcode,
|
||||
parent.getName(NameType.Internal, mapping),
|
||||
getName(mapping),
|
||||
getDescriptor(mapping),
|
||||
itf);
|
||||
}
|
||||
}
|
||||
@@ -43,8 +43,9 @@ public interface IMixin {
|
||||
|
||||
default boolean shouldLoad(List<ITargetedMod> loadedMods) {
|
||||
val side = getSide();
|
||||
return (side == Side.COMMON || side == Side.SERVER && FMLLaunchHandler.side().isServer() ||
|
||||
side == Side.CLIENT && FMLLaunchHandler.side().isClient()) && getFilter().test(loadedMods);
|
||||
return (side == Side.COMMON
|
||||
|| side == Side.SERVER && FMLLaunchHandler.side().isServer()
|
||||
|| side == Side.CLIENT && FMLLaunchHandler.side().isClient()) && getFilter().test(loadedMods);
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
|
||||
@@ -58,10 +58,7 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
static File findJarOf(final ITargetedMod mod) {
|
||||
File result = null;
|
||||
try (val stream = walk(MODS_DIRECTORY_PATH)) {
|
||||
result = stream.filter(mod::isMatchingJar)
|
||||
.map(Path::toFile)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
result = stream.filter(mod::isMatchingJar).map(Path::toFile).findFirst().orElse(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -75,7 +72,8 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
found = path.toFile();
|
||||
break;
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
result = found;
|
||||
}
|
||||
|
||||
@@ -105,21 +105,27 @@ public final class MixinInfo {
|
||||
}
|
||||
|
||||
private static MixinBootstrapperType detect() {
|
||||
if (!isClassPresentSafe("org.spongepowered.asm.launch.MixinBootstrap"))
|
||||
if (!isClassPresentSafe("org.spongepowered.asm.launch.MixinBootstrap")) {
|
||||
return MixinBootstrapperType.None;
|
||||
for (val candidate: MixinInfoCompatCompanion.UNIMIXIN_CANDIDATES) {
|
||||
}
|
||||
for (val candidate : MixinInfoCompatCompanion.UNIMIXIN_CANDIDATES) {
|
||||
if (isClassPresentSafe(candidate)) {
|
||||
return MixinBootstrapperType.UniMixin;
|
||||
}
|
||||
}
|
||||
if (isClassPresentSafe("com.falsepattern.gasstation.GasStation"))
|
||||
if (isClassPresentSafe("com.falsepattern.gasstation.GasStation")) {
|
||||
return MixinBootstrapperType.GasStation;
|
||||
if (isClassPresentSafe("ru.timeconqueror.spongemixins.core.SpongeMixinsCore"))
|
||||
}
|
||||
if (isClassPresentSafe("ru.timeconqueror.spongemixins.core.SpongeMixinsCore")) {
|
||||
return MixinBootstrapperType.SpongeMixins;
|
||||
if (isClassPresentSafe("io.github.crucible.grimoire.Grimoire") || isClassPresentSafe("io.github.crucible.grimoire.common.GrimoireCore"))
|
||||
}
|
||||
if (isClassPresentSafe("io.github.crucible.grimoire.Grimoire") || isClassPresentSafe(
|
||||
"io.github.crucible.grimoire.common.GrimoireCore")) {
|
||||
return MixinBootstrapperType.Grimoire;
|
||||
if (isClassPresentSafe("io.github.tox1cozz.mixinbooterlegacy.MixinBooterLegacyPlugin"))
|
||||
}
|
||||
if (isClassPresentSafe("io.github.tox1cozz.mixinbooterlegacy.MixinBooterLegacyPlugin")) {
|
||||
return MixinBootstrapperType.MixinBooterLegacy;
|
||||
}
|
||||
return MixinBootstrapperType.Other;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,11 @@ public class MixinInfoCompatCompanion {
|
||||
* This is used to determine if a mixin plugin is unimixins. Once MixinInfo is classloaded, this list has no effect.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static final List<String> UNIMIXIN_CANDIDATES = new ArrayList<>(Arrays.asList("io.github.legacymoddingmc.unimixins.compat.CompatCore",
|
||||
"io.github.legacymoddingmc.unimixins.devcompat.DevCompatCore",
|
||||
"io.github.legacymoddingmc.unimixins.all.AllCore",
|
||||
"io.github.legacymoddingmc.unimixins.mixin.MixinModule"));
|
||||
public static final List<String> UNIMIXIN_CANDIDATES = new ArrayList<>(Arrays.asList(
|
||||
"io.github.legacymoddingmc.unimixins.compat.CompatCore",
|
||||
"io.github.legacymoddingmc.unimixins.devcompat.DevCompatCore",
|
||||
"io.github.legacymoddingmc.unimixins.all.AllCore",
|
||||
"io.github.legacymoddingmc.unimixins.mixin.MixinModule"));
|
||||
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
static boolean mixinInfoClassLoaded = false;
|
||||
|
||||
@@ -83,7 +83,8 @@ public class SimpleToast implements IToast {
|
||||
if (hasProgressBar) {
|
||||
val bgWidth = background.getIcon().getIconWidth();
|
||||
Gui.drawRect(3, bgHeight - 4, bgWidth - 3, bgHeight - 3, 0xFFFFFFFF);
|
||||
float f = (float) MathUtil.clampedLerp(displayedProgress, currentProgress,
|
||||
float f = (float) MathUtil.clampedLerp(displayedProgress,
|
||||
currentProgress,
|
||||
(float) (delta - lastDelta) / 100.0F);
|
||||
int i;
|
||||
|
||||
|
||||
@@ -46,7 +46,9 @@ public class ToastBG extends ToastTexture {
|
||||
new ToastBG(new ResourceLocation(Tags.MODID, "textures/gui/toast_narrator.png"), 160, 32, 0xFFAAAA00);
|
||||
@StableAPI.Expose
|
||||
public static final ToastBG TOAST_NARRATOR_ROUNDED =
|
||||
new ToastBG(new ResourceLocation(Tags.MODID, "textures/gui/toast_narrator_rounded.png"), 160, 32,
|
||||
new ToastBG(new ResourceLocation(Tags.MODID, "textures/gui/toast_narrator_rounded.png"),
|
||||
160,
|
||||
32,
|
||||
0xFFAAAA00);
|
||||
@StableAPI.Expose
|
||||
public static final ToastBG TOAST_WHITE =
|
||||
|
||||
@@ -46,8 +46,11 @@ public class ModUpdateInfo {
|
||||
|
||||
@StableAPI.Expose
|
||||
public void log(Logger logger) {
|
||||
logger.info("Updates are available for mod {}: Currently installed version is {}, " +
|
||||
"latest available version is {}. Update URL: {}", modID, currentVersion, latestVersion,
|
||||
logger.info("Updates are available for mod {}: Currently installed version is {}, "
|
||||
+ "latest available version is {}. Update URL: {}",
|
||||
modID,
|
||||
currentVersion,
|
||||
latestVersion,
|
||||
updateURL.isEmpty() ? "unavailable" : updateURL);
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public final class UpdateChecker {
|
||||
* "updateURL": "https://example.com/mods/mymod"
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* <p>
|
||||
* GitHub version entry:
|
||||
* <pre>{@code
|
||||
* {
|
||||
@@ -76,7 +76,7 @@ public final class UpdateChecker {
|
||||
* "repo": "Example/ExampleMod"
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* <p>
|
||||
* The GitHub version entry will automatically fetch the latest release from the specified repository using the GitHub API.
|
||||
*
|
||||
* @param url The URL to check
|
||||
@@ -116,6 +116,7 @@ public final class UpdateChecker {
|
||||
}
|
||||
|
||||
//region deprecated
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use the V2 API instead. This is kept for backwards compatibility.
|
||||
*/
|
||||
|
||||
@@ -603,9 +603,12 @@ public final class MathUtil {
|
||||
f6 = f2;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException(
|
||||
"Something went wrong when converting from HSV to RGB. Input was " + hue + ", " + saturation +
|
||||
", " + value);
|
||||
throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was "
|
||||
+ hue
|
||||
+ ", "
|
||||
+ saturation
|
||||
+ ", "
|
||||
+ value);
|
||||
}
|
||||
|
||||
int j = clamp((int) (f4 * 255.0F), 0, 255);
|
||||
|
||||
@@ -71,6 +71,7 @@ public final class RenderUtil {
|
||||
* @param iconName The icon name
|
||||
* @param width The icon width in pixels
|
||||
* @param height The icon height in pixels
|
||||
*
|
||||
* @return The full resolution texture icon.
|
||||
*/
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
|
||||
@@ -128,8 +128,10 @@ public final class ResourceUtil {
|
||||
}
|
||||
}
|
||||
//Fallback logic
|
||||
System.out.println("Using fallback resource loading logic for " + resourcePath + " with reference to " +
|
||||
referenceClass.getName());
|
||||
System.out.println("Using fallback resource loading logic for "
|
||||
+ resourcePath
|
||||
+ " with reference to "
|
||||
+ referenceClass.getName());
|
||||
return referenceClass.getResourceAsStream(resourcePath);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user