aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/galacticgreg/auxiliary/GalacticGregConfig.java
blob: 39980925a18c447ddb676bbdfb74d2aaf81e359f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package galacticgreg.auxiliary;

import java.io.File;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;

import cpw.mods.fml.common.registry.GameRegistry;
import galacticgreg.GalacticGreg;
import galacticgreg.api.BlockMetaComb;

public class GalacticGregConfig extends ConfigManager {

    public GalacticGregConfig(File pConfigBaseDirectory, String pModCollectionDirectory, String pModID) {
        super(pConfigBaseDirectory, pModCollectionDirectory, pModID);

    }

    public boolean ProfileOreGen;
    public boolean ReportOreGenFailures;
    public boolean PrintDebugMessagesToFMLLog;
    public boolean PrintTraceMessagesToFMLLog;

    public boolean LootChestsEnabled;
    public boolean EnableAEExportCommand;
    public boolean SchematicsEnabled;
    public String LootChestItemOverride;
    public boolean QuietMode;

    public BlockMetaComb CustomLootChest;

    @Override
    protected void PreInit() {
        ProfileOreGen = false;
        ReportOreGenFailures = false;
        PrintDebugMessagesToFMLLog = false;
        PrintTraceMessagesToFMLLog = false;

        LootChestsEnabled = true;

        // Default false, as it is WiP
        EnableAEExportCommand = false;
        SchematicsEnabled = false;

        LootChestItemOverride = "";
        QuietMode = false;
    }

    @Override
    protected void Init() {
        ProfileOreGen = _mainConfig.getBoolean(
            "ProfileOreGen",
            "Debug",
            ProfileOreGen,
            "Enable to profile oregen and register the ingame command ggregprofiler");
        ReportOreGenFailures = _mainConfig.getBoolean(
            "ReportOreGenFailures",
            "Debug",
            ReportOreGenFailures,
            "Report if a ore tileentity could not be placed");
        PrintDebugMessagesToFMLLog = _mainConfig.getBoolean(
            "PrintDebugMessagesToFMLLog",
            "Debug",
            PrintDebugMessagesToFMLLog,
            "Enable debug output, not recommended for servers");
        PrintTraceMessagesToFMLLog = _mainConfig.getBoolean(
            "PrintTraceMessagesToFMLLog",
            "Debug",
            PrintTraceMessagesToFMLLog,
            "Enable trace output. Warning: This will produce gazillions of log entries");
        QuietMode = _mainConfig.getBoolean(
            "QuietMode",
            "Debug",
            QuietMode,
            "In quiet-mode only errors, warnings and fatals will be printed to the logfile/console");

        LootChestsEnabled = _mainConfig.getBoolean(
            "LootChestsEnabled",
            "Extras",
            LootChestsEnabled,
            "Enables/disables the dungeon-chest generator system for asteroids. New config values will be generated if set to true");
        EnableAEExportCommand = _mainConfig.getBoolean(
            "EnableAEExportCommand",
            "Extras",
            EnableAEExportCommand,
            "If set to true, you can export any structure stored on a AE2 spatial storage disk. (Can't be spawned yet, WiP). Requires SchematicsEnabled to be true");
        SchematicsEnabled = _mainConfig.getBoolean(
            "SchematicsEnabled",
            "Extras",
            SchematicsEnabled,
            "Enable the experimental Schematics-handler to spawn exported schematics in dimensions. This is WiP, use at own risk");
        LootChestItemOverride = _mainConfig.getString(
            "CustomLootChest",
            "Extras",
            LootChestItemOverride,
            "Define the chest you wish to use as LootChest. use the <ModID>:<Name>:<meta> format or leave empty for the default Minecraft Chest");

        GalacticGreg.Logger.setDebugOutput(PrintDebugMessagesToFMLLog);
        GalacticGreg.Logger.setTraceOutput(PrintTraceMessagesToFMLLog);
        GalacticGreg.Logger.setQuietMode(QuietMode);
    }

    @Override
    protected void PostInit() {

    }

    public boolean serverPostInit() {
        CustomLootChest = new BlockMetaComb(Blocks.chest);
        try {
            if (LootChestItemOverride != "") {
                String[] args = LootChestItemOverride.split(":");
                String tMod;
                String tName;
                int tMeta;

                if (args.length >= 2) {
                    tMod = args[0];
                    tName = args[1];
                    if (args.length == 3) tMeta = Integer.parseInt(args[2]);
                    else tMeta = 0;

                    Block tBlock = GameRegistry.findBlock(tMod, tName);
                    if (tBlock != null) {
                        GalacticGreg.Logger
                            .debug("Found valid ChestOverride: %s. LootChest replaced", LootChestItemOverride);
                        CustomLootChest = new BlockMetaComb(tBlock, tMeta);
                    }
                }
            }

            return true;
        } catch (Exception e) {
            GalacticGreg.Logger.error(
                "Unable to find custom chest override %s. Make sure item exists. Defaulting to Minecraft:chest",
                LootChestItemOverride);
            e.printStackTrace();
            return false;
        }
    }
}