2323 */
2424package com .fox2code .foxloader .patching .dev ;
2525
26+ import com .fox2code .foxloader .launcher .BuildConfig ;
2627import com .fox2code .foxloader .patching .TransformerUtils ;
2728import org .objectweb .asm .ClassReader ;
2829import org .objectweb .asm .Opcodes ;
3536import java .util .jar .JarEntry ;
3637import java .util .jar .JarFile ;
3738
38- public class DevelopmentSourceConstantData {
39+ public final class DevelopmentSourceConstantData {
3940 private static final int STATUS_DISABLED = -1 ;
4041 private static final int STATUS_DEFAULT = 0 ;
4142 private static final int STATUS_DISPLAY_FIRST = 1 ;
4243 private static final int PUBLIC_STATIC_FINAL = Opcodes .ACC_PUBLIC | Opcodes .ACC_STATIC | Opcodes .ACC_FINAL ;
4344 private static final String CoreConstants = "net/minecraft/common/CoreConstants" ;
4445 private static final String ChatColors = "net/minecraft/common/util/ChatColors" ;
46+ private static final String ASMBuildConfig = "com/fox2code/foxloader/launcher/BuildConfig" ;
4547 public final String internalVersion , version , displayVersion ;
4648 private final ConstantCheck [] regular , displayFirst ;
4749 private final ArrayList <ConstantCheck > chatColorsConstantChecks ;
@@ -54,18 +56,20 @@ private DevelopmentSourceConstantData(ClassNode coreConstantsClassNode, ClassNod
5456 CoreConstantCheck internalVersionCheck = new CoreConstantCheck (this .internalVersion , "INTERNAL_VERSION" );
5557 CoreConstantCheck versionCheck = new CoreConstantCheck (this .version , "VERSION" );
5658 CoreConstantCheck displayVersionCheck = new CoreConstantCheck (this .displayVersion , "DISPLAY_VERSION" );
59+ FLConstantCheck flVersionCheck = new FLConstantCheck (BuildConfig .FOXLOADER_DISPLAY , "FOXLOADER_DISPLAY" );
5760 if (Objects .equals (this .version , this .displayVersion )) {
58- this .regular = new ConstantCheck []{versionCheck , internalVersionCheck };
59- this .displayFirst = new ConstantCheck []{displayVersionCheck , internalVersionCheck };
61+ this .regular = new ConstantCheck []{versionCheck , internalVersionCheck , flVersionCheck };
62+ this .displayFirst = new ConstantCheck []{displayVersionCheck , internalVersionCheck , flVersionCheck };
6063 } else {
6164 this .displayFirst = this .regular = new ConstantCheck []{
62- displayVersionCheck , versionCheck , internalVersionCheck };
65+ displayVersionCheck , versionCheck , internalVersionCheck , flVersionCheck };
6366 }
6467 this .chatColorsConstantChecks = new ArrayList <>();
6568 this .constants = new HashSet <>();
6669 this .constants .add (this .internalVersion );
6770 this .constants .add (this .version );
6871 this .constants .add (this .displayVersion );
72+ this .constants .add (BuildConfig .FOXLOADER_DISPLAY );
6973
7074 for (FieldNode fieldNode : chatColorsClassNode .fields ) {
7175 if ((fieldNode .access & PUBLIC_STATIC_FINAL ) == PUBLIC_STATIC_FINAL &&
@@ -217,6 +221,20 @@ public FieldInsnNode makeFieldInsnNode() {
217221 }
218222 }
219223
224+ private static class FLConstantCheck extends ConstantCheck {
225+ private final String fieldName ;
226+
227+ private FLConstantCheck (String value , String fieldName ) {
228+ super (value );
229+ this .fieldName = fieldName ;
230+ }
231+
232+ public FieldInsnNode makeFieldInsnNode () {
233+ return new FieldInsnNode (Opcodes .GETSTATIC ,
234+ ASMBuildConfig , this .fieldName , "Ljava/lang/String;" );
235+ }
236+ }
237+
220238 private static class ColorConstantCheck extends ConstantCheck {
221239 private final String fieldName ;
222240
0 commit comments