diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/countly/Countly.java b/HMCL/src/main/java/org/jackhuang/hmcl/countly/Countly.java deleted file mode 100644 index f18b196859..0000000000 --- a/HMCL/src/main/java/org/jackhuang/hmcl/countly/Countly.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Hello Minecraft! Launcher - * Copyright (C) 2020 huangyuhui 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 . - */ -package org.jackhuang.hmcl.countly; - -import org.jackhuang.hmcl.util.io.HttpRequest; - -import java.io.IOException; -import java.time.ZonedDateTime; -import java.util.Calendar; -import java.util.Locale; - -import static org.jackhuang.hmcl.util.Pair.pair; - -public class Countly { - - private String deviceId; - private String endpoint; - private String serverURL; - - public void sendMetric(String metrics) throws IOException { - HttpRequest.GET(serverURL + endpoint, - pair("begin_session", "1"), - pair("session_id", "1"), - pair("metrics", metrics), - pair("device_id", deviceId), - pair("timestamp", Long.toString(System.currentTimeMillis())), - pair("tz", Integer.toString(getTimezoneOffset())), - pair("hour", Integer.toString(currentHour())), - pair("dow", Integer.toString(currentDayOfWeek())), - pair("app_key", APP_KEY), - pair("sdk_name", "java-native"), - pair("sdk_version", "20.11.1")) - .getString(); - } - - private static int getTimezoneOffset() { - return ZonedDateTime.now().getOffset().getTotalSeconds() / 60; - } - - private static String getLocale() { - final Locale locale = Locale.getDefault(); - return locale.getLanguage() + "_" + locale.getCountry(); - } - - private static int currentHour() { - return Calendar.getInstance().get(Calendar.HOUR_OF_DAY); - } - - private int currentDayOfWeek() { - int day = Calendar.getInstance().get(Calendar.DAY_OF_WEEK); - switch (day) { - case Calendar.SUNDAY: - return 0; - case Calendar.MONDAY: - return 1; - case Calendar.TUESDAY: - return 2; - case Calendar.WEDNESDAY: - return 3; - case Calendar.THURSDAY: - return 4; - case Calendar.FRIDAY: - return 5; - case Calendar.SATURDAY: - return 6; - } - return 0; - } - - private static final String APP_KEY = ""; -} diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/countly/CrashReport.java b/HMCL/src/main/java/org/jackhuang/hmcl/countly/CrashReport.java index a18d405f7a..6c3847e587 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/countly/CrashReport.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/countly/CrashReport.java @@ -5,14 +5,8 @@ import org.jackhuang.hmcl.util.platform.Architecture; import org.jackhuang.hmcl.util.platform.OperatingSystem; -import java.io.File; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.Map; - -import static org.jackhuang.hmcl.util.Lang.mapOf; -import static org.jackhuang.hmcl.util.Pair.pair; -import static org.jackhuang.hmcl.util.logging.Logger.LOG; public class CrashReport { @@ -20,24 +14,16 @@ public class CrashReport { private final Throwable throwable; private final String stackTrace; - private boolean nonFatal; - public CrashReport(Thread thread, Throwable throwable) { this.thread = thread; this.throwable = throwable; stackTrace = StringUtils.getStackTrace(throwable); - nonFatal = false; } public Throwable getThrowable() { return this.throwable; } - public CrashReport setNonFatal() { - nonFatal = true; - return this; - } - public boolean shouldBeReport() { if (!stackTrace.contains("org.jackhuang")) return false; @@ -48,23 +34,6 @@ public boolean shouldBeReport() { return true; } - public Map getMetrics(long runningTime) { - return mapOf( - pair("_run", runningTime), - pair("_app_version", Metadata.VERSION), - pair("_os", OperatingSystem.SYSTEM_NAME), - pair("_os_version", OperatingSystem.SYSTEM_VERSION), - pair("_disk_current", getDiskAvailable()), - pair("_disk_total", getDiskTotal()), - pair("_ram_current", getMemoryAvailable()), - pair("_ram_total", Runtime.getRuntime().maxMemory() / BYTES_IN_MB), - pair("_error", stackTrace), - pair("_logs", LOG.getLogs()), - pair("_name", throwable.getLocalizedMessage()), - pair("_nonfatal", nonFatal) - ); - } - public String getDisplayText() { return "---- Hello Minecraft! Crash Report ----\n" + " Version: " + Metadata.VERSION + "\n" + @@ -82,29 +51,4 @@ public String getDisplayText() { " JVM Total Memory: " + Runtime.getRuntime().totalMemory() + "\n" + " JVM Free Memory: " + Runtime.getRuntime().freeMemory() + "\n"; } - - private static final Long BYTES_IN_MB = 1024L * 1024; - - private static long getMemoryAvailable() { - Long total = Runtime.getRuntime().totalMemory(); - Long availMem = Runtime.getRuntime().freeMemory(); - return (total - availMem) / BYTES_IN_MB; - } - - private static long getDiskAvailable() { - long total = 0, free = 0; - for (File f : File.listRoots()) { - total += f.getTotalSpace(); - free += f.getUsableSpace(); - } - return (total - free) / BYTES_IN_MB; - } - - private static long getDiskTotal() { - long total = 0; - for (File f : File.listRoots()) { - total += f.getTotalSpace(); - } - return total / BYTES_IN_MB; - } } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/game/LoadingState.java b/HMCL/src/main/java/org/jackhuang/hmcl/game/LoadingState.java deleted file mode 100644 index 6b434a9b59..0000000000 --- a/HMCL/src/main/java/org/jackhuang/hmcl/game/LoadingState.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Hello Minecraft! Launcher - * Copyright (C) 2020 huangyuhui 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 . - */ -package org.jackhuang.hmcl.game; - -import static org.jackhuang.hmcl.util.i18n.I18n.i18n; - -public enum LoadingState { - DEPENDENCIES("launch.state.dependencies"), - MODS("launch.state.modpack"), - LOGGING_IN("launch.state.logging_in"), - LAUNCHING("launch.state.waiting_launching"), - DONE("launch.state.done"); - - private final String key; - - LoadingState(String key) { - this.key = key; - } - - public String getLocalizedMessage() { - return i18n(key); - } -}