From 50474bf8945035854913d1efe9c31d17dcb76097 Mon Sep 17 00:00:00 2001 From: Micle Date: Sun, 9 Jan 2022 19:25:43 +0000 Subject: [PATCH] Started implementing config files for totems. --- .../micle/totemofreviving/config/Config.java | 69 ++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/micle/totemofreviving/config/Config.java b/src/main/java/dev/micle/totemofreviving/config/Config.java index ad698f9..d1fbb38 100644 --- a/src/main/java/dev/micle/totemofreviving/config/Config.java +++ b/src/main/java/dev/micle/totemofreviving/config/Config.java @@ -4,6 +4,8 @@ import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.config.ModConfig; +import java.util.HashMap; + public final class Config { public static void init() { ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Common.spec); @@ -29,12 +31,75 @@ public final class Config { } } - public static final class Server { - static ForgeConfigSpec spec = null; + public final class Server { + static ForgeConfigSpec spec; + + public static final HashMap TOTEM_CONFIGS = new HashMap<>(); Server() { ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder(); + /* + Straw Totem + Iron Totem + Diamond Totem + + Coal Totem + Lapis Totem + Gold Totem + Redstone Totem + Emerald Totem + Quartz Totem + Prismarine Totem + Glowstone Totem + Netherite Totem + */ + TOTEM_CONFIGS.put("Straw Totem", new TotemConfig("Straw Totem", builder, + true, -1, 3, 1, false, 3)); + TOTEM_CONFIGS.put("Iron Totem", new TotemConfig("Iron Totem", builder, + true, -1, 6, 0.75, false, 10)); + TOTEM_CONFIGS.put("Diamond Totem", new TotemConfig("Diamond Totem", builder, + true, -1, 0, 0.5, false, 50)); + spec = builder.build(); } + + public class TotemConfig { + public final String NAME; + public final ForgeConfigSpec.BooleanValue IS_ENABLED; + public final ForgeConfigSpec.IntValue CHARGE_COST; + public final ForgeConfigSpec.IntValue CHARGE_COST_LIMIT; + public final ForgeConfigSpec.DoubleValue CHARGE_COST_MULTIPLIER; + public final ForgeConfigSpec.BooleanValue CAN_REVIVE_MORE_EXPENSIVE_TARGETS; + public final ForgeConfigSpec.IntValue DURABILITY; + + TotemConfig(String totemName, ForgeConfigSpec.Builder builder, boolean isEnabled, int chargeCost, int chargeCostLimit, + double chargeCostMultiplier, boolean canReviveMoreExpensiveTargets, int durability) { + NAME = totemName; + builder.push(NAME); + IS_ENABLED = builder + .comment("Is the " + NAME + " enabled?") + .define("isEnabled", isEnabled); + CHARGE_COST = builder + .comment("The charge cost to revive a player.\n" + + "-1 means the cost is dynamic (follows the amount of deaths the target has)\n" + + "Higher values set the charge cost to static, meaning that this will be the amount of charges needed to revive someone.") + .defineInRange("chargeCost", chargeCost, -1, Integer.MAX_VALUE); + CHARGE_COST_LIMIT = builder + .comment("The max amount of charge this totem can hold at once.\n" + + "0 means unlimited. Only works with dynamic cost.") + .defineInRange("chargeCostLimit", chargeCostLimit, 0, Integer.MAX_VALUE); + CHARGE_COST_MULTIPLIER = builder + .comment("Charge cost multiplier. 0.5 means the charge cost will be 50% of the original cost. Only works with dynamic cost.") + .defineInRange("chargeCostMultiplier", chargeCostMultiplier, 0.01, Integer.MAX_VALUE); + CAN_REVIVE_MORE_EXPENSIVE_TARGETS = builder + .comment("Is the totem able to revive targets that cost more than the totems max charge?\n" + + "This only applies if the totem is fully charged. (dynamic wont work if limit is 0)") + .define("canReviveMoreExpensiveTargets", canReviveMoreExpensiveTargets); + DURABILITY = builder + .comment("The durability of the totem. 0 means unbreakable.") + .defineInRange("durability", durability, 0, Integer.MAX_VALUE); + builder.pop(); + } + } } }