From dc7b8d8ca6e1b14aa89d218410fb96a9cb868d71 Mon Sep 17 00:00:00 2001 From: AnimeGitB Date: Sat, 5 Nov 2022 14:22:17 +1030 Subject: [PATCH] Add warnings to ancient deprecated Banners.json fields Will probably turn these into runtime errors in 1.5.0, people need to stop sharing configs with dead fields and especially stop making PRs with them. --- .../grasscutter/game/gacha/GachaBanner.java | 40 ++++++++++++++++--- .../grasscutter/game/gacha/GachaSystem.java | 1 + 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java index 83dc1fc7e..7afb82cf0 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java @@ -2,6 +2,7 @@ package emu.grasscutter.game.gacha; import static emu.grasscutter.config.Configuration.*; +import emu.grasscutter.Grasscutter; import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.game.player.Player; import emu.grasscutter.net.proto.GachaInfoOuterClass.GachaInfo; @@ -39,14 +40,41 @@ public class GachaBanner { private int eventChance4 = 50; // Chance to win a featured event item private int eventChance5 = 50; // Chance to win a featured event item @Getter private BannerType bannerType = BannerType.STANDARD; - - // Kinda wanna deprecate these but they're in people's configs - private int[] rateUpItems1 = {}; - private int[] rateUpItems2 = {}; - private int eventChance = -1; - private int costItem = 0; @Getter private int wishMaxProgress = 2; + // Deprecated fields that were tolerated in early May 2022 but have apparently still being circulating in new custom configs + // For now, throw up big scary errors on load telling people that they will be banned outright in a future version + @Deprecated private int[] rateUpItems1 = {}; + @Deprecated private int[] rateUpItems2 = {}; + @Deprecated private int eventChance = -1; + @Deprecated private int costItem = 0; + @Deprecated private int softPity = -1; + @Deprecated private int hardPity = -1; + @Deprecated private int minItemType = -1; + @Deprecated private int maxItemType = -1; + + private static void warnDeprecated(String name, String replacement) { + Grasscutter.getLogger().error("Deprecated field found in Banners.json: "+name+" was replaced back in early May 2022, use "+replacement+" instead. If you do not remove this key from your config, it will refuse to load in a future Grasscutter version."); + } + public void onLoad() { + if (eventChance != -1) + warnDeprecated("eventChance", "eventChance4 & eventChance5"); + if (costItem != 0) + warnDeprecated("costItem", "costItemId"); + if (softPity != -1) + warnDeprecated("softPity", "weights5"); + if (hardPity != -1) + warnDeprecated("hardPity", "weights5"); + if (minItemType != -1) + warnDeprecated("minItemType", "fallbackItems[4,5]Pool[1,2]"); + if (maxItemType != -1) + warnDeprecated("maxItemType", "fallbackItems[4,5]Pool[1,2]"); + if (rateUpItems1.length > 0) + warnDeprecated("rateUpItems1", "rateUpItems5"); + if (rateUpItems2.length > 0) + warnDeprecated("rateUpItems2", "rateUpItems4"); + } + public String getPreviewPrefabPath() { if (this.previewPrefabPath != null && !this.previewPrefabPath.isEmpty()) return this.previewPrefabPath; diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java b/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java index 6456d4647..a71caf875 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java @@ -73,6 +73,7 @@ public class GachaSystem extends BaseGameSystem { List banners = DataLoader.loadList("Banners.json", GachaBanner.class); if (banners.size() > 0) { for (GachaBanner banner : banners) { + banner.onLoad(); getGachaBanners().put(banner.getScheduleId(), banner); } Grasscutter.getLogger().debug("Banners successfully loaded.");