Some generic and other warning cleanups

This commit is contained in:
cpw committed 2015-11-13 10:13:47 -05:00
1 parent 02e6d581d3
commit 41c3846c51
16 files changed
+190 -200

No files matched your search

@@ -3,25 +3,20 @@ package net.minecraftforge.common;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.structure.MapGenVillage;
import net.minecraft.world.biome.WorldChunkManager;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraft.world.gen.structure.MapGenVillage;
import net.minecraftforge.common.util.EnumHelper;
public class BiomeManager
{
private static TrackedList<BiomeEntry>[] biomes = setupBiomes();
private static boolean isModded = false;
public static List<BiomeGenBase> oceanBiomes = new ArrayList<BiomeGenBase>();
public static ArrayList<BiomeGenBase> strongHoldBiomes = new ArrayList<BiomeGenBase>();
@@ -36,8 +31,9 @@ public class BiomeManager
private static TrackedList<BiomeEntry>[] setupBiomes()
{
@SuppressWarnings("unchecked")
TrackedList<BiomeEntry>[] currentBiomes = new TrackedList[BiomeType.values().length];
List list = new ArrayList();
List<BiomeEntry> list = new ArrayList<BiomeEntry>();
list.add(new BiomeEntry(BiomeGenBase.forest, 10));
list.add(new BiomeEntry(BiomeGenBase.roofedForest, 10));
@@ -46,7 +42,7 @@ public class BiomeManager
list.add(new BiomeEntry(BiomeGenBase.birchForest, 10));
list.add(new BiomeEntry(BiomeGenBase.swampland, 10));
currentBiomes[BiomeType.WARM.ordinal()] = new TrackedList(list);
currentBiomes[BiomeType.WARM.ordinal()] = new TrackedList<BiomeEntry>(list);
list.clear();
list.add(new BiomeEntry(BiomeGenBase.forest, 10));
@@ -54,21 +50,20 @@ public class BiomeManager
list.add(new BiomeEntry(BiomeGenBase.taiga, 10));
list.add(new BiomeEntry(BiomeGenBase.plains, 10));
currentBiomes[BiomeType.COOL.ordinal()] = new TrackedList(list);
currentBiomes[BiomeType.COOL.ordinal()] = new TrackedList<BiomeEntry>(list);
list.clear();
list.add(new BiomeEntry(BiomeGenBase.icePlains, 30));
list.add(new BiomeEntry(BiomeGenBase.coldTaiga, 10));
currentBiomes[BiomeType.ICY.ordinal()] = new TrackedList(list);
currentBiomes[BiomeType.ICY.ordinal()] = new TrackedList<BiomeEntry>(list);
list.clear();
currentBiomes[BiomeType.DESERT.ordinal()] = new TrackedList(list);
currentBiomes[BiomeType.DESERT.ordinal()] = new TrackedList<BiomeEntry>(list);
return currentBiomes;
}
@SuppressWarnings("unchecked")
public static void addVillageBiome(BiomeGenBase biome, boolean canSpawn)
{
if (!MapGenVillage.villageSpawnBiomes.contains(biome))
@@ -79,7 +74,6 @@ public class BiomeManager
}
}
@SuppressWarnings("unchecked")
public static void removeVillageBiome(BiomeGenBase biome)
{
if (MapGenVillage.villageSpawnBiomes.contains(biome))
@@ -124,8 +118,6 @@ public class BiomeManager
public static void addBiome(BiomeType type, BiomeEntry entry)
{
isModded = true;
int idx = type.ordinal();
List<BiomeEntry> list = idx > biomes.length ? null : biomes[idx];
if (list != null) list.add(entry);
@@ -133,8 +125,6 @@ public class BiomeManager
public static void removeBiome(BiomeType type, BiomeEntry entry)
{
isModded = true;
int idx = type.ordinal();
List<BiomeEntry> list = idx > biomes.length ? null : biomes[idx];
@@ -200,6 +190,7 @@ public class BiomeManager
private static class TrackedList<E> extends ArrayList<E>
{
private static final long serialVersionUID = 1L;
private boolean isModded = false;
public TrackedList(Collection<? extends E> c)
@@ -1,22 +1,24 @@
package net.minecraftforge.common;
import java.util.*;
import com.google.common.collect.ImmutableList;
import net.minecraft.init.Items;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraft.world.WorldServer;
import net.minecraft.world.gen.feature.WorldGenDungeons;
import net.minecraft.world.gen.structure.*;
import net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces.DesertPyramid;
import net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces.JunglePyramid;
import net.minecraft.world.gen.structure.StructureStrongholdPieces.ChestCorridor;
import net.minecraft.world.gen.structure.StructureStrongholdPieces.Library;
import net.minecraft.world.gen.structure.StructureStrongholdPieces.RoomCrossing;
import net.minecraft.world.gen.structure.StructureVillagePieces.House2;
import net.minecraft.world.gen.structure.StructureNetherBridgePieces.Corridor;
import net.minecraft.world.gen.structure.StructureMineshaftPieces;
import net.minecraft.world.gen.structure.StructureNetherBridgePieces;
import net.minecraft.world.gen.structure.StructureOceanMonument;
import net.minecraft.world.gen.structure.StructureStrongholdPieces;
import net.minecraft.world.gen.structure.StructureVillagePieces;
import net.minecraftforge.oredict.OreDictionary;
public class ChestGenHooks
@@ -64,9 +66,9 @@ public class ChestGenHooks
}
// INTERNAL DO NO USE
public static void init(String category, List items, int min, int max)
public static void init(String category, List<WeightedRandomChestContent> items, int min, int max)
{
chestInfo.put(category, new ChestGenHooks(category, (List<WeightedRandomChestContent>)items, min, max));
chestInfo.put(category, new ChestGenHooks(category, items, min, max));
}
static void addDungeonLoot(ChestGenHooks dungeon, ItemStack item, int weight, int min, int max)
@@ -134,6 +136,7 @@ public class ChestGenHooks
public static void removeItem(String category, ItemStack item){ getInfo(category).removeItem(item); }
public static ItemStack getOneItem(String category, Random rand){ return getInfo(category).getOneItem(rand); }
@SuppressWarnings("unused")
private String category;
private int countMin = 0;
private int countMax = 0;
@@ -17,8 +17,7 @@ import com.google.common.collect.HashMultiset;
import com.google.common.collect.Lists;
import com.google.common.collect.MapMaker;
import com.google.common.collect.Multiset;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.MinecraftException;
@@ -34,6 +33,8 @@ import net.minecraft.world.WorldSettings;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.SaveHandler;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.FMLLog;
public class DimensionManager
{
@@ -1,12 +1,11 @@
package net.minecraftforge.common;
import com.google.common.base.Predicate;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import com.google.common.base.Predicate;
import net.minecraft.entity.projectile.EntityFishHook;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatBase;
@@ -901,7 +901,6 @@ public class ForgeChunkManager
}
}
@SuppressWarnings("unchecked")
public static Chunk fetchDormantChunk(long coords, World world)
{
Cache<Long, Chunk> cache = dormantChunkCache.get(world);
@@ -912,7 +911,7 @@ public class ForgeChunkManager
Chunk chunk = cache.getIfPresent(coords);
if (chunk != null)
{
for (ClassInheritanceMultiMap eList : chunk.getEntityLists())
for (ClassInheritanceMultiMap<Entity> eList : chunk.getEntityLists())
{
Iterator<Entity> itr = (Iterator<Entity>)eList.iterator();
while (itr.hasNext())
@@ -24,18 +24,10 @@ import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLeashKnot;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.item.EntityPainting;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.event.ClickEvent;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@@ -46,7 +38,6 @@ import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemSpade;
@@ -556,6 +547,7 @@ public class ForgeHooks
return world.getBlockState(pos).getBlock().getEnchantPowerBonus(world, pos);
}
@SuppressWarnings("deprecation")
public static ChatComponentTranslation onServerChatEvent(NetHandlerPlayServer net, String raw, ChatComponentTranslation comp)
{
ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp);
@@ -698,7 +690,7 @@ public class ForgeHooks
TileEntity tileentity = world.getTileEntity(pos);
if (tileentity != null)
{
Packet pkt = tileentity.getDescriptionPacket();
Packet<?> pkt = tileentity.getDescriptionPacket();
if (pkt != null)
{
entityPlayer.playerNetServerHandler.sendPacket(pkt);
@@ -738,6 +730,7 @@ public class ForgeHooks
newNBT = (NBTTagCompound)itemstack.getTagCompound().copy();
}
net.minecraftforge.event.world.BlockEvent.PlaceEvent placeEvent = null;
@SuppressWarnings("unchecked")
List<net.minecraftforge.common.util.BlockSnapshot> blockSnapshots = (List<BlockSnapshot>)world.capturedBlockSnapshots.clone();
world.capturedBlockSnapshots.clear();
@@ -5,10 +5,6 @@
package net.minecraftforge.common;
import static net.minecraftforge.common.ForgeVersion.buildVersion;
import static net.minecraftforge.common.ForgeVersion.majorVersion;
import static net.minecraftforge.common.ForgeVersion.minorVersion;
import static net.minecraftforge.common.ForgeVersion.revisionVersion;
import static net.minecraftforge.common.config.Configuration.CATEGORY_GENERAL;
import java.io.File;
@@ -83,6 +79,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
private URL updateJSONUrl = null;
@SuppressWarnings("deprecation")
public ForgeModContainer()
{
super(new ModMetadata());
@@ -91,7 +88,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
meta.name = "Minecraft Forge";
meta.version = ForgeVersion.getVersion();
meta.credits = "Made possible with help from many people";
meta.authorList = Arrays.asList("LexManos", "cpw");
meta.authorList = Arrays.asList("LexManos", "cpw", "fry");
meta.description = "Minecraft Forge is a common open source API allowing a broad range of mods " +
"to work cooperatively together. It allows many mods to be created without " +
"them editing the main Minecraft code.";
@@ -42,7 +42,9 @@ public class ForgeVersion
public static final String mcVersion = "1.8.8";
// This is the MCP data version we're using
public static final String mcpVersion = "9.18";
@SuppressWarnings("unused")
private static Status status = PENDING;
@SuppressWarnings("unused")
private static String target = null;
public static int getMajorVersion()
@@ -150,7 +152,9 @@ public class ForgeVersion
FMLLog.log("ForgeVersionCheck", Level.DEBUG, "[%s] Received version check data:\n%s", mod.getModId(), data);
@SuppressWarnings("unchecked")
Map<String, Object> json = new Gson().fromJson(data, Map.class);
@SuppressWarnings("unchecked")
Map<String, String> promos = (Map<String, String>)json.get("promos");
String display_url = (String)json.get("homepage");
@@ -201,6 +205,7 @@ public class ForgeVersion
FMLLog.log("ForgeVersionCheck", Level.INFO, "[%s] Found status: %s Target: %s", mod.getModId(), status, target);
Map<ComparableVersion, String> changes = new LinkedHashMap<ComparableVersion, String>();
@SuppressWarnings("unchecked")
Map<String, String> tmp = (Map<String, String>)json.get(MinecraftForge.MC_VERSION);
if (tmp != null)
{
@@ -1,6 +1,5 @@
package net.minecraftforge.common;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
@@ -1,7 +1,7 @@
package net.minecraftforge.common;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
@@ -54,6 +54,7 @@ public class MinecraftForge
OreDictionary.getOreName(0);
//Force these classes to be defined, Should prevent derp error hiding.
@SuppressWarnings("unused")
CrashReport fake = new CrashReport("ThisIsFake", new Exception("Not real"));
//Lets init World's crash report inner classes to prevent them from hiding errors.
String[] handlers = {
@@ -153,7 +154,7 @@ public class MinecraftForge
//FMLLog.info("\t" + s);
try
{
Class cls = Class.forName(s, false, MinecraftForge.class.getClassLoader());
Class<?> cls = Class.forName(s, false, MinecraftForge.class.getClassLoader());
if (cls != null && !Callable.class.isAssignableFrom(cls))
{
//FMLLog.info("\t% s is not a instance of callable!", s);
@@ -48,7 +48,7 @@ public final class UsernameCache {
/**
* Set a player's current username
*
*
* @param uuid
* the player's {@link java.util.UUID UUID}
* @param username
@@ -67,7 +67,7 @@ public final class UsernameCache {
/**
* Remove a player's username from the cache
*
*
* @param uuid
* the player's {@link java.util.UUID UUID}
* @return if the cache contained the user
@@ -81,7 +81,7 @@ public final class UsernameCache {
save();
return true;
}
return false;
}
@@ -89,7 +89,7 @@ public final class UsernameCache {
* Get the player's last known username
* <p>
* <b>May be <code>null</code></b>
*
*
* @param uuid
* the player's {@link java.util.UUID UUID}
* @return the player's last known username, or <code>null</code> if the
@@ -104,7 +104,7 @@ public final class UsernameCache {
/**
* Check if the cache contains the given player's username
*
*
* @param uuid
* the player's {@link java.util.UUID UUID}
* @return if the cache contains a username for the given player
@@ -117,7 +117,7 @@ public final class UsernameCache {
/**
* Get an immutable copy of the cache's underlying map
*
*
* @return the map
*/
public static Map<UUID, String> getMap()
@@ -144,7 +144,7 @@ public final class UsernameCache {
{
String json = Files.toString(saveFile, charset);
Type type = new TypeToken<Map<UUID, String>>() {}.getType();
Type type = new TypeToken<Map<UUID, String>>() { private static final long serialVersionUID = 1L; }.getType();
map = gson.fromJson(json, type);
}
@@ -5,12 +5,13 @@ import java.util.List;
import net.minecraft.init.Items;
import net.minecraft.item.ItemPotion;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.PotionHelper;
/**
* Used in BrewingRecipeRegistry to maintain the vanilla behaviour.
*
* Most of the code was simply adapted from net.minecraft.tileentity.TileEntityBrewingStand
* Used in BrewingRecipeRegistry to maintain the vanilla behaviour.
*
* Most of the code was simply adapted from net.minecraft.tileentity.TileEntityBrewingStand
*/
public class VanillaBrewingRecipe implements IBrewingRecipe {
@@ -49,8 +50,8 @@ public class VanillaBrewingRecipe implements IBrewingRecipe {
return null;
}
List oldEffects = Items.potionitem.getEffects(inputMeta);
List newEffects = Items.potionitem.getEffects(outputMeta);
List<PotionEffect> oldEffects = Items.potionitem.getEffects(inputMeta);
List<PotionEffect> newEffects = Items.potionitem.getEffects(outputMeta);
boolean hasResult = false;
if ((inputMeta <= 0 || oldEffects != newEffects) && (oldEffects == null || !oldEffects.equals(newEffects) && newEffects != null))
@@ -13,7 +13,6 @@ import java.io.BufferedWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -33,6 +32,7 @@ public class ConfigCategory implements Map<String, Property>
private String languagekey;
private ArrayList<ConfigCategory> children = new ArrayList<ConfigCategory>();
private Map<String, Property> properties = new TreeMap<String, Property>();
@SuppressWarnings("unused")
private int propNumber = 0;
public final ConfigCategory parent;
private boolean changed = false;
@@ -6,7 +6,6 @@
package net.minecraftforge.common.config;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
@@ -54,6 +53,7 @@ public class ConfigElement implements IConfigElement
List<IConfigElement> elements = new ArrayList<IConfigElement>();
Iterator<ConfigCategory> ccI = ctgy.getChildren().iterator();
Iterator<Property> pI = ctgy.getOrderedValues().iterator();
@SuppressWarnings("unused")
int index = 0;
if (categoriesFirst)
@@ -86,7 +86,7 @@ public class Configuration
{
this(file, null);
}
/**
* Create a configuration file for the file given in parameter with the provided config version number.
*/
@@ -110,12 +110,12 @@ public class Configuration
}
catch (Throwable e)
{
File fileBak = new File(file.getAbsolutePath() + "_" +
File fileBak = new File(file.getAbsolutePath() + "_" +
new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".errored");
FMLLog.severe("An exception occurred while loading config file %s. This file will be renamed to %s " +
"and a new config file will be generated.", file.getName(), fileBak.getName());
e.printStackTrace();
file.renameTo(fileBak);
load();
}
@@ -132,7 +132,7 @@ public class Configuration
{
this(file, null, caseSensitiveCustomCategories);
}
@Override
public String toString()
{
@@ -148,16 +148,16 @@ public class Configuration
{
return this.loadedConfigVersion;
}
/******************************************************************************************************************
*
*
* BOOLEAN gets
*
*
*****************************************************************************************************************/
/**
* Gets a boolean Property object without a comment using the default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -170,7 +170,7 @@ public class Configuration
/**
* Gets a boolean Property object with a comment using the default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -181,18 +181,18 @@ public class Configuration
{
Property prop = get(category, key, Boolean.toString(defaultValue), comment, BOOLEAN);
prop.setDefaultValue(Boolean.toString(defaultValue));
if (!prop.isBooleanValue())
{
prop.setValue(defaultValue);
}
return prop;
}
/**
* Gets a boolean array Property without a comment using the default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -205,7 +205,7 @@ public class Configuration
/**
* Gets a boolean array Property with a comment using the default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -216,10 +216,10 @@ public class Configuration
{
return get(category, key, defaultValues, comment, false, -1);
}
/**
* Gets a boolean array Property with all settings defined.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -237,29 +237,29 @@ public class Configuration
{
values[i] = Boolean.toString(defaultValues[i]);
}
Property prop = get(category, key, values, comment, BOOLEAN);
prop.setDefaultValues(values);
prop.setIsListLengthFixed(isListLengthFixed);
prop.setMaxListLength(maxListLength);
if (!prop.isBooleanList())
{
prop.setValues(values);
}
return prop;
}
/* ****************************************************************************************************************
*
*
* INTEGER gets
*
*
*****************************************************************************************************************/
/**
* Gets an integer Property object without a comment using default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -272,7 +272,7 @@ public class Configuration
/**
* Gets an integer Property object with a comment using default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -286,7 +286,7 @@ public class Configuration
/**
* Gets an integer Property object with the defined comment, minimum and maximum bounds.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -301,7 +301,7 @@ public class Configuration
prop.setDefaultValue(Integer.toString(defaultValue));
prop.setMinValue(minValue);
prop.setMaxValue(maxValue);
if (!prop.isIntValue())
{
prop.setValue(defaultValue);
@@ -311,7 +311,7 @@ public class Configuration
/**
* Gets an integer array Property object without a comment using default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -325,7 +325,7 @@ public class Configuration
/**
* Gets an integer array Property object with a comment using default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -340,7 +340,7 @@ public class Configuration
/**
* Gets an integer array Property object with the defined comment, minimum and maximum bounds.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -354,10 +354,10 @@ public class Configuration
{
return get(category, key, defaultValues, comment, minValue, maxValue, false, -1);
}
/**
* Gets an integer array Property object with all settings defined.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -384,7 +384,7 @@ public class Configuration
prop.setMaxValue(maxValue);
prop.setIsListLengthFixed(isListLengthFixed);
prop.setMaxListLength(maxListLength);
if (!prop.isIntList())
{
prop.setValues(values);
@@ -394,14 +394,14 @@ public class Configuration
}
/* ****************************************************************************************************************
*
*
* DOUBLE gets
*
*
*****************************************************************************************************************/
/**
* Gets a double Property object without a comment using default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -414,7 +414,7 @@ public class Configuration
/**
* Gets a double Property object with a comment using default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -425,10 +425,10 @@ public class Configuration
{
return get(category, key, defaultValue, comment, -Double.MAX_VALUE, Double.MAX_VALUE);
}
/**
* Gets a double Property object with the defined comment, minimum and maximum bounds
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -443,7 +443,7 @@ public class Configuration
prop.setDefaultValue(Double.toString(defaultValue));
prop.setMinValue(minValue);
prop.setMaxValue(maxValue);
if (!prop.isDoubleValue())
{
prop.setValue(defaultValue);
@@ -453,7 +453,7 @@ public class Configuration
/**
* Gets a double array Property object without a comment using default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -467,7 +467,7 @@ public class Configuration
/**
* Gets a double array Property object without a comment using default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -479,10 +479,10 @@ public class Configuration
{
return get(category, key, defaultValues, comment, -Double.MAX_VALUE, Double.MAX_VALUE, false, -1);
}
/**
* Gets a double array Property object with the defined comment, minimum and maximum bounds.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -496,10 +496,10 @@ public class Configuration
{
return get(category, key, defaultValues, comment, minValue, maxValue, false, -1);
}
/**
* Gets a double array Property object with all settings defined.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -520,14 +520,14 @@ public class Configuration
values[i] = Double.toString(defaultValues[i]);
}
Property prop = get(category, key, values, comment, DOUBLE);
prop.setDefaultValues(values);
prop.setMinValue(minValue);
prop.setMaxValue(maxValue);
prop.setIsListLengthFixed(isListLengthFixed);
prop.setMaxListLength(maxListLength);
if (!prop.isDoubleList())
{
prop.setValues(values);
@@ -537,14 +537,14 @@ public class Configuration
}
/* ****************************************************************************************************************
*
*
* STRING gets
*
*
*****************************************************************************************************************/
/**
* Gets a string Property without a comment using the default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -554,10 +554,10 @@ public class Configuration
{
return get(category, key, defaultValue, (String) null);
}
/**
* Gets a string Property with a comment using the default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -568,10 +568,10 @@ public class Configuration
{
return get(category, key, defaultValue, comment, STRING);
}
/**
* Gets a string Property with a comment using the defined validationPattern and otherwise default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -585,10 +585,10 @@ public class Configuration
prop.setValidationPattern(validationPattern);
return prop;
}
/**
* Gets a string Property with a comment using the defined validValues array and otherwise default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -603,10 +603,10 @@ public class Configuration
prop.setValidValues(validValues);
return prop;
}
/**
* Gets a string array Property without a comment using the default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -616,10 +616,10 @@ public class Configuration
{
return get(category, key, defaultValues, (String) null, false, -1, (Pattern) null);
}
/**
* Gets a string array Property with a comment using the default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -630,10 +630,10 @@ public class Configuration
{
return get(category, key, defaultValues, comment, false, -1, (Pattern) null);
}
/**
* Gets a string array Property with a comment using the defined validationPattern and otherwise default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -645,10 +645,10 @@ public class Configuration
{
return get(category, key, defaultValues, comment, false, -1, validationPattern);
}
/**
* Gets a string array Property with a comment with all settings defined.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -668,16 +668,16 @@ public class Configuration
prop.setValidationPattern(validationPattern);
return prop;
}
/* ****************************************************************************************************************
*
*
* GENERIC gets
*
*
*****************************************************************************************************************/
/**
* Gets a Property object of the specified type using default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValue the default value
@@ -711,7 +711,7 @@ public class Configuration
else if (defaultValue != null)
{
Property prop = new Property(key, defaultValue, type);
prop.setValue(defaultValue); //Set and mark as dirty to signify it should save
prop.setValue(defaultValue); //Set and mark as dirty to signify it should save
cat.put(key, prop);
prop.setDefaultValue(defaultValue);
prop.comment = comment;
@@ -725,7 +725,7 @@ public class Configuration
/**
* Gets a list (array) Property object of the specified type using default settings.
*
*
* @param category the config category
* @param key the Property key value
* @param defaultValues an array containing the default values
@@ -772,11 +772,11 @@ public class Configuration
}
/* ****************************************************************************************************************
*
*
* Other methods
*
*
*************************************************************************************************************** */
public boolean hasCategory(String category)
{
return categories.get(category) != null;
@@ -963,17 +963,17 @@ public class Configuration
else if (i + 1 == line.length())
{
name = line.substring(nameStart, nameEnd + 1);
if (currentCat == null)
{
throw new RuntimeException(String.format("'%s' has no scope in '%s:%d'", name, fileName, lineNum));
}
tmpList = new ArrayList<String>();
skip = true;
}
break;
case '>':
@@ -994,17 +994,17 @@ public class Configuration
case '~':
if (tmpList != null) // allow special characters as part of string lists
break;
if (line.startsWith(CONFIG_VERSION_MARKER))
{
int colon = line.indexOf(':');
if (colon != -1)
loadedConfigVersion = line.substring(colon + 1).trim();
skip = true;
}
break;
default:
if (tmpList != null) // allow special characters as part of string lists
break;
@@ -1079,7 +1079,7 @@ public class Configuration
if (this.definedConfigVersion != null)
buffer.write(CONFIG_VERSION_MARKER + ": " + this.definedConfigVersion + NEW_LINE + NEW_LINE);
if (children.isEmpty())
{
save(buffer);
@@ -1105,7 +1105,7 @@ public class Configuration
}
private void save(BufferedWriter out) throws IOException
{
{
for (ConfigCategory cat : categories.values())
{
if (!cat.isChild())
@@ -1181,7 +1181,7 @@ public class Configuration
/**
* Adds a comment to the specified ConfigCategory object
*
*
* @param category the config category
* @param comment a String comment
*/
@@ -1197,10 +1197,10 @@ public class Configuration
{
this.setCategoryComment(category, comment);
}
/**
* Adds a language key to the specified ConfigCategory object
*
*
* @param category the config category
* @param langKey a language key string such as configcategory.general
*/
@@ -1211,7 +1211,7 @@ public class Configuration
getCategory(category).setLanguageKey(langKey);
return this;
}
/**
* Sets the custom IConfigEntry class that should be used in place of the standard entry class (which is just a button that
* navigates into the category). This class MUST provide a constructor with the following parameter types: {@code GuiConfig} (the parent
@@ -1220,16 +1220,16 @@ public class Configuration
*/
public Configuration setCategoryConfigEntryClass(String category, Class<? extends IConfigEntry> clazz)
{
if (!caseSensitiveCustomCategories)
category = category.toLowerCase(Locale.ENGLISH);
getCategory(category).setConfigEntryClass(clazz);
return this;
}
/**
* Sets the flag for whether or not this category can be edited while a world is running. Care should be taken to ensure
* that only properties that are truly dynamic can be changed from the in-game options menu. Only set this flag to
* that only properties that are truly dynamic can be changed from the in-game options menu. Only set this flag to
* true if all child properties/categories are unable to be modified while a world is running.
*/
public Configuration setCategoryRequiresWorldRestart(String category, boolean requiresWorldRestart)
@@ -1239,7 +1239,7 @@ public class Configuration
getCategory(category).setRequiresWorldRestart(requiresWorldRestart);
return this;
}
/**
* Sets whether or not this ConfigCategory requires Minecraft to be restarted when changed.
* Defaults to false. Only set this flag to true if ALL child properties/categories require
@@ -1253,7 +1253,7 @@ public class Configuration
getCategory(category).setRequiresMcRestart(requiresMcRestart);
return this;
}
/**
* Sets the order that direct child properties of this config category will be written to the config file and will be displayed in
* config GUIs.
@@ -1265,7 +1265,7 @@ public class Configuration
getCategory(category).setPropertyOrder(propOrder);
return this;
}
private void setChild(String name, Configuration child)
{
if (!children.containsKey(name))
@@ -1291,6 +1291,7 @@ public class Configuration
public static class UnicodeInputStreamReader extends Reader
{
private final InputStreamReader input;
@SuppressWarnings("unused")
private final String defaultEnc;
public UnicodeInputStreamReader(InputStream source, String encoding) throws IOException
@@ -1362,7 +1363,7 @@ public class Configuration
public boolean hasChanged()
{
if (changed) return true;
for (ConfigCategory cat : categories.values())
{
if (cat.hasChanged()) return true;
@@ -1394,10 +1395,10 @@ public class Configuration
{
return ImmutableSet.copyOf(categories.keySet());
}
/**
* Renames a property in a given category.
*
*
* @param category the category in which the property resides
* @param oldPropName the existing property name
* @param newPropName the new property name
@@ -1416,10 +1417,10 @@ public class Configuration
}
return false;
}
/**
* Moves a property from one category to another.
*
*
* @param oldCategory the category the property currently resides in
* @param propName the name of the property to move
* @param newCategory the category the property should be moved to
@@ -1436,7 +1437,7 @@ public class Configuration
}
return false;
}
/**
* Copies property objects from another Configuration object to this one using the list of category names. Properties that only exist in the
* "from" object are ignored. Pass null for the ctgys array to include all categories.
@@ -1445,7 +1446,7 @@ public class Configuration
{
if (ctgys == null)
ctgys = this.getCategoryNames().toArray(new String[this.getCategoryNames().size()]);
for (String ctgy : ctgys)
if (fromConfig.hasCategory(ctgy) && this.hasCategory(ctgy))
{
@@ -1456,10 +1457,10 @@ public class Configuration
thiscc.put(entry.getKey(), fromcc.get(entry.getKey()));
}
}
/**
* Creates a string property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1470,10 +1471,10 @@ public class Configuration
{
return getString(name, category, defaultValue, comment, name, null);
}
/**
* Creates a string property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1485,10 +1486,10 @@ public class Configuration
{
return getString(name, category, defaultValue, comment, langKey, null);
}
/**
* Creates a string property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1499,10 +1500,10 @@ public class Configuration
{
return getString(name, category, defaultValue, comment, name, pattern);
}
/**
* Creates a string property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1518,10 +1519,10 @@ public class Configuration
prop.comment = comment + " [default: " + defaultValue + "]";
return prop.getString();
}
/**
* Creates a string property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1533,10 +1534,10 @@ public class Configuration
{
return getString(name, category, defaultValue, comment, validValues, name);
}
/**
* Creates a string property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1553,10 +1554,10 @@ public class Configuration
prop.comment = comment + " [default: " + defaultValue + "]";
return prop.getString();
}
/**
* Creates a string list property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1567,10 +1568,10 @@ public class Configuration
{
return getStringList(name, category, defaultValues, comment, (String[]) null, name);
}
/**
* Creates a string list property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1581,10 +1582,10 @@ public class Configuration
{
return getStringList(name, category, defaultValue, comment, validValues, name);
}
/**
* Creates a string list property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1599,10 +1600,10 @@ public class Configuration
prop.comment = comment + " [default: " + prop.getDefault() + "]";
return prop.getStringList();
}
/**
* Creates a boolean property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1613,10 +1614,10 @@ public class Configuration
{
return getBoolean(name, category, defaultValue, comment, name);
}
/**
* Creates a boolean property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1631,10 +1632,10 @@ public class Configuration
prop.comment = comment + " [default: " + defaultValue + "]";
return prop.getBoolean(defaultValue);
}
/**
* Creates a integer property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1647,10 +1648,10 @@ public class Configuration
{
return getInt(name, category, defaultValue, minValue, maxValue, comment, name);
}
/**
* Creates a integer property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1669,10 +1670,10 @@ public class Configuration
prop.setMaxValue(maxValue);
return prop.getInt(defaultValue) < minValue ? minValue : (prop.getInt(defaultValue) > maxValue ? maxValue : prop.getInt(defaultValue));
}
/**
* Creates a float property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1685,10 +1686,10 @@ public class Configuration
{
return getFloat(name, category, defaultValue, minValue, maxValue, comment, name);
}
/**
* Creates a float property.
*
*
* @param name Name of the property.
* @param category Category of the property.
* @param defaultValue Default value of the property.
@@ -1715,7 +1716,7 @@ public class Configuration
}
return defaultValue;
}
public File getConfigFile()
{
return file;