<commit_before>package musician101.controlcreativemode;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;

import musician101.controlcreativemode.util.CCMUtils;

import org.bukkit.Material;
import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;

public class Config
{
	ControlCreativeMode plugin;
	public boolean blockLavaBucket;
	public boolean blockTNTMinecart;
	public boolean blockWaterBucket;
	public boolean checkForUpdate;
	public List<EntityType> noEntityBasedInventory = new ArrayList<EntityType>();
	public List<EntityType> noSpawn = new ArrayList<EntityType>();
	public List<ItemStack> noBlockBasedInventory = new ArrayList<ItemStack>();
	public List<ItemStack> noDrop = new ArrayList<ItemStack>();
	public List<ItemStack> noPlace = new ArrayList<ItemStack>();
	public List<ItemStack> noThrow = new ArrayList<ItemStack>();
	
	public Config(ControlCreativeMode plugin)
	{
		this.plugin = plugin;
		File config = new File(plugin.getDataFolder(), "config.yml");
		if (!config.exists())
		{
			if (!config.getParentFile().mkdirs()) plugin.getLogger().warning("Could not create config.yml");
			plugin.saveDefaultConfig();
		}
		reloadConfiguration();
	}
	
	public void reloadConfiguration()
	{
		plugin.reloadConfig();
		final FileConfiguration config = plugin.getConfig();
		blockLavaBucket = config.getBoolean("blockLavaBucket", true);
		blockTNTMinecart = config.getBoolean("blockTNTMinecart", true);
		blockWaterBucket = config.getBoolean("blockWaterBucket", true);
		checkForUpdate = config.getBoolean("checkForUpdate", true);
		
		for (String mob : config.getStringList("noEntityBasedInventory"))
		{
			if (mob.equalsIgnoreCase("all"))
				for (EntityType entity : EntityType.values())
					noEntityBasedInventory.add(entity);
			else
				noEntityBasedInventory.add(EntityType.valueOf(mob.toUpperCase()));
		}
		
		/* Includes support for MONSTER_EGG being used to spawn ANY type of Entity
		 * Example: Chicken, Zombie, Minecart, Item Frame, etc.
		 */ 
		for (String mob : config.getStringList("noSpawn"))
		{
			if (mob.equalsIgnoreCase("all"))
				for (EntityType entity : EntityType.values())
					noSpawn.add(entity);
			else
				noSpawn.add(EntityType.valueOf(mob.toUpperCase()));
		}
		
		for (Entry<String, Object> entry : config.getConfigurationSection("noBlockBasedInventory").getValues(true).entrySet())
		{
			if (!(entry.getValue() instanceof MemorySection))
			{
				for (Object data : (List<?>) entry.getValue())
				{
					if (data.equals("all"))
						for (int dura : CCMUtils.getDurabilities(Material.getMaterial(entry.getKey().toUpperCase())))
							noBlockBasedInventory.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, (short) dura));
					else
						noBlockBasedInventory.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, Short.valueOf(data.toString())));
				}
			}
		}
		
		for (Entry<String, Object> entry : config.getConfigurationSection("noDrop").getValues(true).entrySet())
		{
			if (!(entry.getValue() instanceof MemorySection))
			{
				for (Object data : (List<?>) entry.getValue())
				{
					if (data.equals("all"))
						for (int dura : CCMUtils.getDurabilities(Material.getMaterial(entry.getKey().toUpperCase())))
							noDrop.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, (short) dura));
					else
						noDrop.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, Short.valueOf(data.toString())));
				}
			}
		}
		
		for (Entry<String, Object> entry : config.getConfigurationSection("noPlace").getValues(true).entrySet())
		{
			if (!(entry.getValue() instanceof MemorySection))
			{
				for (Object data : (List<?>) entry.getValue())
				{
					if (data.equals("all"))
						for (int dura : CCMUtils.getDurabilities(Material.getMaterial(entry.getKey().toUpperCase())))
							noPlace.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, (short) dura));
					else
						noPlace.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, Short.valueOf(data.toString())));
				}
			}
		}
		
		for (Entry<String, Object> entry : config.getConfigurationSection("noThrow").getValues(true).entrySet())
		{
			if (!(entry.getValue() instanceof MemorySection))
			{
				for (Object data : (List<?>) entry.getValue())
				{
					if (data.equals("all"))
						for (int dura : CCMUtils.getDurabilities(Material.getMaterial(entry.getKey().toUpperCase())))
							noThrow.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, (short) dura));
					else
						noThrow.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, Short.valueOf(data.toString())));
				}
			}
		}
	}
}<commit_msg>Add option for server owners to use an "all" option for various options.<commit_after>package musician101.controlcreativemode;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;

import musician101.controlcreativemode.util.CCMUtils;

import org.bukkit.Material;
import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;

public class Config
{
	ControlCreativeMode plugin;
	public boolean blockLavaBucket;
	public boolean blockTNTMinecart;
	public boolean blockWaterBucket;
	public boolean checkForUpdate;
	public List<EntityType> noEntityBasedInventory = new ArrayList<EntityType>();
	public List<EntityType> noSpawn = new ArrayList<EntityType>();
	public List<ItemStack> noBlockBasedInventory = new ArrayList<ItemStack>();
	public List<ItemStack> noDrop = new ArrayList<ItemStack>();
	public List<ItemStack> noPlace = new ArrayList<ItemStack>();
	public List<ItemStack> noThrow = new ArrayList<ItemStack>();
	
