• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyclopsMC / CommonCapabilities / #479006808

15 Aug 2025 06:35AM UTC coverage: 39.826%. Remained the same
#479006808

push

github

rubensworks
Bump mod version

914 of 2295 relevant lines covered (39.83%)

0.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/org/cyclops/commoncapabilities/GeneralConfig.java
1
package org.cyclops.commoncapabilities;
2

3
import com.google.common.collect.Lists;
4
import net.minecraftforge.eventbus.api.SubscribeEvent;
5
import net.minecraftforge.fml.config.ModConfig;
6
import net.minecraftforge.fml.event.config.ModConfigEvent;
7
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
8
import org.apache.logging.log4j.Level;
9
import org.cyclops.commoncapabilities.api.capability.itemhandler.ItemMatch;
10
import org.cyclops.commoncapabilities.ingredient.TagComparator;
11
import org.cyclops.cyclopscore.config.ConfigurableProperty;
12
import org.cyclops.cyclopscore.config.extendedconfig.DummyConfig;
13
import org.cyclops.cyclopscore.init.ModBase;
14
import org.cyclops.cyclopscore.nbt.path.NbtParseException;
15
import org.cyclops.cyclopscore.nbt.path.NbtPath;
16
import org.cyclops.cyclopscore.nbt.path.navigate.INbtPathNavigation;
17
import org.cyclops.cyclopscore.nbt.path.navigate.NbtPathNavigationList;
18
import org.cyclops.cyclopscore.tracking.Analytics;
19
import org.cyclops.cyclopscore.tracking.Versions;
20

21
import java.util.List;
22

23
/**
24
 * A config with general options for this mod.
25
 * @author rubensworks
26
 *
27
 */
28
public class GeneralConfig extends DummyConfig {
29

30
    @ConfigurableProperty(category = "core", comment = "If the recipe loader should crash when finding invalid recipes.", requiresMcRestart = true, configLocation = ModConfig.Type.SERVER)
31
    public static boolean crashOnInvalidRecipe = false;
×
32

33
    @ConfigurableProperty(category = "core", comment = "If mod compatibility loader should crash hard if errors occur in that process.", requiresMcRestart = true, configLocation = ModConfig.Type.SERVER)
34
    public static boolean crashOnModCompatCrash = false;
×
35

36
    @ConfigurableProperty(category = "core", comment = "If an anonymous mod startup analytics request may be sent to our analytics service.")
37
    public static boolean analytics = true;
×
38

39
    @ConfigurableProperty(category = "core", comment = "If the version checker should be enabled.")
40
    public static boolean versionChecker = true;
×
41

42
    @ConfigurableProperty(category = "machine", comment = "The NBT Paths that should be filtered away when checking equality.", configLocation = ModConfig.Type.SERVER)
43
    public static List<String> ignoreNbtPathsForEqualityFilters = Lists.newArrayList(
×
44
            "$.ForgeCaps[\"astralsorcery:cap_item_amulet_holder\"]", // Astral Sorcery
45
            "$.binding" // Blood Magic Blood Orb player bindings
46
    );
47

48
    public GeneralConfig() {
49
        super(CommonCapabilities._instance, "general");
×
50
        FMLJavaModLoadingContext.get().getModEventBus().register(this);
×
51
    }
×
52

53
    @Override
54
    public void onRegistered() {
55
        getMod().putGenericReference(ModBase.REFKEY_CRASH_ON_INVALID_RECIPE, GeneralConfig.crashOnInvalidRecipe);
×
56
        getMod().putGenericReference(ModBase.REFKEY_CRASH_ON_MODCOMPAT_CRASH, GeneralConfig.crashOnModCompatCrash);
×
57

58
        if(analytics) {
×
59
            Analytics.registerMod(getMod(), Reference.GA_TRACKING_ID);
×
60
        }
61
        if(versionChecker) {
×
62
            Versions.registerMod(getMod(), CommonCapabilities._instance, Reference.VERSION_URL);
×
63
        }
64
    }
×
65

66
    @SubscribeEvent
67
    public void onConfigLoad(ModConfigEvent.Loading event) {
68
        updateNbtComparator();
×
69
    }
×
70

71
    @SubscribeEvent
72
    public void onConfigReload(ModConfigEvent.Reloading event) {
73
        updateNbtComparator();
×
74
    }
×
75

76
    protected void updateNbtComparator() {
77
        List<INbtPathNavigation> navigations = Lists.newArrayList();
×
78
        for (String path : ignoreNbtPathsForEqualityFilters) {
×
79
            try {
80
                navigations.add(NbtPath.parse(path).asNavigation());
×
81
            } catch (NbtParseException e) {
×
82
                CommonCapabilities.clog(Level.ERROR, String.format("Failed to parse NBT path to filter: %s", path));
×
83
            }
×
84
        }
×
85
        ItemMatch.TAG_COMPARATOR = TagComparator.INSTANCE = new TagComparator(new NbtPathNavigationList(navigations));
×
86
    }
×
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc