Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions HMCL/src/main/java/org/jackhuang/hmcl/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@
import org.jackhuang.hmcl.setting.ConfigHolder;
import org.jackhuang.hmcl.setting.SambaException;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.util.FileSaver;
import org.jackhuang.hmcl.util.*;
import org.jackhuang.hmcl.task.AsyncTaskExecutor;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.upgrade.UpdateChecker;
import org.jackhuang.hmcl.upgrade.UpdateHandler;
import org.jackhuang.hmcl.util.CrashReporter;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.io.JarUtils;
import org.jackhuang.hmcl.util.platform.Architecture;
import org.jackhuang.hmcl.util.platform.CommandBuilder;
Expand Down
15 changes: 15 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,21 @@ public void setDisableAutoShowUpdateDialog(boolean disableAutoShowUpdateDialog)
this.disableAutoShowUpdateDialog.set(disableAutoShowUpdateDialog);
}

@SerializedName("disableAprilFools")
private final BooleanProperty disableAprilFools = new SimpleBooleanProperty(false);

public BooleanProperty disableAprilFoolsProperty() {
return disableAprilFools;
}

public boolean isDisableAprilFools() {
return disableAprilFools.get();
}

public void setDisableAprilFools(boolean disableAprilFools) {
this.disableAprilFools.set(disableAprilFools);
}

@SerializedName("shownTips")
private final ObservableMap<String, Object> shownTips = FXCollections.observableHashMap();

Expand Down
2 changes: 2 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ public static void onApplicationStop() {
public static void initialize(Stage stage) {
LOG.info("Start initializing application");

LOG.info("April Fools: " + AprilFools.isEnabled());

if (System.getProperty("prism.lcdtext") == null) {
String fontAntiAliasing = globalConfig().getFontAntiAliasing();
if ("lcd".equalsIgnoreCase(fontAntiAliasing)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.jackhuang.hmcl.upgrade.UpdateChannel;
import org.jackhuang.hmcl.upgrade.UpdateChecker;
import org.jackhuang.hmcl.upgrade.UpdateHandler;
import org.jackhuang.hmcl.util.AprilFools;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.i18n.I18n;
import org.jackhuang.hmcl.util.i18n.SupportedLocale;
Expand Down Expand Up @@ -224,6 +225,14 @@ public SettingsPage() {
settingsPane.getContent().add(disableAutoShowUpdateDialogPane);
}

if (AprilFools.isStartInAprilFoolsDay()) {
LineToggleButton disableAprilFools = new LineToggleButton();
disableAprilFools.setTitle("不启用愚人节功能");
// disableAprilFools.setSubtitle("在愚人节当天,HMCL会自动启动一个特殊的版本,以庆祝愚人节。");
disableAprilFools.selectedProperty().bindBidirectional(config().disableAprilFoolsProperty());
settingsPane.getContent().add(disableAprilFools);
}

{
MultiFileItem<EnumCommonDirectory> fileCommonLocation = new MultiFileItem<>();
fileCommonLocation.loadChildren(Arrays.asList(
Expand Down
54 changes: 54 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/util/AprilFools.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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.setting.ConfigHolder;

import java.time.LocalDate;
import java.time.Month;

public final class AprilFools {

private static final boolean START_IN_APRIL_FOOLS_DAY;
private static final boolean ENABLED;

static {
var date = LocalDate.now();
START_IN_APRIL_FOOLS_DAY = date.getMonth() == Month.APRIL && date.getDayOfMonth() == 1;

String value = System.getProperty("hmcl.april_fools", System.getenv("HMCL_APRIL_FOOLS"));
if ("true".equalsIgnoreCase(value)) {
ENABLED = true;
} else if ("false".equalsIgnoreCase(value) || ConfigHolder.config().isDisableAprilFools()) {
ENABLED = false;
} else {
ENABLED = START_IN_APRIL_FOOLS_DAY;
}
}

public static boolean isStartInAprilFoolsDay() {
return START_IN_APRIL_FOOLS_DAY;
}

public static boolean isEnabled() {
return ENABLED;
}

private AprilFools() {
}
}
Loading