	public Config(ControlCreativeMode plugin)
	{
		this.plugin = plugin;
		File config = new File(plugin.getDataFolder(), "config.yml");
		if (!config.exists())
		{
			if (!config.getParentFile().mkdirs()) plugin.getLogger().warning("Could not create config.yml");
			plugin.saveDefaultConfig();
		}
		reloadConfiguration();
	}
	
	public void reloadConfiguration()
	{
		plugin.reloadConfig();
		final FileConfiguration config = plugin.getConfig();
		blockLavaBucket = config.getBoolean("blockLavaBucket", true);
		blockTNTMinecart = config.getBoolean("blockTNTMinecart", true);
		blockWaterBucket = config.getBoolean("blockWaterBucket", true);
		checkForUpdate = config.getBoolean("checkForUpdate", true);
		
		for (String mob : config.getStringList("noEntityBasedInventory"))
		{
			if (mob.equalsIgnoreCase("all"))
				for (EntityType entity : EntityType.values())
					noEntityBasedInventory.add(entity);
			else
				noEntityBasedInventory.add(EntityType.valueOf(mob.toUpperCase()));
		}
		
		/* Includes support for MONSTER_EGG being used to spawn ANY type of Entity
		 * Example: Chicken, Zombie, Minecart, Item Frame, etc.
		 */ 
		for (String mob : config.getStringList("noSpawn"))
		{
			if (mob.equalsIgnoreCase("all"))
				for (EntityType entity : EntityType.values())
					noSpawn.add(entity);
			else
				noSpawn.add(EntityType.valueOf(mob.toUpperCase()));
		}
		
		for (Entry<String, Object> entry : config.getConfigurationSection("noBlockBasedInventory").getValues(true).entrySet())
		{
			if (!(entry.getValue() instanceof MemorySection))
			{
				if (entry.getKey().equalsIgnoreCase("all"))
				{
					for (Material m : Material.values())
						if (m.isBlock())
							for (int dura : CCMUtils.getDurabilities(m))
								noBlockBasedInventory.add(new ItemStack(m, 0, (short) dura));
				}
				else
				{
					for (Object data : (List<?>) entry.getValue())
					{
						if (data.equals("all"))
							for (int dura : CCMUtils.getDurabilities(Material.getMaterial(entry.getKey().toUpperCase())))
								noBlockBasedInventory.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, (short) dura));
						else
							noBlockBasedInventory.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, Short.valueOf(data.toString())));
					}
				}
			}
		}
		
		for (Entry<String, Object> entry : config.getConfigurationSection("noDrop").getValues(true).entrySet())
		{
			if (!(entry.getValue() instanceof MemorySection))
			{
				if (entry.getKey().equalsIgnoreCase("all"))
				{
					for (Material m : Material.values())
						for (int dura : CCMUtils.getDurabilities(m))
							noDrop.add(new ItemStack(m, 0, (short) dura));
				}
				else
				{
					for (Object data : (List<?>) entry.getValue())
					{
						if (data.equals("all"))
							for (int dura : CCMUtils.getDurabilities(Material.getMaterial(entry.getKey().toUpperCase())))
								noDrop.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, (short) dura));
						else
							noDrop.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, Short.valueOf(data.toString())));
					}
				}
			}
		}
		
		for (Entry<String, Object> entry : config.getConfigurationSection("noPlace").getValues(true).entrySet())
		{
			if (!(entry.getValue() instanceof MemorySection))
			{
				if (entry.getKey().equalsIgnoreCase("all"))
				{
					for (Material m : Material.values())
						if (m.isBlock())
							for (int dura : CCMUtils.getDurabilities(m))
								noPlace.add(new ItemStack(m, 0, (short) dura));
				}
				else
				{
					for (Object data : (List<?>) entry.getValue())
					{
						if (data.equals("all"))
							for (int dura : CCMUtils.getDurabilities(Material.getMaterial(entry.getKey().toUpperCase())))
								noPlace.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, (short) dura));
						else
							noPlace.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, Short.valueOf(data.toString())));
					}
				}
			}
		}
		
		for (Entry<String, Object> entry : config.getConfigurationSection("noThrow").getValues(true).entrySet())
		{
			if (!(entry.getValue() instanceof MemorySection))
			{
				for (Object data : (List<?>) entry.getValue())
				{
					if (data.equals("all"))
						for (int dura : CCMUtils.getDurabilities(Material.getMaterial(entry.getKey().toUpperCase())))
							noThrow.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, (short) dura));
					else
						noThrow.add(new ItemStack(Material.getMaterial(entry.getKey().toUpperCase()), 0, Short.valueOf(data.toString())));
				}
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.1444791370990633, 'fraction_numerical': 0.0029331062541394647, 'mean_word_length': 4.440041173443129, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1880473', 'n_tokens_mistral': 3852, 'n_tokens_neox': 3200, 'n_words': 612}