Here are the examples of the java api codechicken.lib.config.ConfigTag taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
30 Examples
19
Source : NEIClientConfig.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
public static boolean isWorldSpecific(String setting) {
if (world == null) {
return false;
}
ConfigTag tag = world.config.getTag(setting, false);
return tag != null && tag.value != null;
}
19
Source : NEIClientConfig.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
public static void toggleBooleanSetting(String setting) {
ConfigTag tag = getSetting(setting);
tag.setBooleanValue(!tag.getBooleanValue());
}
19
Source : NEIClientConfig.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
public static void cycleSetting(String setting, int max) {
ConfigTag tag = getSetting(setting);
tag.setIntValue((tag.getIntValue() + 1) % max);
}
19
Source : Option.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
/**
* @return true if the world config contains a tag with this name
*/
public boolean worldSpecific(String s) {
ConfigTag tag = worldConfigSet().config.getTag(s, false);
return tag != null && tag.value != null;
}
19
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
// Copes the config and ensures its the same.
@Test
public void testCopy() throws Throwable {
Path dir = Files.createTempDirectory("copy_test");
Path testFile = dir.resolve("test.cfg");
copyTestFile(testFile);
ConfigTag configA = new StandardConfigFile(testFile).load();
ConfigTag configB = configA.copy();
ensureSameRaw(configA, configB);
}
18
Source : WirelessBolt.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
public static void init(ConfigTag rpconfig) {
ConfigTag boltconfig = rpconfig.getTag("boltEffect").useBraces();
ConfigTag damageconfig = boltconfig.getTag("damage").setComment("Damages are in half hearts:If an enreplacedy gets knocked into another bolt it may suffer multiple hits");
enreplacedydamage = damageconfig.getTag("enreplacedy").setComment("").getIntValue(5);
playerdamage = damageconfig.getTag("player").setComment("").getIntValue(3);
}
18
Source : GuiWirelessSniffer.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
public static void loadColours(ConfigTag addonconfig) {
ConfigTag snifferconifg = addonconfig.getTag("sniffer.gui").useBraces();
ConfigTag colourconfig = snifferconifg.getTag("colour").setPosition(0).setComment("Colours are in 0xAARRGGBB format:Alpha should be FF");
ConfigTag borderconfig = snifferconifg.getTag("border").setPosition(1).setNewLine(true);
colourOn = new ColourARGB(colourconfig.getTag("on").setPosition(0).setComment("").getHexValue(0xffFF0000));
colourOff = new ColourARGB(colourconfig.getTag("off").setPosition(1).getHexValue(0xff700000));
colourJammed = new ColourARGB(colourconfig.getTag("jammed").setPosition(2).getHexValue(0xff707070));
colourPOn = new ColourARGB(colourconfig.getTag("private.on").setPosition(0).getHexValue(0xff40F000));
colourPOff = new ColourARGB(colourconfig.getTag("private.off").setPosition(1).getHexValue(0xff40A000));
borderOn = new ColourARGB(borderconfig.getTag("on").setPosition(0).getHexValue(0xffEE0000));
borderOff = new ColourARGB(borderconfig.getTag("off").setPosition(1).getHexValue(0xff500000));
borderJammed = new ColourARGB(borderconfig.getTag("jammed").setPosition(2).getHexValue(0xff505050));
borderPOn = new ColourARGB(borderconfig.getTag("private.on").setPosition(0).getHexValue(0xff20E000));
borderPOff = new ColourARGB(borderconfig.getTag("private.off").setPosition(1).getHexValue(0xff209000));
}
18
Source : EnderStorageConfig.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
/**
* Created by covers1624 on 28/10/19.
*/
public clreplaced EnderStorageConfig {
private static ConfigTag config;
public static ItemStack personalItem;
public static boolean anarchyMode;
public static int storageSize;
public static boolean disableCreatorVisuals;
public static boolean useVanillaEnderChestSounds;
public static void load() {
if (config != null) {
throw new IllegalStateException("Tried to load config more than once.");
}
config = new StandardConfigFile(Paths.get("./config/EnderStorage.cfg")).load();
// ConfigSyncManager.registerSync(new ResourceLocation("enderstorage:config"), config);
ConfigTag personalItemTag = //
config.getTag("personalItem").setComment(//
"The RegistryName for the Item to lock EnderChests and Tanks.").setDefaultString("minecraft:diamond");
anarchyMode = //
config.getTag("anarchyMode").setComment(//
"Causes chests to lose personal settings and drop the diamond on break.").setDefaultBoolean(//
false).getBoolean();
storageSize = //
config.getTag("item_storage_size").setComment(//
"The size of each inventory of EnderStorage, 0 = 3x3, 1 = 3x9, 2 = 6x9, default = 1").setDefaultInt(//
1).getInt();
disableCreatorVisuals = //
config.getTag("disableCreatorVisuals").setComment(//
"Disables the tank on top of creators heads.").setDefaultBoolean(//
false).getBoolean();
useVanillaEnderChestSounds = //
config.getTag("useVanillaEnderChestsSounds").setComment(//
"Enable this to make EnderStorage use vanilla's EnderChest sounds instead of the standard chest.").setDefaultBoolean(//
false).getBoolean();
ResourceLocation personalItemName = new ResourceLocation(personalItemTag.getString());
if (ForgeRegistries.ITEMS.containsKey(personalItemName)) {
personalItem = new ItemStack(ForgeRegistries.ITEMS.getValue(personalItemName));
} else {
EnderStorage.logger.warn("Failed to load PersonaItem '{}', does not exist. Using default.", personalItemName);
personalItemTag.resetToDefault();
personalItem = new ItemStack(Items.DIAMOND);
}
config.save();
}
}
18
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
// Copes the config, modifies it, writes it to a stream, reads with readNetwork, ensures they are 'effectively' the same.
@Test
public void testReadNetwork() throws Throwable {
Path dir = Files.createTempDirectory("read_network");
Path testFile = dir.resolve("test.cfg");
copyTestFile(testFile);
ConfigTag testConfig = new StandardConfigFile(testFile).load();
ConfigTag testClone = testConfig.copy();
testClone.getTag("Tag1").getTag("integer").setInt(333333);
testClone.getTag("Tag1").getTag("string").setString("MAGIIIIC");
MCDataByteBuf buf = new MCDataByteBuf(Unpooled.buffer());
testClone.write(buf);
testConfig.readNetwork(buf);
ensureSameSynced(testConfig, testClone);
}
18
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
// Copes the config, modifies it, writes it to a stream, reads using 'readNetwork', saves the file back, loads it and enures the same as original.
@Test
public void testReadNetworkWriteFile() throws Throwable {
Path dir = Files.createTempDirectory("read_stream_network_read");
Path testFile = dir.resolve("test.cfg");
copyTestFile(testFile);
ConfigTag testConfig = new StandardConfigFile(testFile).load();
ConfigTag baseConfig = testConfig.copy();
ConfigTag testClone = testConfig.copy();
testClone.getTag("Tag1").getTag("integer").setInt(333333);
testClone.getTag("Tag1").getTag("string").setString("MAGIIIIC");
MCDataByteBuf buf = new MCDataByteBuf(Unpooled.buffer());
testClone.write(buf);
testConfig.readNetwork(buf);
testConfig.save();
ConfigTag loaded = new StandardConfigFile(testFile).load();
ensureSameRaw(loaded, baseConfig);
}
18
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
// Copies the config, modifies it then ensures they are different.
@Test(expected = ConfigTestException.clreplaced)
public void testCopyFail() throws Throwable {
Path dir = Files.createTempDirectory("copy_test_fail");
Path testFile = dir.resolve("test.cfg");
copyTestFile(testFile);
ConfigTag configA = new StandardConfigFile(testFile).load();
ConfigTag configB = configA.copy();
configB.setTagVersion("boop");
ConfigTag tag1 = configB.getTag("Tag1");
tag1.getTag("string").setString("nope");
tag1.getTag("boolean_array").getBooleanList().clear();
ensureSameRaw(configA, configB);
}
18
Source : StandardConfigSerializer.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
@Override
public void save(Path file, ConfigTag tag) {
if (Files.exists(file)) {
SneakyUtils.sneaky(() -> Files.delete(file));
}
if (!Files.exists(file.getParent())) {
SneakyUtils.sneaky(() -> Files.createDirectories(file.getParent()));
}
try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(file, StandardOpenOption.CREATE))) {
writeTag((ConfigTagImpl) tag, writer, 0);
} catch (IOException e) {
logger.error("Failed to save config file: {}", file, e);
}
}
18
Source : ChickenChunksConfig.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
/**
* Created by covers1624 on 5/4/20.
*/
public clreplaced ChickenChunksConfig {
private static ConfigTag config;
private static ConfigTag playerRestrictions;
private static final Map<UUID, Restrictions> perPlayerRestrictions = new HashMap<>();
private static boolean opsBypreplacedRestrictions;
private static boolean opsAccessAllLoaders;
private static boolean globalAllowOffline;
private static int globalOfflineTimeout;
private static int globalTotalAllowedChunks;
private static int globalChunksPerLoader;
public static void load() {
config = new StandardConfigFile(Paths.get("./config/ChickenChunks.cfg")).load();
opsBypreplacedRestrictions = //
config.getTag("opsBypreplacedRestrictions").setComment(//
"If Players with OP permissions bypreplaced chunk loading restrictions.").setDefaultBoolean(//
false).getBoolean();
opsAccessAllLoaders = //
config.getTag("opsAccessAllLoaders").setComment(//
"If Players with OP permissions can manage other users ChunkLoaders").setDefaultBoolean(//
true).getBoolean();
globalAllowOffline = //
config.getTag("allowOffline").setComment(//
"If chunks should stay loaded when a ChunkLoader's owner is offline.").setDefaultBoolean(//
true).getBoolean();
globalOfflineTimeout = //
config.getTag("offlineTimeout").setComment(//
"How long in minutes ChickenChunks should wait after a Player logs out to unload their chunks. Only effective when allowOffline=false").setDefaultInt(//
0).getInt();
globalTotalAllowedChunks = //
config.getTag("totalAllowedChunks").setComment(//
"The number of chunks each player is allowed to load in total.").setDefaultInt(//
5000).getInt();
globalChunksPerLoader = //
config.getTag("chunksPerLoader").setComment(//
"The number of chunks each ChunkLoader is allowed to load in total.").setDefaultInt(//
400).getInt();
playerRestrictions = //
config.getTag("playerRestrictions").setSyncToClient().setComment("Specifies restrictions for each player, Use /chickenchunks instead.");
// TODO Re add this when the config system gets rewritten..
// ConfigSyncManager.registerSync(new ResourceLocation(MOD_ID, "player_restrictions"), playerRestrictions);
playerRestrictions.setSyncCallback((tag, syncType) -> {
perPlayerRestrictions.clear();
for (String uuidString : tag.getChildNames()) {
ConfigTag playerTag = tag.getTag(uuidString);
UUID uuid = UUID.fromString(uuidString);
perPlayerRestrictions.put(uuid, new Restrictions(playerTag));
}
});
config.save();
playerRestrictions.runSync();
}
public static boolean doesBypreplacedRestrictions(MinecraftServer server, UUID playerUUID) {
ServerPlayerEnreplacedy player = server.getPlayerList().getPlayerByUUID(playerUUID);
if (player != null && server.getPlayerList().getOppedPlayers().hasEntry(player.getGameProfile())) {
return opsBypreplacedRestrictions;
}
return false;
}
public static boolean doesBypreplacedLoaderAccess(ServerPlayerEnreplacedy player) {
if (player.getServer().getPlayerList().getOppedPlayers().hasEntry(player.getGameProfile())) {
return opsAccessAllLoaders;
}
return false;
}
public static Restrictions getOrCreateRestrictions(UUID player) {
return perPlayerRestrictions.computeIfAbsent(player, e -> {
ConfigTag tag = playerRestrictions.getTag(player.toString()).markDirty();
tag.save();
return new Restrictions(tag);
});
}
public static void resetRestrictions(UUID player) {
perPlayerRestrictions.remove(player);
playerRestrictions.deleteTag(player.toString());
playerRestrictions.save();
}
public static Restrictions getRestrictions(UUID player) {
return perPlayerRestrictions.getOrDefault(player, Restrictions.EMPTY);
}
public static clreplaced Restrictions {
public static final Restrictions EMPTY = new Restrictions();
private Optional<Boolean> allowOffline = Optional.empty();
private Optional<Integer> offlineTimeout = Optional.empty();
private Optional<Integer> totalAllowedChunks = Optional.empty();
private Optional<Integer> chunksPerLoader = Optional.empty();
private ConfigTag tag;
public Restrictions() {
}
public Restrictions(ConfigTag tag) {
this.tag = tag;
allowOffline = //
Optional.ofNullable(tag.getTagIfPresent("allowOffline")).map(ConfigTag::getBoolean);
offlineTimeout = //
Optional.ofNullable(tag.getTagIfPresent("offlineTimeout")).map(ConfigTag::getInt);
totalAllowedChunks = //
Optional.ofNullable(tag.getTagIfPresent("totalAllowedChunks")).map(ConfigTag::getInt);
chunksPerLoader = //
Optional.ofNullable(tag.getTagIfPresent("chunksPerLoader")).map(ConfigTag::getInt);
}
public boolean canLoadOffline() {
return allowOffline.orElse(globalAllowOffline);
}
public int getOfflineTimeout() {
return offlineTimeout.orElse(globalOfflineTimeout);
}
public int getTotalAllowedChunks() {
return totalAllowedChunks.orElse(globalTotalAllowedChunks);
}
public int getChunksPerLoader() {
return chunksPerLoader.orElse(globalChunksPerLoader);
}
public void setAllowOffline(boolean state) {
tag.getTag("allowOffline").setBoolean(state).save();
allowOffline = Optional.of(state);
}
public void setOfflineTimeout(int num) {
tag.getTag("offlineTimeout").setInt(num).save();
offlineTimeout = Optional.of(num);
}
public void setTotalAllowedChunks(int num) {
tag.getTag("totalAllowedChunks").setInt(num).save();
totalAllowedChunks = Optional.of(num);
}
public void setChunksPerLoader(int num) {
tag.getTag("chunksPerLoader").setInt(num).save();
chunksPerLoader = Optional.of(num);
}
public void remAllowOffline() {
tag.deleteTag("allowOffline").save();
allowOffline = Optional.empty();
}
public void remOfflineTimeout() {
tag.deleteTag("offlineTimeout").save();
offlineTimeout = Optional.empty();
}
public void remTotalAllowedChunks() {
tag.deleteTag("totalAllowedChunks").save();
totalAllowedChunks = Optional.empty();
}
public void remChunksPerLoader() {
tag.deleteTag("chunksPerLoader").save();
chunksPerLoader = Optional.empty();
}
public boolean isEmpty() {
return !allowOffline.isPresent() && !offlineTimeout.isPresent() && !totalAllowedChunks.isPresent() && !chunksPerLoader.isPresent();
}
}
}
17
Source : Option.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
public void copyGlobal(String s, boolean recursive) {
if (!worldConfig()) {
return;
}
ConfigTag tag = globalConfigSet().config.getTag(s);
worldConfigSet().config.getTag(s).setValue(tag.getValue());
if (recursive) {
for (String s2 : tag.childTagMap().keySet()) {
copyGlobal(s + "." + s2);
}
}
}
17
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
// Copes the config, writes the original to the stream, modifies the copy, reads stream to copy, ensures they are the same.
@Test
public void testWriteReadStream() throws Throwable {
Path dir = Files.createTempDirectory("write_read_stream_test");
Path testFile = dir.resolve("test.cfg");
copyTestFile(testFile);
ConfigTag configA = new StandardConfigFile(testFile).load();
ConfigTag configB = configA.copy();
MCDataByteBuf byteStream = new MCDataByteBuf(Unpooled.buffer());
configA.write(byteStream);
ConfigTag tag1 = configB.getTag("Tag1");
tag1.getTag("string").setString("nope");
tag1.getTag("boolean_array").getBooleanList().clear();
configB.read(byteStream);
ensureSameRaw(configA, configB);
}
17
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
// Loads the config, saves it to a new file, loads it again, and compares the first loaded and the save-loaded.
@Test
public void testReadWriteRead() throws Throwable {
Path dir = Files.createTempDirectory("read_write_back_test");
Path before = dir.resolve("before.cfg");
Path after = dir.resolve("after.cfg");
copyTestFile(before);
ConfigFile beforeCFile = new StandardConfigFile(before);
ConfigTag beforeConfig = beforeCFile.load();
replacedert.replacedertFalse(beforeCFile.didError());
StandardConfigSerializer.INSTANCE.save(after, beforeConfig);
ConfigTag afterConfig = new StandardConfigFile(after).load();
ensureSameRaw(beforeConfig, afterConfig);
}
17
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
// Copies the config, deletes a tag from it, copyFrom should fail.
@Test(expected = IllegalArgumentException.clreplaced)
public void testCopyFromFail() throws Throwable {
Path dir = Files.createTempDirectory("copy_from_fail_test");
Path testFile = dir.resolve("test.cfg");
copyTestFile(testFile);
ConfigTag configA = new StandardConfigFile(testFile).load();
ConfigTag configB = configA.copy();
configA.deleteTag("Tag1");
configB.copyFrom(configA);
ensureSameRaw(configA, configB);
}
17
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
// Copes the config, modifies it, writes to stream, reads from stream with 'readNetwork', ensures effectively the same, calls 'netowrkRestore'
// ensures the config is the same as the unmodified version.
@Test
public void testReadNetworkRevert() throws Throwable {
Path dir = Files.createTempDirectory("read_network");
Path testFile = dir.resolve("test.cfg");
copyTestFile(testFile);
ConfigTag testConfig = new StandardConfigFile(testFile).load();
ConfigTag baseConfig = testConfig.copy();
ConfigTag testClone = testConfig.copy();
testClone.getTag("Tag1").getTag("integer").setInt(333333);
testClone.getTag("Tag1").getTag("string").setString("MAGIIIIC");
MCDataByteBuf buf = new MCDataByteBuf(Unpooled.buffer());
testClone.write(buf);
testConfig.readNetwork(buf);
ensureSameSynced(testConfig, testClone);
testConfig.networkRestore();
ensureSameSynced(testConfig, baseConfig);
}
17
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
// Copes the config, writes the original to the stream, deletes a tag from the copy, read should fail.
@Test(expected = IllegalArgumentException.clreplaced)
public void testWriteReadStreamFail() throws Throwable {
Path dir = Files.createTempDirectory("write_read_stream_test_fail");
Path testFile = dir.resolve("test.cfg");
copyTestFile(testFile);
ConfigTag configA = new StandardConfigFile(testFile).load();
ConfigTag configB = configA.copy();
MCDataByteBuf byteStream = new MCDataByteBuf(Unpooled.buffer());
configA.write(byteStream);
configB.deleteTag("Tag1");
configB.read(byteStream);
ensureSameRaw(configA, configB);
}
17
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
// Should produce a config identical to our test file.
@Test
public void testGeneration() throws Throwable {
Path dir = Files.createTempDirectory("generation_test");
ConfigTag generated_config = new StandardConfigFile(dir.resolve("generated.cfg")).load();
generated_config.setTagVersion("1.1");
generated_config.setComment("This is a config comment.");
ConfigTag tag = generated_config.getTag("Tag1").setComment("Specifies a new ConfigTag");
tag.setTagVersion("1.2.3.4");
ConfigTag bool = tag.getTag("boolean").setDefaultBoolean(false);
ConfigTag string = tag.getTag("string").setDefaultString("This is a string with data, Cannot be Multi Line.");
ConfigTag integer = tag.getTag("integer").setDefaultInt(123456789);
ConfigTag doubl_e = tag.getTag("double").setDefaultDouble(1.2345);
ConfigTag hex = tag.getTag("hex").setDefaultHex(0xFFFFFFFF);
ConfigTag boolArray = tag.getTag("boolean_array").setDefaultBooleanList(Arrays.asList(true, false, true, false));
ConfigTag stringArray = tag.getTag("string_array").setDefaultStringList(Arrays.asList("value", "value2", "value33"));
ConfigTag intArray = tag.getTag("integer_array").setDefaultIntList(Arrays.asList(1, 2, 3, 4, 5, 6));
ConfigTag doubleArray = tag.getTag("double_array").setDefaultDoubleList(Arrays.asList(1.2, 3.4, 5.6, 7.8));
ConfigTag hexArray = tag.getTag("hex_array").setDefaultHexList(Arrays.asList(0xFFFF, 0x00FF));
ConfigTag tag2 = generated_config.getTag("Tag2");
ConfigTag tag3 = tag2.getTag("Tag3");
ConfigTag tag4 = tag3.getTag("Tag4");
ConfigTag depthTest = tag4.getTag("depth_test").setDefaultBoolean(true);
generated_config.save();
Path staticFile = dir.resolve("static.cfg");
copyTestFile(staticFile);
ConfigTag staticConfig = new StandardConfigFile(staticFile).load();
ensureSameRaw(staticConfig, generated_config);
}
17
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
// Copies the config, modifies it, then 'resets' it with copyFrom, ensures they are the same.
@Test
public void testCopyFrom() throws Throwable {
Path dir = Files.createTempDirectory("copy_from_test");
Path testFile = dir.resolve("test.cfg");
copyTestFile(testFile);
ConfigTag configA = new StandardConfigFile(testFile).load();
ConfigTag configB = configA.copy();
ConfigTag tag1 = configB.getTag("Tag1");
tag1.getTag("string").setString("nope");
tag1.getTag("boolean_array").getBooleanList().clear();
configB.copyFrom(configA);
ensureSameRaw(configA, configB);
}
17
Source : ProxyClient.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
private void loadClientConfig() {
ConfigTag tag;
ConfigTag clientTag = CodeChickenLib.config.getTag("client");
clientTag.deleteTag("block_renderer_dispatcher_misc");
tag = //
clientTag.getTag("catchBlockRenderExceptions").setComment(//
"With this enabled, CCL will catch all exceptions thrown whilst rendering blocks.", //
"If an exception is caught, the block will not be rendered.");
catchBlockRenderExceptions = tag.setDefaultBoolean(true).getBoolean();
tag = //
clientTag.getTag("catchItemRenderExceptions").setComment(//
"With this enabled, CCL will catch all exceptions thrown whilst rendering items.", //
"By default CCL will only enhance the crash report, but with 'attemptRecoveryOnItemRenderException' enabled", //
" CCL will attempt to recover after the exception.");
messagePlayerOnRenderExceptionCaught = tag.setDefaultBoolean(true).getBoolean();
clientTag.save();
}
17
Source : AbstractConfigFile.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
@Override
public void save(ConfigTag tag) {
try {
serializer.save(file, tag);
} catch (IOException e) {
logger.error("Unable to save config file '{}'.", file, e);
}
}
17
Source : CodeChickenLib.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
/**
* Created by covers1624 on 12/10/2016.
*/
@Mod(CodeChickenLib.MOD_ID)
public clreplaced CodeChickenLib {
public static final String MOD_ID = "codechickenlib";
public static ConfigTag config;
public static Proxy proxy;
public CodeChickenLib() {
proxy = DistExecutor.safeRunForDist(() -> ProxyClient::new, () -> Proxy::new);
FMLJavaModLoadingContext.get().getModEventBus().register(this);
MinecraftForge.EVENT_BUS.addListener(CCLCommands::registerCommands);
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> OpenGLUtils::init);
CCLCommands.registerArguments();
}
@SubscribeEvent
public void onCommonSetup(FMLCommonSetupEvent event) {
proxy.commonSetup(event);
config = new StandardConfigFile(Paths.get("config/ccl.cfg")).load();
CCLNetwork.init();
}
@SubscribeEvent
public void onClientSetup(FMLClientSetupEvent event) {
proxy.clientSetup(event);
}
@SubscribeEvent
public void onServerSetup(FMLDedicatedServerSetupEvent event) {
proxy.serverSetup(event);
}
}
16
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
private static void ensureSameRaw(ConfigTag a, ConfigTag b) throws ConfigTestException {
String aName = a.getQualifiedName();
String bName = b.getQualifiedName();
if (a.isValue()) {
if (!b.isValue()) {
throw new ConfigTestException(String.format("Tag B '%s' is not a value like tag A '%s'.", bName, aName));
}
ConfigTag.TagType aType = a.getTagType();
if (aType != b.getTagType()) {
throw new ConfigTestException(String.format("Tag B '%s' is not the same type as A '%s'. A: '%s', B: '%s'.", bName, aName, aType, b.getTagType()));
}
if (aType == ConfigTag.TagType.LIST) {
if (a.getListType() != b.getListType()) {
throw new ConfigTestException(String.format("Tag B '%s' is not of the same list type as A '%s'. A: '%s', B: '%s'.", bName, aName, a.getListType(), b.getListType()));
}
}
if (!a.getRawValue().equals(b.getRawValue())) {
throw new ConfigTestException(String.format("Tab B '%s' does not have the same value as tag A '%s', A: '%s', B: '%s'.", bName, aName, a.getRawValue(), b.getRawValue()));
}
}
if (a.isCategory()) {
if (!b.isCategory()) {
throw new ConfigTestException(String.format("Tag B '%s' is not a category like tag A '%s'.", bName, aName));
}
if (!Objects.equals(a.getTagVersion(), b.getTagVersion())) {
throw new ConfigTestException(String.format("Tag B '%s' does not have the same version flag as Tag A '%s'. A: '%s', B: '%s'.", bName, aName, a.getTagVersion(), b.getTagVersion()));
}
List<String> aChildren = a.getChildNames();
List<String> bChildren = b.getChildNames();
for (String aChild : aChildren) {
if (!bChildren.contains(aChild)) {
throw new ConfigTestException(String.format("Tag B '%s' does not have a child '%s' that Tag A '%s' does.", bName, aChild, aName));
}
}
for (String bChild : bChildren) {
if (!aChildren.contains(bChild)) {
throw new ConfigTestException(String.format("Tag A '%s' does not have a child '%s' that Tag B '%s' does.", aName, bChild, bName));
}
}
for (String child : aChildren) {
ensureSameRaw(a.getTag(child), b.getTag(child));
}
}
}
16
Source : ConfigTests.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
private static void ensureSameSynced(ConfigTag a, ConfigTag b) throws ConfigTestException {
String aName = a.getQualifiedName();
String bName = b.getQualifiedName();
if (a.isValue()) {
if (!b.isValue()) {
throw new ConfigTestException(String.format("Tag B '%s' is not a value like tag A '%s'.", bName, aName));
}
ConfigTag.TagType aType = a.getTagType();
if (aType != b.getTagType()) {
throw new ConfigTestException(String.format("Tag B '%s' is not the same type as A '%s'. A: '%s', B: '%s'.", bName, aName, aType, b.getTagType()));
}
if (aType == ConfigTag.TagType.LIST) {
if (a.getListType() != b.getListType()) {
throw new ConfigTestException(String.format("Tag B '%s' is not of the same list type as A '%s'. A: '%s', B: '%s'.", bName, aName, a.getListType(), b.getListType()));
}
}
if (!a.getSyncedValue().equals(b.getSyncedValue())) {
throw new ConfigTestException(String.format("Tab B '%s' does not have the same value as tag A '%s', A: '%s', B: '%s'.", bName, aName, a.getRawValue(), b.getRawValue()));
}
}
if (a.isCategory()) {
if (!b.isCategory()) {
throw new ConfigTestException(String.format("Tag B '%s' is not a category like tag A '%s'.", bName, aName));
}
if (!Objects.equals(a.getTagVersion(), b.getTagVersion())) {
throw new ConfigTestException(String.format("Tag B '%s' does not have the same version flag as Tag A '%s'. A: '%s', B: '%s'.", bName, aName, a.getTagVersion(), b.getTagVersion()));
}
List<String> aChildren = a.getChildNames();
List<String> bChildren = b.getChildNames();
for (String aChild : aChildren) {
if (!bChildren.contains(aChild)) {
throw new ConfigTestException(String.format("Tag B '%s' does not have a child '%s' that Tag A '%s' does.", bName, aChild, aName));
}
}
for (String bChild : bChildren) {
if (!aChildren.contains(bChild)) {
throw new ConfigTestException(String.format("Tag A '%s' does not have a child '%s' that Tag B '%s' does.", aName, bChild, bName));
}
}
for (String child : aChildren) {
ensureSameSynced(a.getTag(child), b.getTag(child));
}
}
}
15
Source : ChickenChunksConfig.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
public static void load() {
config = new StandardConfigFile(Paths.get("./config/ChickenChunks.cfg")).load();
opsBypreplacedRestrictions = //
config.getTag("opsBypreplacedRestrictions").setComment(//
"If Players with OP permissions bypreplaced chunk loading restrictions.").setDefaultBoolean(//
false).getBoolean();
opsAccessAllLoaders = //
config.getTag("opsAccessAllLoaders").setComment(//
"If Players with OP permissions can manage other users ChunkLoaders").setDefaultBoolean(//
true).getBoolean();
globalAllowOffline = //
config.getTag("allowOffline").setComment(//
"If chunks should stay loaded when a ChunkLoader's owner is offline.").setDefaultBoolean(//
true).getBoolean();
globalOfflineTimeout = //
config.getTag("offlineTimeout").setComment(//
"How long in minutes ChickenChunks should wait after a Player logs out to unload their chunks. Only effective when allowOffline=false").setDefaultInt(//
0).getInt();
globalTotalAllowedChunks = //
config.getTag("totalAllowedChunks").setComment(//
"The number of chunks each player is allowed to load in total.").setDefaultInt(//
5000).getInt();
globalChunksPerLoader = //
config.getTag("chunksPerLoader").setComment(//
"The number of chunks each ChunkLoader is allowed to load in total.").setDefaultInt(//
400).getInt();
playerRestrictions = //
config.getTag("playerRestrictions").setSyncToClient().setComment("Specifies restrictions for each player, Use /chickenchunks instead.");
// TODO Re add this when the config system gets rewritten..
// ConfigSyncManager.registerSync(new ResourceLocation(MOD_ID, "player_restrictions"), playerRestrictions);
playerRestrictions.setSyncCallback((tag, syncType) -> {
perPlayerRestrictions.clear();
for (String uuidString : tag.getChildNames()) {
ConfigTag playerTag = tag.getTag(uuidString);
UUID uuid = UUID.fromString(uuidString);
perPlayerRestrictions.put(uuid, new Restrictions(playerTag));
}
});
config.save();
playerRestrictions.runSync();
}
15
Source : ChickenChunksConfig.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
public static Restrictions getOrCreateRestrictions(UUID player) {
return perPlayerRestrictions.computeIfAbsent(player, e -> {
ConfigTag tag = playerRestrictions.getTag(player.toString()).markDirty();
tag.save();
return new Restrictions(tag);
});
}
14
Source : EnderStorageConfig.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
public static void load() {
if (config != null) {
throw new IllegalStateException("Tried to load config more than once.");
}
config = new StandardConfigFile(Paths.get("./config/EnderStorage.cfg")).load();
// ConfigSyncManager.registerSync(new ResourceLocation("enderstorage:config"), config);
ConfigTag personalItemTag = //
config.getTag("personalItem").setComment(//
"The RegistryName for the Item to lock EnderChests and Tanks.").setDefaultString("minecraft:diamond");
anarchyMode = //
config.getTag("anarchyMode").setComment(//
"Causes chests to lose personal settings and drop the diamond on break.").setDefaultBoolean(//
false).getBoolean();
storageSize = //
config.getTag("item_storage_size").setComment(//
"The size of each inventory of EnderStorage, 0 = 3x3, 1 = 3x9, 2 = 6x9, default = 1").setDefaultInt(//
1).getInt();
disableCreatorVisuals = //
config.getTag("disableCreatorVisuals").setComment(//
"Disables the tank on top of creators heads.").setDefaultBoolean(//
false).getBoolean();
useVanillaEnderChestSounds = //
config.getTag("useVanillaEnderChestsSounds").setComment(//
"Enable this to make EnderStorage use vanilla's EnderChest sounds instead of the standard chest.").setDefaultBoolean(//
false).getBoolean();
ResourceLocation personalItemName = new ResourceLocation(personalItemTag.getString());
if (ForgeRegistries.ITEMS.containsKey(personalItemName)) {
personalItem = new ItemStack(ForgeRegistries.ITEMS.getValue(personalItemName));
} else {
EnderStorage.logger.warn("Failed to load PersonaItem '{}', does not exist. Using default.", personalItemName);
personalItemTag.resetToDefault();
personalItem = new ItemStack(Items.DIAMOND);
}
config.save();
}
13
Source : Proxy.java
with MIT License
from TheCBProject
with MIT License
from TheCBProject
public void preInit() {
ModItems.init();
PacketCustom.replacedignHandler(NET_CHANNEL, new WRServerPH());
ConfigTag coreconfig = SaveManager.config().getTag("core").useBraces().setPosition(10);
WirelessBolt.init(coreconfig);
EnreplacedyRegistry.registerModEnreplacedy(new ResourceLocation("wrcbe:tracker"), EnreplacedyWirelessTracker.clreplaced, "tracker", 0, WirelessRedstone.instance, 64, 1, true);
}