1010import i18nupdatemod .entity .GameMetaData ;
1111import i18nupdatemod .util .FileUtil ;
1212import i18nupdatemod .util .Log ;
13+ import org .jetbrains .annotations .NotNull ;
1314
14- import java .io .InputStream ;
15- import java .io .InputStreamReader ;
15+ import java .io .*;
1616import java .nio .file .Files ;
1717import java .nio .file .Path ;
1818import java .nio .file .Paths ;
1919import java .util .ArrayList ;
20+ import java .util .HashSet ;
2021import java .util .List ;
2122import java .util .Objects ;
2223import java .util .stream .Collectors ;
@@ -28,12 +29,15 @@ public class I18nUpdateMod {
2829
2930 public static final Gson GSON = new Gson ();
3031
31- public static void init (Path minecraftPath , String minecraftVersion , String loader ) {
32+ public static void init (Path minecraftPath , String minecraftVersion , String loader , @ NotNull HashSet < String > modDomainsSet ) {
3233 try (InputStream is = I18nUpdateMod .class .getResourceAsStream ("/i18nMetaData.json" )) {
3334 MOD_VERSION = GSON .fromJson (new InputStreamReader (is ), JsonObject .class ).get ("version" ).getAsString ();
3435 } catch (Exception e ) {
3536 Log .warning ("Error getting version: " + e );
3637 }
38+
39+ modDomainsSet .remove ("i18nupdatemod" );
40+
3741 Log .info (String .format ("I18nUpdate Mod %s is loaded in %s with %s" , MOD_VERSION , minecraftVersion , loader ));
3842 Log .debug (String .format ("Minecraft path: %s" , minecraftPath ));
3943 String localStorage = getLocalStoragePos (minecraftPath );
@@ -62,23 +66,19 @@ public static void init(Path minecraftPath, String minecraftVersion, String load
6266
6367 //Update resource pack
6468 List <ResourcePack > languagePacks = new ArrayList <>();
65- boolean convertNotNeed = assets .downloads .size () == 1 && assets .downloads .get (0 ).targetVersion .equals (minecraftVersion );
66- String applyFileName = assets .downloads .get (0 ).fileName ;
6769 for (GameAssetDetail .AssetDownloadDetail it : assets .downloads ) {
6870 FileUtil .setTemporaryDirPath (Paths .get (localStorage , "." + MOD_ID , it .targetVersion ));
69- ResourcePack languagePack = new ResourcePack (it .fileName , convertNotNeed );
71+ ResourcePack languagePack = new ResourcePack (it .fileName );
7072 languagePack .checkUpdate (it .fileUrl , it .md5Url );
7173 languagePacks .add (languagePack );
7274 }
7375
7476 //Convert resourcepack
75- if (!convertNotNeed ) {
76- FileUtil .setTemporaryDirPath (Paths .get (localStorage , "." + MOD_ID , minecraftVersion ));
77- applyFileName = assets .covertFileName ;
78- GameMetaData metaData = I18nConfig .getPackFormat (minecraftVersion );
79- ResourcePackConverter converter = new ResourcePackConverter (languagePacks , applyFileName );
80- converter .convert (metaData , getResourcePackDescription (assets .downloads ));
81- }
77+ FileUtil .setTemporaryDirPath (Paths .get (localStorage , "." + MOD_ID , minecraftVersion ));
78+ String applyFileName = assets .covertFileName ;
79+ GameMetaData metaData = I18nConfig .getPackFormat (minecraftVersion );
80+ ResourcePackConverter converter = new ResourcePackConverter (languagePacks , applyFileName );
81+ converter .convert (metaData , getResourcePackDescription (assets .downloads ), modDomainsSet );
8282
8383 //Apply resource pack
8484 GameConfig config = new GameConfig (minecraftPath .resolve ("options.txt" ));
@@ -123,4 +123,5 @@ public static String getLocalStoragePos(Path minecraftPath) {
123123 Objects ::nonNull
124124 ).findFirst ().orElse (xdgDataHome );
125125 }
126+
126127}
0 commit comments