text:
package someguy.deadliernights;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Creature;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitTask;

/**
 * The core class of DeadlierNights. Starts all scheduled events and handles
 * processing.
 *
 * @author Someguyfromcrowd
 *
 */
public class DeadlierNights extends JavaPlugin implements Listener
{
	private boolean chat;
	private boolean log;

	private boolean potionEnable;
	private boolean mobEnable;
	private boolean scareEnable;
	private boolean fatigueEnable; // TODO: Implement fatigue
	private boolean moonEnable; // TODO: Implement moon moon

	private boolean configError;
	private boolean potionError;
	private boolean mobError;
	private boolean scareError;
	// private boolean fatigueError; //TODO: this too

	private int decayRate;
	private int shortestDelay;
	private ArrayList<EffectTimePair> effects;
	private ArrayList<MobBuff> mobBuffs;
	private ArrayList<Scare> scares;

	private ArrayList<String> defined;
	private HashMap<String, Integer> playerMap;
	private HashMap<String, Boolean> exemptMap;
	private HashMap<String, HashMap<Scare, Integer>> scareMap;

	@Override
	public void onEnable()
	{
		loadConfig();
		loadEffects();
		loadMobBuffs();
		loadScares();

		playerMap = new HashMap<String, Integer>();
		exemptMap = new HashMap<String, Boolean>();
		scareMap = new HashMap<String, HashMap<Scare, Integer>>();
		shortestDelay = getShortestDelay();

		getServer().getPluginManager().registerEvents(this, this);
		for (Player player : getServer().getOnlinePlayers())
		{
			playerMap.put(player.getName(), 0);
			exemptMap.put(player.getName(), player.hasPermission("deadliernights.exempt"));
			scareMap.put(player.getName(), new HashMap<Scare, Integer>());
			for (Scare scare : scares)
			{
				scareMap.get(player.getName()).put(scare, -1 * scare.getExtraFrequencyRandom());
			}
		}

		@SuppressWarnings("unused")
		BukkitTask checker = new PlayerCheckTask(this).runTaskTimer(this, 0, 20L);
	}

	/**
	 * Goes through the list of players and increments their exposure counters
	 * if they are in total darkness. If not, their counters are either reset or
	 * decremented. Any relevant potion effects are either added or removed.
	 */
	public void checkPlayers()
	{
		for (Player player : getServer().getOnlinePlayers())
		{
			String playerName = player.getName();
			if (!playerMap.containsKey(playerName))
			{
				playerMap.put(playerName, 0);
				exemptMap.put(playerName, player.hasPermission("deadliernights.exempt"));
				scareMap.put(playerName, new HashMap<Scare, Integer>());
				for (Scare scare : scares)
				{
					scareMap.get(playerName).put(scare, -1 * scare.getExtraFrequencyRandom());
				}
			}

			if (!exemptMap.get(playerName).booleanValue() && getServer().getWorld(player.getWorld().getName()).getTime() % 24000 >= 14000 && player.getLocation().getBlock().getLightFromBlocks() == 0 && !(player.getGameMode().equals(GameMode.CREATIVE)))
			{
				playerMap.put(playerName, playerMap.get(playerName) + 1);
				int current = playerMap.get(playerName);

				if (potionEnable)
				{
					for (EffectTimePair pair : effects)
					{
						if (!moonEnable || pair.isRunning(this.getMoonPhase(player.getWorld())))
						{
							if (pair.getDelay() < current)
							{
								if (!player.hasPotionEffect(pair.getEffect()))
								{
									player.addPotionEffect(new PotionEffect(pair.getEffect(), Integer.MAX_VALUE, pair.getLevel()), true);
									if (log)
										getLogger().info("Applied " + pair.getEffect().getName() + " " + pair.getLevel() + " to " + playerName);
								}
							}
							else if (pair.getDelay() == current)
							{
								player.addPotionEffect(new PotionEffect(pair.getEffect(), Integer.MAX_VALUE, pair.getLevel()), true);
								if (log)
									getLogger().info("Applied " + pair.getEffect().getName() + " " + pair.getLevel() + " to " + playerName);
								if (chat && !pair.getText().equals(""))
									player.sendMessage(pair.getText());
							}
						}
					}
				}
			}
			else if (playerMap.get(playerName) > 0)
			{
				if (decayRate == 0)
				{
					if (playerMap.get(playerName) >= shortestDelay)
					{
						if (log)
							getLogger().info("Debuffs removed from " + playerName);
						if (chat)
							player.sendMessage("You escape from the darkness.");
						for (EffectTimePair pair : effects)
						{
							player.removePotionEffect(pair.getEffect());
						}
					}
					playerMap.put(playerName, 0);
				}
				else
				{
					int startVal = playerMap.get(playerName);
					playerMap.put(playerName, playerMap.get(player.getName()) - decayRate);
					if (playerMap.get(playerName) < 0)
						playerMap.put(playerName, 0);

					for (EffectTimePair pair : effects)
					{
						if (player.hasPotionEffect(pair.getEffect()) && playerMap.get(playerName) < pair.getDelay() && startVal >= pair.getDelay())
						{
							player.removePotionEffect(pair.getEffect());
							if (chat && !pair.getOffText().equals(""))
								player.sendMessage(pair.getOffText());
						}
					}
				}
			}
		}
	}

	/**
	 * Reacts to monster spawns by applying potion effects if needed
	 *
	 * @param e
	 */

	@EventHandler
	public void onCreatureSpawn(CreatureSpawnEvent e)
	{
		if (mobEnable)
		{
			for (Player player : getServer().getOnlinePlayers())
			{
				String playerName = player.getName();
				if (!playerMap.containsKey(playerName))
				{
					playerMap.put(playerName, 0);
					exemptMap.put(playerName, player.hasPermission("deadliernights.exempt"));
					scareMap.put(playerName, new HashMap<Scare, Integer>());
					for (Scare scare : scares)
					{
						scareMap.get(playerName).put(scare, -1 * scare.getExtraFrequencyRandom());
					}
				}
				if (player.getLocation().distance(e.getLocation()) <= 32)
				{
					for (MobBuff buff : mobBuffs)
					{
						if (!moonEnable || buff.isRunning(this.getMoonPhase(player.getWorld())))
						{
							if (buff.getMobs().contains(e.getEntityType()) && buff.getDelay() < playerMap.get(player.getName()))
							{
								for (PotionEffect eff : buff.getBuffs())
								{
									e.getEntity().addPotionEffect(eff, true);
								}

								if (buff.getHealthMult() != 1)
									e.getEntity().setMaxHealth(e.getEntity().getMaxHealth() * buff.getHealthMult());

								if (!buff.canDrown())
									e.getEntity().setMaximumAir(Integer.MAX_VALUE);

								if (buff.autoChase())
									((Creature) e.getEntity()).setTarget(player);

							}
						}
					}
				}
			}
		}
	}

	/**
	 * Checks to see if players have exceeded the scare thresholds and performs
	 * relevant events if this is the case
	 */
	public void scarePlayers()
	{
		if (scareEnable)
		{
			for (Player player : getServer().getOnlinePlayers())
			{
				String playerName = player.getName();
				if (!playerMap.containsKey(playerName))
				{
					playerMap.put(playerName, 0);
					exemptMap.put(playerName, player.hasPermission("deadliernights.exempt"));
					scareMap.put(playerName, new HashMap<Scare, Integer>());
					for (Scare scare : scares)
					{
						scareMap.get(playerName).put(scare, -1 * scare.getExtraFrequencyRandom());
					}
				}

				for (Scare scare : scares)
				{
					if (!moonEnable || scare.isRunning(this.getMoonPhase(player.getWorld())))
					{
						if (scare.getDelay() <= playerMap.get(playerName))
						{
							if (scareMap.get(playerName).get(scare) > scare.getFrequency() && scare.triggerScare())
							{
								if (scare.getType().equals(ScareType.FAKESOUND))
								{
									int randomX = player.getLocation().getBlockX() + ((int) (2 * Math.random() * scare.getRange())) - scare.getRange();
									int randomY = player.getLocation().getBlockY();
									int randomZ = player.getLocation().getBlockZ() + ((int) (2 * Math.random() * scare.getRange())) - scare.getRange();
									player.playSound(new Location(player.getWorld(), randomX, randomY, randomZ), Sound.valueOf(scare.getSoundToPlay().toUpperCase()), 1, 1);
								}
								scareMap.get(playerName).put(scare, -1 * scare.getExtraFrequencyRandom());
							}
							else
							{
								scareMap.get(playerName).put(scare, scareMap.get(playerName).get(scare) + 1);
							}
						}
					}

				}
			}
		}
	}

	/**
	 * @param event
	 */
	@EventHandler(priority = EventPriority.MONITOR)
	public void onGamemodeChange(PlayerGameModeChangeEvent event)
	{
		if (event.getNewGameMode().equals(GameMode.CREATIVE))
		{
			if (playerMap.containsKey(event.getPlayer().getName()))
			{
				playerMap.put(event.getPlayer().getName(), 0);
				curePlayer(event.getPlayer());
			}
		}

	}

	/**
	 * @param event
	 */
	@EventHandler(priority = EventPriority.MONITOR)
	public void onPlayerRespawn(PlayerRespawnEvent event)
	{
		String playerName = event.getPlayer().getName();
		if (!playerMap.containsKey(playerName))
		{
			playerMap.put(playerName, 0);
			exemptMap.put(playerName, event.getPlayer().hasPermission("deadliernights.exempt"));
			scareMap.put(playerName, new HashMap<Scare, Integer>());
			for (Scare scare : scares)
			{
				scareMap.get(playerName).put(scare, -1 * scare.getExtraFrequencyRandom());
			}
		}
		playerMap.put(event.getPlayer().getName(), 0);
		for (EffectTimePair pair : effects)
		{
			if (event.getPlayer().hasPotionEffect(pair.getEffect()) && playerMap.get(event.getPlayer().getName()) < pair.getDelay())
			{
				event.getPlayer().removePotionEffect(pair.getEffect());
			}
		}
	}

	/**
	 * @param event
	 */
	@EventHandler(priority = EventPriority.MONITOR)
	public void onPlayerLogin(PlayerJoinEvent event)
	{
		String playerName = event.getPlayer().getName();
		if (!playerMap.containsKey(playerName))
		{
			playerMap.put(playerName, 0);
			exemptMap.put(playerName, event.getPlayer().hasPermission("deadliernights.exempt"));
			scareMap.put(playerName, new HashMap<Scare, Integer>());
			for (Scare scare : scares)
			{
				scareMap.get(playerName).put(scare, -1 * scare.getExtraFrequencyRandom());
			}
		}
		for (EffectTimePair pair : effects)
		{
			if (event.getPlayer().hasPotionEffect(pair.getEffect()) && playerMap.get(event.getPlayer().getName()) < pair.getDelay())
			{
				event.getPlayer().removePotionEffect(pair.getEffect());
			}
		}
	}

