├── .github
└── workflows
│ ├── beta.yml
│ ├── common.yml
│ ├── pull-request.yml
│ └── release.yml
├── .gitignore
├── LICENSE
├── README.md
├── build.gradle.kts
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle.kts
└── src
└── main
├── java
└── i18nupdatemod
│ ├── I18nUpdateMod.java
│ ├── core
│ ├── GameConfig.java
│ ├── I18nConfig.java
│ ├── ResourcePack.java
│ └── ResourcePackConverter.java
│ ├── entity
│ ├── AssetMetaData.java
│ ├── GameAssetDetail.java
│ ├── GameMetaData.java
│ └── I18nMetaData.java
│ ├── fabricloader
│ └── FabricLoaderMod.java
│ ├── launchwrapper
│ └── LaunchWrapperTweaker.java
│ ├── modlauncher
│ └── ModLauncherService.java
│ └── util
│ ├── AssetUtil.java
│ ├── BsDiffUtil.java
│ ├── DigestUtil.java
│ ├── FileUtil.java
│ ├── Log.java
│ ├── Reflection.java
│ ├── Version.java
│ └── VersionRange.java
└── resources
├── META-INF
└── services
│ └── cpw.mods.modlauncher.api.ITransformationService
├── fabric.mod.json
└── i18nMetaData.json
/.github/workflows/beta.yml:
--------------------------------------------------------------------------------
1 | name: Beta
2 | on:
3 | push:
4 | branches:
5 | - 'main'
6 |
7 | jobs:
8 | build-beta:
9 | name: Build Beta
10 | uses: ./.github/workflows/common.yml
11 | with:
12 | type: Beta
13 | secrets: inherit
--------------------------------------------------------------------------------
/.github/workflows/common.yml:
--------------------------------------------------------------------------------
1 | name: Common
2 | on:
3 | workflow_call:
4 | inputs:
5 | type:
6 | required: true
7 | type: string
8 | is-snapshot:
9 | required: false
10 | type: boolean
11 | default: true
12 | change-log:
13 | required: false
14 | type: string
15 |
16 | jobs:
17 | build-common:
18 | name: Build Common
19 | runs-on: ubuntu-latest
20 | environment: Build
21 | steps:
22 | -
23 | name: Checkout
24 | uses: actions/checkout@v4
25 | -
26 | name: Set up JDK
27 | uses: actions/setup-java@v4
28 | with:
29 | distribution: 'oracle'
30 | java-version: '21'
31 | cache: 'gradle'
32 | -
33 | name: Build
34 | env:
35 | IS_SNAPSHOT: ${{ inputs.is-snapshot }}
36 | run: |
37 | ./gradlew clean shadowJar --info --stacktrace
38 | -
39 | name: Publish Modrinth
40 | if: ${{ !inputs.is-snapshot }}
41 | env:
42 | IS_SNAPSHOT: ${{ inputs.is-snapshot }}
43 | CHANGE_LOG: ${{ inputs.change-log }}
44 | MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
45 | run: |
46 | ./gradlew modrinth modrinthSyncBody --info --stacktrace
47 | -
48 | name: Publish CurseForge
49 | if: ${{ !inputs.is-snapshot }}
50 | env:
51 | IS_SNAPSHOT: ${{ inputs.is-snapshot }}
52 | CHANGE_LOG: ${{ inputs.change-log }}
53 | CURSE_TOKEN: ${{ secrets.CURSE_TOKEN }}
54 | run: |
55 | ./gradlew curseforge --info --stacktrace
56 | -
57 | uses: actions/upload-artifact@v4
58 | with:
59 | name: I18nUpdateMod-${{ inputs.type }}-${{ github.run_number }}
60 | path: build/libs
--------------------------------------------------------------------------------
/.github/workflows/pull-request.yml:
--------------------------------------------------------------------------------
1 | name: Pull Request
2 | on:
3 | pull_request:
4 | types:
5 | - opened
6 | - synchronize
7 | - reopened
8 | branches:
9 | - 'main'
10 |
11 | jobs:
12 | build-pull-request:
13 | name: Build Pull Request
14 | uses: ./.github/workflows/common.yml
15 | with:
16 | type: PullRequest
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 | on:
3 | release:
4 | types: [published]
5 |
6 | jobs:
7 | build-release:
8 | name: Build Release
9 | uses: ./.github/workflows/common.yml
10 | with:
11 | type: Release
12 | is-snapshot: false
13 | change-log: ${{ github.event.release.body }}
14 | secrets: inherit
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | build/
3 | !gradle/wrapper/gradle-wrapper.jar
4 | !**/src/main/**/build/
5 | !**/src/test/**/build/
6 |
7 | ### IntelliJ IDEA ###
8 | .idea
9 | *.iws
10 | *.iml
11 | *.ipr
12 | out/
13 | !**/src/main/**/out/
14 | !**/src/test/**/out/
15 |
16 | ### Eclipse ###
17 | .apt_generated
18 | .classpath
19 | .factorypath
20 | .project
21 | .settings
22 | .springBeans
23 | .sts4-cache
24 | bin/
25 | !**/src/main/**/bin/
26 | !**/src/test/**/bin/
27 |
28 | ### NetBeans ###
29 | /nbproject/private/
30 | /nbbuild/
31 | /dist/
32 | /nbdist/
33 | /.nb-gradle/
34 |
35 | ### VS Code ###
36 | .vscode/
37 |
38 | ### Mac OS ###
39 | .DS_Store
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for
11 | software and other kinds of works, specifically designed to ensure
12 | cooperation with the community in the case of network server software.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | our General Public Licenses are intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users.
19 |
20 | When we speak of free software, we are referring to freedom, not
21 | price. Our General Public Licenses are designed to make sure that you
22 | have the freedom to distribute copies of free software (and charge for
23 | them if you wish), that you receive source code or can get it if you
24 | want it, that you can change the software or use pieces of it in new
25 | free programs, and that you know you can do these things.
26 |
27 | Developers that use our General Public Licenses protect your rights
28 | with two steps: (1) assert copyright on the software, and (2) offer
29 | you this License which gives you legal permission to copy, distribute
30 | and/or modify the software.
31 |
32 | A secondary benefit of defending all users' freedom is that
33 | improvements made in alternate versions of the program, if they
34 | receive widespread use, become available for other developers to
35 | incorporate. Many developers of free software are heartened and
36 | encouraged by the resulting cooperation. However, in the case of
37 | software used on network servers, this result may fail to come about.
38 | The GNU General Public License permits making a modified version and
39 | letting the public access it on a server without ever releasing its
40 | source code to the public.
41 |
42 | The GNU Affero General Public License is designed specifically to
43 | ensure that, in such cases, the modified source code becomes available
44 | to the community. It requires the operator of a network server to
45 | provide the source code of the modified version running there to the
46 | users of that server. Therefore, public use of a modified version, on
47 | a publicly accessible server, gives the public access to the source
48 | code of the modified version.
49 |
50 | An older license, called the Affero General Public License and
51 | published by Affero, was designed to accomplish similar goals. This is
52 | a different license, not a version of the Affero GPL, but Affero has
53 | released a new version of the Affero GPL which permits relicensing under
54 | this license.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | TERMS AND CONDITIONS
60 |
61 | 0. Definitions.
62 |
63 | "This License" refers to version 3 of the GNU Affero General Public License.
64 |
65 | "Copyright" also means copyright-like laws that apply to other kinds of
66 | works, such as semiconductor masks.
67 |
68 | "The Program" refers to any copyrightable work licensed under this
69 | License. Each licensee is addressed as "you". "Licensees" and
70 | "recipients" may be individuals or organizations.
71 |
72 | To "modify" a work means to copy from or adapt all or part of the work
73 | in a fashion requiring copyright permission, other than the making of an
74 | exact copy. The resulting work is called a "modified version" of the
75 | earlier work or a work "based on" the earlier work.
76 |
77 | A "covered work" means either the unmodified Program or a work based
78 | on the Program.
79 |
80 | To "propagate" a work means to do anything with it that, without
81 | permission, would make you directly or secondarily liable for
82 | infringement under applicable copyright law, except executing it on a
83 | computer or modifying a private copy. Propagation includes copying,
84 | distribution (with or without modification), making available to the
85 | public, and in some countries other activities as well.
86 |
87 | To "convey" a work means any kind of propagation that enables other
88 | parties to make or receive copies. Mere interaction with a user through
89 | a computer network, with no transfer of a copy, is not conveying.
90 |
91 | An interactive user interface displays "Appropriate Legal Notices"
92 | to the extent that it includes a convenient and prominently visible
93 | feature that (1) displays an appropriate copyright notice, and (2)
94 | tells the user that there is no warranty for the work (except to the
95 | extent that warranties are provided), that licensees may convey the
96 | work under this License, and how to view a copy of this License. If
97 | the interface presents a list of user commands or options, such as a
98 | menu, a prominent item in the list meets this criterion.
99 |
100 | 1. Source Code.
101 |
102 | The "source code" for a work means the preferred form of the work
103 | for making modifications to it. "Object code" means any non-source
104 | form of a work.
105 |
106 | A "Standard Interface" means an interface that either is an official
107 | standard defined by a recognized standards body, or, in the case of
108 | interfaces specified for a particular programming language, one that
109 | is widely used among developers working in that language.
110 |
111 | The "System Libraries" of an executable work include anything, other
112 | than the work as a whole, that (a) is included in the normal form of
113 | packaging a Major Component, but which is not part of that Major
114 | Component, and (b) serves only to enable use of the work with that
115 | Major Component, or to implement a Standard Interface for which an
116 | implementation is available to the public in source code form. A
117 | "Major Component", in this context, means a major essential component
118 | (kernel, window system, and so on) of the specific operating system
119 | (if any) on which the executable work runs, or a compiler used to
120 | produce the work, or an object code interpreter used to run it.
121 |
122 | The "Corresponding Source" for a work in object code form means all
123 | the source code needed to generate, install, and (for an executable
124 | work) run the object code and to modify the work, including scripts to
125 | control those activities. However, it does not include the work's
126 | System Libraries, or general-purpose tools or generally available free
127 | programs which are used unmodified in performing those activities but
128 | which are not part of the work. For example, Corresponding Source
129 | includes interface definition files associated with source files for
130 | the work, and the source code for shared libraries and dynamically
131 | linked subprograms that the work is specifically designed to require,
132 | such as by intimate data communication or control flow between those
133 | subprograms and other parts of the work.
134 |
135 | The Corresponding Source need not include anything that users
136 | can regenerate automatically from other parts of the Corresponding
137 | Source.
138 |
139 | The Corresponding Source for a work in source code form is that
140 | same work.
141 |
142 | 2. Basic Permissions.
143 |
144 | All rights granted under this License are granted for the term of
145 | copyright on the Program, and are irrevocable provided the stated
146 | conditions are met. This License explicitly affirms your unlimited
147 | permission to run the unmodified Program. The output from running a
148 | covered work is covered by this License only if the output, given its
149 | content, constitutes a covered work. This License acknowledges your
150 | rights of fair use or other equivalent, as provided by copyright law.
151 |
152 | You may make, run and propagate covered works that you do not
153 | convey, without conditions so long as your license otherwise remains
154 | in force. You may convey covered works to others for the sole purpose
155 | of having them make modifications exclusively for you, or provide you
156 | with facilities for running those works, provided that you comply with
157 | the terms of this License in conveying all material for which you do
158 | not control copyright. Those thus making or running the covered works
159 | for you must do so exclusively on your behalf, under your direction
160 | and control, on terms that prohibit them from making any copies of
161 | your copyrighted material outside their relationship with you.
162 |
163 | Conveying under any other circumstances is permitted solely under
164 | the conditions stated below. Sublicensing is not allowed; section 10
165 | makes it unnecessary.
166 |
167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168 |
169 | No covered work shall be deemed part of an effective technological
170 | measure under any applicable law fulfilling obligations under article
171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 | similar laws prohibiting or restricting circumvention of such
173 | measures.
174 |
175 | When you convey a covered work, you waive any legal power to forbid
176 | circumvention of technological measures to the extent such circumvention
177 | is effected by exercising rights under this License with respect to
178 | the covered work, and you disclaim any intention to limit operation or
179 | modification of the work as a means of enforcing, against the work's
180 | users, your or third parties' legal rights to forbid circumvention of
181 | technological measures.
182 |
183 | 4. Conveying Verbatim Copies.
184 |
185 | You may convey verbatim copies of the Program's source code as you
186 | receive it, in any medium, provided that you conspicuously and
187 | appropriately publish on each copy an appropriate copyright notice;
188 | keep intact all notices stating that this License and any
189 | non-permissive terms added in accord with section 7 apply to the code;
190 | keep intact all notices of the absence of any warranty; and give all
191 | recipients a copy of this License along with the Program.
192 |
193 | You may charge any price or no price for each copy that you convey,
194 | and you may offer support or warranty protection for a fee.
195 |
196 | 5. Conveying Modified Source Versions.
197 |
198 | You may convey a work based on the Program, or the modifications to
199 | produce it from the Program, in the form of source code under the
200 | terms of section 4, provided that you also meet all of these conditions:
201 |
202 | a) The work must carry prominent notices stating that you modified
203 | it, and giving a relevant date.
204 |
205 | b) The work must carry prominent notices stating that it is
206 | released under this License and any conditions added under section
207 | 7. This requirement modifies the requirement in section 4 to
208 | "keep intact all notices".
209 |
210 | c) You must license the entire work, as a whole, under this
211 | License to anyone who comes into possession of a copy. This
212 | License will therefore apply, along with any applicable section 7
213 | additional terms, to the whole of the work, and all its parts,
214 | regardless of how they are packaged. This License gives no
215 | permission to license the work in any other way, but it does not
216 | invalidate such permission if you have separately received it.
217 |
218 | d) If the work has interactive user interfaces, each must display
219 | Appropriate Legal Notices; however, if the Program has interactive
220 | interfaces that do not display Appropriate Legal Notices, your
221 | work need not make them do so.
222 |
223 | A compilation of a covered work with other separate and independent
224 | works, which are not by their nature extensions of the covered work,
225 | and which are not combined with it such as to form a larger program,
226 | in or on a volume of a storage or distribution medium, is called an
227 | "aggregate" if the compilation and its resulting copyright are not
228 | used to limit the access or legal rights of the compilation's users
229 | beyond what the individual works permit. Inclusion of a covered work
230 | in an aggregate does not cause this License to apply to the other
231 | parts of the aggregate.
232 |
233 | 6. Conveying Non-Source Forms.
234 |
235 | You may convey a covered work in object code form under the terms
236 | of sections 4 and 5, provided that you also convey the
237 | machine-readable Corresponding Source under the terms of this License,
238 | in one of these ways:
239 |
240 | a) Convey the object code in, or embodied in, a physical product
241 | (including a physical distribution medium), accompanied by the
242 | Corresponding Source fixed on a durable physical medium
243 | customarily used for software interchange.
244 |
245 | b) Convey the object code in, or embodied in, a physical product
246 | (including a physical distribution medium), accompanied by a
247 | written offer, valid for at least three years and valid for as
248 | long as you offer spare parts or customer support for that product
249 | model, to give anyone who possesses the object code either (1) a
250 | copy of the Corresponding Source for all the software in the
251 | product that is covered by this License, on a durable physical
252 | medium customarily used for software interchange, for a price no
253 | more than your reasonable cost of physically performing this
254 | conveying of source, or (2) access to copy the
255 | Corresponding Source from a network server at no charge.
256 |
257 | c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 |
263 | d) Convey the object code by offering access from a designated
264 | place (gratis or for a charge), and offer equivalent access to the
265 | Corresponding Source in the same way through the same place at no
266 | further charge. You need not require recipients to copy the
267 | Corresponding Source along with the object code. If the place to
268 | copy the object code is a network server, the Corresponding Source
269 | may be on a different server (operated by you or a third party)
270 | that supports equivalent copying facilities, provided you maintain
271 | clear directions next to the object code saying where to find the
272 | Corresponding Source. Regardless of what server hosts the
273 | Corresponding Source, you remain obligated to ensure that it is
274 | available for as long as needed to satisfy these requirements.
275 |
276 | e) Convey the object code using peer-to-peer transmission, provided
277 | you inform other peers where the object code and Corresponding
278 | Source of the work are being offered to the general public at no
279 | charge under subsection 6d.
280 |
281 | A separable portion of the object code, whose source code is excluded
282 | from the Corresponding Source as a System Library, need not be
283 | included in conveying the object code work.
284 |
285 | A "User Product" is either (1) a "consumer product", which means any
286 | tangible personal property which is normally used for personal, family,
287 | or household purposes, or (2) anything designed or sold for incorporation
288 | into a dwelling. In determining whether a product is a consumer product,
289 | doubtful cases shall be resolved in favor of coverage. For a particular
290 | product received by a particular user, "normally used" refers to a
291 | typical or common use of that class of product, regardless of the status
292 | of the particular user or of the way in which the particular user
293 | actually uses, or expects or is expected to use, the product. A product
294 | is a consumer product regardless of whether the product has substantial
295 | commercial, industrial or non-consumer uses, unless such uses represent
296 | the only significant mode of use of the product.
297 |
298 | "Installation Information" for a User Product means any methods,
299 | procedures, authorization keys, or other information required to install
300 | and execute modified versions of a covered work in that User Product from
301 | a modified version of its Corresponding Source. The information must
302 | suffice to ensure that the continued functioning of the modified object
303 | code is in no case prevented or interfered with solely because
304 | modification has been made.
305 |
306 | If you convey an object code work under this section in, or with, or
307 | specifically for use in, a User Product, and the conveying occurs as
308 | part of a transaction in which the right of possession and use of the
309 | User Product is transferred to the recipient in perpetuity or for a
310 | fixed term (regardless of how the transaction is characterized), the
311 | Corresponding Source conveyed under this section must be accompanied
312 | by the Installation Information. But this requirement does not apply
313 | if neither you nor any third party retains the ability to install
314 | modified object code on the User Product (for example, the work has
315 | been installed in ROM).
316 |
317 | The requirement to provide Installation Information does not include a
318 | requirement to continue to provide support service, warranty, or updates
319 | for a work that has been modified or installed by the recipient, or for
320 | the User Product in which it has been modified or installed. Access to a
321 | network may be denied when the modification itself materially and
322 | adversely affects the operation of the network or violates the rules and
323 | protocols for communication across the network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders of
351 | that material) supplement the terms of this License with terms:
352 |
353 | a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 |
356 | b) Requiring preservation of specified reasonable legal notices or
357 | author attributions in that material or in the Appropriate Legal
358 | Notices displayed by works containing it; or
359 |
360 | c) Prohibiting misrepresentation of the origin of that material, or
361 | requiring that modified versions of such material be marked in
362 | reasonable ways as different from the original version; or
363 |
364 | d) Limiting the use for publicity purposes of names of licensors or
365 | authors of the material; or
366 |
367 | e) Declining to grant rights under trademark law for use of some
368 | trade names, trademarks, or service marks; or
369 |
370 | f) Requiring indemnification of licensors and authors of that
371 | material by anyone who conveys the material (or modified versions of
372 | it) with contractual assumptions of liability to the recipient, for
373 | any liability that these contractual assumptions directly impose on
374 | those licensors and authors.
375 |
376 | All other non-permissive additional terms are considered "further
377 | restrictions" within the meaning of section 10. If the Program as you
378 | received it, or any part of it, contains a notice stating that it is
379 | governed by this License along with a term that is a further
380 | restriction, you may remove that term. If a license document contains
381 | a further restriction but permits relicensing or conveying under this
382 | License, you may add to a covered work material governed by the terms
383 | of that license document, provided that the further restriction does
384 | not survive such relicensing or conveying.
385 |
386 | If you add terms to a covered work in accord with this section, you
387 | must place, in the relevant source files, a statement of the
388 | additional terms that apply to those files, or a notice indicating
389 | where to find the applicable terms.
390 |
391 | Additional terms, permissive or non-permissive, may be stated in the
392 | form of a separately written license, or stated as exceptions;
393 | the above requirements apply either way.
394 |
395 | 8. Termination.
396 |
397 | You may not propagate or modify a covered work except as expressly
398 | provided under this License. Any attempt otherwise to propagate or
399 | modify it is void, and will automatically terminate your rights under
400 | this License (including any patent licenses granted under the third
401 | paragraph of section 11).
402 |
403 | However, if you cease all violation of this License, then your
404 | license from a particular copyright holder is reinstated (a)
405 | provisionally, unless and until the copyright holder explicitly and
406 | finally terminates your license, and (b) permanently, if the copyright
407 | holder fails to notify you of the violation by some reasonable means
408 | prior to 60 days after the cessation.
409 |
410 | Moreover, your license from a particular copyright holder is
411 | reinstated permanently if the copyright holder notifies you of the
412 | violation by some reasonable means, this is the first time you have
413 | received notice of violation of this License (for any work) from that
414 | copyright holder, and you cure the violation prior to 30 days after
415 | your receipt of the notice.
416 |
417 | Termination of your rights under this section does not terminate the
418 | licenses of parties who have received copies or rights from you under
419 | this License. If your rights have been terminated and not permanently
420 | reinstated, you do not qualify to receive new licenses for the same
421 | material under section 10.
422 |
423 | 9. Acceptance Not Required for Having Copies.
424 |
425 | You are not required to accept this License in order to receive or
426 | run a copy of the Program. Ancillary propagation of a covered work
427 | occurring solely as a consequence of using peer-to-peer transmission
428 | to receive a copy likewise does not require acceptance. However,
429 | nothing other than this License grants you permission to propagate or
430 | modify any covered work. These actions infringe copyright if you do
431 | not accept this License. Therefore, by modifying or propagating a
432 | covered work, you indicate your acceptance of this License to do so.
433 |
434 | 10. Automatic Licensing of Downstream Recipients.
435 |
436 | Each time you convey a covered work, the recipient automatically
437 | receives a license from the original licensors, to run, modify and
438 | propagate that work, subject to this License. You are not responsible
439 | for enforcing compliance by third parties with this License.
440 |
441 | An "entity transaction" is a transaction transferring control of an
442 | organization, or substantially all assets of one, or subdividing an
443 | organization, or merging organizations. If propagation of a covered
444 | work results from an entity transaction, each party to that
445 | transaction who receives a copy of the work also receives whatever
446 | licenses to the work the party's predecessor in interest had or could
447 | give under the previous paragraph, plus a right to possession of the
448 | Corresponding Source of the work from the predecessor in interest, if
449 | the predecessor has it or can get it with reasonable efforts.
450 |
451 | You may not impose any further restrictions on the exercise of the
452 | rights granted or affirmed under this License. For example, you may
453 | not impose a license fee, royalty, or other charge for exercise of
454 | rights granted under this License, and you may not initiate litigation
455 | (including a cross-claim or counterclaim in a lawsuit) alleging that
456 | any patent claim is infringed by making, using, selling, offering for
457 | sale, or importing the Program or any portion of it.
458 |
459 | 11. Patents.
460 |
461 | A "contributor" is a copyright holder who authorizes use under this
462 | License of the Program or a work on which the Program is based. The
463 | work thus licensed is called the contributor's "contributor version".
464 |
465 | A contributor's "essential patent claims" are all patent claims
466 | owned or controlled by the contributor, whether already acquired or
467 | hereafter acquired, that would be infringed by some manner, permitted
468 | by this License, of making, using, or selling its contributor version,
469 | but do not include claims that would be infringed only as a
470 | consequence of further modification of the contributor version. For
471 | purposes of this definition, "control" includes the right to grant
472 | patent sublicenses in a manner consistent with the requirements of
473 | this License.
474 |
475 | Each contributor grants you a non-exclusive, worldwide, royalty-free
476 | patent license under the contributor's essential patent claims, to
477 | make, use, sell, offer for sale, import and otherwise run, modify and
478 | propagate the contents of its contributor version.
479 |
480 | In the following three paragraphs, a "patent license" is any express
481 | agreement or commitment, however denominated, not to enforce a patent
482 | (such as an express permission to practice a patent or covenant not to
483 | sue for patent infringement). To "grant" such a patent license to a
484 | party means to make such an agreement or commitment not to enforce a
485 | patent against the party.
486 |
487 | If you convey a covered work, knowingly relying on a patent license,
488 | and the Corresponding Source of the work is not available for anyone
489 | to copy, free of charge and under the terms of this License, through a
490 | publicly available network server or other readily accessible means,
491 | then you must either (1) cause the Corresponding Source to be so
492 | available, or (2) arrange to deprive yourself of the benefit of the
493 | patent license for this particular work, or (3) arrange, in a manner
494 | consistent with the requirements of this License, to extend the patent
495 | license to downstream recipients. "Knowingly relying" means you have
496 | actual knowledge that, but for the patent license, your conveying the
497 | covered work in a country, or your recipient's use of the covered work
498 | in a country, would infringe one or more identifiable patents in that
499 | country that you have reason to believe are valid.
500 |
501 | If, pursuant to or in connection with a single transaction or
502 | arrangement, you convey, or propagate by procuring conveyance of, a
503 | covered work, and grant a patent license to some of the parties
504 | receiving the covered work authorizing them to use, propagate, modify
505 | or convey a specific copy of the covered work, then the patent license
506 | you grant is automatically extended to all recipients of the covered
507 | work and works based on it.
508 |
509 | A patent license is "discriminatory" if it does not include within
510 | the scope of its coverage, prohibits the exercise of, or is
511 | conditioned on the non-exercise of one or more of the rights that are
512 | specifically granted under this License. You may not convey a covered
513 | work if you are a party to an arrangement with a third party that is
514 | in the business of distributing software, under which you make payment
515 | to the third party based on the extent of your activity of conveying
516 | the work, and under which the third party grants, to any of the
517 | parties who would receive the covered work from you, a discriminatory
518 | patent license (a) in connection with copies of the covered work
519 | conveyed by you (or copies made from those copies), or (b) primarily
520 | for and in connection with specific products or compilations that
521 | contain the covered work, unless you entered into that arrangement,
522 | or that patent license was granted, prior to 28 March 2007.
523 |
524 | Nothing in this License shall be construed as excluding or limiting
525 | any implied license or other defenses to infringement that may
526 | otherwise be available to you under applicable patent law.
527 |
528 | 12. No Surrender of Others' Freedom.
529 |
530 | If conditions are imposed on you (whether by court order, agreement or
531 | otherwise) that contradict the conditions of this License, they do not
532 | excuse you from the conditions of this License. If you cannot convey a
533 | covered work so as to satisfy simultaneously your obligations under this
534 | License and any other pertinent obligations, then as a consequence you may
535 | not convey it at all. For example, if you agree to terms that obligate you
536 | to collect a royalty for further conveying from those to whom you convey
537 | the Program, the only way you could satisfy both those terms and this
538 | License would be to refrain entirely from conveying the Program.
539 |
540 | 13. Remote Network Interaction; Use with the GNU General Public License.
541 |
542 | Notwithstanding any other provision of this License, if you modify the
543 | Program, your modified version must prominently offer all users
544 | interacting with it remotely through a computer network (if your version
545 | supports such interaction) an opportunity to receive the Corresponding
546 | Source of your version by providing access to the Corresponding Source
547 | from a network server at no charge, through some standard or customary
548 | means of facilitating copying of software. This Corresponding Source
549 | shall include the Corresponding Source for any work covered by version 3
550 | of the GNU General Public License that is incorporated pursuant to the
551 | following paragraph.
552 |
553 | Notwithstanding any other provision of this License, you have
554 | permission to link or combine any covered work with a work licensed
555 | under version 3 of the GNU General Public License into a single
556 | combined work, and to convey the resulting work. The terms of this
557 | License will continue to apply to the part which is the covered work,
558 | but the work with which it is combined will remain governed by version
559 | 3 of the GNU General Public License.
560 |
561 | 14. Revised Versions of this License.
562 |
563 | The Free Software Foundation may publish revised and/or new versions of
564 | the GNU Affero General Public License from time to time. Such new versions
565 | will be similar in spirit to the present version, but may differ in detail to
566 | address new problems or concerns.
567 |
568 | Each version is given a distinguishing version number. If the
569 | Program specifies that a certain numbered version of the GNU Affero General
570 | Public License "or any later version" applies to it, you have the
571 | option of following the terms and conditions either of that numbered
572 | version or of any later version published by the Free Software
573 | Foundation. If the Program does not specify a version number of the
574 | GNU Affero General Public License, you may choose any version ever published
575 | by the Free Software Foundation.
576 |
577 | If the Program specifies that a proxy can decide which future
578 | versions of the GNU Affero General Public License can be used, that proxy's
579 | public statement of acceptance of a version permanently authorizes you
580 | to choose that version for the Program.
581 |
582 | Later license versions may give you additional or different
583 | permissions. However, no additional obligations are imposed on any
584 | author or copyright holder as a result of your choosing to follow a
585 | later version.
586 |
587 | 15. Disclaimer of Warranty.
588 |
589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597 |
598 | 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 | SUCH DAMAGES.
609 |
610 | 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 | How to Apply These Terms to Your New Programs
622 |
623 | If you develop a new program, and you want it to be of the greatest
624 | possible use to the public, the best way to achieve this is to make it
625 | free software which everyone can redistribute and change under these terms.
626 |
627 | To do so, attach the following notices to the program. It is safest
628 | to attach them to the start of each source file to most effectively
629 | state the exclusion of warranty; and each file should have at least
630 | the "copyright" line and a pointer to where the full notice is found.
631 |
632 |
633 | Copyright (C)
634 |
635 | This program is free software: you can redistribute it and/or modify
636 | it under the terms of the GNU Affero General Public License as published
637 | by the Free Software Foundation, either version 3 of the License, or
638 | (at your option) any later version.
639 |
640 | This program is distributed in the hope that it will be useful,
641 | but WITHOUT ANY WARRANTY; without even the implied warranty of
642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 | GNU Affero General Public License for more details.
644 |
645 | You should have received a copy of the GNU Affero General Public License
646 | along with this program. If not, see .
647 |
648 | Also add information on how to contact you by electronic and paper mail.
649 |
650 | If your software can interact with users remotely through a computer
651 | network, you should also make sure that it provides a way for users to
652 | get its source. For example, if your program is a web application, its
653 | interface could display a "Source" link that leads users to an archive
654 | of the code. There are many ways you could offer source, and different
655 | solutions will be better for different programs; see section 13 for the
656 | specific requirements.
657 |
658 | You should also get your employer (if you work as a programmer) or school,
659 | if any, to sign a "copyright disclaimer" for the program, if necessary.
660 | For more information on this, and how to apply and follow the GNU AGPL, see
661 | .
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 自动汉化更新模组Ⅲ
2 |
3 | [](https://github.com/CFPAOrg/I18nUpdateMod3/tags)
4 | [](https://www.curseforge.com/minecraft/mc-mods/i18nupdatemod)
5 | [](https://modrinth.com/mod/i18nupdatemod)
6 | [](https://github.com/CFPAOrg/I18nUpdateMod3/blob/main/LICENSE)
7 | [](https://github.com/CFPAOrg/I18nUpdateMod3/actions)
8 | [](https://github.com/CFPAOrg/I18nUpdateMod3/stargazers)
9 |
10 | [](https://github.com/CFPAOrg/I18nUpdateMod3)
11 |
12 | 更现代的自动汉化更新模组。
13 |
14 | 「[简体中文资源包(Minecraft Mod Language Package)](https://github.com/CFPAOrg/Minecraft-Mod-Language-Package)」是由「[CFPAOrg](http://cfpa.team/)」团队维护的「自动汉化资源包」,可以将一些Mod中的文本翻译为中文。
15 | 本Mod用于自动下载、更新、应用「简体中文资源包」。
16 |
17 | ## 下载
18 |
19 | - [CurseForge](https://www.curseforge.com/minecraft/mc-mods/i18nupdatemod)
20 | - [Modrinth](https://modrinth.com/mod/i18nupdatemod)
21 |
22 | ## 支持的版本
23 |
24 | - Minecraft:1.6.1~1.21.5 都支持
25 | - Mod加载器:MinecraftForge、NeoForge、Fabric、Quilt 都支持
26 | - Java:8~21 都支持
27 |
28 | 仅仅需要在mods文件夹中放置本Mod的jar文件即可,Mod本身与各主流Minecraft版本、Mod Loader、Java版本均兼容,Mod本身不需要进行任何版本隔离。
29 |
30 | ## 支持的「简体中文资源包」
31 |
32 | 为了尽可能实用,目前本Mod会根据游戏版本自动下载、合并、转换「简体中文资源包」。
33 |
34 | - 官方资源:1.10.2、1.12.2、1.16、1.18、1.19、1.20、1.21
35 | - 合并转换:会合并加转换最近版本的一些资源包,尽可能做最大化的支持
36 | - 特别说明:1.13开始将语言文件变化为json格式,所以不能将1.12.2的资源包用于1.13以上,反之同理
37 |
38 | ## 开发环境
39 |
40 | 请使用Java 8及以上的JDK构建。
41 | ```shell
42 | gradle clean shadowJar
43 | ```
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("java")
3 | id("com.github.johnrengelman.shadow") version "8.1.1"
4 | id("com.modrinth.minotaur") version "2.8.4"
5 | id("io.github.CDAGaming.cursegradle") version "1.6.1"
6 | }
7 |
8 | group = "i18nupdatemod"
9 | version = project.properties["version"].toString() + if ("false" == System.getenv("IS_SNAPSHOT")) "" else "-SNAPSHOT"
10 |
11 | java {
12 | sourceCompatibility = JavaVersion.VERSION_1_8
13 | targetCompatibility = JavaVersion.VERSION_1_8
14 | }
15 |
16 | tasks.shadowJar {
17 | manifest {
18 | attributes(
19 | "TweakClass" to "i18nupdatemod.launchwrapper.LaunchWrapperTweaker",
20 | "TweakOrder" to 33,
21 | "Automatic-Module-Name" to "i18nupdatemod",
22 | )
23 | }
24 | minimize()
25 | archiveBaseName.set("I18nUpdateMod")
26 | relocate("com.google.archivepatcher", "include.com.google.archivepatcher")
27 | dependencies {
28 | include(dependency("net.runelite.archive-patcher:archive-patcher-applier:.*"))
29 | }
30 | exclude("LICENSE")
31 | }
32 |
33 | repositories {
34 | mavenCentral()
35 | maven("https://libraries.minecraft.net/")
36 | maven("https://maven.fabricmc.net/")
37 | maven("https://files.minecraftforge.net/maven")
38 | maven("https://repo.runelite.net/")
39 | }
40 |
41 | configurations.configureEach {
42 | isTransitive = false
43 | }
44 |
45 | dependencies {
46 | testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.3")
47 | testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.3")
48 | implementation("net.runelite.archive-patcher:archive-patcher-applier:1.2")
49 | compileOnly("org.jetbrains:annotations:24.1.0")
50 |
51 | implementation("net.fabricmc:fabric-loader:0.15.9")
52 | implementation("cpw.mods:modlauncher:8.1.3")
53 | implementation("net.minecraft:launchwrapper:1.12")
54 |
55 | implementation("commons-io:commons-io:2.16.1")
56 | implementation("org.ow2.asm:asm:9.7")
57 | implementation("com.google.code.gson:gson:2.11.0")
58 |
59 | }
60 |
61 | tasks.test {
62 | useJUnitPlatform()
63 | }
64 |
65 | tasks.processResources {
66 | filesMatching("**") {
67 | expand(
68 | "version" to project.version,
69 | )
70 | }
71 | }
72 |
73 | val supportMinecraftVersions = project.properties["minecraft"].toString().split(",")
74 |
75 | modrinth {
76 | token.set(System.getenv("MODRINTH_TOKEN"))
77 | projectId.set("PWERr14M")
78 | versionNumber.set("${project.version}")
79 | versionName.set("I18nUpdateMod ${project.version}")
80 | versionType.set("release")
81 | uploadFile.set(tasks["shadowJar"])
82 | gameVersions.set(supportMinecraftVersions)
83 | loaders.set(listOf("fabric", "forge", "neoforge", "quilt"))
84 | syncBodyFrom.set(rootProject.file("README.md").readText())
85 | changelog.set(System.getenv("CHANGE_LOG"))
86 | }
87 |
88 | val curseForgeSpecialVersions = project.properties["curseforge"].toString().split(",")
89 |
90 | curseforge {
91 | apiKey = if (System.getenv("CURSE_TOKEN") != null) System.getenv("CURSE_TOKEN") else "dummy"
92 | project {
93 | id = "297404"
94 | releaseType = "release"
95 | mainArtifact(tasks["shadowJar"]) {
96 | this.displayName = "I18nUpdateMod ${project.version}"
97 | }
98 | gameVersionStrings.addAll(supportMinecraftVersions)
99 | gameVersionStrings.addAll(curseForgeSpecialVersions)
100 | changelog = if (System.getenv("CHANGE_LOG") != null) System.getenv("CHANGE_LOG") else "No change log"
101 | }
102 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | version=3.6.2
2 | minecraft=1.6.1,1.6.2,1.6.4,1.7.2,1.7.10,1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2,1.13.2,1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5
3 | curseforge=NeoForge,Forge,Fabric,Quilt,Client,Java 8,Java 9,Java 10,Java 11,Java 12,Java 13,Java 14,Java 15,Java 16,Java 17,Java 18
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CFPAOrg/I18nUpdateMod3/a1d52a05c7a206cda54a3187a6ab47fa6143140c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Stop when "xargs" is not available.
209 | if ! command -v xargs >/dev/null 2>&1
210 | then
211 | die "xargs is not available"
212 | fi
213 |
214 | # Use "xargs" to parse quoted args.
215 | #
216 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
217 | #
218 | # In Bash we could simply go:
219 | #
220 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
221 | # set -- "${ARGS[@]}" "$@"
222 | #
223 | # but POSIX shell has neither arrays nor command substitution, so instead we
224 | # post-process each arg (as a line of input to sed) to backslash-escape any
225 | # character that might be a shell metacharacter, then use eval to reverse
226 | # that process (while maintaining the separation between arguments), and wrap
227 | # the whole thing up as a single "set" statement.
228 | #
229 | # This will of course break if any of these variables contains a newline or
230 | # an unmatched quote.
231 | #
232 |
233 | eval "set -- $(
234 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
235 | xargs -n1 |
236 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
237 | tr '\n' ' '
238 | )" '"$@"'
239 |
240 | exec "$JAVACMD" "$@"
241 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if %ERRORLEVEL% equ 0 goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if %ERRORLEVEL% equ 0 goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | set EXIT_CODE=%ERRORLEVEL%
84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86 | exit /b %EXIT_CODE%
87 |
88 | :mainEnd
89 | if "%OS%"=="Windows_NT" endlocal
90 |
91 | :omega
92 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "I18nUpdateMod"
2 |
3 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/I18nUpdateMod.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.JsonObject;
5 | import i18nupdatemod.core.GameConfig;
6 | import i18nupdatemod.core.I18nConfig;
7 | import i18nupdatemod.core.ResourcePack;
8 | import i18nupdatemod.core.ResourcePackConverter;
9 | import i18nupdatemod.entity.GameAssetDetail;
10 | import i18nupdatemod.util.FileUtil;
11 | import i18nupdatemod.util.Log;
12 |
13 | import java.io.InputStream;
14 | import java.io.InputStreamReader;
15 | import java.nio.file.Files;
16 | import java.nio.file.Path;
17 | import java.nio.file.Paths;
18 | import java.util.ArrayList;
19 | import java.util.List;
20 | import java.util.Objects;
21 | import java.util.stream.Collectors;
22 | import java.util.stream.Stream;
23 |
24 | public class I18nUpdateMod {
25 | public static final String MOD_ID = "i18nupdatemod";
26 | public static String MOD_VERSION;
27 |
28 | public static final Gson GSON = new Gson();
29 |
30 | public static void init(Path minecraftPath, String minecraftVersion, String loader) {
31 | try (InputStream is = I18nUpdateMod.class.getResourceAsStream("/i18nMetaData.json")) {
32 | MOD_VERSION = GSON.fromJson(new InputStreamReader(is), JsonObject.class).get("version").getAsString();
33 | } catch (Exception e) {
34 | Log.warning("Error getting version: " + e);
35 | }
36 | Log.info(String.format("I18nUpdate Mod %s is loaded in %s with %s", MOD_VERSION, minecraftVersion, loader));
37 | Log.debug(String.format("Minecraft path: %s", minecraftPath));
38 | String localStorage = getLocalStoragePos(minecraftPath);
39 | Log.debug(String.format("Local Storage Pos: %s", localStorage));
40 |
41 | try {
42 | Class.forName("com.netease.mc.mod.network.common.Library");
43 | Log.warning("I18nUpdateMod will get resource pack from Internet, whose content is uncontrolled.");
44 | Log.warning("This behavior contraries to Netease Minecraft developer content review rule: " +
45 | "forbidden the content in game not match the content for reviewing.");
46 | Log.warning("To follow this rule, I18nUpdateMod won't download any thing.");
47 | Log.warning("I18nUpdateMod会从互联网获取内容不可控的资源包。");
48 | Log.warning("这一行为违背了网易我的世界「开发者内容审核制度」:禁止上传与提审内容不一致的游戏内容。");
49 | Log.warning("为了遵循这一制度,I18nUpdateMod不会下载任何内容。");
50 | return;
51 | } catch (ClassNotFoundException ignored) {
52 | }
53 |
54 | FileUtil.setResourcePackDirPath(minecraftPath.resolve("resourcepacks"));
55 |
56 | int minecraftMajorVersion = Integer.parseInt(minecraftVersion.split("\\.")[1]);
57 |
58 | try {
59 | //Get asset
60 | GameAssetDetail assets = I18nConfig.getAssetDetail(minecraftVersion, loader);
61 |
62 | //Update resource pack
63 | List languagePacks = new ArrayList<>();
64 | boolean convertNotNeed = assets.downloads.size() == 1 && assets.downloads.get(0).targetVersion.equals(minecraftVersion);
65 | String applyFileName = assets.downloads.get(0).fileName;
66 | for (GameAssetDetail.AssetDownloadDetail it : assets.downloads) {
67 | FileUtil.setTemporaryDirPath(Paths.get(localStorage, "." + MOD_ID, it.targetVersion));
68 | ResourcePack languagePack = new ResourcePack(it.fileName, convertNotNeed);
69 | languagePack.checkUpdate(it.fileUrl, it.md5Url);
70 | languagePacks.add(languagePack);
71 | }
72 |
73 | //Convert resourcepack
74 | if (!convertNotNeed) {
75 | FileUtil.setTemporaryDirPath(Paths.get(localStorage, "." + MOD_ID, minecraftVersion));
76 | applyFileName = assets.covertFileName;
77 | ResourcePackConverter converter = new ResourcePackConverter(languagePacks, applyFileName);
78 | converter.convert(assets.covertPackFormat, getResourcePackDescription(assets.downloads));
79 | }
80 |
81 | //Apply resource pack
82 | GameConfig config = new GameConfig(minecraftPath.resolve("options.txt"));
83 | config.addResourcePack("Minecraft-Mod-Language-Modpack",
84 | (minecraftMajorVersion <= 12 ? "" : "file/") + applyFileName);
85 | config.writeToFile();
86 | } catch (Exception e) {
87 | Log.warning(String.format("Failed to update resource pack: %s", e));
88 | // e.printStackTrace();
89 | }
90 | }
91 |
92 | private static String getResourcePackDescription(List downloads) {
93 | return downloads.size() > 1 ?
94 | String.format("该包由%s版本合并\n作者:CFPA团队及汉化项目贡献者",
95 | downloads.stream().map(it -> it.targetVersion).collect(Collectors.joining("和"))) :
96 | String.format("该包对应的官方支持版本为%s\n作者:CFPA团队及汉化项目贡献者",
97 | downloads.get(0).targetVersion);
98 |
99 | }
100 |
101 | public static String getLocalStoragePos(Path minecraftPath) {
102 | Path userHome = Paths.get(System.getProperty("user.home"));
103 | Path oldPath = userHome.resolve("." + MOD_ID);
104 | if (Files.exists(oldPath)) {
105 | return userHome.toString();
106 | }
107 |
108 | // https://developer.apple.com/documentation/foundation/url/3988452-applicationsupportdirectory#discussion
109 | String macAppSupport = System.getProperty("os.name").contains("OS X") ?
110 | userHome.resolve("Library/Application Support").toString() : null;
111 | String localAppData = System.getenv("LocalAppData");
112 |
113 | // XDG_DATA_HOME fallbacks to ~/.local/share
114 | // https://specifications.freedesktop.org/basedir-spec/latest/#variables
115 | String xdgDataHome = System.getenv("XDG_DATA_HOME");
116 | if (xdgDataHome == null) {
117 | xdgDataHome = userHome.resolve(".local/share").toString();
118 | }
119 |
120 | return Stream.of(localAppData, macAppSupport).filter(
121 | Objects::nonNull
122 | ).findFirst().orElse(xdgDataHome);
123 | }
124 | }
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/core/GameConfig.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.core;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.reflect.TypeToken;
5 | import i18nupdatemod.util.Log;
6 | import org.apache.commons.io.FileUtils;
7 |
8 | import java.lang.reflect.Type;
9 | import java.nio.charset.StandardCharsets;
10 | import java.nio.file.Files;
11 | import java.nio.file.Path;
12 | import java.util.LinkedHashMap;
13 | import java.util.List;
14 | import java.util.Map;
15 | import java.util.stream.Collectors;
16 |
17 | public class GameConfig {
18 | private static final Gson GSON = new Gson();
19 | private static final Type STRING_LIST_TYPE = new TypeToken>() {
20 | }.getType();
21 | protected Map configs = new LinkedHashMap<>();
22 | private final Path configFile;
23 |
24 | public GameConfig(Path configFile) throws Exception {
25 | this.configFile = configFile;
26 | if (!Files.exists(configFile)) {
27 | return;
28 | }
29 | this.configs = FileUtils.readLines(configFile.toFile(), StandardCharsets.UTF_8).stream()
30 | .map(it -> it.split(":", 2))
31 | .filter(it -> it.length == 2)
32 | .collect(Collectors.toMap(it -> it[0], it -> it[1], (a, b) -> a, LinkedHashMap::new));
33 | }
34 |
35 | public void writeToFile() throws Exception {
36 | FileUtils.writeLines(configFile.toFile(), "UTF-8", configs.entrySet().stream()
37 | .map(it -> it.getKey() + ":" + it.getValue()).collect(Collectors.toList()));
38 | }
39 |
40 | public void addResourcePack(String baseName, String resourcePack) {
41 | List resourcePacks = GSON.fromJson(
42 | configs.computeIfAbsent("resourcePacks", it -> "[]"), STRING_LIST_TYPE);
43 | //If resource packs already contains target resource pack, nothing to do
44 | if (resourcePacks.contains(resourcePack)) {
45 | return;
46 | }
47 | //Remove other Minecraft Mod Language Pack
48 | resourcePacks = resourcePacks.stream().filter(it -> !it.contains(baseName)).collect(Collectors.toList());
49 | resourcePacks.add(resourcePack);
50 | configs.put("resourcePacks", GSON.toJson(resourcePacks));
51 | Log.info(String.format("Resource Packs: %s", configs.get("resourcePacks")));
52 | // configs.put("lang", "zh_cn");
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/core/I18nConfig.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.core;
2 |
3 | import com.google.gson.Gson;
4 | import i18nupdatemod.entity.AssetMetaData;
5 | import i18nupdatemod.entity.GameAssetDetail;
6 | import i18nupdatemod.entity.GameMetaData;
7 | import i18nupdatemod.entity.I18nMetaData;
8 | import i18nupdatemod.util.Log;
9 | import i18nupdatemod.util.Version;
10 | import i18nupdatemod.util.VersionRange;
11 |
12 | import java.io.InputStream;
13 | import java.io.InputStreamReader;
14 | import java.util.List;
15 | import java.util.stream.Collectors;
16 |
17 | public class I18nConfig {
18 | /**
19 | * CFPAOrg/Minecraft-Mod-Language-Package
20 | */
21 | private static final String CFPA_ASSET_ROOT = "http://downloader1.meitangdehulu.com:22943/";
22 | private static final Gson GSON = new Gson();
23 | private static I18nMetaData i18nMetaData;
24 |
25 | static {
26 | init();
27 | }
28 |
29 | private static void init() {
30 | try (InputStream is = I18nConfig.class.getResourceAsStream("/i18nMetaData.json")) {
31 | if (is != null) {
32 | i18nMetaData = GSON.fromJson(new InputStreamReader(is), I18nMetaData.class);
33 | } else {
34 | Log.warning("Error getting index: is is null");
35 | }
36 | } catch (Exception e) {
37 | Log.warning("Error getting index: " + e);
38 | }
39 | }
40 |
41 | private static GameMetaData getGameMetaData(String minecraftVersion) {
42 | Version version = Version.from(minecraftVersion);
43 | return i18nMetaData.games.stream().filter(it -> {
44 | VersionRange range = new VersionRange(it.gameVersions);
45 | return range.contains(version);
46 | }).findFirst().orElseThrow(() -> new IllegalStateException(String.format("Version %s not found in i18n meta", minecraftVersion)));
47 | }
48 |
49 | private static AssetMetaData getAssetMetaData(String minecraftVersion, String loader) {
50 | List current = i18nMetaData.assets.stream()
51 | .filter(it -> it.targetVersion.equals(minecraftVersion))
52 | .collect(Collectors.toList());
53 | return current.stream()
54 | .filter(it -> it.loader.equalsIgnoreCase(loader)).findFirst().orElseGet(() -> current.get(0));
55 | }
56 |
57 | public static GameAssetDetail getAssetDetail(String minecraftVersion, String loader) {
58 | GameMetaData convert = getGameMetaData(minecraftVersion);
59 | GameAssetDetail ret = new GameAssetDetail();
60 |
61 | ret.downloads = convert.convertFrom.stream().map(it -> getAssetMetaData(it, loader)).map(it -> {
62 | GameAssetDetail.AssetDownloadDetail adi = new GameAssetDetail.AssetDownloadDetail();
63 | adi.fileName = it.filename;
64 | adi.fileUrl = CFPA_ASSET_ROOT + it.filename;
65 | adi.md5Url = CFPA_ASSET_ROOT + it.md5Filename;
66 | adi.targetVersion = it.targetVersion;
67 | return adi;
68 | }).collect(Collectors.toList());
69 | ret.covertPackFormat = convert.packFormat;
70 | ret.covertFileName =
71 | String.format("Minecraft-Mod-Language-Modpack-Converted-%s.zip", minecraftVersion);
72 | return ret;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/core/ResourcePack.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.core;
2 |
3 | import i18nupdatemod.util.AssetUtil;
4 | import i18nupdatemod.util.DigestUtil;
5 | import i18nupdatemod.util.FileUtil;
6 | import i18nupdatemod.util.Log;
7 |
8 | import java.io.FileNotFoundException;
9 | import java.io.IOException;
10 | import java.net.URISyntaxException;
11 | import java.nio.file.Files;
12 | import java.nio.file.Path;
13 | import java.nio.file.StandardCopyOption;
14 | import java.security.NoSuchAlgorithmException;
15 | import java.util.concurrent.TimeUnit;
16 |
17 | public class ResourcePack {
18 | /**
19 | * Limit update check frequency
20 | */
21 | private static final long UPDATE_TIME_GAP = TimeUnit.DAYS.toMillis(1);
22 | private final String filename;
23 | private final Path filePath;
24 | private final Path tmpFilePath;
25 | private final boolean saveToGame;
26 | private String remoteMd5;
27 |
28 | public ResourcePack(String filename, boolean saveToGame) {
29 | //If target version is not current version, not save
30 | this.saveToGame = saveToGame;
31 | this.filename = filename;
32 | this.filePath = FileUtil.getResourcePackPath(filename);
33 | this.tmpFilePath = FileUtil.getTemporaryPath(filename);
34 | try {
35 | FileUtil.syncTmpFile(filePath, tmpFilePath, saveToGame);
36 | } catch (Exception e) {
37 | Log.warning(
38 | String.format("Error while sync temp file %s <-> %s: %s", filePath, tmpFilePath, e));
39 | }
40 | }
41 |
42 | public void checkUpdate(String fileUrl, String md5Url) throws IOException, URISyntaxException, NoSuchAlgorithmException {
43 | if (isUpToDate(md5Url)) {
44 | Log.debug("Already up to date.");
45 | return;
46 | }
47 | //In this time, we can only download full file
48 | downloadFull(fileUrl, md5Url);
49 | //In the future, we will download patch file and merge local file
50 | }
51 |
52 | private boolean isUpToDate(String md5Url) throws IOException, URISyntaxException, NoSuchAlgorithmException {
53 | //Not exist -> Update
54 | if (!Files.exists(tmpFilePath)) {
55 | Log.debug("Local file %s not exist.", tmpFilePath);
56 | return false;
57 | }
58 | //Last update time not exceed gap -> Not Update
59 | if (Files.getLastModifiedTime(tmpFilePath).to(TimeUnit.MILLISECONDS)
60 | > System.currentTimeMillis() - UPDATE_TIME_GAP) {
61 | Log.debug("Local file %s has been updated recently.", tmpFilePath);
62 | return true;
63 | }
64 | //Check Update
65 | return checkMd5(tmpFilePath, md5Url);
66 | }
67 |
68 | private boolean checkMd5(Path localFile, String md5Url) throws IOException, URISyntaxException, NoSuchAlgorithmException {
69 | String localMd5 = DigestUtil.md5Hex(localFile);
70 | if (remoteMd5 == null) {
71 | remoteMd5 = AssetUtil.getString(md5Url);
72 | }
73 | Log.debug("%s md5: %s, remote md5: %s", localFile, localMd5, remoteMd5);
74 | return localMd5.equalsIgnoreCase(remoteMd5);
75 | }
76 |
77 | private void downloadFull(String fileUrl, String md5Url) throws IOException {
78 | try {
79 | Path downloadTmp = FileUtil.getTemporaryPath(filename + ".tmp");
80 | AssetUtil.download(fileUrl, downloadTmp);
81 | if (!checkMd5(downloadTmp, md5Url)) {
82 | throw new IOException("Download MD5 not match");
83 | }
84 | Files.move(downloadTmp, tmpFilePath, StandardCopyOption.REPLACE_EXISTING);
85 | Log.debug(String.format("Updates temp file: %s", tmpFilePath));
86 | } catch (Exception e) {
87 | Log.warning("Error while downloading: %s", e);
88 | }
89 | if (!Files.exists(tmpFilePath)) {
90 | throw new FileNotFoundException("Tmp file not found.");
91 | }
92 | FileUtil.syncTmpFile(filePath, tmpFilePath, saveToGame);
93 | }
94 |
95 | public Path getTmpFilePath() {
96 | return tmpFilePath;
97 | }
98 |
99 | public String getFilename() {
100 | return filename;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/core/ResourcePackConverter.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.core;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.GsonBuilder;
5 | import i18nupdatemod.util.FileUtil;
6 | import i18nupdatemod.util.Log;
7 | import org.apache.commons.io.IOUtils;
8 |
9 | import java.io.InputStream;
10 | import java.io.InputStreamReader;
11 | import java.nio.charset.StandardCharsets;
12 | import java.nio.file.Files;
13 | import java.nio.file.Path;
14 | import java.util.Enumeration;
15 | import java.util.HashSet;
16 | import java.util.List;
17 | import java.util.Set;
18 | import java.util.stream.Collectors;
19 | import java.util.zip.ZipEntry;
20 | import java.util.zip.ZipFile;
21 | import java.util.zip.ZipOutputStream;
22 |
23 | public class ResourcePackConverter {
24 | private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
25 | private final List sourcePath;
26 | private final Path filePath;
27 | private final Path tmpFilePath;
28 |
29 | public ResourcePackConverter(List resourcePack, String filename) {
30 | this.sourcePath = resourcePack.stream().map(ResourcePack::getTmpFilePath).collect(Collectors.toList());
31 | this.filePath = FileUtil.getResourcePackPath(filename);
32 | this.tmpFilePath = FileUtil.getTemporaryPath(filename);
33 | }
34 |
35 | public void convert(int packFormat, String description) throws Exception {
36 | Set fileList = new HashSet<>();
37 | try (ZipOutputStream zos = new ZipOutputStream(
38 | Files.newOutputStream(tmpFilePath),
39 | StandardCharsets.UTF_8)) {
40 | // zos.setMethod(ZipOutputStream.STORED);
41 | for (Path p : sourcePath) {
42 | Log.info("Converting: " + p);
43 | try (ZipFile zf = new ZipFile(p.toFile(), StandardCharsets.UTF_8)) {
44 | for (Enumeration extends ZipEntry> e = zf.entries(); e.hasMoreElements(); ) {
45 | ZipEntry ze = e.nextElement();
46 | String name = ze.getName();
47 | // Don't put same file
48 | if (fileList.contains(name)) {
49 | // Log.debug(name + ": DUPLICATE");
50 | continue;
51 | }
52 | fileList.add(name);
53 | // Log.debug(name);
54 |
55 | // Put file into new zip
56 | zos.putNextEntry(new ZipEntry(name));
57 | InputStream is = zf.getInputStream(ze);
58 | if (name.equalsIgnoreCase("pack.mcmeta")) {
59 | //Convert pack.mcmeta
60 | zos.write(convertPackMeta(is, packFormat, description));
61 | } else {
62 | //Copy other file
63 | IOUtils.copy(is, zos);
64 | }
65 | zos.closeEntry();
66 | }
67 | }
68 | }
69 | zos.close();
70 | Log.info("Converted: %s -> %s", sourcePath, tmpFilePath);
71 | FileUtil.syncTmpFile(tmpFilePath, filePath, true);
72 | } catch (Exception e) {
73 | throw new Exception(String.format("Error converting %s to %s: %s", sourcePath, tmpFilePath, e));
74 | }
75 | }
76 |
77 | private byte[] convertPackMeta(InputStream is, int packFormat, String description) {
78 | PackMeta meta = GSON.fromJson(new InputStreamReader(is, StandardCharsets.UTF_8), PackMeta.class);
79 | meta.pack.pack_format = packFormat;
80 | meta.pack.description = description;
81 | return GSON.toJson(meta).getBytes(StandardCharsets.UTF_8);
82 | }
83 |
84 | private static class PackMeta {
85 | Pack pack;
86 |
87 | private static class Pack {
88 | int pack_format;
89 | String description;
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/entity/AssetMetaData.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.entity;
2 |
3 | public class AssetMetaData {
4 | public String loader;
5 | public String targetVersion;
6 | public String filename;
7 | public String md5Filename;
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/entity/GameAssetDetail.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.entity;
2 |
3 | import java.util.List;
4 |
5 | public class GameAssetDetail {
6 | public List downloads;
7 | public Integer covertPackFormat;
8 | public String covertFileName;
9 |
10 | public static class AssetDownloadDetail {
11 | public String fileName;
12 | public String fileUrl;
13 | public String md5Url;
14 | public String targetVersion;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/entity/GameMetaData.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.entity;
2 |
3 | import java.util.List;
4 |
5 | public class GameMetaData {
6 | public String gameVersions;
7 | public int packFormat;
8 | public List convertFrom;
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/entity/I18nMetaData.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.entity;
2 |
3 | import java.util.List;
4 |
5 | public class I18nMetaData {
6 | public String version;
7 | public List games;
8 | public List assets;
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/fabricloader/FabricLoaderMod.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.fabricloader;
2 |
3 | import i18nupdatemod.I18nUpdateMod;
4 | import i18nupdatemod.util.Log;
5 | import i18nupdatemod.util.Reflection;
6 | import net.fabricmc.api.ClientModInitializer;
7 | import net.fabricmc.loader.api.FabricLoader;
8 |
9 | import java.nio.file.Path;
10 |
11 | //1.14-latest
12 | public class FabricLoaderMod implements ClientModInitializer {
13 |
14 | @Override
15 | public void onInitializeClient() {
16 | Path gameDir = FabricLoader.getInstance().getGameDir();
17 | Log.setMinecraftLogFile(gameDir);
18 | String mcVersion = getMcVersion();
19 | if (mcVersion == null) {
20 | Log.warning("Minecraft version not found");
21 | return;
22 | }
23 | I18nUpdateMod.init(gameDir, mcVersion, "Fabric");
24 | }
25 |
26 | private String getMcVersion() {
27 | try {
28 | // Fabric
29 | return (String) Reflection.clazz("net.fabricmc.loader.impl.FabricLoaderImpl")
30 | .get("INSTANCE")
31 | .get("getGameProvider()")
32 | .get("getNormalizedGameVersion()").get();
33 | } catch (Exception ignored) {
34 |
35 | }
36 | try {
37 | // Quilt
38 | return (String) Reflection.clazz("org.quiltmc.loader.impl.QuiltLoaderImpl")
39 | .get("INSTANCE")
40 | .get("getGameProvider()")
41 | .get("getNormalizedGameVersion()").get();
42 | } catch (Exception ignored) {
43 |
44 | }
45 | return null;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/launchwrapper/LaunchWrapperTweaker.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.launchwrapper;
2 |
3 | import i18nupdatemod.I18nUpdateMod;
4 | import i18nupdatemod.util.Log;
5 | import i18nupdatemod.util.Reflection;
6 | import net.minecraft.launchwrapper.ITweaker;
7 | import net.minecraft.launchwrapper.LaunchClassLoader;
8 |
9 | import java.io.File;
10 | import java.util.List;
11 |
12 | //1.6-1.12.2
13 | public class LaunchWrapperTweaker implements ITweaker {
14 |
15 | @Override
16 | public void acceptOptions(List args, File gameDir, File assetsDir, String profile) {
17 | Log.setMinecraftLogFile(gameDir.toPath());
18 | String mcVersion = getMcVersion();
19 | if (mcVersion == null) {
20 | Log.warning("Failed to get minecraft version.");
21 | return;
22 | }
23 | I18nUpdateMod.init(gameDir.toPath(), mcVersion, "Forge");
24 | }
25 |
26 | @Override
27 | public void injectIntoClassLoader(LaunchClassLoader classLoader) {
28 |
29 | }
30 |
31 | @Override
32 | public String getLaunchTarget() {
33 | return "";
34 | }
35 |
36 | @Override
37 | public String[] getLaunchArguments() {
38 | return new String[0];
39 | }
40 |
41 | private String getMcVersion() {
42 | try {
43 | // 1.6~1.7.10
44 | // 1.6: https://github.com/MinecraftForge/FML/blob/16launch/common/cpw/mods/fml/relauncher/FMLInjectionData.java#L32
45 | // 1.7.10: https://github.com/MinecraftForge/MinecraftForge/blob/1.7.10/fml/src/main/java/cpw/mods/fml/relauncher/FMLInjectionData.java#L32
46 | return (String)
47 | Reflection.clazz("cpw.mods.fml.relauncher.FMLInjectionData").get("mccversion").get();
48 | } catch (Exception ignored) {
49 | }
50 |
51 | try {
52 | // 1.8
53 | // https://github.com/MinecraftForge/FML/blob/1.8/src/main/java/net/minecraftforge/fml/relauncher/FMLInjectionData.java#L32
54 | return (String)
55 | Reflection.clazz("net.minecraftforge.fml.relauncher.FMLInjectionData").get("mccversion").get();
56 | } catch (Exception ignored) {
57 | }
58 |
59 | try {
60 | // 1.8.8~1.12.2
61 | // 1.8.8: https://github.com/MinecraftForge/MinecraftForge/blob/1.8.8/src/main/java/net/minecraftforge/common/ForgeVersion.java#L42
62 | // 1.12.2: https://github.com/MinecraftForge/MinecraftForge/blob/1.12.x/src/main/java/net/minecraftforge/common/ForgeVersion.java#L64
63 | return (String) Reflection.clazz("net.minecraftforge.common.ForgeVersion").get("mcVersion").get();
64 | } catch (Exception ignored) {
65 | }
66 | return null;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/modlauncher/ModLauncherService.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.modlauncher;
2 |
3 | import com.google.gson.JsonObject;
4 | import cpw.mods.modlauncher.Launcher;
5 | import cpw.mods.modlauncher.api.IEnvironment;
6 | import cpw.mods.modlauncher.api.ITransformationService;
7 | import cpw.mods.modlauncher.api.ITransformer;
8 | import cpw.mods.modlauncher.api.IncompatibleEnvironmentException;
9 | import i18nupdatemod.I18nUpdateMod;
10 | import i18nupdatemod.util.Log;
11 | import i18nupdatemod.util.Reflection;
12 | import org.jetbrains.annotations.NotNull;
13 |
14 | import java.io.InputStream;
15 | import java.io.InputStreamReader;
16 | import java.nio.file.Path;
17 | import java.util.Collections;
18 | import java.util.List;
19 | import java.util.Optional;
20 | import java.util.Set;
21 |
22 | import static i18nupdatemod.I18nUpdateMod.GSON;
23 |
24 | //1.13-latest
25 | public class ModLauncherService implements ITransformationService {
26 | @Override
27 | public @NotNull String name() {
28 | return "I18nUpdateMod";
29 | }
30 |
31 | @Override
32 | public void initialize(IEnvironment environment) {
33 | Optional minecraftPath = environment.getProperty(IEnvironment.Keys.GAMEDIR.get());
34 | if (!minecraftPath.isPresent()) {
35 | Log.warning("Minecraft path not found");
36 | return;
37 | }
38 | Log.setMinecraftLogFile(minecraftPath.get());
39 | String minecraftVersion = getMinecraftVersion();
40 | if (minecraftVersion == null) {
41 | Log.warning("Minecraft version not found");
42 | return;
43 | }
44 | I18nUpdateMod.init(minecraftPath.get(), minecraftVersion, "Forge");
45 | }
46 |
47 | @Override
48 | public void beginScanning(IEnvironment environment) {
49 |
50 | }
51 |
52 | @Override
53 | public void onLoad(IEnvironment env, Set otherServices) throws IncompatibleEnvironmentException {
54 |
55 | }
56 |
57 | @Override
58 | public @NotNull List transformers() {
59 | return Collections.emptyList();
60 | }
61 |
62 | private String getMinecraftVersion() {
63 | // MinecraftForge 1.13~1.20.2
64 | // NeoForge 1.20.1~
65 | try {
66 | String[] args = (String[]) Reflection.clazz(Launcher.INSTANCE).get("argumentHandler").get("args").get();
67 | for (int i = 0; i < args.length - 1; ++i) {
68 | if (args[i].equalsIgnoreCase("--fml.mcversion")) {
69 | return args[i + 1];
70 | }
71 | }
72 | } catch (Exception e) {
73 | Log.warning("Error getting minecraft version: %s", e);
74 | }
75 |
76 | // MinecraftForge 1.20.3~
77 | // 1.20.3: https://github.com/MinecraftForge/MinecraftForge/blob/1.20.x/fmlloader/src/main/java/net/minecraftforge/fml/loading/VersionInfo.java
78 | try {
79 | Class> clazz = Class.forName("net.minecraftforge.fml.loading.FMLLoader");
80 | try (InputStream is = clazz.getResourceAsStream("/forge_version.json")) {
81 | return GSON.fromJson(new InputStreamReader(is), JsonObject.class).get("mc").getAsString();
82 | }
83 | } catch (Exception e) {
84 | Log.warning("Error getting minecraft version: %s", e);
85 | }
86 | return null;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/util/AssetUtil.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.util;
2 |
3 | import org.apache.commons.io.FileUtils;
4 | import org.apache.commons.io.IOUtils;
5 |
6 | import java.io.IOException;
7 | import java.net.URI;
8 | import java.net.URISyntaxException;
9 | import java.nio.charset.StandardCharsets;
10 | import java.nio.file.Path;
11 | import java.util.concurrent.TimeUnit;
12 |
13 | public class AssetUtil {
14 | public static void download(String url, Path localFile) throws IOException, URISyntaxException {
15 | Log.info("Downloading: %s -> %s", url, localFile);
16 | FileUtils.copyURLToFile(new URI(url).toURL(), localFile.toFile(),
17 | (int) TimeUnit.SECONDS.toMillis(3), (int) TimeUnit.SECONDS.toMillis(33));
18 | Log.debug("Downloaded: %s -> %s", url, localFile);
19 | }
20 |
21 | public static String getString(String url) throws IOException, URISyntaxException {
22 | return IOUtils.toString(new URI(url).toURL(), StandardCharsets.UTF_8);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/util/BsDiffUtil.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.util;
2 |
3 | import com.google.archivepatcher.applier.bsdiff.BsPatch;
4 |
5 | import java.io.RandomAccessFile;
6 | import java.nio.file.Files;
7 | import java.nio.file.Path;
8 |
9 | public class BsDiffUtil {
10 | public static void applyPatch(Path oldFile, Path patchFile, Path newFile) throws Exception {
11 | BsPatch.applyPatch(new RandomAccessFile(oldFile.toFile(), "r"),
12 | Files.newOutputStream(newFile),
13 | Files.newInputStream(patchFile)
14 | );
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/util/DigestUtil.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.util;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.nio.file.Files;
6 | import java.nio.file.Path;
7 | import java.security.MessageDigest;
8 | import java.security.NoSuchAlgorithmException;
9 |
10 | public class DigestUtil {
11 | public static String md5Hex(Path file) throws IOException, NoSuchAlgorithmException {
12 | try (InputStream is = Files.newInputStream(file)) {
13 | MessageDigest dig = MessageDigest.getInstance("MD5");
14 |
15 | final byte[] buf = new byte[114514];
16 |
17 | for (int read = is.read(buf); read != -1; read = is.read(buf)) {
18 | dig.update(buf, 0, read);
19 | }
20 |
21 | return hexString(dig.digest());
22 | }
23 | }
24 |
25 | private static final String HEX = "0123456789ABCDEF";
26 |
27 | public static String hexString(byte[] data) {
28 | StringBuilder sb = new StringBuilder();
29 | for (byte d : data) {
30 | sb.append(HEX.charAt((d & 0xf0) >>> 4));
31 | sb.append(HEX.charAt(d & 0xf));
32 | }
33 | return sb.toString();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/util/FileUtil.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.util;
2 |
3 | import java.io.IOException;
4 | import java.nio.file.Files;
5 | import java.nio.file.Path;
6 | import java.nio.file.StandardCopyOption;
7 |
8 | public class FileUtil {
9 | private static Path resourcePackDirPath;
10 | private static Path temporaryDirPath;
11 |
12 | public static void setResourcePackDirPath(Path path) {
13 | safeCreateDir(path);
14 | resourcePackDirPath = path;
15 | }
16 |
17 | public static void setTemporaryDirPath(Path temporaryDirPath) {
18 | safeCreateDir(temporaryDirPath);
19 | FileUtil.temporaryDirPath = temporaryDirPath;
20 | }
21 |
22 | private static void safeCreateDir(Path path) {
23 | try {
24 | if (!Files.isDirectory(path)) {
25 | Files.createDirectories(path);
26 | }
27 | } catch (Exception e) {
28 | Log.warning("Cannot create dir: " + e);
29 | }
30 | }
31 |
32 | public static Path getResourcePackPath(String filename) {
33 | return resourcePackDirPath.resolve(filename);
34 | }
35 |
36 | public static Path getTemporaryPath(String filename) {
37 | return temporaryDirPath.resolve(filename);
38 | }
39 |
40 | public static void syncTmpFile(Path filePath, Path tmpFilePath, boolean saveToGame) throws IOException {
41 | //Both temp and current file not found
42 | if (!Files.exists(filePath) && !Files.exists(tmpFilePath)) {
43 | Log.debug("Both temp and current file not found");
44 | return;
45 | }
46 |
47 | int cmp = compareTmpFile(filePath, tmpFilePath);
48 | Path from, to;
49 | if (cmp == 0) {
50 | Log.debug("Temp and current file has already been synchronized");
51 | return;
52 | } else if (cmp < 0) {
53 | //Current file is newer
54 | from = filePath;
55 | to = tmpFilePath;
56 | } else {
57 | //Temp file is newer
58 | from = tmpFilePath;
59 | to = filePath;
60 | }
61 |
62 | if (!saveToGame && to == filePath) {
63 | //Don't save to game
64 | return;
65 | }
66 |
67 | Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
68 | //Ensure same last modified time
69 | Files.setLastModifiedTime(to, Files.getLastModifiedTime(from));
70 | Log.info(String.format("Synchronized: %s -> %s", from, to));
71 | }
72 |
73 | private static int compareTmpFile(Path filePath, Path tmpFilePath) throws IOException {
74 | if (!Files.exists(filePath)) {
75 | return 1;
76 | }
77 | if (!Files.exists(tmpFilePath)) {
78 | return -1;
79 | }
80 | return Files.getLastModifiedTime(tmpFilePath).compareTo(Files.getLastModifiedTime(filePath));
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/util/Log.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.util;
2 |
3 | import java.io.Writer;
4 | import java.nio.charset.StandardCharsets;
5 | import java.nio.file.Files;
6 | import java.nio.file.Path;
7 | import java.text.DateFormat;
8 | import java.text.SimpleDateFormat;
9 | import java.util.Date;
10 |
11 | public class Log {
12 | private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
13 | private static Writer fileWriter;
14 |
15 | public static void setMinecraftLogFile(Path minecraftDir) {
16 | setLogFile(minecraftDir.resolve("logs/I18nUpdateMod.log"));
17 | }
18 |
19 | public static void setLogFile(Path path) {
20 | try {
21 | fileWriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8);
22 | } catch (Exception e) {
23 | System.err.printf("Error setting log file: %s%n\r\n", e);
24 | }
25 | }
26 |
27 | enum Level {
28 | DEBUG(Out.FILE_ONLY), INFO(Out.STD_OUT), WARNING(Out.STD_ERR);
29 | final Out out;
30 |
31 | Level(Out out) {
32 | this.out = out;
33 | }
34 | }
35 |
36 | enum Out {
37 | FILE_ONLY,
38 | STD_OUT,
39 | STD_ERR
40 | }
41 |
42 | private static void log(Level level, String message) {
43 | String out = String.format("[%s] [%s]: %s\r\n", DATE_FORMAT.format(new Date()), level.name(), message);
44 | if (fileWriter != null) {
45 | try {
46 | fileWriter.write(out);
47 | fileWriter.flush();
48 | } catch (Exception e) {
49 | System.err.printf("Error writing log: %s%n\r\n", e);
50 | }
51 | }
52 | switch (level.out) {
53 | case STD_OUT:
54 | System.out.print(out);
55 | return;
56 | case STD_ERR:
57 | System.err.print(out);
58 | }
59 | }
60 |
61 | public static void debug(String message) {
62 | log(Level.DEBUG, message);
63 | }
64 |
65 | public static void debug(String format, Object... args) {
66 | debug(String.format(format, args));
67 | }
68 |
69 | public static void info(String message) {
70 | log(Level.INFO, message);
71 | }
72 |
73 | public static void info(String format, Object... args) {
74 | info(String.format(format, args));
75 | }
76 |
77 | public static void warning(String message) {
78 | log(Level.WARNING, message);
79 | }
80 |
81 | public static void warning(String format, Object... args) {
82 | warning(String.format(format, args));
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/util/Reflection.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.util;
2 |
3 | import java.lang.reflect.Field;
4 | import java.lang.reflect.Method;
5 |
6 | public class Reflection {
7 | private final Class> clazz;
8 | private Object instance;
9 |
10 | public Reflection(Class> clazz) {
11 | this.clazz = clazz;
12 | }
13 |
14 | public Reflection(Object instance) {
15 | if (instance == null) {
16 | throw new IllegalArgumentException("Instance cannot be null");
17 | }
18 | this.clazz = instance.getClass();
19 | this.instance = instance;
20 | }
21 |
22 | public static Reflection clazz(String className) throws ClassNotFoundException {
23 | return new Reflection(Class.forName(className));
24 | }
25 |
26 | public static Reflection clazz(Class> clazz) {
27 | return new Reflection(clazz);
28 | }
29 |
30 | public static Reflection clazz(Object instance) {
31 | return new Reflection(instance);
32 | }
33 |
34 | private Reflection getField(String field) throws Exception {
35 | Field field0 = clazz.getDeclaredField(field);
36 | field0.setAccessible(true);
37 | return new Reflection(field0.get(instance));
38 | }
39 |
40 | private Reflection invokeMethod(String method) throws Exception {
41 | Method method1 = clazz.getDeclaredMethod(method);
42 | method1.setAccessible(true);
43 | return new Reflection(method1.invoke(instance));
44 | }
45 |
46 | /**
47 | * Get field or invoke method
48 | *
49 | * @param fieldOrMethod fieldName or methodName()
50 | * @return result
51 | * @throws Exception
52 | */
53 | public Reflection get(String fieldOrMethod) throws Exception {
54 | // System.out.println("Getting " + fieldOrMethod);
55 | if (fieldOrMethod.endsWith(")")) {
56 | return invokeMethod(fieldOrMethod.replace("()", ""));
57 | } else {
58 | return getField(fieldOrMethod);
59 | }
60 | }
61 |
62 | public Object get() {
63 | return instance;
64 | }
65 | }
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/util/Version.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.util;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import org.jetbrains.annotations.Nullable;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 | import java.util.Objects;
9 |
10 | public class Version implements Comparable {
11 | public final String version;
12 | private final List versions = new ArrayList<>();
13 |
14 | public static @Nullable Version from(String version) {
15 | if (version == null || version.isEmpty()) {
16 | return null;
17 | }
18 | return new Version(version);
19 | }
20 |
21 | private Version(@NotNull String version) {
22 | this.version = version;
23 | parseVersion(version);
24 | }
25 |
26 | enum VersionParseState {
27 | START, READING_NUMBER
28 | }
29 |
30 | private void parseVersion(@NotNull String version) {
31 | VersionParseState state = VersionParseState.START;
32 | StringBuilder buffer = new StringBuilder();
33 | for (char c : version.toCharArray()) {
34 | switch (state) {
35 | case START:
36 | if (Character.isDigit(c)) {
37 | buffer.append(c);
38 | state = VersionParseState.READING_NUMBER;
39 | } else {
40 | return;
41 | }
42 | break;
43 | case READING_NUMBER:
44 | if (Character.isDigit(c)) {
45 | buffer.append(c);
46 | } else {
47 | versions.add(Integer.parseInt(buffer.toString()));
48 | buffer = new StringBuilder();
49 | if (c == '.') {
50 | state = VersionParseState.START;
51 | } else {
52 | return;
53 | }
54 | }
55 | break;
56 | }
57 | }
58 | versions.add(Integer.parseInt(buffer.toString()));
59 | }
60 |
61 | @Override
62 | public int compareTo(@NotNull Version o) {
63 | int min = Math.min(versions.size(), o.versions.size());
64 | for (int i = 0; i < min; ++i) {
65 | if (!Objects.equals(versions.get(i), o.versions.get(i))) {
66 | return Integer.compare(versions.get(i), o.versions.get(i));
67 | }
68 | }
69 | return Integer.compare(versions.size(), o.versions.size());
70 | }
71 | }
--------------------------------------------------------------------------------
/src/main/java/i18nupdatemod/util/VersionRange.java:
--------------------------------------------------------------------------------
1 | package i18nupdatemod.util;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | public class VersionRange {
6 | private Version fromVersion;
7 | private boolean containsLeft;
8 | private Version toVersion;
9 | private boolean containsRight;
10 |
11 | public VersionRange(String range) {
12 | parseVersionRange(range);
13 | }
14 |
15 | enum RangeParseState {
16 | START, READING_FIRST_VERSION, READING_SECOND_VERSION
17 | }
18 |
19 | private void parseVersionRange(@NotNull String range) {
20 | RangeParseState state = RangeParseState.START;
21 | StringBuilder buffer = new StringBuilder();
22 | for (char c : range.toCharArray()) {
23 | switch (state) {
24 | case START:
25 | state = RangeParseState.READING_FIRST_VERSION;
26 | if (c == '[') {
27 | containsLeft = true;
28 | } else if (c == '(') {
29 | containsLeft = false;
30 | } else {
31 | throw new IllegalArgumentException("Range illegal");
32 | }
33 | break;
34 | case READING_FIRST_VERSION:
35 | if (c == ',') {
36 | fromVersion = Version.from(buffer.toString());
37 | buffer = new StringBuilder();
38 | state = RangeParseState.READING_SECOND_VERSION;
39 | } else {
40 | buffer.append(c);
41 | }
42 | break;
43 | case READING_SECOND_VERSION:
44 | if (c == ']') {
45 | toVersion = Version.from(buffer.toString());
46 | containsRight = true;
47 | return;
48 | } else if (c == ')') {
49 | toVersion = Version.from(buffer.toString());
50 | containsRight = false;
51 | return;
52 | } else {
53 | buffer.append(c);
54 | }
55 | }
56 | }
57 | throw new IllegalArgumentException("Range illegal");
58 | }
59 |
60 | public boolean contains(@NotNull Version version) {
61 | if (fromVersion != null) {
62 | int cmp = version.compareTo(fromVersion);
63 | if (cmp < 0 || (!containsLeft && cmp == 0)) {
64 | return false;
65 | }
66 | }
67 | if (toVersion != null) {
68 | int cmp = version.compareTo(toVersion);
69 | return cmp <= 0 && (containsRight || cmp != 0);
70 | }
71 | return true;
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.ITransformationService:
--------------------------------------------------------------------------------
1 | i18nupdatemod.modlauncher.ModLauncherService
--------------------------------------------------------------------------------
/src/main/resources/fabric.mod.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": 1,
3 | "id": "i18nupdatemod",
4 | "version": "${version}",
5 | "environment": "client",
6 | "entrypoints": {
7 | "client": [
8 | "i18nupdatemod.fabricloader.FabricLoaderMod"
9 | ]
10 | },
11 | "name": "I18nUpdateMod",
12 | "description": "Brand new Minecraft Mod Language Package update mod.",
13 | "contact": {
14 | "homepage": "https://github.com/xfl03/I18nUpdateMod3",
15 | "issues": "https://github.com/xfl03/I18nUpdateMod3/issues",
16 | "sources": "https://github.com/xfl03/I18nUpdateMod3"
17 | },
18 | "authors": [
19 | {
20 | "name": "xfl03",
21 | "contact": {
22 | "homepage": "https://github.com/xfl03"
23 | }
24 | }
25 | ],
26 | "license": "AGPL-3.0-only"
27 | }
--------------------------------------------------------------------------------
/src/main/resources/i18nMetaData.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "${version}",
3 | "games": [
4 | {
5 | "gameVersions": "[1.6.1,1.8.9]",
6 | "packFormat": 1,
7 | "convertFrom": [
8 | "1.10.2",
9 | "1.12.2"
10 | ]
11 | },
12 | {
13 | "gameVersions": "[1.9,1.10.2]",
14 | "packFormat": 2,
15 | "convertFrom": [
16 | "1.10.2",
17 | "1.12.2"
18 | ]
19 | },
20 | {
21 | "gameVersions": "[1.11,1.12.2]",
22 | "packFormat": 3,
23 | "convertFrom": [
24 | "1.12.2"
25 | ]
26 | },
27 | {
28 | "gameVersions": "[1.13,1.14.4]",
29 | "packFormat": 4,
30 | "convertFrom": [
31 | "1.16"
32 | ]
33 | },
34 | {
35 | "gameVersions": "[1.15,1.16.1]",
36 | "packFormat": 5,
37 | "convertFrom": [
38 | "1.16"
39 | ]
40 | },
41 | {
42 | "gameVersions": "[1.16.2,1.16.5]",
43 | "packFormat": 6,
44 | "convertFrom": [
45 | "1.16"
46 | ]
47 | },
48 | {
49 | "gameVersions": "[1.17,1.17.1]",
50 | "packFormat": 7,
51 | "convertFrom": [
52 | "1.18",
53 | "1.16"
54 | ]
55 | },
56 | {
57 | "gameVersions": "[1.18,1.18.2]",
58 | "packFormat": 8,
59 | "convertFrom": [
60 | "1.18"
61 | ]
62 | },
63 | {
64 | "gameVersions": "[1.19,1.19.2]",
65 | "packFormat": 9,
66 | "convertFrom": [
67 | "1.19",
68 | "1.18"
69 | ]
70 | },
71 | {
72 | "gameVersions": "[1.19.3,1.19.3]",
73 | "packFormat": 12,
74 | "convertFrom": [
75 | "1.19",
76 | "1.18"
77 | ]
78 | },
79 | {
80 | "gameVersions": "[1.19.4,1.19.4]",
81 | "packFormat": 13,
82 | "convertFrom": [
83 | "1.19",
84 | "1.18"
85 | ]
86 | },
87 | {
88 | "gameVersions": "[1.20,1.20.1]",
89 | "packFormat": 15,
90 | "convertFrom": [
91 | "1.20",
92 | "1.19",
93 | "1.18"
94 | ]
95 | },
96 | {
97 | "gameVersions": "[1.20.2,1.20.2]",
98 | "packFormat": 18,
99 | "convertFrom": [
100 | "1.20",
101 | "1.19",
102 | "1.18"
103 | ]
104 | },
105 | {
106 | "gameVersions": "[1.20.3,1.20.4]",
107 | "packFormat": 22,
108 | "convertFrom": [
109 | "1.20",
110 | "1.19",
111 | "1.18"
112 | ]
113 | },
114 | {
115 | "gameVersions": "[1.20.5,1.20.6]",
116 | "packFormat": 32,
117 | "convertFrom": [
118 | "1.20",
119 | "1.19",
120 | "1.18"
121 | ]
122 | },
123 | {
124 | "gameVersions": "[1.21,1.21.1]",
125 | "packFormat": 34,
126 | "convertFrom": [
127 | "1.21",
128 | "1.20",
129 | "1.19"
130 | ]
131 | },
132 | {
133 | "gameVersions": "[1.21.2,1.21.3]",
134 | "packFormat": 42,
135 | "convertFrom": [
136 | "1.21",
137 | "1.20",
138 | "1.19"
139 | ]
140 | },
141 | {
142 | "gameVersions": "[1.21.4,1.21.4]",
143 | "packFormat": 46,
144 | "convertFrom": [
145 | "1.21",
146 | "1.20",
147 | "1.19"
148 | ]
149 | },
150 | {
151 | "gameVersions": "[1.21.5,1.21.5]",
152 | "packFormat": 55,
153 | "convertFrom": [
154 | "1.21",
155 | "1.20",
156 | "1.19"
157 | ]
158 | }
159 | ],
160 | "assets": [
161 | {
162 | "targetVersion": "1.10.2",
163 | "loader": "Forge",
164 | "filename": "Minecraft-Mod-Language-Modpack-1-10-2.zip",
165 | "md5Filename": "1.10.2.md5"
166 | },
167 | {
168 | "targetVersion": "1.12.2",
169 | "loader": "Forge",
170 | "filename": "Minecraft-Mod-Language-Modpack.zip",
171 | "md5Filename": "1.12.2.md5"
172 | },
173 | {
174 | "targetVersion": "1.16",
175 | "loader": "Forge",
176 | "filename": "Minecraft-Mod-Language-Modpack-1-16.zip",
177 | "md5Filename": "1.16.md5"
178 | },
179 | {
180 | "targetVersion": "1.16",
181 | "loader": "Fabric",
182 | "filename": "Minecraft-Mod-Language-Modpack-1-16-Fabric.zip",
183 | "md5Filename": "1.16-fabric.md5"
184 | },
185 | {
186 | "targetVersion": "1.18",
187 | "loader": "Forge",
188 | "filename": "Minecraft-Mod-Language-Modpack-1-18.zip",
189 | "md5Filename": "1.18.md5"
190 | },
191 | {
192 | "targetVersion": "1.18",
193 | "loader": "Fabric",
194 | "filename": "Minecraft-Mod-Language-Modpack-1-18-Fabric.zip",
195 | "md5Filename": "1.18-fabric.md5"
196 | },
197 | {
198 | "targetVersion": "1.19",
199 | "loader": "Forge",
200 | "filename": "Minecraft-Mod-Language-Modpack-1-19.zip",
201 | "md5Filename": "1.19.md5"
202 | },
203 | {
204 | "targetVersion": "1.20",
205 | "loader": "Forge",
206 | "filename": "Minecraft-Mod-Language-Modpack-1-20.zip",
207 | "md5Filename": "1.20.md5"
208 | },
209 | {
210 | "targetVersion": "1.20",
211 | "loader": "Fabric",
212 | "filename": "Minecraft-Mod-Language-Modpack-1-20-Fabric.zip",
213 | "md5Filename": "1.20-fabric.md5"
214 | },
215 | {
216 | "targetVersion": "1.21",
217 | "loader": "Forge",
218 | "filename": "Minecraft-Mod-Language-Modpack-1-21.zip",
219 | "md5Filename": "1.21.md5"
220 | },
221 | {
222 | "targetVersion": "1.21",
223 | "loader": "Fabric",
224 | "filename": "Minecraft-Mod-Language-Modpack-1-21-Fabric.zip",
225 | "md5Filename": "1.21-fabric.md5"
226 | }
227 | ]
228 | }
--------------------------------------------------------------------------------