diff options
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/internal')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java | 25 | ||||
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/internal/utils/Deprecator.java | 64 |
2 files changed, 79 insertions, 10 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java index bc0e3a9..874abd2 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java @@ -35,10 +35,17 @@ import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.utils.TickDelay; public class Preferences extends InternalConfig { + + @Dropdown( + name = "Release Channel", + options = {"Releases", "Pre-Releases"} + ) + public static int updateChannel = 0; + @Switch( - name = "Enable Blur" + name = "Debug Mode" ) - public static boolean enableBlur = true; + public static boolean DEBUG = false; @KeyBind( name = "OneConfig Keybind", @@ -46,23 +53,21 @@ public class Preferences extends InternalConfig { ) public static OneKeyBind oneConfigKeyBind = new OneKeyBind(UKeyboard.KEY_RSHIFT); - @Dropdown( - name = "Release Channel", - options = {"Releases", "Pre-Releases"}, - size = 2 + @Switch( + name = "Enable Blur", + subcategory = "GUI Settings" ) - public static int updateChannel = 0; + public static boolean enableBlur = true; @Switch( name = "Use custom GUI scale", - subcategory = "GUI Scale", - size = 2 + subcategory = "GUI Settings" ) public static boolean enableCustomScale = false; @Slider( name = "Custom GUI scale", - subcategory = "GUI Scale", + subcategory = "GUI Settings", min = 0.5f, max = 5f ) diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/utils/Deprecator.java b/src/main/java/cc/polyfrost/oneconfig/internal/utils/Deprecator.java new file mode 100644 index 0000000..e8d048c --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/internal/utils/Deprecator.java @@ -0,0 +1,64 @@ +/* + * This file is part of OneConfig. + * OneConfig - Next Generation Config Library for Minecraft: Java Edition + * Copyright (C) 2021, 2022 Polyfrost. + * <https://polyfrost.cc> <https://github.com/Polyfrost/> + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * OneConfig is licensed under the terms of version 3 of the GNU Lesser + * General Public License as published by the Free Software Foundation, AND + * under the Additional Terms Applicable to OneConfig, as published by Polyfrost, + * either version 1.0 of the Additional Terms, 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License. If not, see <https://www.gnu.org/licenses/>. You should + * have also received a copy of the Additional Terms Applicable + * to OneConfig, as published by Polyfrost. If not, see + * <https://polyfrost.cc/legal/oneconfig/additional-terms> + */ + +package cc.polyfrost.oneconfig.internal.utils; + +import cc.polyfrost.oneconfig.utils.LogScanner; +import cc.polyfrost.oneconfig.utils.Notifications; + +import java.util.ArrayList; +import java.util.List; + +/** + * Class used by OneConfig for deprecation related utilities. + */ +public final class Deprecator { + private static final List<String> warned = new ArrayList<>(); + + /** + * mark a method as deprecated. When a method has this call, it will + * throw a new exception to grab the name (or package) of the mod that called said method. <br> + * This will then send a notification detailing this to the user, and throw an UnsupportedOperationException to print a stack to the log. + */ + public static void markDeprecated() { + try { + throw new Exception("This method is deprecated"); + } catch (Exception e) { + String culprit = LogScanner.identifyCallerFromStacktrace(e).stream().map(activeMod -> activeMod.name).findFirst().orElse("Unknown"); + // sometimes it blames OneConfig as well so + if(culprit.equals("OneConfig")) return; + if (!warned.contains(culprit)) { + warned.add(culprit); + Notifications.INSTANCE.send("Deprecation Warning", "The mod '" + culprit + "' is using a deprecated method, and will no longer work in the future. Please report this to the mod author."); + try { + throw new UnsupportedOperationException("Method " + e.getStackTrace()[1].getClassName() + "." + e.getStackTrace()[1].getMethodName() + "() is deprecated; but is still being used by mod " + culprit + "!"); + } catch (UnsupportedOperationException e1) { + e1.printStackTrace(); + } + } + } + } +} |