-
Notifications
You must be signed in to change notification settings - Fork 846
支持愚人节模式 #5791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
支持愚人节模式 #5791
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
e92a02c
Add April Fools feature logging
Glavo 19a9071
Add April Fools disable setting
Glavo 02d6692
Refactor AprilFools to add getter methods
Glavo 2a2d003
update
Glavo 97f82d9
Add near April Fools' Day detection
Glavo 26a12b9
i18n: Add April Fools disable setting strings
Glavo d798606
Apply April Fools rotation to title when enabled
Glavo 8fba9d7
Refactor April Fools config check priority
Glavo 9228cec
Refactor April Fools settings visibility logic
Glavo c544b19
Rename aprilMode variable to aprilFoolsMode
Glavo fa7a39a
i18n: Fix Traditional Chinese text in April Fools setting
Glavo d0a8857
Add regional whitelist for April Fools support
Glavo 8b160e3
Remove unused Set import from AprilFools
Glavo d77e682
Update regional whitelist for April Fools
Glavo 266b912
Add April Fools language switch dialog
Glavo 0bc3084
i18n: Externalize April Fools dialog strings
Glavo cb93893
Remove unused Locale import from Controllers
Glavo 6ec6871
Wait for file saves before application exit
Glavo aa40158
Merge remote-tracking branch 'upstream/main' into april-fools
Glavo d7137a9
Fix file save completion check in waitForAllSaves
Glavo ec2f0cf
Clarify shutdown hook behavior in FileSaver
Glavo ad989af
Add application restart capability
Glavo f4a720f
i18n: Update April Fools dialog text
Glavo 7cd5d16
i18n: Simplify Classical Chinese language label
Glavo 67cc924
i18n: Refine April Fools dialog wording
Glavo 3d39ce8
Simplify April Fools dialog confirmation flow
Glavo 2938e64
Remove AprilFools check from title rotation
Glavo 85b6049
Refactor FileSaver queue to use sealed Action interface
Glavo db7a18f
i18n: Fix Classical Chinese language label text
Glavo 62b174e
Refactor FileSaver waitForAllSaves with CountDownLatch
Glavo 94c26db
Convert FileSaver javadoc to line comment
Glavo b695a99
Clarify FileSaver waitForAllSaves javadoc
Glavo fb8befd
Replace wildcard import with explicit util imports
Glavo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
HMCL/src/main/java/org/jackhuang/hmcl/util/AprilFools.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * Hello Minecraft! Launcher | ||
| * Copyright (C) 2026 huangyuhui <huanghongxun2008@126.com> and contributors | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
| package org.jackhuang.hmcl.util; | ||
|
|
||
| import org.jackhuang.hmcl.util.i18n.LocaleUtils; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.Month; | ||
| import java.util.List; | ||
|
|
||
| import static org.jackhuang.hmcl.setting.ConfigHolder.config; | ||
Glavo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// April Fools' Day utilities. | ||
| /// | ||
| /// This class provides methods to check if it is April Fools' Day or near April Fools' Day. | ||
| /// It also provides a method to check if April Fools is enabled. | ||
| /// | ||
| /// @author Glavo | ||
| public final class AprilFools { | ||
|
|
||
| private static final boolean ENABLED; | ||
| private static final boolean SHOW_APRIL_FOOLS_SETTINGS; | ||
|
|
||
| static { | ||
| var date = LocalDate.now(); | ||
|
|
||
| // Some countries/regions may oppose April Fools' Day for various reasons. | ||
| // Therefore, we use a regional whitelist to avoid risks. | ||
| // Currently, we have only listed a limited set of countries/regions for testing. | ||
| // We will investigate more countries/regions in the future to expand this list. | ||
| boolean supportedRegion = List.of( | ||
| "CN", "TW", "HK", "MO", "JP", "KR", "VN", "SG", "MY", | ||
| "ES", "DE", "FR", "GB", "RU", "UA", "US" | ||
| ).contains(LocaleUtils.SYSTEM_DEFAULT.getCountry()); | ||
|
|
||
| boolean aprilFoolsMode; | ||
| String value = System.getProperty("hmcl.april_fools", System.getenv("HMCL_APRIL_FOOLS")); | ||
| if ("true".equalsIgnoreCase(value)) | ||
Glavo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| aprilFoolsMode = true; | ||
| else if ("false".equalsIgnoreCase(value) || !supportedRegion) | ||
| aprilFoolsMode = false; | ||
| else | ||
| aprilFoolsMode = date.getMonth() == Month.APRIL && date.getDayOfMonth() == 1; | ||
|
|
||
| ENABLED = aprilFoolsMode && !config().isDisableAprilFools(); | ||
| SHOW_APRIL_FOOLS_SETTINGS = aprilFoolsMode || supportedRegion && date.getMonth() == Month.MARCH && date.getDayOfMonth() > 30; | ||
|
|
||
| } | ||
|
|
||
|
Comment on lines
+51
to
+63
|
||
| /// Whether April Fools settings should be shown. | ||
| /// | ||
| /// This method returns true if April Fools settings should be shown. | ||
| public static boolean isShowAprilFoolsSettings() { | ||
| return SHOW_APRIL_FOOLS_SETTINGS; | ||
| } | ||
|
|
||
| /// Whether April Fools is enabled. | ||
| /// | ||
| /// This method returns true if April Fools is enabled. | ||
| public static boolean isEnabled() { | ||
| return ENABLED; | ||
| } | ||
|
|
||
Glavo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private AprilFools() { | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.