	/**
	 * @param event
	 */
	@EventHandler(priority = EventPriority.MONITOR)
	public void onPlayerLogout(PlayerQuitEvent event)
	{
		String playerName = event.getPlayer().getName();
		if (!playerMap.containsKey(playerName))
		{
			playerMap.put(playerName, 0);
			exemptMap.put(playerName, event.getPlayer().hasPermission("deadliernights.exempt"));
			scareMap.put(playerName, new HashMap<Scare, Integer>());
			for (Scare scare : scares)
			{
				scareMap.get(playerName).put(scare, -1 * scare.getExtraFrequencyRandom());
			}
		}
		for (EffectTimePair pair : effects)
		{
			if (event.getPlayer().hasPotionEffect(pair.getEffect()) && playerMap.get(event.getPlayer().getName()) < pair.getDelay())
			{
				event.getPlayer().removePotionEffect(pair.getEffect());
			}
		}
	}

	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
	{
		if (cmd.getName().equalsIgnoreCase("DNchat"))
		{
			if (args.length == 0)
			{
				if (chat)
					sender.sendMessage("[DeadlierNights]: Chat messages are enabled");
				else
					sender.sendMessage("[DeadlierNights]: Chat messages are disabled");
				return true;
			}
			else if (args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("on"))
			{
				chat = true;
				sender.sendMessage("[DeadlierNights]: Chat messages enabled.");
				return true;
			}
			else if (args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disable") || args[0].equalsIgnoreCase("off"))
			{
				chat = false;
				sender.sendMessage("[DeadlierNights]: Chat messages disabled.");
				return true;
			}
			else
				return false;

		}
		else if (cmd.getName().equalsIgnoreCase("DNlog"))
		{
			if (args.length == 0)
			{
				if (log)
					sender.sendMessage("[DeadlierNights]: Log messages are enabled");
				else
					sender.sendMessage("[DeadlierNights]: Log messages are disabled");
				return true;
			}
			else if (args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("on"))
			{
				log = true;
				sender.sendMessage("[DeadlierNights]: Log messages enabled.");
				return true;
			}
			else if (args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disable") || args[0].equalsIgnoreCase("off"))
			{
				log = false;
				sender.sendMessage("[DeadlierNights]: Log messages disabled.");
				return true;
			}
			else
			{
				return false;
			}
		}
		else if (cmd.getName().equalsIgnoreCase("DNpotion"))
		{
			if (args.length == 0)
			{
				if (potionEnable)
					sender.sendMessage("[DeadlierNights]: Potion debuffs are enabled");
				else
					sender.sendMessage("[DeadlierNights]: Potion debuffs are disabled");
				return true;
			}
			else
			{
				if (args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("on"))
				{
					potionEnable = true;
					sender.sendMessage("[DeadlierNights]: Potion debuffs enabled.");
					return true;
				}
				else if (args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disable") || args[0].equalsIgnoreCase("off"))
				{
					potionEnable = false;
					sender.sendMessage("[DeadlierNights]: Potion debuffs disabled.");

					for (Player player : getServer().getOnlinePlayers())
					{
						String playerName = player.getName();
						if (!playerMap.containsKey(playerName))
						{
							playerMap.put(playerName, 0);
							exemptMap.put(playerName, player.hasPermission("deadliernights.exempt"));
							scareMap.put(playerName, new HashMap<Scare, Integer>());
							for (Scare scare : scares)
							{
								scareMap.get(player.getName()).put(scare, -1 * scare.getExtraFrequencyRandom());
							}
						}

						for (EffectTimePair pair : effects)
							if (player.hasPotionEffect(pair.getEffect()) && playerMap.get(player.getName()) >= pair.getDelay())
							{
								player.removePotionEffect(pair.getEffect());
							}

					}

					return true;
				}
				else
					return false;
			}
		}
		else if (cmd.getName().equalsIgnoreCase("DNmob"))
		{
			if (args.length == 0)
			{
				if (mobEnable)
					sender.sendMessage("[DeadlierNights]: Mob buffs are enabled");
				else
					sender.sendMessage("[DeadlierNights]: Mob buffs are disabled");
				return true;
			}
			else
			{
				if (args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("on"))
				{
					mobEnable = true;
					sender.sendMessage("[DeadlierNights]: Mob buffs enabled.");
					return true;
				}
				else if (args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disable") || args[0].equalsIgnoreCase("off"))
				{
					mobEnable = false;
					sender.sendMessage("[DeadlierNights]: Mob buffs disabled.");
					return true;
				}
				else
					return false;
			}
		}
		else if (cmd.getName().equalsIgnoreCase("DNscare"))
		{
			if (args.length == 0)
			{
				if (scareEnable)
					sender.sendMessage("[DeadlierNights]: Scares are enabled");
				else
					sender.sendMessage("[DeadlierNights]: Scares are disabled");
				return true;
			}
			else
			{
				if (args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("on"))
				{
					scareEnable = true;
					sender.sendMessage("[DeadlierNights]: Scares enabled.");
					return true;
				}
				else if (args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disable") || args[0].equalsIgnoreCase("off"))
				{
					scareEnable = false;
					sender.sendMessage("[DeadlierNights]: Scares disabled.");
					return true;
				}
				else
					return false;
			}
		}
		else if (cmd.getName().equalsIgnoreCase("DNfatigue"))
		{
			if (args.length == 0)
			{
				if (fatigueEnable)
					sender.sendMessage("[DeadlierNights]: Fatigue is enabled");
				else
					sender.sendMessage("[DeadlierNights]: Fatigue is disabled");
				return true;
			}
			else
			{
				if (args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("on"))
				{
					fatigueEnable = true;
					sender.sendMessage("[DeadlierNights]: Fatigue enabled.");
					return true;
				}
				else if (args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disable") || args[0].equalsIgnoreCase("off"))
				{
					fatigueEnable = false;
					sender.sendMessage("[DeadlierNights]: Fatigue disabled.");
					return true;
				}
				else
					return false;
			}
		}
		else if (cmd.getName().equalsIgnoreCase("DNMoon"))
		{
			if (args.length == 0)
			{
				if (moonEnable)
					sender.sendMessage("[DeadlierNights]: Moon effects are enabled");
				else
					sender.sendMessage("[DeadlierNights]: Moon effects are disabled");
				return true;
			}
			else
			{
				if (args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("on"))
				{
					moonEnable = true;
					sender.sendMessage("[DeadlierNights]: Moon effects enabled.");
					return true;
				}
				else if (args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disable") || args[0].equalsIgnoreCase("off"))
				{
					scareEnable = false;
					sender.sendMessage("[DeadlierNights]: Moon effects disabled.");
					return true;
				}
				else
					return false;
			}
		}
		else if (cmd.getName().equalsIgnoreCase("DNDecay"))
		{
			if (args.length == 0)
			{
				if (decayRate == 0)
					sender.sendMessage("[DeadlierNights]: Decay is currently disabled.");
				else
					sender.sendMessage("[DeadlierNights]: The decay is currently set to " + decayRate + "/sec");
				return true;
			}
			else
			{
				try
				{
					int input = Integer.parseInt(args[0]);
					decayRate = input;
					sender.sendMessage("[DeadlierNights]: The decay is now set to " + decayRate + "/sec");
				}
				catch (NumberFormatException e)
				{
					return false;
				}
				return true;
			}
		}
		else if (cmd.getName().equalsIgnoreCase("DNreload"))
		{
			reload();
			sender.sendMessage("[DeadlierNights]: All configuration files reloaded!");
			return true;
		}
		else if (cmd.getName().equalsIgnoreCase("DNexempt"))
		{
			if (args.length == 0)
			{
				if (exemptMap.get(sender.getName()).booleanValue())
					sender.sendMessage("[DeadlierNights]: You are immune to DeadlierNights");
				else
					sender.sendMessage("[DeadlierNights]: You are not immune to DeadlierNights");
				return true;
			}
			else if (args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("on"))
			{
				exemptMap.put(sender.getName(), Boolean.TRUE);
				sender.sendMessage("[DeadlierNights]: You are now immune to DeadlierNights.");
				return true;
			}
			else if (args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disable") || args[0].equalsIgnoreCase("off"))
			{
				exemptMap.put(sender.getName(), Boolean.FALSE);
				sender.sendMessage("[DeadlierNights]: You are no longer immune to DeadlierNights.");
				return true;
			}
			else
			{
				return false;
			}
		}
		else if (cmd.getName().equalsIgnoreCase("DNexempto"))
		{
			if (args.length == 0)
			{
				return false;
			}
			else
			{
				String playerName = pickPlayer(args[0]);
				if (playerName.equals("<FAILED>"))
				{
					sender.sendMessage("[DeadlierNights]: Couldn't pick a player with that name.");
					return false;
				}
				else
				{
					if (args.length == 1)
					{
						if (exemptMap.get(playerName).booleanValue())
						{
							sender.sendMessage("[DeadlierNights]: " + playerName + " is exempt from DeadlierNights");
							return true;
						}
						else
						{
							sender.sendMessage("[DeadlierNights]: " + playerName + " is not exempt from DeadlierNights");
							return true;
						}
					}
					else if (args.length == 2)
					{
						if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("enable") || args[1].equalsIgnoreCase("on"))
						{
							exemptMap.put(playerName, Boolean.TRUE);
							sender.sendMessage("[DeadlierNights]: " + playerName + " is now exempt from DeadlierNights");
							getServer().getPlayer(playerName).sendMessage("[DeadlierNights]: You are now immune to DeadlierNights.");
							return true;
						}
						else if (args[1].equalsIgnoreCase("false") || args[1].equalsIgnoreCase("disable") || args[1].equalsIgnoreCase("off"))
						{
							exemptMap.put(playerName, Boolean.FALSE);
							sender.sendMessage("[DeadlierNights]: " + playerName + " is no longer exempt from DeadlierNights");
							getServer().getPlayer(playerName).sendMessage("[DeadlierNights]: You are no longer immune to DeadlierNights.");
							return true;
						}
						else
							return false;
					}
					else
						return false;
				}

			}
		}
		else if (cmd.getName().equalsIgnoreCase("DNcure"))
		{
			if (args.length >= 1)
			{
				Player player = getServer().getPlayer(pickPlayer(args[0]));
				this.curePlayer(player);
				return true;
			}
			else
			{
				Player player = getServer().getPlayer(sender.getName());
				this.curePlayer(player);
				return true;
			}
		}
		else if (cmd.getName().equalsIgnoreCase("DNhelp"))
		{
			if (args.length == 0)
			{
				sender.sendMessage("[DeadlierNights]: For help, type one of the following commands:");
				sender.sendMessage("Info: /dnhelp info");
				sender.sendMessage("Version: /dnhelp version");
				return true;
			}
			else if (args.length >= 1)
			{
				if (args[0].equalsIgnoreCase("info"))
				{
					sender.sendMessage("DeadlierNights is a plugin designed to make nighttime survival more difficult. Staying in the dark for too long at night can afflict you with debuffs, make mobs stronger, and more.");
					return true;
				}
				else if (args[0].equalsIgnoreCase("version"))
				{
					sender.sendMessage("The current version of DeadlierNights is " + this.getDescription().getVersion());
					return true;
				}
				else
					return false;
			}
			else
				return false;
		}
		else if (cmd.getName().equalsIgnoreCase("DNstatus"))
		{
			if (args.length == 0)
			{
				sender.sendMessage("[DeadlierNights]: Type a command below to view DN's status:");
				sender.sendMessage("/dnstatus config: View information about config files");
				sender.sendMessage("/dnstatus players: View information about player exposure");
				return true;
			}
			else if (args.length == 1)
			{
				if (args[0].equalsIgnoreCase("config"))
				{
					sender.sendMessage("[DeadlierNights]: The following configuration files are loaded");
					if (configError)
						sender.sendMessage("config: ERROR");
					else
						sender.sendMessage("config: loaded");
					if (potionError)
						sender.sendMessage("effects: ERROR; " + effects.size() + " effects loaded");
					else if (!potionEnable)
						sender.sendMessage("effects: disabled; " + effects.size() + " effects loaded");
					else
						sender.sendMessage("effects: loaded; " + effects.size() + " effects loaded");
					if (mobError)
						sender.sendMessage("mobBuffs: ERROR; " + effects.size() + " mob buffs loaded");
					else if (!mobEnable)
						sender.sendMessage("mobBuffs: disabled; " + mobBuffs.size() + " mob buffs loaded");
					else
						sender.sendMessage("mobBuffs: loaded; " + mobBuffs.size() + " mob buffs  loaded");
					if (scareError)
						sender.sendMessage("scares: ERROR; " + scares.size() + " scares loaded");
					else if (!scareEnable)
						sender.sendMessage("scares: disabled; " + scares.size() + " scares loaded");
					else
						sender.sendMessage("scares: loaded; " + scares.size() + " scares loaded");
					return true;
				}
				else if (args[0].equalsIgnoreCase("players"))
				{
					sender.sendMessage("[DeadlierNights]: Information for players is as follows:");

					for (Player player : getServer().getOnlinePlayers())
					{
						if (exemptMap.containsKey(player.getName()))
						{
							if (exemptMap.get(player.getName()))
								sender.sendMessage(player.getName() + " is exempt from DeadlierNights");
							else
								sender.sendMessage(player.getName() + " has an exposure level of " + playerMap.get(player.getName()));
						}
					}
					return true;
				}
				else
					return false;
			}
			else
				return false;
		}
		else
		{
			return false;
		}

	}

	private void loadConfig()
	{
		configError = false;
		defined = new ArrayList<String>();
		Scanner scanner;
		int line = 0;
		try
		{
			scanner = new Scanner(new File("plugins\\DeadlierNights\\config.txt"));
			try
			{
				String input = "";
				while (scanner.hasNext())
				{
					try
					{
						line++;
						input = scanner.nextLine();
						if (input.contains("decay rate:"))
						{
							decayRate = intConfigCheck(input, "decay rate:");
							if (decayRate < 0)
								throw new DNConfigException("Error: decay rate must have a value greater or equal to zero on line " + line);
						}

						else if (input.contains("chat:"))
							chat = boolConfigCheck(input, "chat:");
						else if (input.contains("log:"))
							log = boolConfigCheck(input, "log:");
						else if (input.contains("potionDebuff:"))
							potionEnable = boolConfigCheck(input, "potionDebuff:");
						else if (input.contains("mobBuff:"))
							mobEnable = boolConfigCheck(input, "mobBuff:");
						else if (input.contains("scare:"))
							scareEnable = boolConfigCheck(input, "scare:");
						else if (input.contains("fatigue:"))
							fatigueEnable = boolConfigCheck(input, "fatigue:");
						else if (input.contains("moonEffects:"))
							moonEnable = boolConfigCheck(input, "moonEffects:");
					}
					catch (DNConfigException e)
					{
						configError = true;
						getLogger().warning(e.getMessage() + line);
					}
					catch (NumberFormatException e)
					{
						configError = true;
						getLogger().warning("Error: Can't read an entry in config.txt (is there a typo on line " + line + "?)");
					}
				}
			}
			finally
			{
				scanner.close();
			}
		}
		catch (FileNotFoundException e)
		{
			try
			{
				getLogger().info(new java.io.File(".").getCanonicalPath());
			}
			catch (IOException e1)
			{
				configError = true;
				e1.printStackTrace();
			}
			try
			{
				(new File("plugins\\DeadlierNights")).mkdirs();
				PrintWriter out = new PrintWriter(new File("plugins\\DeadlierNights\\config.txt"));
				out.println("decay rate: 0");
				out.println("chat: true");
				out.println("log: true");
				out.println("potionDebuff: true");
				out.println("mobBuff: true");
				out.close();
				loadConfig();
			}
			catch (IOException ee)
			{
				configError = true;
				getLogger().warning(ee.getMessage());
			}
		}
	}

	private void loadEffects()
	{
		potionError = false;
		boolean ready = true;
		effects = new ArrayList<EffectTimePair>();
		Scanner scanner;
		int line = 0;
		try
		{
			scanner = new Scanner(new File("plugins\\DeadlierNights\\effects.txt"));
			try
			{
				String input = "";
				while (scanner.hasNext())
				{
					boolean done = false;
					int newDelay = -1;
					PotionEffectType newEffect = null;
					int newLevel = 0;
					String newText = "";
					String newOffText = "";
					MoonPhase minMoon = MoonPhase.NEW;
					MoonPhase maxMoon = MoonPhase.FULL;

					if (!ready)
						ready = scanner.nextLine().contains("---");
					while (ready && !done)
					{
						try
						{
							line++;
							input = scanner.nextLine();
							if (input.contains("delay:"))
							{
								newDelay = Integer.parseInt(input.replaceAll("delay:", "").replaceAll("^[ \t]+", ""));
								if (newDelay <= 0)
									throw new DNConfigException("Error: delay must have a value greater than zero on line " + line);
							}

							else if (input.contains("effect:"))
							{
								newEffect = PotionEffectType.getByName(stringConfigCheck(input, "effect:").replaceAll("[ \t]+[0-9]+$", "").toUpperCase());
								newLevel = Integer.parseInt(stringConfigCheck(input, "effect:").replaceAll("^[A-Z,a-z]*[ \t]+", "")) - 1;
							}
							else if (input.contains("offtext:"))
								newOffText = stringConfigCheck(input, "offtext:");
							else if (input.contains("text:"))
								newText = stringConfigCheck(input, "text:");
							else if (input.contains("minMoon:"))
								minMoon = MoonPhase.valueOf(stringConfigCheck(input, "minMoon:"));
							else if (input.contains("maxMoon:"))
								maxMoon = MoonPhase.valueOf(stringConfigCheck(input, "maxMoon:"));
							if (input.contains("---"))
							{
								done = true;
								if (newDelay == -1 || newEffect == null)
									throw new DNConfigException("Error: delay or effect is missing from an effects entry on line " + line);
								effects.add(new EffectTimePair(newDelay, newEffect, newLevel, newText, newOffText, minMoon.getBright(), maxMoon.getBright()));
							}
						}
						catch (DNConfigException e)
						{
							getLogger().warning("Error: Can't read an entry in effects.txt (is there a typo on line " + line + "?)");
							potionError = true;
							ready = false;
						}
						catch (NumberFormatException e)
						{
							getLogger().warning("Error: Can't read an entry in effects.txt (is there a typo on line " + line + "?)");
							potionError = true;
							ready = false;
						}
						catch (IllegalArgumentException e)
						{
							getLogger().warning("Error: Can't read an entry in effects.txt (is there a typo on line " + line + "?)");
							potionError = true;
							ready = false;
						}
					}
				}
			}
			finally
			{
				scanner.close();
			}
		}
		catch (FileNotFoundException e)
		{
			try
			{
				getLogger().info(new java.io.File(".").getCanonicalPath());
			}
			catch (IOException e1)
			{
				potionError = true;
				e1.printStackTrace();
			}
			try
			{
				(new File("plugins\\DeadlierNights")).mkdirs();
				PrintWriter out = new PrintWriter(new File("plugins\\DeadlierNights\\effects.txt"));
				out.println("delay: 5");
				out.println("effect: SLOW");
				out.println("level: 1");
				out.println("text: Example Text 1");
				out.println("offtext: Example Off Text 1");
				out.println("---");
				out.println("delay: 10");
				out.println("effect: WEAKNESS");
				out.println("level: 2");
				out.println("text: Example Text 2");
				out.println("offtext: Example Off Text 2");
				out.println("---");
				out.println("delay: 15");
				out.println("effect: BLINDNESS");
				out.println("level: 3");
				out.println("text: Example Text 3");
				out.println("---");
				out.close();
				loadEffects();
			}
			catch (IOException ee)
			{
				potionError = true;
				getLogger().warning(ee.getMessage());
			}
		}
	}

	private void loadMobBuffs()
	{
		mobError = false;
		boolean ready = true;
		mobBuffs = new ArrayList<MobBuff>();
		Scanner scanner;
		int line = 0;
		try
		{
			scanner = new Scanner(new File("plugins\\DeadlierNights\\mobBuffs.txt"));
			try
			{
				String input = "";
				while (scanner.hasNext())
				{
					boolean done = false;
					int newDelay = -1;
					PotionEffectType newEffect = null;
					int newLevel = 0;
					ArrayList<EntityType> mobs = new ArrayList<EntityType>();
					ArrayList<PotionEffect> effects = new ArrayList<PotionEffect>();
					double healthMult = 1;
					boolean canDrown = true;
					boolean autoChase = false;
					MoonPhase minMoon = MoonPhase.NEW;
					MoonPhase maxMoon = MoonPhase.FULL;

					if (!ready)
						ready = scanner.nextLine().contains("---");

					while (!done && ready)
					{
						try
						{
							line++;
							input = scanner.nextLine();
							if (input.contains("delay:"))
								newDelay = Integer.parseInt(input.replaceAll("delay:", "").replaceAll("^[ \t]+", ""));
							else if (input.contains("mob:"))
								mobs.add(EntityType.valueOf(stringConfigCheck(input, "mob:").toUpperCase()));
							else if (input.contains("effect:"))
							{
								newEffect = PotionEffectType.getByName(stringConfigCheck(input, "effect:").replaceAll("[ \t]+[0-9]+$", ""));
								newLevel = Integer.parseInt(stringConfigCheck(input, "effect:").replaceAll("^[A-Z,a-z]*[ \t]+", "")) - 1;
								effects.add(new PotionEffect(newEffect, Integer.MAX_VALUE, newLevel));
							}
							else if (input.contains("healthMult:"))
								healthMult = doubleConfigCheck(input, "healthMult:");
							else if (input.contains("canDrown:"))
								canDrown = boolConfigCheck(input, "canDrown:");
							else if (input.contains("autoChase:"))
								autoChase = boolConfigCheck(input, "autoChase:");
							else if (input.contains("minMoon:"))
								minMoon = MoonPhase.valueOf(stringConfigCheck(input, "minMoon:"));
							else if (input.contains("maxMoon:"))
								maxMoon = MoonPhase.valueOf(stringConfigCheck(input, "maxMoon:"));

							if (input.contains("---"))
							{
								done = true;
								if (mobs.size() == 0)
									throw new DNConfigException("Error: There are no mobs specified in mobs.txt on line ");
								if (newDelay == -1)
									throw new DNConfigException("Error: There is no delay specified in mobs.txt on line ");
								mobBuffs.add(new MobBuff(newDelay, mobs, effects, healthMult, canDrown, autoChase, minMoon.getBright(), maxMoon.getBright()));
							}
						}
						catch (DNConfigException e)
						{
							getLogger().warning(e.getMessage() + " " + line);
							mobError = true;
							ready = false;
						}
						catch (NumberFormatException e)
						{
							getLogger().warning("Error: Can't read an entry in mobBuffs.txt (is there a typo on line " + line + "?)");
							mobError = true;
							ready = false;
						}
						catch (IllegalArgumentException e)
						{
							getLogger().warning("Error: Can't read an entry in mobBuffs.txt (is there a typo on line " + line + "?)");
							mobError = true;
							ready = false;
						}
					}
				}
			}

			finally
			{
				scanner.close();
			}
		}
		catch (FileNotFoundException e)
		{
			try
			{
				getLogger().info(new java.io.File(".").getCanonicalPath());
			}
			catch (IOException e1)
			{
				mobError = true;
				e1.printStackTrace();
			}
			try
			{
				(new File("plugins\\DeadlierNights")).mkdirs();
				PrintWriter out = new PrintWriter(new File("plugins\\DeadlierNights\\mobBuffs.txt"));
				out.println("delay: 5");
				out.println("mob: skeleton");
				out.println("effect: speed 1");
				out.println("---");
				out.println("delay: 15");
				out.println("mob: zombie");
				out.println("mob: skeleton");
				out.println("effect: jump 3");
				out.println("healthMult: 1.5");
				out.println("canDrown: false");
				out.println("---");
				out.close();
				loadMobBuffs();
			}
			catch (IOException ee)
			{
				mobError = true;
				getLogger().warning(ee.getMessage());
			}
		}

	}

	// TODO: Add documentation to config files

	// TODO: Make server commands write to the config files

	private void loadScares()
	{
		scareError = false;
		boolean ready = true;
		scares = new ArrayList<Scare>();
		Scanner scanner;
		int line = 0;
		try
		{
			scanner = new Scanner(new File("plugins\\DeadlierNights\\scares.txt"));
			try
			{
				String input = "";
				while (scanner.hasNext())
				{
					boolean done = false;
					ScareType newType = null;
					int newDelay = -1;
					int newFrequency = -1;
					int newExtraFrequency = 0;
					double newProbability = -1;
					MoonPhase minMoon = MoonPhase.NEW;
					MoonPhase maxMoon = MoonPhase.FULL;

					String newSoundToPlay = null;
					int newVolume = 1;
					int newRange = 10;

					if (!ready)
						ready = scanner.nextLine().contains("---");

					while (!done && ready)
					{
						try
						{
							line++;
							input = scanner.nextLine();
							if (input.contains("type:"))
								newType = ScareType.valueOf(stringConfigCheck(input, "type:").toUpperCase());
							else if (input.contains("delay:"))
							{
								newDelay = Integer.parseInt(stringConfigCheck(input, "delay:"));
								if (newDelay <= 0)
									throw new DNConfigException("Error: Delay must have a value of greater than zero on line ");
							}
							else if (input.contains("extrafrequency:"))
							{
								newExtraFrequency = Integer.parseInt(stringConfigCheck(input, "extrafrequency:"));
								if (newExtraFrequency < 0)
									throw new DNConfigException("Error: Extra frequency must have a value of greater or equal to zero on line ");
							}
							else if (input.contains("frequency:"))
							{
								newFrequency = Integer.parseInt(stringConfigCheck(input, "frequency:"));
								if (newFrequency <= 0)
									throw new DNConfigException("Error: Frequency must have a value of greater than zero on line ");
							}
							else if (input.contains("probability"))
								newProbability = Double.parseDouble(input.replaceAll("probability:", "").replaceAll("^[ \t]+", ""));
							else if (input.contains("minMoon:"))
								minMoon = MoonPhase.valueOf(stringConfigCheck(input, "minMoon:"));
							else if (input.contains("maxMoon:"))
								maxMoon = MoonPhase.valueOf(stringConfigCheck(input, "maxMoon:"));
							else if (input.contains("sound:"))
								newSoundToPlay = input.replaceAll("sound:", "").replaceAll("^[ \t]+", "");
							else if (input.contains("volume:"))
								newVolume = intConfigCheck(input, "volume:");
							else if (input.contains("range:"))
								newRange = intConfigCheck(input, "range:");
							if (input.contains("---"))
							{
								done = true;
								if (newType == null)
									throw new DNConfigException("Scare is missing a type; ends on line ");
								else
								{
									if (newDelay == -1)
										throw new DNConfigException("Error: FakeSound scare is missing a delay on line ");
									if (newFrequency == -1)
										throw new DNConfigException("Error: FakeSound scare is missing a frequency on line ");
									if (newProbability == -1)
										throw new DNConfigException("Error: FakeSound scare is missing a probability on line ");

									if (newType.equals(ScareType.FAKESOUND))
									{
										if (newSoundToPlay == null)
											throw new DNConfigException("Error: FakeSound scare is missing a sound on line ");
										scares.add(new Scare(ScareType.FAKESOUND, newDelay, newFrequency, newExtraFrequency, newProbability, newSoundToPlay, newVolume, newRange, minMoon.getBright(), maxMoon.getBright()));
									}
								}
							}
						}
						catch (DNConfigException e)
						{
							getLogger().warning(e.getMessage() + " " + line);
							scareError = true;
							ready = false;
						}
						catch (NumberFormatException e)
						{
							getLogger().warning("ERROR: Can't read an entry in scares.txt (is there a typo on line " + line + "?)");
							scareError = true;
							ready = false;
						}
					}
				}
			}

			finally
			{
				scanner.close();
			}
		}
		catch (FileNotFoundException e)
		{
			try
			{
				getLogger().info(new java.io.File(".").getCanonicalPath());
			}
			catch (IOException e1)
			{
				scareError = true;
				e1.printStackTrace();
			}
			try
			{
				(new File("plugins\\DeadlierNights")).mkdirs();
				PrintWriter out = new PrintWriter(new File("plugins\\DeadlierNights\\scares.txt"));
				out.println("type: fakesound");
				out.println("sound: mob.skeleton.say");
				out.println("delay: 10");
				out.println("frequency: 5");
				out.println("probability: 0.75");
				out.println("---");
				out.close();
			}
			catch (IOException ee)
			{
				scareError = true;
				getLogger().warning(ee.getMessage());
			}
		}

	}

	// TODO: Make this more forgiving

	private boolean boolConfigCheck(String input, String check) throws DNConfigException
	{
		if (input.replaceAll(check, "").replaceAll("^[ \t]+", "").equalsIgnoreCase("true"))
		{
			defined.add(check);
			return true;
		}
		else if (input.replaceAll(check, "").replaceAll("^[ \t]+", "").equalsIgnoreCase("false"))
		{
			defined.add(check);
			return false;
		}
		else
			throw new DNConfigException("Error: Invalid token; can only be true/false on line ");
	}

	// TODO: Make this more forgiving

	private int intConfigCheck(String input, String check) throws DNConfigException
	{
		try
		{
			int temp = Integer.parseInt((input.replaceAll(check, "").replaceAll("^[ \t]+", "")));
			if (temp < 0)
				throw new NumberFormatException();
			else
				return temp;
		}
		catch (NumberFormatException e)
		{
			throw new DNConfigException("Error: Invalid token; must be a positive integer on line ");
		}
	}

	private double doubleConfigCheck(String input, String check) throws DNConfigException
	{
		if (defined.contains(check))
			throw new DNConfigException("Error: Setting has already been defined; redefinition occurred on line ");
		else
		{
			try
			{
				double temp = Double.parseDouble((input.replaceAll(check, "").replaceAll("^[ \t]+", "")));
				if (temp < 0)
					throw new NumberFormatException();
				else
					return temp;
			}
			catch (NumberFormatException e)
			{
				throw new DNConfigException("Error: Invalid token; must be a positive real number on line ");
			}
		}
	}

	private String stringConfigCheck(String input, String check)
	{
		return (input.replaceAll(check, "").replaceAll("^[ \t]+", ""));
	}

	/**
	 * Reloads the plugin's configuration files by calling the relevant internal
	 * methods.
	 */
	public void reload()
	{
		loadConfig();
		loadEffects();
		loadMobBuffs();
		loadScares();
		for (Player player : getServer().getOnlinePlayers())
		{
			playerMap.put(player.getName(), 0);
			exemptMap.put(player.getName(), player.hasPermission("deadliernights.exempt"));
			scareMap.put(player.getName(), new HashMap<Scare, Integer>());
			for (Scare scare : scares)
			{
				scareMap.get(player.getName()).put(scare, -1 * scare.getExtraFrequencyRandom());
			}
		}
	}

	/**
	 * @param match
	 * @return the name of the player matched if the method succeeds or <FAILED>
	 *         if not
	 */

	// TODO: Verify if these is needed

	public String pickPlayer(String match)
	{
		int count = 0;
		String possible = "";
		for (Player player : getServer().getOnlinePlayers())
		{
			if (player.getName().toLowerCase().startsWith(match.toLowerCase()))
			{
				possible = player.getName();
				count++;
			}
		}
		if (count == 1)
			return possible;
		else
			return "<FAILED>";
	}

	/**
	 * @param potions
	 * @return the strongest potion of each type in the set of effects
	 */

	// Currently unused
	public ArrayList<PotionEffect> condensePotions(ArrayList<PotionEffect> potions)
	{
		ArrayList<PotionEffect> toReturn = new ArrayList<PotionEffect>();
		ArrayList<PotionEffectType> types = new ArrayList<PotionEffectType>();
		HashMap<PotionEffectType, Integer> maxes = new HashMap<PotionEffectType, Integer>();
		playerMap = new HashMap<String, Integer>();
		exemptMap = new HashMap<String, Boolean>();
		scareMap = new HashMap<String, HashMap<Scare, Integer>>();
		shortestDelay = getShortestDelay();

		for (PotionEffect eff : potions)
		{
			if (!types.contains(eff.getType()))
				types.add(eff.getType());
			if (!maxes.containsKey(eff.getType()))
				maxes.put(eff.getType(), eff.getAmplifier());
			else if (maxes.get(eff.getType()) < eff.getAmplifier())
				maxes.put(eff.getType(), eff.getAmplifier());
		}
		for (int i = 0; i < maxes.size(); i++)
		{
			toReturn.add(new PotionEffect(types.get(i), Integer.MAX_VALUE, maxes.get(types.get(i))));
		}
		return toReturn;
	}

	private int getShortestDelay()
	{
		int shortest = Integer.MAX_VALUE;

		for (EffectTimePair pair : effects)
		{
			if (pair.getDelay() < shortest)
				shortest = pair.getDelay();
		}

		return shortest;
	}

	/**
	 * @param player
	 */
	public void curePlayer(Player player)
	{
		playerMap.put(player.getName(), 0);

		for (EffectTimePair effect : effects)
		{
			player.removePotionEffect(effect.getEffect());
		}

		player.sendMessage("[DeadlierNights]: You have been cured of your exposure.");
	}

	/**
	 * Gets the
	 *
	 * @param player
	 * @param sender
	 */
	public void queryPlayer(Player player, Player sender)
	{
		sender.sendMessage(player.getName() + " currently has an exposure level of " + playerMap.get(player.getName()));
	}

	private MoonPhase getMoonPhase(World world)
	{
		long time = world.getFullTime();
		time = time / 24000;
		int phase = (int) (time % 8);
		switch (phase)
		{
		case 0:
			return MoonPhase.FULL;
		case 1:
			return MoonPhase.GIBBOUS;
		case 2:
			return MoonPhase.QUARTER;
		case 3:
			return MoonPhase.CRESCENT;
		case 4:
			return MoonPhase.NEW;
		case 5:
			return MoonPhase.CRESCENT;
		case 6:
			return MoonPhase.QUARTER;
		case 7:
			return MoonPhase.GIBBOUS;
		default:
			return MoonPhase.FULL;
		}
	}
}


text:
from django.contrib.sites.models import Site

def g(request):
    domain = request.META['HTTP_X_FORWARDED_SERVER']
    site = Site.objects.get(domain=domain)
    ctx = {}
    ctx['site'] = site
    ctx['domain'] = domain
    return ctx

redpajama_set_name: RedPajamaGithub


text:
  Saint-Hippolyte-de-Montaigu est
       un village
       géographiquement positionné dans le département de Gard en Languedoc-Roussillon. Elle totalisait 219 habitants en 2008.

À coté de Saint-Hippolyte-de-Montaigu sont localisées les communes de
Saint-Maximin localisée à 5 km, 609 habitants,
Saint-Victor-des-Oules localisée à 1 km, 249 habitants,
La Capelle-et-Masmolène localisée à 4 km, 376 habitants,
Vallabrix à 3 km, 365 habitants,
Argilliers localisée à 5 km, 284 habitants,
Uzès localisée à 6 km, 7 935 habitants,
 entre autres. De plus, Saint-Hippolyte-de-Montaigu est située à seulement 24 km de Nîmes.

Si vous pensez emmenager à Saint-Hippolyte-de-Montaigu, vous pourrez aisément trouver une maison à acheter.

Le parc d'habitations, à Saint-Hippolyte-de-Montaigu, se décomposait en 2011 en un appartements et 132 maisons soit
 un marché relativement équilibré.


text:
A dark syntax theme for Atom.

![Screenshot](https://raw.githubusercontent.com/jensjns/artillery-syntax/master/screenshot.png)


text:
package spark.examples

class Vector(val elements: Array[Double]) extends Serializable {
  def length = elements.length

  def apply(index: Int) = elements(index)

  def + (other: Vector): Vector = {
    if (length != other.length)
      throw new IllegalArgumentException("Vectors of different length")
    return Vector(length, i => this(i) + other(i))
  }

  def - (other: Vector): Vector = {
    if (length != other.length)
      throw new IllegalArgumentException("Vectors of different length")
    return Vector(length, i => this(i) - other(i))
  }

  def dot(other: Vector): Double = {
    if (length != other.length)
      throw new IllegalArgumentException("Vectors of different length")
    var ans = 0.0
    var i = 0
    while (i < length) {
      ans += this(i) * other(i)
      i += 1
    }
    return ans
  }

  def * (scale: Double): Vector = Vector(length, i => this(i) * scale)

  def / (d: Double): Vector = this * (1 / d)

  def unary_- = this * -1

  def sum = elements.reduceLeft(_ + _)

  def squaredDist(other: Vector): Double = {
    var ans = 0.0
    var i = 0
    while (i < length) {
      ans += (this(i) - other(i)) * (this(i) - other(i))
      i += 1
    }
    return ans
  }

  def dist(other: Vector): Double = math.sqrt(squaredDist(other))

  override def toString = elements.mkString("(", ", ", ")")
}

object Vector {
  def apply(elements: Array[Double]) = new Vector(elements)

  def apply(elements: Double*) = new Vector(elements.toArray)

  def apply(length: Int, initializer: Int => Double): Vector = {
    val elements = new Array[Double](length)
    for (i <- 0 until length)
      elements(i) = initializer(i)
    return new Vector(elements)
  }

  def zeros(length: Int) = new Vector(new Array[Double](length))

  def ones(length: Int) = Vector(length, _ => 1)

  class Multiplier(num: Double) {
    def * (vec: Vector) = vec * num
  }

  implicit def doubleToMultiplier(num: Double) = new Multiplier(num)

  implicit object VectorAccumParam extends spark.AccumulatorParam[Vector] {
    def addInPlace(t1: Vector, t2: Vector) = t1 + t2
    def zero(initialValue: Vector) = Vector.zeros(initialValue.length)
  }
}


text:
// =================== DO NOT EDIT THIS FILE ====================
// Generated by Modello 1.8.3,
// any modifications will be overwritten.
// ==============================================================

package com.webix.ui.model.context;

  //---------------------------------/
 //- Imported classes and packages -/
//---------------------------------/

import com.webix.ui.model.AnimateConfig;
import com.webix.ui.model.Baselayout;
import com.webix.ui.model.Baseview;
import com.webix.ui.model.DelimiterConfig;
import com.webix.ui.model.EventHandler;
import com.webix.ui.model.EventHandlerList;
import com.webix.ui.model.GraphItemConfig;
import com.webix.ui.model.NavigationConfig;
import com.webix.ui.model.PaddingConfig;
import com.webix.ui.model.Proto;
import com.webix.ui.model.RGBColorList;
import com.webix.ui.model.TypeConfig;
import com.webix.ui.model.UnknownType;
import com.webix.ui.model.View;
import com.webix.ui.model.auxiliary.Calendar;
import com.webix.ui.model.auxiliary.Colorboard;
import com.webix.ui.model.auxiliary.Pager;
import com.webix.ui.model.auxiliary.Resizer;
import com.webix.ui.model.auxiliary.Spacer;
import com.webix.ui.model.auxiliary.Tooltip;
import com.webix.ui.model.auxiliary.Video;
import com.webix.ui.model.data.Chart;
import com.webix.ui.model.data.Datatable;
import com.webix.ui.model.data.Dataview;
import com.webix.ui.model.data.Grouplist;
import com.webix.ui.model.data.List;
import com.webix.ui.model.data.Property;
import com.webix.ui.model.data.Tree;
import com.webix.ui.model.data.Treetable;
import com.webix.ui.model.data.Unitlist;
import com.webix.ui.model.form.Button;
import com.webix.ui.model.form.Checkbox;
import com.webix.ui.model.form.Colorpicker;
import com.webix.ui.model.form.Combo;
import com.webix.ui.model.form.Counter;
import com.webix.ui.model.form.Datepicker;
import com.webix.ui.model.form.Fieldset;
import com.webix.ui.model.form.Icon;
import com.webix.ui.model.form.Label;
import com.webix.ui.model.form.Multiselect;
import com.webix.ui.model.form.Multitext;
import com.webix.ui.model.form.Radio;
import com.webix.ui.model.form.Richselect;
import com.webix.ui.model.form.Search;
import com.webix.ui.model.form.Segmented;
import com.webix.ui.model.form.Select;
import com.webix.ui.model.form.Slider;
import com.webix.ui.model.form.Tabbar;
import com.webix.ui.model.form.Text;
import com.webix.ui.model.form.Textarea;
import com.webix.ui.model.form.Toggle;
import com.webix.ui.model.html.Htmlform;
import com.webix.ui.model.html.Iframe;
import com.webix.ui.model.html.Scrollview;
import com.webix.ui.model.html.Template;
import com.webix.ui.model.layouts.Accordion;
import com.webix.ui.model.layouts.Accordionitem;
import com.webix.ui.model.layouts.Carousel;
import com.webix.ui.model.layouts.Form;
import com.webix.ui.model.layouts.Headerlayout;
import com.webix.ui.model.layouts.Layout;
import com.webix.ui.model.layouts.Multiview;
import com.webix.ui.model.layouts.Tabview;
import com.webix.ui.model.layouts.Toolbar;

/**
 *
 * A context menu.
 * The component presents a pop-up menu that is displayed when the
 * user clicks the right mouse button in the client area. You can
 * configure any nesting level complexity. Check contextmenu
 * documentation for more detailed description.
 *
 *
 * @version $Revision$ $Date$
 */
@com.webix.ui.model.WebixEvent({
    com.webix.ui.model.Event.ON_AFTER_ADD,
    com.webix.ui.model.Event.ON_AFTER_CONTEXT_MENU,
    com.webix.ui.model.Event.ON_AFTER_DELETE,
    com.webix.ui.model.Event.ON_AFTER_DROP,
    com.webix.ui.model.Event.ON_AFTER_LOAD,
    com.webix.ui.model.Event.ON_AFTER_RENDER,
    com.webix.ui.model.Event.ON_AFTER_SCROLL,
    com.webix.ui.model.Event.ON_AFTER_SELECT,
    com.webix.ui.model.Event.ON_AFTER_SORT,
    com.webix.ui.model.Event.ON_BEFORE_ADD,
    com.webix.ui.model.Event.ON_BEFORE_CONTEXT_MENU,
    com.webix.ui.model.Event.ON_BEFORE_DELETE,
    com.webix.ui.model.Event.ON_BEFORE_DRAG,
    com.webix.ui.model.Event.ON_BEFORE_DRAG_IN,
    com.webix.ui.model.Event.ON_BEFORE_DROP,
    com.webix.ui.model.Event.ON_BEFORE_DROP_OUT,
    com.webix.ui.model.Event.ON_BEFORE_LOAD,
    com.webix.ui.model.Event.ON_BEFORE_RENDER,
    com.webix.ui.model.Event.ON_BEFORE_SELECT,
    com.webix.ui.model.Event.ON_BEFORE_SHOW,
    com.webix.ui.model.Event.ON_BEFORE_SORT,
    com.webix.ui.model.Event.ON_BIND_REQUEST,
    com.webix.ui.model.Event.ON_DATA_REQUEST,
    com.webix.ui.model.Event.ON_DATA_UPDATE,
    com.webix.ui.model.Event.ON_DESTRUCT,
    com.webix.ui.model.Event.ON_DRAG_OUT,
    com.webix.ui.model.Event.ON_HIDE,
    com.webix.ui.model.Event.ON_ITEM_CLICK,
    com.webix.ui.model.Event.ON_ITEM_DBL_CLICK,
    com.webix.ui.model.Event.ON_ITEM_RENDER,
    com.webix.ui.model.Event.ON_KEY_PRESS,
    com.webix.ui.model.Event.ON_LOAD_ERROR,
    com.webix.ui.model.Event.ON_LONG_TOUCH,
    com.webix.ui.model.Event.ON_MENU_ITEM_CLICK,
    com.webix.ui.model.Event.ON_MOUSE_MOVE,
    com.webix.ui.model.Event.ON_MOUSE_MOVING,
    com.webix.ui.model.Event.ON_MOUSE_OUT,
    com.webix.ui.model.Event.ON_PASTE,
    com.webix.ui.model.Event.ON_SELECT_CHANGE,
    com.webix.ui.model.Event.ON_SHOW,
    com.webix.ui.model.Event.ON_SWIPE_X,
    com.webix.ui.model.Event.ON_SWIPE_Y,
    com.webix.ui.model.Event.ON_TIMED_KEY_PRESS,
    com.webix.ui.model.Event.ON_TOUCH_END,
    com.webix.ui.model.Event.ON_TOUCH_MOVE,
    com.webix.ui.model.Event.ON_TOUCH_START,
    com.webix.ui.model.Event.ON_VALIDATION_ERROR,
    com.webix.ui.model.Event.ON_VALIDATION_SUCCESS,
    com.webix.ui.model.Event.ON_VIEW_MOVE,
    com.webix.ui.model.Event.ON_VIEW_MOVE_END,
    com.webix.ui.model.Event.ON_VIEW_RESIZE
})
@com.webix.ui.model.WebixName("contextmenu")
@javax.xml.bind.annotation.XmlRootElement
public class Contextmenu
    extends View
    implements java.io.Serializable
{

      //--------------------------/
     //- Class/Member Variables -/
    //--------------------------/

    /**
     * Adjusts window size to the size of an html node it is
     * initiated in

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("bool")
    private Boolean autofit;

    /**
     * Sets focus on the window the moment it appears on the
     * page

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("bool")
    private Boolean autofocus;

    /**
     * Height of view will be adjusted to show all items

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("bool")
    private Boolean autoheight;

    /**
     * Width of view will be adjusted to show all items

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("bool")
    private Boolean autowidth;

    /**
     * The content of window body: template or view

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("string|view")
    private View body;

    /**
     * Enables/disables clipboard support

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("bool|string")
    private String clipboard;

    /**
     * Enables or disables drag-and-drop

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("bool|string")
    private String drag;

    /**
     * Enables autoscroll of component during drag-n-drop

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("bool|string")
    private String dragscroll;

    /**
     * Allows defining custom 'move' logic for the component.

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("function")
    private String externalData;

    /**
     * Sets the view header

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("object|string")
    private String head;

    /**
     * Defines the header height (43 by default)

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("number")
    private Integer headHeight;

    /**
     * Defines x or y orientation of layout

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("string")
    private String layout;

    /**
     * The left offset of the window

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("number")
    private Integer left;

    /**
     * The area for which context object in inited

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("string")
    private String master;

    /**
     * Switches window modality

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("bool")
    private Boolean modal;

    /**
     * The delay between a real mouse action and invoking the
     * related events

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("number")
    private Integer mouseEventDelay;

    /**
     * Makes view movable

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("bool")
    private Boolean move;

    /**
     * Activates the selection keyboard navigation

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("bool")
    private Boolean navigation;

    /**
     * Attaches a click behavior for component items with the
     * specified CSS class.

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("hash")
    private java.util.Map<String, String> onClick;

    /**
     * A property used to define custom context-click (right click)
     * handlers for elements in the DataTable cells

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("hash")
    private java.util.Map<String, String> onContext;

    /**
     * Attaches a dblclick behavior for component items with the
     * specified CSS class.

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("function")
    private java.util.Map<String, String> onDblClick;

    /**
     * Attaches a mousemove behaviour for component items with the
     * specified CSS class.

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("function")
    private java.util.Map<String, String> onMouseMove;

    /**
     * Sets paddings of the chart content

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("object")
    private PaddingConfig padding;

    /**
     * Sets position of the window relative to the the screen

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("string|function")
    private String position;

    /**
     * Positions a popup window relative to the component it's
     * connected with

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("string")
    private String relative;

    /**
     * Enables/disables the scroll bar

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("bool|string")
    private String scroll;

    /**
     * The time during which the component is scrolled to the
     * specified position (in milliseconds)

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("string")
    private String scrollSpeed;

    /**
     * Enables/disables item selection or multiselection in
     * grouplist

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("bool|string")
    private String select;

    /**
     * Aligns submenu towards main menu

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("string")
    private String subMenuPos;

    /**
     * Defines submenu configuration

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("object")
    private Menu submenu;

    /**
     * Sets the template according to which data will be copied to
     * the clipboard

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("function")
    private String templateCopy;

    /**
     * The top offset of a window

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("number")
    private Integer top;

    /**
     * Defines width of view in items

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("int")
    private Integer xCount;

    /**
     * Defines height of view in items

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("number")
    private Integer yCount;

    /**
     * Stack order of the component

Webix
     * API Reference
     */
    @com.webix.ui.model.WebixType("number")
    private Integer zIndex;

      //-----------/
     //- Methods -/
    //-----------/

    /**
     * Get the content of window body: template or view

Webix
     * API Reference
     *
     * @return View
     */
    public View getBody()
    {
        return this.body;
    } //-- View getBody()

    /**
     * Get enables/disables clipboard support

Webix
     * API Reference
     *
     * @return String
     */
    public String getClipboard()
    {
        return this.clipboard;
    } //-- String getClipboard()

    /**
     * Get enables or disables drag-and-drop

Webix
     * API Reference
     *
     * @return String
     */
    public String getDrag()
    {
        return this.drag;
    } //-- String getDrag()

    /**
     * Get enables autoscroll of component during drag-n-drop

Webix
     * API Reference
     *
     * @return String
     */
    public String getDragscroll()
    {
        return this.dragscroll;
    } //-- String getDragscroll()

    /**
     * Get allows defining custom 'move' logic for the
     * component.

Webix
     * API Reference
     *
     * @return String
     */
    public String getExternalData()
    {
        return this.externalData;
    } //-- String getExternalData()

    /**
     * Get sets the view header

Webix
     * API Reference
     *
     * @return String
     */
    public String getHead()
    {
        return this.head;
    } //-- String getHead()

    /**
     * Get defines the header height (43 by default)

Webix
     * API Reference
     *
     * @return Integer
     */
    public Integer getHeadHeight()
    {
        return this.headHeight;
    } //-- Integer getHeadHeight()

    /**
     * Get defines x or y orientation of layout

Webix
     * API Reference
     *
     * @return String
     */
    public String getLayout()
    {
        return this.layout;
    } //-- String getLayout()

    /**
     * Get the left offset of the window

Webix
     * API Reference
     *
     * @return Integer
     */
    public Integer getLeft()
    {
        return this.left;
    } //-- Integer getLeft()

    /**
     * Get the area for which context object in inited

Webix
     * API Reference
     *
     * @return String
     */
    public String getMaster()
    {
        return this.master;
    } //-- String getMaster()

    /**
     * Get the delay between a real mouse action and invoking the
     * related events

Webix
     * API Reference
     *
     * @return Integer
     */
    public Integer getMouseEventDelay()
    {
        return this.mouseEventDelay;
    } //-- Integer getMouseEventDelay()

    /**
     * Get attaches a click behavior for component items with the
     * specified CSS class.

Webix
     * API Reference
     *
     * @return java.util.Map<String, String>
     */
    public java.util.Map<String, String> getOnClick()
    {
        return this.onClick;
    } //-- java.util.Map<String, String> getOnClick()

    /**
     * Get a property used to define custom context-click (right
     * click) handlers for elements in the DataTable cells

Webix
     * API Reference
     *
     * @return java.util.Map<String, String>
     */
    public java.util.Map<String, String> getOnContext()
    {
        return this.onContext;
    } //-- java.util.Map<String, String> getOnContext()

    /**
     * Get attaches a dblclick behavior for component items with
     * the specified CSS class.

Webix
     * API Reference
     *
     * @return java.util.Map<String, String>
     */
    public java.util.Map<String, String> getOnDblClick()
    {
        return this.onDblClick;
    } //-- java.util.Map<String, String> getOnDblClick()

    /**
     * Get attaches a mousemove behaviour for component items with
     * the specified CSS class.

Webix
     * API Reference
     *
     * @return java.util.Map<String, String>
     */
    public java.util.Map<String, String> getOnMouseMove()
    {
        return this.onMouseMove;
    } //-- java.util.Map<String, String> getOnMouseMove()

    /**
     * Get sets paddings of the chart content

Webix
     * API Reference
     *
     * @return PaddingConfig
     */
    public PaddingConfig getPadding()
    {
        return this.padding;
    } //-- PaddingConfig getPadding()

    /**
     * Get sets position of the window relative to the the
     * screen

Webix
     * API Reference
     *
     * @return String
     */
    public String getPosition()
    {
        return this.position;
    } //-- String getPosition()

    /**
     * Get positions a popup window relative to the component it's
     * connected with

Webix
     * API Reference
     *
     * @return String
     */
    public String getRelative()
    {
        return this.relative;
    } //-- String getRelative()

    /**
     * Get enables/disables the scroll bar

Webix
     * API Reference
     *
     * @return String
     */
    public String getScroll()
    {
        return this.scroll;
    } //-- String getScroll()

    /**
     * Get the time during which the component is scrolled to the
     * specified position (in milliseconds)

Webix
     * API Reference
     *
     * @return String
     */
    public String getScrollSpeed()
    {
        return this.scrollSpeed;
    } //-- String getScrollSpeed()

    /**
     * Get enables/disables item selection or multiselection in
     * grouplist

Webix
     * API Reference
     *
     * @return String
     */
    public String getSelect()
    {
        return this.select;
    } //-- String getSelect()

    /**
     * Get aligns submenu towards main menu

Webix
     * API Reference
     *
     * @return String
     */
    public String getSubMenuPos()
    {
        return this.subMenuPos;
    } //-- String getSubMenuPos()

    /**
     * Get defines submenu configuration

Webix
     * API Reference
     *
     * @return Menu
     */
    public Menu getSubmenu()
    {
        return this.submenu;
    } //-- Menu getSubmenu()

    /**
     * Get sets the template according to which data will be copied
     * to the clipboard

Webix
     * API Reference
     *
     * @return String
     */
    public String getTemplateCopy()
    {
        return this.templateCopy;
    } //-- String getTemplateCopy()

    /**
     * Get the top offset of a window

Webix
     * API Reference
     *
     * @return Integer
     */
    public Integer getTop()
    {
        return this.top;
    } //-- Integer getTop()

    /**
     * Get defines width of view in items

Webix
     * API Reference
     *
     * @return Integer
     */
    public Integer getXCount()
    {
        return this.xCount;
    } //-- Integer getXCount()

    /**
     * Get defines height of view in items

Webix
     * API Reference
     *
     * @return Integer
     */
    public Integer getYCount()
    {
        return this.yCount;
    } //-- Integer getYCount()

    /**
     * Get stack order of the component

Webix
     * API Reference
     *
     * @return Integer
     */
    public Integer getZIndex()
    {
        return this.zIndex;
    } //-- Integer getZIndex()

    /**
     * Get adjusts window size to the size of an html node it is
     * initiated in

Webix
     * API Reference
     *
     * @return Boolean
     */
    public Boolean isAutofit()
    {
        return this.autofit;
    } //-- Boolean isAutofit()

    /**
     * Get sets focus on the window the moment it appears on the
     * page

Webix
     * API Reference
     *
     * @return Boolean
     */
    public Boolean isAutofocus()
    {
        return this.autofocus;
    } //-- Boolean isAutofocus()

    /**
     * Get height of view will be adjusted to show all items

Webix
     * API Reference
     *
     * @return Boolean
     */
    public Boolean isAutoheight()
    {
        return this.autoheight;
    } //-- Boolean isAutoheight()

    /**
     * Get width of view will be adjusted to show all items

Webix
     * API Reference
     *
     * @return Boolean
     */
    public Boolean isAutowidth()
    {
        return this.autowidth;
    } //-- Boolean isAutowidth()

    /**
     * Get switches window modality

Webix
     * API Reference
     *
     * @return Boolean
     */
    public Boolean isModal()
    {
        return this.modal;
    } //-- Boolean isModal()

    /**
     * Get makes view movable

Webix
     * API Reference
     *
     * @return Boolean
     */
    public Boolean isMove()
    {
        return this.move;
    } //-- Boolean isMove()

    /**
     * Get activates the selection keyboard navigation

Webix
     * API Reference
     *
     * @return Boolean
     */
    public Boolean isNavigation()
    {
        return this.navigation;
    } //-- Boolean isNavigation()

    /**
     * Set adjusts window size to the size of an html node it is
     * initiated in

Webix
     * API Reference
     *
     * @param autofit
     */
    public void setAutofit( Boolean autofit )
    {
        this.autofit = autofit;
    } //-- void setAutofit( Boolean )

    /**
     * Set sets focus on the window the moment it appears on the
     * page

Webix
     * API Reference
     *
     * @param autofocus
     */
    public void setAutofocus( Boolean autofocus )
    {
        this.autofocus = autofocus;
    } //-- void setAutofocus( Boolean )

    /**
     * Set height of view will be adjusted to show all items

Webix
     * API Reference
     *
     * @param autoheight
     */
    public void setAutoheight( Boolean autoheight )
    {
        this.autoheight = autoheight;
    } //-- void setAutoheight( Boolean )

    /**
     * Set width of view will be adjusted to show all items

Webix
     * API Reference
     *
     * @param autowidth
     */
    public void setAutowidth( Boolean autowidth )
    {
        this.autowidth = autowidth;
    } //-- void setAutowidth( Boolean )

    /**
     * Set the content of window body: template or view

Webix
     * API Reference
     *
     * @param body
     */
    public void setBody( View body )
    {
        this.body = body;
    } //-- void setBody( View )

    /**
     * Set enables/disables clipboard support

Webix
     * API Reference
     *
     * @param clipboard
     */
    public void setClipboard( String clipboard )
    {
        this.clipboard = clipboard;
    } //-- void setClipboard( String )

    /**
     * Set enables or disables drag-and-drop

Webix
     * API Reference
     *
     * @param drag
     */
    public void setDrag( String drag )
    {
        this.drag = drag;
    } //-- void setDrag( String )

    /**
     * Set enables autoscroll of component during drag-n-drop

Webix
     * API Reference
     *
     * @param dragscroll
     */
    public void setDragscroll( String dragscroll )
    {
        this.dragscroll = dragscroll;
    } //-- void setDragscroll( String )

    /**
     * Set allows defining custom 'move' logic for the
     * component.

Webix
     * API Reference
     *
     * @param externalData
     */
    public void setExternalData( String externalData )
    {
        this.externalData = externalData;
    } //-- void setExternalData( String )

    /**
     * Set sets the view header

Webix
     * API Reference
     *
     * @param head
     */
    public void setHead( String head )
    {
        this.head = head;
    } //-- void setHead( String )

    /**
     * Set defines the header height (43 by default)

Webix
     * API Reference
     *
     * @param headHeight
     */
    public void setHeadHeight( Integer headHeight )
    {
        this.headHeight = headHeight;
    } //-- void setHeadHeight( Integer )

    /**
     * Set defines x or y orientation of layout

Webix
     * API Reference
     *
     * @param layout
     */
    public void setLayout( String layout )
    {
        this.layout = layout;
    } //-- void setLayout( String )

    /**
     * Set the left offset of the window

Webix
     * API Reference
     *
     * @param left
     */
    public void setLeft( Integer left )
    {
        this.left = left;
    } //-- void setLeft( Integer )

    /**
     * Set the area for which context object in inited

Webix
     * API Reference
     *
     * @param master
     */
    public void setMaster( String master )
    {
        this.master = master;
    } //-- void setMaster( String )

    /**
     * Set switches window modality

Webix
     * API Reference
     *
     * @param modal
     */
    public void setModal( Boolean modal )
    {
        this.modal = modal;
    } //-- void setModal( Boolean )

    /**
     * Set the delay between a real mouse action and invoking the
     * related events

Webix
     * API Reference
     *
     * @param mouseEventDelay
     */
    public void setMouseEventDelay( Integer mouseEventDelay )
    {
        this.mouseEventDelay = mouseEventDelay;
    } //-- void setMouseEventDelay( Integer )

    /**
     * Set makes view movable

Webix
     * API Reference
     *
     * @param move
     */
    public void setMove( Boolean move )
    {
        this.move = move;
    } //-- void setMove( Boolean )

    /**
     * Set activates the selection keyboard navigation

Webix
     * API Reference
     *
     * @param navigation
     */
    public void setNavigation( Boolean navigation )
    {
        this.navigation = navigation;
    } //-- void setNavigation( Boolean )

    /**
     * Set attaches a click behavior for component items with the
     * specified CSS class.

Webix
     * API Reference
     *
     * @param onClick
     */
    public void setOnClick( java.util.Map<String, String> onClick )
    {
        this.onClick = onClick;
    } //-- void setOnClick( java.util.Map<String, String> )

    /**
     * Set a property used to define custom context-click (right
     * click) handlers for elements in the DataTable cells

Webix
     * API Reference
     *
     * @param onContext
     */
    public void setOnContext( java.util.Map<String, String> onContext )
    {
        this.onContext = onContext;
    } //-- void setOnContext( java.util.Map<String, String> )

    /**
     * Set attaches a dblclick behavior for component items with
     * the specified CSS class.

Webix
     * API Reference
     *
     * @param onDblClick
     */
    public void setOnDblClick( java.util.Map<String, String> onDblClick )
    {
        this.onDblClick = onDblClick;
    } //-- void setOnDblClick( java.util.Map<String, String> )

    /**
     * Set attaches a mousemove behaviour for component items with
     * the specified CSS class.

Webix
     * API Reference
     *
     * @param onMouseMove
     */
    public void setOnMouseMove( java.util.Map<String, String> onMouseMove )
    {
        this.onMouseMove = onMouseMove;
    } //-- void setOnMouseMove( java.util.Map<String, String> )

    /**
     * Set sets paddings of the chart content

Webix
     * API Reference
     *
     * @param padding
     */
    public void setPadding( PaddingConfig padding )
    {
        this.padding = padding;
    } //-- void setPadding( PaddingConfig )

    /**
     * Set sets position of the window relative to the the
     * screen

Webix
     * API Reference
     *
     * @param position
     */
    public void setPosition( String position )
    {
        this.position = position;
    } //-- void setPosition( String )

    /**
     * Set positions a popup window relative to the component it's
     * connected with

Webix
     * API Reference
     *
     * @param relative
     */
    public void setRelative( String relative )
    {
        this.relative = relative;
    } //-- void setRelative( String )

    /**
     * Set enables/disables the scroll bar

Webix
     * API Reference
     *
     * @param scroll
     */
    public void setScroll( String scroll )
    {
        this.scroll = scroll;
    } //-- void setScroll( String )

    /**
     * Set the time during which the component is scrolled to the
     * specified position (in milliseconds)

Webix
     * API Reference
     *
     * @param scrollSpeed
     */
    public void setScrollSpeed( String scrollSpeed )
    {
        this.scrollSpeed = scrollSpeed;
    } //-- void setScrollSpeed( String )

    /**
     * Set enables/disables item selection or multiselection in
     * grouplist

Webix
     * API Reference
     *
     * @param select
     */
    public void setSelect( String select )
    {
        this.select = select;
    } //-- void setSelect( String )

    /**
     * Set aligns submenu towards main menu

Webix
     * API Reference
     *
     * @param subMenuPos
     */
    public void setSubMenuPos( String subMenuPos )
    {
        this.subMenuPos = subMenuPos;
    } //-- void setSubMenuPos( String )

    /**
     * Set defines submenu configuration

Webix
     * API Reference
     *
     * @param submenu
     */
    public void setSubmenu( Menu submenu )
    {
        this.submenu = submenu;
    } //-- void setSubmenu( Menu )

    /**
     * Set sets the template according to which data will be copied
     * to the clipboard

Webix
     * API Reference
     *
     * @param templateCopy
     */
    public void setTemplateCopy( String templateCopy )
    {
        this.templateCopy = templateCopy;
    } //-- void setTemplateCopy( String )

    /**
     * Set the top offset of a window

Webix
     * API Reference
     *
     * @param top
     */
    public void setTop( Integer top )
    {
        this.top = top;
    } //-- void setTop( Integer )

    /**
     * Set defines width of view in items

Webix
     * API Reference
     *
     * @param xCount
     */
    public void setXCount( Integer xCount )
    {
        this.xCount = xCount;
    } //-- void setXCount( Integer )

    /**
     * Set defines height of view in items

Webix
     * API Reference
     *
     * @param yCount
     */
    public void setYCount( Integer yCount )
    {
        this.yCount = yCount;
    } //-- void setYCount( Integer )

    /**
     * Set stack order of the component

Webix
     * API Reference
     *
     * @param zIndex
     */
    public void setZIndex( Integer zIndex )
    {
        this.zIndex = zIndex;
    } //-- void setZIndex( Integer )

}


text:
require 'date'
require 'google/apis/core/base_service'
require 'google/apis/core/json_representation'
require 'google/apis/core/hashable'
require 'google/apis/errors'

module Google
  module Apis
    module AdminDatatransferV1

      class Application
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class ApplicationDataTransfer
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class ApplicationTransferParam
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class ApplicationsListResponse
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class DataTransfer
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class DataTransfersListResponse
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Application
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :etag, as: 'etag'
          property :id, :numeric_string => true, as: 'id'
          property :kind, as: 'kind'
          property :name, as: 'name'
          collection :transfer_params, as: 'transferParams', class: Google::Apis::AdminDatatransferV1::ApplicationTransferParam, decorator: Google::Apis::AdminDatatransferV1::ApplicationTransferParam::Representation

        end
      end

      class ApplicationDataTransfer
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :application_id, :numeric_string => true, as: 'applicationId'
          collection :application_transfer_params, as: 'applicationTransferParams', class: Google::Apis::AdminDatatransferV1::ApplicationTransferParam, decorator: Google::Apis::AdminDatatransferV1::ApplicationTransferParam::Representation

          property :application_transfer_status, as: 'applicationTransferStatus'
        end
      end

      class ApplicationTransferParam
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :key, as: 'key'
          collection :value, as: 'value'
        end
      end

      class ApplicationsListResponse
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :applications, as: 'applications', class: Google::Apis::AdminDatatransferV1::Application, decorator: Google::Apis::AdminDatatransferV1::Application::Representation

          property :etag, as: 'etag'
          property :kind, as: 'kind'
          property :next_page_token, as: 'nextPageToken'
        end
      end

      class DataTransfer
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :application_data_transfers, as: 'applicationDataTransfers', class: Google::Apis::AdminDatatransferV1::ApplicationDataTransfer, decorator: Google::Apis::AdminDatatransferV1::ApplicationDataTransfer::Representation

          property :etag, as: 'etag'
          property :id, as: 'id'
          property :kind, as: 'kind'
          property :new_owner_user_id, as: 'newOwnerUserId'
          property :old_owner_user_id, as: 'oldOwnerUserId'
          property :overall_transfer_status_code, as: 'overallTransferStatusCode'
          property :request_time, as: 'requestTime', type: DateTime

        end
      end

      class DataTransfersListResponse
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :data_transfers, as: 'dataTransfers', class: Google::Apis::AdminDatatransferV1::DataTransfer, decorator: Google::Apis::AdminDatatransferV1::DataTransfer::Representation

          property :etag, as: 'etag'
          property :kind, as: 'kind'
          property :next_page_token, as: 'nextPageToken'
        end
      end
    end
  end
end


text:
<?xml version="1.0" encoding="UTF-8"?><!--
    JBoss, Home of Professional Open Source
    Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
    contributors by the @authors tag. See the copyright.txt in the
    distribution for a full listing of individual contributors.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<switchyard xmlns="urn:switchyard-config:switchyard:2.0">
    <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="camel-rss-binding" targetNamespace="urn:switchyard-quickstart:camel-rss-binding:2.1.0.Final">
        <service name="PrintService" promote="PrintService/PrintService">
            <rss:binding.rss xmlns:rss="urn:switchyard-component-camel-rss:config:2.0">
                <rss:feedURI>file:src/test/resources/rss.xml</rss:feedURI>
                <rss:splitEntries>true</rss:splitEntries>
                <rss:filter>false</rss:filter>
                <rss:feedHeader>true</rss:feedHeader>
                <rss:consume>
                    <rss:initialDelay>1000</rss:initialDelay>
                    <rss:delay>60000</rss:delay>
                </rss:consume>
            </rss:binding.rss>
        </service>
        <component name="PrintService">
            <implementation.bean xmlns="urn:switchyard-component-bean:config:1.0" class="org.switchyard.quickstarts.camel.rss.binding.PrintServiceImpl"/>
            <service name="PrintService">
                <interface.java interface="org.switchyard.quickstarts.camel.rss.binding.PrintService"/>
            </service>
        </component>
    </composite>
</switchyard>


text:
using namespace cv;
using namespace std;

String face_cascade_name = "haarcascade_frontalface_alt.xml";
CascadeClassifier face_cascade;

Mat detectAndDisplay( Mat frame, CascadeClassifier face_cascade )
{
  std::vector<Rect> faces;
  Mat frame_gray;

  cvtColor( frame, frame_gray, CV_BGR2GRAY );
  equalizeHist( frame_gray, frame_gray );

  //-- Detect faces
  face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );

  for( int i = 0; i < faces.size(); i++ )
  {
    cout << "looping through faces" << endl;
    Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
    //ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );

    Mat faceROI = frame( faces[i] );
    return faceROI;

  }

 }

int main(int argc, char *argv[])
{
    Mat faces;
    cout << "opennig cam" << endl;
    VideoCapture cap(-1);
    face_cascade.load(face_cascade_name);
    cout << "entering while loop" << endl;
    while(true)
    {
        cap.read(faces);
        cout << "read from cam" << endl;
        Mat faceROI = detectAndDisplay(faces, face_cascade);
        cout << "getting size and faces" << endl;
        imshow("faces", faces);

        if(!faceROI.empty())
        {
             if((faceROI.rows * faceROI.cols) > 10000)
             {
                   imwrite("face.jpg", faceROI);
                   break;
             }
        }
        if(waitKey(1) == 'q')
            break;
    }
    return 0;
}


text:
[Home](./index.md) > [sip.js](./sip.js.md) > [PrackableIncomingResponseWithSession](./sip.js.prackableincomingresponsewithsession.md) > [prack](./sip.js.prackableincomingresponsewithsession.prack.md)

## PrackableIncomingResponseWithSession.prack() method

Send an PRACK to acknowledge this response.

Signature:

```typescript
prack(options?: RequestOptions): OutgoingPrackRequest;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  options | [RequestOptions](./sip.js.requestoptions.md) | Request options bucket. |

Returns:

[OutgoingPrackRequest](./sip.js.outgoingprackrequest.md)


text:
[![Support Ukraine](https://img.shields.io/badge/Support-Ukraine-FFD500?style=flat&labelColor=005BBB)](https://opensource.fb.com/support-ukraine) [![License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/facebook/mcrouter/blob/master/LICENSE)

Mcrouter (pronounced mc router) is a memcached protocol router for scaling [memcached](http://memcached.org/)
deployments. It's a core component of cache
infrastructure at Facebook and Instagram where mcrouter handles almost
5 billion requests per second at peak.

Mcrouter is developed and maintained by Facebook.

See https://github.com/facebook/mcrouter/wiki to get started.

## Quick start guide

### New! Ubuntu package available

Currently, we support Ubuntu Bionic (18.04) amd64.
Here is how to install it:

Add the repo key:

    $ wget -O - https://facebook.github.io/mcrouter/debrepo/bionic/PUBLIC.KEY | sudo apt-key add

Add the following line to apt sources file /etc/apt/sources.list

    deb https://facebook.github.io/mcrouter/debrepo/bionic bionic contrib

Update the local repo cache:

    $ sudo apt-get update

Install mcrouter:

    $ sudo apt-get install mcrouter

### Installing From Source

See https://github.com/facebook/mcrouter/wiki/mcrouter-installation for more
detailed installation instructions.

Mcrouter depends on [folly](https://github.com/facebook/folly), [wangle](https://github.com/facebook/wangle), [fizz](https://github.com/facebookincubator/fizz), and [fbthrift](https://github.com/facebook/fbthrift).

The installation is a standard autotools flow:

    $ autoreconf --install
    $ ./configure
    $ make
    $ sudo make install
    $ mcrouter --help

Assuming you have a memcached instance on the local host running on port 5001,
the simplest mcrouter setup is:

    $ mcrouter \
        --config-str='{"pools":{"A":{"servers":["127.0.0.1:5001"]}},
                      "route":"PoolRoute|A"}' \
        -p 5000
    $ echo -ne "get key\r\n" | nc 0 5000

(nc is the GNU Netcat, http://netcat.sourceforge.net/)

## Features

+ Memcached ASCII protocol
+ Connection pooling
+ Multiple hashing schemes
+ Prefix routing
+ Replicated pools
+ Production traffic shadowing
+ Online reconfiguration
+ Flexible routing
+ Destination health monitoring/automatic failover
+ Cold cache warm up
+ Broadcast operations
+ Reliable delete stream
+ Multi-cluster support
+ Rich stats and debug commands
+ Quality of service
+ Large values
+ Multi-level caches
+ IPv6 support
+ SSL support

## Links

Documentation: https://github.com/facebook/mcrouter/wiki
Engineering discussions and support: https://www.facebook.com/groups/mcrouter

## License

Copyright (c) Facebook, Inc. and its affiliates.

Licensed under the MIT license:
https://github.com/facebook/mcrouter/blob/master/LICENSE


text:
package com.beancore.entity;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;

import com.beancore.config.CatchableWeaponType;
import com.beancore.ui.GamePlayingPanel;

public abstract class CatchableWeapon {
    private int posX;
    private int posY;

    private int width;
    private int height;
    private Image weaponImage;

    private GamePlayingPanel gamePlayingPanel;
    private CatchableWeaponType weaponType;
    private boolean useAnimation;
    private boolean useAnimationDone;
    private int speed;
    private boolean weaponDisappear;

    public CatchableWeapon(GamePlayingPanel gamePlayingPanel, CatchableWeaponType weaponType) {
	this.gamePlayingPanel = gamePlayingPanel;
	this.weaponType = weaponType;
	this.useAnimation = false;
	this.useAnimationDone = false;
	this.weaponDisappear = false;
    }

    public Rectangle getRectangle() {
	return new Rectangle(posX, posY, width, height);
    }

    public void draw(Graphics g) {
	Graphics2D g2d = (Graphics2D) g;
	g2d.drawImage(weaponImage, posX, posY, width, height, gamePlayingPanel);
    }

    public int getPosX() {
	return posX;
    }

    public void setPosX(int posX) {
	this.posX = posX;
    }

    public int getPosY() {
	return posY;
    }

    public void setPosY(int posY) {
	this.posY = posY;
    }

    public int getWidth() {
	return width;
    }

    public void setWidth(int width) {
	this.width = width;
    }

    public int getHeight() {
	return height;
    }

    public void setHeight(int height) {
	this.height = height;
    }

    public Image getWeaponImage() {
	return weaponImage;
    }

    public void setWeaponImage(Image weaponImage) {
	this.weaponImage = weaponImage;
    }

    public GamePlayingPanel getGamePlayingPanel() {
	return gamePlayingPanel;
    }

    public void setGamePlayingPanel(GamePlayingPanel gamePlayingPanel) {
	this.gamePlayingPanel = gamePlayingPanel;
    }

    public CatchableWeaponType getWeaponType() {
	return weaponType;
    }

    public void setWeaponType(CatchableWeaponType weaponType) {
	this.weaponType = weaponType;
    }

    public int getSpeed() {
	return speed;
    }

    public void setSpeed(int speed) {
	this.speed = speed;
    }

    public boolean isUseAnimation() {
	return useAnimation;
    }

    public void setUseAnimation(boolean useAnimation) {
	this.useAnimation = useAnimation;
    }

    public boolean isUseAnimationDone() {
	return useAnimationDone;
    }

    public void setUseAnimationDone(boolean useAnimationDone) {
	this.useAnimationDone = useAnimationDone;
    }

    public boolean isWeaponDisappear() {
	return weaponDisappear;
    }

    public void setWeaponDisappear(boolean weaponDisappear) {
	this.weaponDisappear = weaponDisappear;
    }

}