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

CyclopsMC / CommonCapabilities / #479006705

21 Mar 2024 03:43PM UTC coverage: 39.629% (-0.3%) from 39.919%
#479006705

push

github

rubensworks
Fix failing unit tests

877 of 2213 relevant lines covered (39.63%)

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.neoforged.bus.api.SubscribeEvent;
5
import net.neoforged.fml.config.ModConfig;
6
import net.neoforged.fml.event.config.ModConfigEvent;
7
import org.apache.logging.log4j.Level;
8
import org.cyclops.commoncapabilities.api.capability.itemhandler.ItemMatch;
9
import org.cyclops.commoncapabilities.ingredient.TagComparator;
10
import org.cyclops.cyclopscore.config.ConfigurableProperty;
11
import org.cyclops.cyclopscore.config.extendedconfig.DummyConfig;
12
import org.cyclops.cyclopscore.init.ModBase;
13
import org.cyclops.cyclopscore.nbt.path.NbtParseException;
14
import org.cyclops.cyclopscore.nbt.path.NbtPath;
15
import org.cyclops.cyclopscore.nbt.path.navigate.INbtPathNavigation;
16
import org.cyclops.cyclopscore.nbt.path.navigate.NbtPathNavigationList;
17
import org.cyclops.cyclopscore.tracking.Analytics;
18
import org.cyclops.cyclopscore.tracking.Versions;
19

20
import java.util.List;
21

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

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

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

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

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

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

48
    public GeneralConfig() {
49
        super(CommonCapabilities._instance, "general");
×
50
        CommonCapabilities._instance.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

© 2026 Coveralls, Inc