text:
layout: post
title: 'Revisitando la nueva web del Senado'
date: 2012-12-03 21:20:16+00:00
tags:
  - javascript
  - optimization
  - performance
permalink: revisitando-nueva-web-senado
---

Hace unos días hacía un [análisis del rediseño de la web del Senado](/estudiando-el-rediseno-de-la-web-del-senado-de-espana/), justo tras su lanzamiento, desde el punto de vista de rendimiento web y mejores prácticas a la hora de desarrollar sitios web. La nueva web del Senado sufría múltiples problemas poco más que inaceptables para un proyecto tan reciente y con tal presupuesto.

<!-- more -->
Pero al igual que destacaba dichos problemas, unas semanas después debo mencionar que varios de ellos han sido resueltos. Aunque aún quedan algunos por resolver, es de destacar que hayan seguido trabajando en el sitio.
![Web del Senado de España](/assets/images/posts/web-senado.jpg)

## Mejoras
### Senado.es ya funciona sin www
Ahora, la URL [senado.es](http://senado.es) redirecciona a [www.senado.es](http://www.senado.es) ([fuente](http://www.webpagetest.org/result/121203_ZZ_4QD/1/details/))

### Indexable por robots
Su [robots.txt](http://www.senado.es/robots.txt) ha cambiado y ahora permite a los buscadores indexar el contenido del sitio.

### Compresión Gzip
Ahora los recursos se sirven con compresión GZIP habilitada ([fuente](http://gtmetrix.com/compare/BN8ZgvCB/3gwi5Qp4)). Entre otras mejoras, la página principal _pesa_ ahora menos de la mitad, y han mejorado considerablemente el índica PageSpeed y YSlow ([fuente](http://gtmetrix.com/reports/www.senado.es/eS68ECWL)).

### Errores 404
Ahora en la página principal, ya sólo hay 1 request que da error 404 ([fuente](http://www.webpagetest.org/result/121203_ZZ_4QD/1/details/)).

## Todavía hay algunos problemas que solucionar
Pese a todo, aún quedan mejoras por hacer, como la minificación de ficheros, optimización de imágenes, tratar de reducir el número de peticiones y corregir el Mime Type devuelto por el servidor.

Además, con la modificación del fichero [robots.txt](http://www.senado.es/robots.txt) existen detalles dignos de mención. El fichero actual tiene este contenido:

```
User-agent: *
Disallow: /cgi-bin/
Disallow: /detalleiniciativa/
Disallow: /expedientappendixblobservlet/
Disallow: /expedientdocblobservlet/
Disallow: /fichasenador/
Disallow: /resultadobuscador/
Disallow: /senstream/
Disallow: /*senstream*
Disallow: /legis9/publicaciones/html/textos/CG_B015.html
Disallow: /legis9/publicaciones/pdf/cortes/bocg/CG_B015.PDF
Disallow: /legis9/publicaciones/html/textos/CG_B100.html
Disallow: /legis9/publicaciones/pdf/cortes/bocg/CG_B100.PDF
Disallow: /legis4/publicaciones/pdf/senado/bocg/l0019.PDF
Disallow: /legis3/publicaciones/pdf/senado/bocg/l0342.PDF
Disallow: /legis3/publicaciones/pdf/senado/bocg/l0347.PDF
Disallow: /legis2/publicaciones/pdf/senado/bocg/l0140.PDF
Visit-time: 0200-0600
```

Si lo comparamos con [la versión del mismo fichero](/estudiando-el-rediseno-de-la-web-del-senado-de-espana/#no-indexable) cuando publicaron el rediseño, ahora vemos nuevas direcciones bloqueadas.

Que se pretenda evitar el indexado de las iniciativas parlamentarias y fichas de los senadores atenta directamente contra la transparencia de información y el servicio que pretende dar esta web. Además, el bloqueo se realiza sobre una dirección que ni siquiera es la dirección donde está dicho contenido.

¿Por qué se evita el indexado del contenido más útil para el ciudadano?

Aunque en ese caso, en lugar de restringir /detalleiniciativa/, /web/actividadparlamentaria/iniciativas/detalleiniciativa/

Y en vez de /fichasenador/ deberían haber restringido algo como /web/composicionorganizacion/senadores/composicionsenado/fichasenador/

Por otra parte, se evita el indexado de una serie de documentos PDF y páginas HTML, también por alguna razón que me supera. Pero es casi peor el hecho de que de los 6 documentos, sólo 2 existen y las 2 páginas HTML tampoco existen.

Por último, han introducido la limitación del indexado de páginas para que se haga entre las 02:00 y 06:00 AM GMT.  A mí me parece un poco extraño querer limitar el rastreo a las horas de menos tráfico. Un documento creado durante el día no podrá aparecer en los resultados de búsqueda hasta el día siguiente como mínimo. Y no deja de ser una señal de que el sitio no se comporta bien con un tráfico normal más el tráfico que puedan generar los bots de los buscadores.

## Conclusiones
En general, está bien que hayan continuado haciendo mejoras en el sitio, aunque por el camino han tomado decisiones ciertamente discutibles.


text:
package com.planet_ink.coffee_mud.Abilities.Prayers;
import com.planet_ink.coffee_mud.core.interfaces.*;
import com.planet_ink.coffee_mud.core.*;
import com.planet_ink.coffee_mud.core.collections.*;
import com.planet_ink.coffee_mud.Abilities.interfaces.*;
import com.planet_ink.coffee_mud.Areas.interfaces.*;
import com.planet_ink.coffee_mud.Behaviors.interfaces.*;
import com.planet_ink.coffee_mud.CharClasses.interfaces.*;
import com.planet_ink.coffee_mud.Commands.interfaces.*;
import com.planet_ink.coffee_mud.Common.interfaces.*;
import com.planet_ink.coffee_mud.Exits.interfaces.*;
import com.planet_ink.coffee_mud.Items.interfaces.*;
import com.planet_ink.coffee_mud.Libraries.interfaces.*;
import com.planet_ink.coffee_mud.Locales.interfaces.*;
import com.planet_ink.coffee_mud.MOBS.interfaces.*;
import com.planet_ink.coffee_mud.Races.interfaces.*;

import java.util.*;

public class Prayer_Rot extends Prayer
{
	@Override public String ID() { return "Prayer_Rot"; }
	private final static String localizedName = CMLib.lang().L("Rot");
	@Override public String name() { return localizedName; }
	@Override public String displayText(){ return "";}
	@Override protected int canAffectCode(){return Ability.CAN_ITEMS;}
	@Override protected int canTargetCode(){return Ability.CAN_ITEMS;}
	@Override public int abstractQuality(){ return Ability.QUALITY_INDIFFERENT;}
	@Override public long flags(){return Ability.FLAG_UNHOLY;}
	@Override public int classificationCode(){return ((affecting() instanceof Food)&&(!canBeUninvoked()))?Ability.ACODE_PROPERTY:Ability.ACODE_PRAYER|Ability.DOMAIN_CORRUPTION;}
	private long nextTry=System.currentTimeMillis();

	@Override
	public void executeMsg(Environmental host, CMMsg msg)
	{
		super.executeMsg(host,msg);
		if((host instanceof Item)
		&&(((msg.tool() instanceof ShopKeeper)&&(msg.targetMinor()==CMMsg.TYP_GET))
			||(msg.targetMinor()==CMMsg.TYP_ROOMRESET))
		&&(msg.target()==host))
		{
			if(host instanceof Decayable)
			{
				((Decayable)host).setDecayTime(0);
				if(host instanceof Physical)
				{
					final Ability A=((Physical)host).fetchEffect("Poison_Rotten");
					if(A!=null)
						((Physical)host).delEffect(A);
				}
			}
			else
			if(host instanceof Container)
			{
				final List<Item> V=((Container)host).getDeepContents();
				for(int f=0;f<V.size();f++)
					if(V.get(f) != null)
					{
						if(V.get(f) instanceof Decayable)
							((Decayable)V.get(f)).setDecayTime(0);
						final Ability A=V.get(f).fetchEffect("Poison_Rotten");
						if(A!=null)
							V.get(f).delEffect(A);
					}
			}
		}
	}

	public void setRot(Item I)
	{
		if(((I instanceof Decayable)&&(((Decayable)I).decayTime()==0))
		&&(I.owner()!=null)
		&&(I.fetchEffect("Poison_Rotten")==null))
		{
			long newTime=0;
			switch(I.material()&RawMaterial.MATERIAL_MASK)
			{
			case RawMaterial.MATERIAL_FLESH:
				{
						newTime=
						System.currentTimeMillis()+(
						   CMProps.getTickMillis()
							*CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY)
						  );
				break;
				}
			case RawMaterial.MATERIAL_VEGETATION:
				{
						newTime=
						System.currentTimeMillis()+(
						CMProps.getTickMillis()
						*CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY)
						*5);
				break;
				}
			}
			if(I instanceof Drink)
			{
				switch(((Drink)I).liquidType())
				{
				case RawMaterial.RESOURCE_BLOOD:
					newTime=
						System.currentTimeMillis()+(
						CMProps.getTickMillis()
						*CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY));
					break;
				case RawMaterial.RESOURCE_MILK:
					newTime=
						System.currentTimeMillis()+(
						CMProps.getTickMillis()
						*CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY)
						*5);
					break;
				}
			}
			switch(I.material())
			{
			case RawMaterial.RESOURCE_BLOOD:
				newTime=
					System.currentTimeMillis()+(
					CMProps.getTickMillis()
					*CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY));
				break;
			case RawMaterial.RESOURCE_MILK:
				newTime=
					System.currentTimeMillis()+(
					CMProps.getTickMillis()
					*CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY)
					*5);
				break;
			case RawMaterial.RESOURCE_HERBS:
			case RawMaterial.RESOURCE_WAX:
			case RawMaterial.RESOURCE_COFFEEBEANS:
			case RawMaterial.RESOURCE_SEAWEED:
			case RawMaterial.RESOURCE_SUGAR:
			case RawMaterial.RESOURCE_COCOA:
			case RawMaterial.RESOURCE_MUSHROOMS:
			case RawMaterial.RESOURCE_VINE:
			case RawMaterial.RESOURCE_FLOWERS:
			case RawMaterial.RESOURCE_NUTS:
			case RawMaterial.RESOURCE_CRACKER:
			case RawMaterial.RESOURCE_PIPEWEED:
			case RawMaterial.RESOURCE_GARLIC:
			case RawMaterial.RESOURCE_SOAP:
			case RawMaterial.RESOURCE_ASH:
				newTime=0;
				break;
			}
			if(I instanceof Decayable)
				((Decayable)I).setDecayTime(newTime);
		}
		if((((Decayable)I).decayTime()>0)
		&&(System.currentTimeMillis()>((Decayable)I).decayTime())
		&&(!CMLib.flags().isABonusItems(I)))
		{
			if(I.fetchEffect("Poison_Rotten")==null)
			{
				final Ability A=CMClass.getAbility("Poison_Rotten");
				if(A!=null)
					I.addNonUninvokableEffect(A);
			}
			if(I instanceof Food)
				((Food)I).setNourishment(0);
			else
			if(I instanceof Drink)
				((Drink)I).setThirstQuenched(0);
			((Decayable)I).setDecayTime(0);
		}
	}

	@Override
	public boolean okMessage(Environmental host, CMMsg msg)
	{
		if((affecting()==null)||(System.currentTimeMillis()>nextTry))
		{
			nextTry=System.currentTimeMillis()+60000;
			if(host instanceof Item)
				setRot(((Item)host));
			else
			if(host instanceof Container)
			{
				final List<Item> V=((Container)host).getDeepContents();
				for(int v=0;v<V.size();v++)
					if(V.get(v) != null)
						setRot(V.get(v));
			}
		}
		return super.okMessage(host,msg);
	}

	@Override
	public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
	{
		final Item target=getTarget(mob,mob.location(),givenTarget,commands,Wearable.FILTER_UNWORNONLY);
		if(target==null)
			return false;

		if((!(target instanceof Food))
			&&(!(target instanceof Drink)))
		{
			mob.tell(L("You cannot rot @x1!",target.name(mob)));
			return false;
		}

		if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
			return false;

		final boolean success=proficiencyCheck(mob,0,auto);

		if(success)
		{
			final CMMsg msg=CMClass.getMsg(mob,target,this,verbalCastCode(mob,target,auto),
									auto?"":L("^S<S-NAME> rot <T-NAMESELF>@x1.^?",inTheNameOf(mob)),
									auto?"":L("^S<S-NAME> rots <T-NAMESELF>@x1.^?",inTheNameOf(mob)),
									auto?"":L("^S<S-NAME> rots <T-NAMESELF>@x1.^?",inTheNameOf(mob)));
			if(mob.location().okMessage(mob,msg))
			{
				mob.location().send(mob,msg);
				boolean doneSomething=false;
				if((target instanceof Drink)&&(((Drink)target).liquidType()!=RawMaterial.RESOURCE_SALTWATER))
				{
					((Drink)target).setLiquidType(RawMaterial.RESOURCE_SALTWATER);
					doneSomething=true;
				}
				final Ability A=CMClass.getAbility("Poison_Rotten");
				if(A!=null)
					target.addNonUninvokableEffect(A);
				if((target instanceof Pill)
				&&(!((Pill)target).getSpellList().equals("Prayer_DrunkenStupor")))
				{
					doneSomething=true;
					((Pill)target).setSpellList("Prayer_DrunkenStupor");
				}
				if((target instanceof Potion)
				&&(!((Potion)target).getSpellList().equals("Prayer_DrunkenStupor")))
				{
					doneSomething=true;
					((Potion)target).setSpellList("Prayer_DrunkenStupor");
				}
				if(doneSomething)
					mob.location().showHappens(CMMsg.MSG_OK_VISUAL,L("@x1 appears rotted!",target.name()));
				target.recoverPhyStats();
				mob.location().recoverRoomStats();
			}
		}
		else
			return beneficialWordsFizzle(mob,target,L("<S-NAME> @x1 for rotting, but nothing happens.",prayWord(mob)));
		// return whether it worked
		return success;
	}
}

redpajama_set_name: RedPajamaGithub


text:
SpreeSuperfishMenu
==================

Replaces the standard Spree menu with the Superfish menu (http://users.tpg.com.au/j_birch/plugins/superfish/).

Thsis revision was developed and tested with Spree 1.0.  The default styling is the default provided with Superfish.  You can change it by overiding the style attributes with your stylesheet.  If you want to instead use it within a custom layout, just rework the hook into the current views and include it into your view where appropriate.

Installation
============

Add the following to your Gemspec file:

	gem "spree_superfish_menu", :git => 'git://github.com/markalinn/Spree-Superfish-Menu.git'

		or for Spree 0.60.x

	gem "spree_superfish_menu", :git => 'git://github.com/markalinn/Spree-Superfish-Menu.git', :branch => '0-60'

Todo
====
Test

Copyright (c) 2011 Mark Linn, released under the New BSD License


text:
package com.google.common.util.concurrent;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Platform.restoreInterruptIfIsInterruptedException;

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
 * A TimeLimiter implementation which actually does not attempt to limit time at all. This may be
 * desirable to use in some unit tests. More importantly, attempting to debug a call which is
 * time-limited would be extremely annoying, so this gives you a time-limiter you can easily swap in
 * for your real time-limiter while you're debugging.
 *
 * @author Kevin Bourrillion
 * @author Jens Nyman
 * @since 1.0
 */
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class FakeTimeLimiter implements TimeLimiter {
  @CanIgnoreReturnValue // TODO(kak): consider removing this
  @Override
  public <T> T newProxy(
      T target, Class<T> interfaceType, long timeoutDuration, TimeUnit timeoutUnit) {
    checkNotNull(target);
    checkNotNull(interfaceType);
    checkNotNull(timeoutUnit);
    return target; // ha ha
  }

  @CanIgnoreReturnValue // TODO(kak): consider removing this
  @Override
  @ParametricNullness
  public <T extends @Nullable Object> T callWithTimeout(
      Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit) throws ExecutionException {
    checkNotNull(callable);
    checkNotNull(timeoutUnit);
    try {
      return callable.call();
    } catch (RuntimeException e) {
      throw new UncheckedExecutionException(e);
    } catch (Exception e) {
      restoreInterruptIfIsInterruptedException(e);
      throw new ExecutionException(e);
    } catch (Error e) {
      throw new ExecutionError(e);
    }
  }

  @CanIgnoreReturnValue // TODO(kak): consider removing this
  @Override
  @ParametricNullness
  public <T extends @Nullable Object> T callUninterruptiblyWithTimeout(
      Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit) throws ExecutionException {
    return callWithTimeout(callable, timeoutDuration, timeoutUnit);
  }

  @Override
  public void runWithTimeout(Runnable runnable, long timeoutDuration, TimeUnit timeoutUnit) {
    checkNotNull(runnable);
    checkNotNull(timeoutUnit);
    try {
      runnable.run();
    } catch (RuntimeException e) {
      throw new UncheckedExecutionException(e);
    } catch (Error e) {
      throw new ExecutionError(e);
    }
  }

  @Override
  public void runUninterruptiblyWithTimeout(
      Runnable runnable, long timeoutDuration, TimeUnit timeoutUnit) {
    runWithTimeout(runnable, timeoutDuration, timeoutUnit);
  }
}


text:
require 'rails_helper'

RSpec.describe AllFieldType, :type => :model do
  pending "add some examples to (or delete) #{__FILE__}"
end


text:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>9Gag Numbers</title>
    <script src="scripts/9gag-numbers.js"></script>
</head>
<body onload="handleIO()">
</body>
</html>


text:
using System;
using System.Linq;
using FluentFTP.Helpers;
using FluentFTP.Client.Modules;
using System.Threading;
using System.Threading.Tasks;

namespace FluentFTP {
	public partial class FtpClient {

		/// <summary>
		/// Sets the work directory on the server
		/// </summary>
		/// <param name="path">The path of the directory to change to</param>
		public void SetWorkingDirectory(string path) {

			path = path.GetFtpPath();

			LogFunction(nameof(SetWorkingDirectory), new object[] { path });

			FtpReply reply;

			// exit if invalid path
			if (path == "." || path == "./") {
				return;
			}

			lock (m_lock) {
				// modify working dir
				if (!(reply = Execute("CWD " + path)).Success) {
					throw new FtpCommandException(reply);
				}

			}
		}

	}
}


text:
package net.roguelogic.mods.bigfusion.utils.joml;

/**
 * Efficiently performs frustum intersection tests by caching the frustum planes of an arbitrary transformation {@link Matrix4f matrix}.
 *

 * This class is preferred over the frustum intersection methods in {@link Matrix4f} when many objects need to be culled by the same static frustum.
 *
 * @author Kai Burjack
 */
public class FrustumIntersection {

    /**
     * Return value of {@link #intersectAab(float, float, float, float, float, float) intersectAab()}
     * and its different overloads identifying the plane with equation <tt>x=-1</tt> when using the identity frustum.
     */
    public static final int PLANE_NX = 0;
    /**
     * Return value of {@link #intersectAab(float, float, float, float, float, float) intersectAab()}
     * and its different overloads identifying the plane with equation <tt>x=1</tt> when using the identity frustum.
     */
    public static final int PLANE_PX = 1;
    /**
     * Return value of {@link #intersectAab(float, float, float, float, float, float) intersectAab()}
     * and its different overloads identifying the plane with equation <tt>y=-1</tt> when using the identity frustum.
     */
    public static final int PLANE_NY= 2;
    /**
     * Return value of {@link #intersectAab(float, float, float, float, float, float) intersectAab()}
     * and its different overloads identifying the plane with equation <tt>y=1</tt> when using the identity frustum.
     */
    public static final int PLANE_PY = 3;
    /**
     * Return value of {@link #intersectAab(float, float, float, float, float, float) intersectAab()}
     * and its different overloads identifying the plane with equation <tt>z=-1</tt> when using the identity frustum.
     */
    public static final int PLANE_NZ = 4;
    /**
     * Return value of {@link #intersectAab(float, float, float, float, float, float) intersectAab()}
     * and its different overloads identifying the plane with equation <tt>z=1</tt> when using the identity frustum.
     */
    public static final int PLANE_PZ = 5;

    /**
     * Return value of {@link #intersectAab(float, float, float, float, float, float) intersectAab()}
     * and its different overloads indicating that the axis-aligned box intersects the frustum.
     */
    public static final int INTERSECT = -1;
    /**
     * Return value of {@link #intersectAab(float, float, float, float, float, float) intersectAab()}
     * and its different overloads indicating that the axis-aligned box is fully inside of the frustum.
     */
    public static final int INSIDE = -2;
    /**
     * Return value of {@link #intersectSphere(Vector3f, float)} or {@link #intersectSphere(float, float, float, float)}
     * indicating that the sphere is completely outside of the frustum.
     */
    public static final int OUTSIDE = -3;

    /**
     * The value in a bitmask for
     * {@link #intersectAab(float, float, float, float, float, float, int) intersectAab()}
     * that identifies the plane with equation <tt>x=-1</tt> when using the identity frustum.
     */
    public static final int PLANE_MASK_NX = 1<<PLANE_NX;
    /**
     * The value in a bitmask for
     * {@link #intersectAab(float, float, float, float, float, float, int) intersectAab()}
     * that identifies the plane with equation <tt>x=1</tt> when using the identity frustum.
     */
    public static final int PLANE_MASK_PX = 1<<PLANE_PX;
    /**
     * The value in a bitmask for
     * {@link #intersectAab(float, float, float, float, float, float, int) intersectAab()}
     * that identifies the plane with equation <tt>y=-1</tt> when using the identity frustum.
     */
    public static final int PLANE_MASK_NY = 1<<PLANE_NY;
    /**
     * The value in a bitmask for
     * {@link #intersectAab(float, float, float, float, float, float, int) intersectAab()}
     * that identifies the plane with equation <tt>y=1</tt> when using the identity frustum.
     */
    public static final int PLANE_MASK_PY = 1<<PLANE_PY;
    /**
     * The value in a bitmask for
     * {@link #intersectAab(float, float, float, float, float, float, int) intersectAab()}
     * that identifies the plane with equation <tt>z=-1</tt> when using the identity frustum.
     */
    public static final int PLANE_MASK_NZ = 1<<PLANE_NZ;
    /**
     * The value in a bitmask for
     * {@link #intersectAab(float, float, float, float, float, float, int) intersectAab()}
     * that identifies the plane with equation <tt>z=1</tt> when using the identity frustum.
     */
    public static final int PLANE_MASK_PZ = 1<<PLANE_PZ;

    private float nxX, nxY, nxZ, nxW;
    private float pxX, pxY, pxZ, pxW;
    private float nyX, nyY, nyZ, nyW;
    private float pyX, pyY, pyZ, pyW;
    private float nzX, nzY, nzZ, nzW;
    private float pzX, pzY, pzZ, pzW;

    private final Vector4f[] planes = new Vector4f[6];
    {
        for (int i = 0; i < 6; i++) {
            planes[i] = new Vector4f();
        }
    }

    /**
     * Create a new {@link FrustumIntersection} with undefined frustum planes.
     *

     * Before using any of the frustum culling methods, make sure to define the frustum planes using {@link #set(Matrix4f)}.
     */
    public FrustumIntersection() {
    }

    /**
     * Create a new {@link FrustumIntersection} from the given {@link Matrix4f matrix} by extracing the matrix's frustum planes.
     *

     * In order to update the compute frustum planes later on, call {@link #set(Matrix4f)}.
     *
     * @see #set(Matrix4f)
     *
     * @param m
     *          the {@link Matrix4f} to create the frustum culler from
     */
    public FrustumIntersection(Matrix4f m) {
        set(m);
    }

    /**
     * Update the stored frustum planes of this {@link FrustumIntersection} with the given {@link Matrix4f matrix}.
     *

     * Reference:
     * Fast Extraction of Viewing Frustum Planes from the World-View-Projection Matrix
     *
     * @param m
     *          the {@link Matrix4f matrix} to update this frustum culler's frustum planes from
     * @return this
     */
    public FrustumIntersection set(Matrix4f m) {
        float invl;
        nxX = m.m03() + m.m00(); nxY = m.m13() + m.m10(); nxZ = m.m23() + m.m20(); nxW = m.m33() + m.m30();
        invl = (float) (1.0 / Math.sqrt(nxX * nxX + nxY * nxY + nxZ * nxZ));
        nxX *= invl; nxY *= invl; nxZ *= invl; nxW *= invl;
        planes[0].set(nxX, nxY, nxZ, nxW);
        pxX = m.m03() - m.m00(); pxY = m.m13() - m.m10(); pxZ = m.m23() - m.m20(); pxW = m.m33() - m.m30();
        invl = (float) (1.0 / Math.sqrt(pxX * pxX + pxY * pxY + pxZ * pxZ));
        pxX *= invl; pxY *= invl; pxZ *= invl; pxW *= invl;
        planes[1].set(pxX, pxY, pxZ, pxW);
        nyX = m.m03() + m.m01(); nyY = m.m13() + m.m11(); nyZ = m.m23() + m.m21(); nyW = m.m33() + m.m31();
        invl = (float) (1.0 / Math.sqrt(nyX * nyX + nyY * nyY + nyZ * nyZ));
        nyX *= invl; nyY *= invl; nyZ *= invl; nyW *= invl;
        planes[2].set(nyX, nyY, nyZ, nyW);
        pyX = m.m03() - m.m01(); pyY = m.m13() - m.m11(); pyZ = m.m23() - m.m21(); pyW = m.m33() - m.m31();
        invl = (float) (1.0 / Math.sqrt(pyX * pyX + pyY * pyY + pyZ * pyZ));
        pyX *= invl; pyY *= invl; pyZ *= invl; pyW *= invl;
        planes[3].set(pyX, pyY, pyZ, pyW);
        nzX = m.m03() + m.m02(); nzY = m.m13() + m.m12(); nzZ = m.m23() + m.m22(); nzW = m.m33() + m.m32();
        invl = (float) (1.0 / Math.sqrt(nzX * nzX + nzY * nzY + nzZ * nzZ));
        nzX *= invl; nzY *= invl; nzZ *= invl; nzW *= invl;
        planes[4].set(nzX, nzY, nzZ, nzW);
        pzX = m.m03() - m.m02(); pzY = m.m13() - m.m12(); pzZ = m.m23() - m.m22(); pzW = m.m33() - m.m32();
        invl = (float) (1.0 / Math.sqrt(pzX * pzX + pzY * pzY + pzZ * pzZ));
        pzX *= invl; pzY *= invl; pzZ *= invl; pzW *= invl;
        planes[5].set(pzX, pzY, pzZ, pzW);
        return this;
    }

    /**
     * Test whether the given point is within the frustum defined by this frustum culler.
     *
     * @param point
     *          the point to test
     * @return true if the given point is inside the frustum; false otherwise
     */
    public boolean testPoint(Vector3f point) {
        return testPoint(point.x, point.y, point.z);
    }

    /**
     * Test whether the given point <tt>(x, y, z)</tt> is within the frustum defined by this frustum culler.
     *
     * @param x
     *          the x-coordinate of the point
     * @param y
     *          the y-coordinate of the point
     * @param z
     *          the z-coordinate of the point
     * @return true if the given point is inside the frustum; false otherwise
     */
    public boolean testPoint(float x, float y, float z) {
        return nxX * x + nxY * y + nxZ * z + nxW >= 0 &&
               pxX * x + pxY * y + pxZ * z + pxW >= 0 &&
               nyX * x + nyY * y + nyZ * z + nyW >= 0 &&
               pyX * x + pyY * y + pyZ * z + pyW >= 0 &&
               nzX * x + nzY * y + nzZ * z + nzW >= 0 &&
               pzX * x + pzY * y + pzZ * z + pzW >= 0;
    }

    /**
     * Test whether the given sphere is partly or completely within or outside of the frustum defined by this frustum culler.
     *

     * The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive
     * can occur, when the method returns <tt>true</tt> for spheres that are actually not visible.
     * See iquilezles.org for an examination of this problem.
     *
     * @param center
     *          the sphere's center
     * @param radius
     *          the sphere's radius
     * @return true if the given sphere is partly or completely inside the frustum;
     *         false otherwise
     */
    public boolean testSphere(Vector3f center, float radius) {
        return testSphere(center.x, center.y, center.z, radius);
    }

    /**
     * Test whether the given sphere is partly or completely within or outside of the frustum defined by this frustum culler.
     *

     * The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive
     * can occur, when the method returns <tt>true</tt> for spheres that are actually not visible.
     * See iquilezles.org for an examination of this problem.
     *
     * @param x
     *          the x-coordinate of the sphere's center
     * @param y
     *          the y-coordinate of the sphere's center
     * @param z
     *          the z-coordinate of the sphere's center
     * @param r
     *          the sphere's radius
     * @return true if the given sphere is partly or completely inside the frustum;
     *         false otherwise
     */
    public boolean testSphere(float x, float y, float z, float r) {
        return nxX * x + nxY * y + nxZ * z + nxW >= -r &&
               pxX * x + pxY * y + pxZ * z + pxW >= -r &&
               nyX * x + nyY * y + nyZ * z + nyW >= -r &&
               pyX * x + pyY * y + pyZ * z + pyW >= -r &&
               nzX * x + nzY * y + nzZ * z + nzW >= -r &&
               pzX * x + pzY * y + pzZ * z + pzW >= -r;
    }

    /**
     * Determine whether the given sphere is partly or completely within or outside of the frustum defined by this frustum culler.
     *

     * The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive
     * can occur, when the method returns <tt>true</tt> for spheres that are actually not visible.
     * See iquilezles.org for an examination of this problem.
     *
     * @param center
     *          the sphere's center
     * @param radius
     *          the sphere's radius
     * @return {@link #INSIDE} if the given sphere is completely inside the frustum, or {@link #INTERSECT} if the sphere intersects
     *         the frustum, or {@link #OUTSIDE} if the sphere is outside of the frustum
     */
    public int intersectSphere(Vector3f center, float radius) {
        return intersectSphere(center.x, center.y, center.z, radius);
    }

    /**
     * Determine whether the given sphere is partly or completely within or outside of the frustum defined by this frustum culler.
     *

     * The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive
     * can occur, when the method returns <tt>true</tt> for spheres that are actually not visible.
     * See iquilezles.org for an examination of this problem.
     *
     * @param x
     *          the x-coordinate of the sphere's center
     * @param y
     *          the y-coordinate of the sphere's center
     * @param z
     *          the z-coordinate of the sphere's center
     * @param r
     *          the sphere's radius
     * @return {@link #INSIDE} if the given sphere is completely inside the frustum, or {@link #INTERSECT} if the sphere intersects
     *         the frustum, or {@link #OUTSIDE} if the sphere is outside of the frustum
     */
    public int intersectSphere(float x, float y, float z, float r) {
        boolean inside = true;
        float dist;
        dist = nxX * x + nxY * y + nxZ * z + nxW;
        if (dist >= -r) {
            inside &= dist >= r;
            dist = pxX * x + pxY * y + pxZ * z + pxW;
            if (dist >= -r) {
                inside &= dist >= r;
                dist = nyX * x + nyY * y + nyZ * z + nyW;
                if (dist >= -r) {
                    inside &= dist >= r;
                    dist = pyX * x + pyY * y + pyZ * z + pyW;
                    if (dist >= -r) {
                        inside &= dist >= r;
                        dist = nzX * x + nzY * y + nzZ * z + nzW;
                        if (dist >= -r) {
                            inside &= dist >= r;
                            dist = pzX * x + pzY * y + pzZ * z + pzW;
                            if (dist >= -r) {
                                inside &= dist >= r;
                                return inside ? INSIDE : INTERSECT;
                            }
                        }
                    }
                }
            }
        }
        return OUTSIDE;
    }

    /**
     * Test whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler.
     * The box is specified via its min and max corner coordinates.
     *

     * The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive
     * can occur, when the method returns <tt>-1</tt> for boxes that are actually not visible/do not intersect the frustum.
     * See iquilezles.org for an examination of this problem.
     *
     * @param min
     *          the minimum corner coordinates of the axis-aligned box
     * @param max
     *          the maximum corner coordinates of the axis-aligned box
     * @return true if the axis-aligned box is completely or partly inside of the frustum; false otherwise
     */
    public boolean testAab(Vector3f min, Vector3f max) {
        return testAab(min.x, min.y, min.z, max.x, max.y, max.z);
    }

    /**
     * Test whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler.
     * The box is specified via its min and max corner coordinates.
     *

     * The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive
     * can occur, when the method returns <tt>-1</tt> for boxes that are actually not visible/do not intersect the frustum.
     * See iquilezles.org for an examination of this problem.
     *

     * Reference: Efficient View Frustum Culling
     *
     * @param minX
     *          the x-coordinate of the minimum corner
     * @param minY
     *          the y-coordinate of the minimum corner
     * @param minZ
     *          the z-coordinate of the minimum corner
     * @param maxX
     *          the x-coordinate of the maximum corner
     * @param maxY
     *          the y-coordinate of the maximum corner
     * @param maxZ
     *          the z-coordinate of the maximum corner
     * @return true if the axis-aligned box is completely or partly inside of the frustum; false otherwise
     */
    public boolean testAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
        /*
         * This is an implementation of the "2.4 Basic intersection test" of the mentioned site.
         * It does not distinguish between partially inside and fully inside, though, so the test with the 'p' vertex is omitted.
         */
        return nxX * (nxX < 0 ? minX : maxX) + nxY * (nxY < 0 ? minY : maxY) + nxZ * (nxZ < 0 ? minZ : maxZ) >= -nxW &&
               pxX * (pxX < 0 ? minX : maxX) + pxY * (pxY < 0 ? minY : maxY) + pxZ * (pxZ < 0 ? minZ : maxZ) >= -pxW &&
               nyX * (nyX < 0 ? minX : maxX) + nyY * (nyY < 0 ? minY : maxY) + nyZ * (nyZ < 0 ? minZ : maxZ) >= -nyW &&
               pyX * (pyX < 0 ? minX : maxX) + pyY * (pyY < 0 ? minY : maxY) + pyZ * (pyZ < 0 ? minZ : maxZ) >= -pyW &&
               nzX * (nzX < 0 ? minX : maxX) + nzY * (nzY < 0 ? minY : maxY) + nzZ * (nzZ < 0 ? minZ : maxZ) >= -nzW &&
               pzX * (pzX < 0 ? minX : maxX) + pzY * (pzY < 0 ? minY : maxY) + pzZ * (pzZ < 0 ? minZ : maxZ) >= -pzW;
    }

    /**
     * Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler
     * and, if the box is not inside this frustum, return the index of the plane that culled it.
     * The box is specified via its min and max corner coordinates.
     *

     * The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive
     * can occur, when the method returns <tt>-1</tt> for boxes that are actually not visible/do not intersect the frustum.
     * See iquilezles.org for an examination of this problem.
     *
     * @param min
     *          the minimum corner coordinates of the axis-aligned box
     * @param max
     *          the maximum corner coordinates of the axis-aligned box
     * @return the index of the first plane that culled the box, if the box does not intersect the frustum;
     *         or {@link #INTERSECT} if the box intersects the frustum, or {@link #INSIDE} if the box is fully inside of the frustum.
     *         The plane index is one of {@link #PLANE_NX}, {@link #PLANE_PX}, {@link #PLANE_NY}, {@link #PLANE_PY}, {@link #PLANE_NZ} and {@link #PLANE_PZ}
     */
    public int intersectAab(Vector3f min, Vector3f max) {
        return intersectAab(min.x, min.y, min.z, max.x, max.y, max.z);
    }

    /**
     * Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler
     * and, if the box is not inside this frustum, return the index of the plane that culled it.
     * The box is specified via its min and max corner coordinates.
     *

     * The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive
     * can occur, when the method returns <tt>-1</tt> for boxes that are actually not visible/do not intersect the frustum.
     * See iquilezles.org for an examination of this problem.
     *

     * Reference: Efficient View Frustum Culling
     *
     * @param minX
     *          the x-coordinate of the minimum corner
     * @param minY
     *          the y-coordinate of the minimum corner
     * @param minZ
     *          the z-coordinate of the minimum corner
     * @param maxX
     *          the x-coordinate of the maximum corner
     * @param maxY
     *          the y-coordinate of the maximum corner
     * @param maxZ
     *          the z-coordinate of the maximum corner
     * @return the index of the first plane that culled the box, if the box does not intersect the frustum,
     *         or {@link #INTERSECT} if the box intersects the frustum, or {@link #INSIDE} if the box is fully inside of the frustum.
     *         The plane index is one of {@link #PLANE_NX}, {@link #PLANE_PX}, {@link #PLANE_NY}, {@link #PLANE_PY}, {@link #PLANE_NZ} and {@link #PLANE_PZ}
     */
    public int intersectAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
        /*
         * This is an implementation of the "2.4 Basic intersection test" of the mentioned site.
         *
         * In addition to the algorithm in the paper, this method also returns the index of the first plane that culled the box.
         */
        int plane = PLANE_NX;
        boolean inside = true;
        if (nxX * (nxX < 0 ? minX : maxX) + nxY * (nxY < 0 ? minY : maxY) + nxZ * (nxZ < 0 ? minZ : maxZ) >= -nxW) {
            plane = PLANE_PX;
            inside &= nxX * (nxX < 0 ? maxX : minX) + nxY * (nxY < 0 ? maxY : minY) + nxZ * (nxZ < 0 ? maxZ : minZ) >= -nxW;
            if (pxX * (pxX < 0 ? minX : maxX) + pxY * (pxY < 0 ? minY : maxY) + pxZ * (pxZ < 0 ? minZ : maxZ) >= -pxW) {
                plane = PLANE_NY;
                inside &= pxX * (pxX < 0 ? maxX : minX) + pxY * (pxY < 0 ? maxY : minY) + pxZ * (pxZ < 0 ? maxZ : minZ) >= -pxW;
                if (nyX * (nyX < 0 ? minX : maxX) + nyY * (nyY < 0 ? minY : maxY) + nyZ * (nyZ < 0 ? minZ : maxZ) >= -nyW) {
                    plane = PLANE_PY;
                    inside &= nyX * (nyX < 0 ? maxX : minX) + nyY * (nyY < 0 ? maxY : minY) + nyZ * (nyZ < 0 ? maxZ : minZ) >= -nyW;
                    if (pyX * (pyX < 0 ? minX : maxX) + pyY * (pyY < 0 ? minY : maxY) + pyZ * (pyZ < 0 ? minZ : maxZ) >= -pyW) {
                        plane = PLANE_NZ;
                        inside &= pyX * (pyX < 0 ? maxX : minX) + pyY * (pyY < 0 ? maxY : minY) + pyZ * (pyZ < 0 ? maxZ : minZ) >= -pyW;
                        if (nzX * (nzX < 0 ? minX : maxX) + nzY * (nzY < 0 ? minY : maxY) + nzZ * (nzZ < 0 ? minZ : maxZ) >= -nzW) {
                            plane = PLANE_PZ;
                            inside &= nzX * (nzX < 0 ? maxX : minX) + nzY * (nzY < 0 ? maxY : minY) + nzZ * (nzZ < 0 ? maxZ : minZ) >= -nzW;
                            if (pzX * (pzX < 0 ? minX : maxX) + pzY * (pzY < 0 ? minY : maxY) + pzZ * (pzZ < 0 ? minZ : maxZ) >= -pzW) {
                                inside &= pzX * (pzX < 0 ? maxX : minX) + pzY * (pzY < 0 ? maxY : minY) + pzZ * (pzZ < 0 ? maxZ : minZ) >= -pzW;
                                return inside ? INSIDE : INTERSECT;
                            }
                        }
                    }
                }
            }
        }
        return plane;
    }

    /**
     * Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler
     * and, if the box is not inside this frustum, return the index of the plane that culled it.
     * The box is specified via its min and max corner coordinates.
     *

     * This method differs from {@link #intersectAab(Vector3f, Vector3f)} in that
     * it allows to mask-off planes that should not be calculated. For example, in order to only test a box against the
     * left frustum plane, use a mask of {@link #PLANE_MASK_NX}. Or in order to test all planes except the left plane, use
     * a mask of <tt>(~0 ^ PLANE_MASK_NX)</tt>.
     *

     * The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive
     * can occur, when the method returns <tt>-1</tt> for boxes that are actually not visible/do not intersect the frustum.
     * See iquilezles.org for an examination of this problem.
     *
     * @param min
     *          the minimum corner coordinates of the axis-aligned box
     * @param max
     *          the maximum corner coordinates of the axis-aligned box
     * @param mask
     *          contains as bitset all the planes that should be tested.
     *          This value can be any combination of
     *          {@link #PLANE_MASK_NX}, {@link #PLANE_MASK_PY},
     *          {@link #PLANE_MASK_NY}, {@link #PLANE_MASK_PY},
     *          {@link #PLANE_MASK_NZ} and {@link #PLANE_MASK_PZ}
     * @return the index of the first plane that culled the box, if the box does not intersect the frustum,
     *         or {@link #INTERSECT} if the box intersects the frustum, or {@link #INSIDE} if the box is fully inside of the frustum.
     *         The plane index is one of {@link #PLANE_NX}, {@link #PLANE_PX}, {@link #PLANE_NY}, {@link #PLANE_PY}, {@link #PLANE_NZ} and {@link #PLANE_PZ}
     */
    public int intersectAab(Vector3f min, Vector3f max, int mask) {
        return intersectAab(min.x, min.y, min.z, max.x, max.y, max.z, mask);
    }

    /**
     * Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler
     * and, if the box is not inside this frustum, return the index of the plane that culled it.
     * The box is specified via its min and max corner coordinates.
     *

     * This method differs from {@link #intersectAab(float, float, float, float, float, float)} in that
     * it allows to mask-off planes that should not be calculated. For example, in order to only test a box against the
     * left frustum plane, use a mask of {@link #PLANE_MASK_NX}. Or in order to test all planes except the left plane, use
     * a mask of <tt>(~0 ^ PLANE_MASK_NX)</tt>.
     *

     * The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive
     * can occur, when the method returns <tt>-1</tt> for boxes that are actually not visible/do not intersect the frustum.
     * See iquilezles.org for an examination of this problem.
     *

     * Reference: Efficient View Frustum Culling
     *
     * @param minX
     *          the x-coordinate of the minimum corner
     * @param minY
     *          the y-coordinate of the minimum corner
     * @param minZ
     *          the z-coordinate of the minimum corner
     * @param maxX
     *          the x-coordinate of the maximum corner
     * @param maxY
     *          the y-coordinate of the maximum corner
     * @param maxZ
     *          the z-coordinate of the maximum corner
     * @param mask
     *          contains as bitset all the planes that should be tested.
     *          This value can be any combination of
     *          {@link #PLANE_MASK_NX}, {@link #PLANE_MASK_PY},
     *          {@link #PLANE_MASK_NY}, {@link #PLANE_MASK_PY},
     *          {@link #PLANE_MASK_NZ} and {@link #PLANE_MASK_PZ}
     * @return the index of the first plane that culled the box, if the box does not intersect the frustum,
     *         or {@link #INTERSECT} if the box intersects the frustum, or {@link #INSIDE} if the box is fully inside of the frustum.
     *         The plane index is one of {@link #PLANE_NX}, {@link #PLANE_PX}, {@link #PLANE_NY}, {@link #PLANE_PY}, {@link #PLANE_NZ} and {@link #PLANE_PZ}
     */
    public int intersectAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ, int mask) {
        /*
         * This is an implementation of the first algorithm in "2.5 Plane masking and coherency" of the mentioned site.
         *
         * In addition to the algorithm in the paper, this method also returns the index of the first plane that culled the box.
         */
        int plane = PLANE_NX;
        boolean inside = true;
        if ((mask & PLANE_MASK_NX) == 0 || nxX * (nxX < 0 ? minX : maxX) + nxY * (nxY < 0 ? minY : maxY) + nxZ * (nxZ < 0 ? minZ : maxZ) >= -nxW) {
            plane = PLANE_PX;
            inside &= nxX * (nxX < 0 ? maxX : minX) + nxY * (nxY < 0 ? maxY : minY) + nxZ * (nxZ < 0 ? maxZ : minZ) >= -nxW;
            if ((mask & PLANE_MASK_PX) == 0 || pxX * (pxX < 0 ? minX : maxX) + pxY * (pxY < 0 ? minY : maxY) + pxZ * (pxZ < 0 ? minZ : maxZ) >= -pxW) {
                plane = PLANE_NY;
                inside &= pxX * (pxX < 0 ? maxX : minX) + pxY * (pxY < 0 ? maxY : minY) + pxZ * (pxZ < 0 ? maxZ : minZ) >= -pxW;
                if ((mask & PLANE_MASK_NY) == 0 || nyX * (nyX < 0 ? minX : maxX) + nyY * (nyY < 0 ? minY : maxY) + nyZ * (nyZ < 0 ? minZ : maxZ) >= -nyW) {
                    plane = PLANE_PY;
                    inside &= nyX * (nyX < 0 ? maxX : minX) + nyY * (nyY < 0 ? maxY : minY) + nyZ * (nyZ < 0 ? maxZ : minZ) >= -nyW;
                    if ((mask & PLANE_MASK_PY) == 0 || pyX * (pyX < 0 ? minX : maxX) + pyY * (pyY < 0 ? minY : maxY) + pyZ * (pyZ < 0 ? minZ : maxZ) >= -pyW) {
                        plane = PLANE_NZ;
                        inside &= pyX * (pyX < 0 ? maxX : minX) + pyY * (pyY < 0 ? maxY : minY) + pyZ * (pyZ < 0 ? maxZ : minZ) >= -pyW;
                        if ((mask & PLANE_MASK_NZ) == 0 || nzX * (nzX < 0 ? minX : maxX) + nzY * (nzY < 0 ? minY : maxY) + nzZ * (nzZ < 0 ? minZ : maxZ) >= -nzW) {
                            plane = PLANE_PZ;
                            inside &= nzX * (nzX < 0 ? maxX : minX) + nzY * (nzY < 0 ? maxY : minY) + nzZ * (nzZ < 0 ? maxZ : minZ) >= -nzW;
                            if ((mask & PLANE_MASK_PZ) == 0 || pzX * (pzX < 0 ? minX : maxX) + pzY * (pzY < 0 ? minY : maxY) + pzZ * (pzZ < 0 ? minZ : maxZ) >= -pzW) {
                                inside &= pzX * (pzX < 0 ? maxX : minX) + pzY * (pzY < 0 ? maxY : minY) + pzZ * (pzZ < 0 ? maxZ : minZ) >= -pzW;
                                return inside ? INSIDE : INTERSECT;
                            }
                        }
                    }
                }
            }
        }
        return plane;
    }

    /**
     * Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler
     * and, if the box is not inside this frustum, return the index of the plane that culled it.
     * The box is specified via its min and max corner coordinates.
     *

     * This method differs from {@link #intersectAab(Vector3f, Vector3f)} in that
     * it allows to mask-off planes that should not be calculated. For example, in order to only test a box against the
     * left frustum plane, use a mask of {@link #PLANE_MASK_NX}. Or in order to test all planes except the left plane, use
     * a mask of <tt>(~0 ^ PLANE_MASK_NX)</tt>.
     *

     * In addition, the startPlane denotes the first frustum plane to test the box against. To use this effectively means to store the
     * plane that previously culled an axis-aligned box (as returned by <tt>intersectAab()</tt>) and in the next frame use the return value
     * as the argument to the startPlane parameter of this method. The assumption is that the plane that culled the object previously will also
     * cull it now (temporal coherency) and the culling computation is likely reduced in that case.
     *

     * The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive
     * can occur, when the method returns <tt>-1</tt> for boxes that are actually not visible/do not intersect the frustum.
     * See iquilezles.org for an examination of this problem.
     *
     * @param min
     *          the minimum corner coordinates of the axis-aligned box
     * @param max
     *          the maximum corner coordinates of the axis-aligned box
     * @param mask
     *          contains as bitset all the planes that should be tested.
     *          This value can be any combination of
     *          {@link #PLANE_MASK_NX}, {@link #PLANE_MASK_PY},
     *          {@link #PLANE_MASK_NY}, {@link #PLANE_MASK_PY},
     *          {@link #PLANE_MASK_NZ} and {@link #PLANE_MASK_PZ}
     * @param startPlane
     *          the first frustum plane to test the axis-aligned box against. It is one of
     *          {@link #PLANE_NX}, {@link #PLANE_PX}, {@link #PLANE_NY}, {@link #PLANE_PY}, {@link #PLANE_NZ} and {@link #PLANE_PZ}
     * @return the index of the first plane that culled the box, if the box does not intersect the frustum,
     *         or {@link #INTERSECT} if the box intersects the frustum, or {@link #INSIDE} if the box is fully inside of the frustum.
     *         The plane index is one of {@link #PLANE_NX}, {@link #PLANE_PX}, {@link #PLANE_NY}, {@link #PLANE_PY}, {@link #PLANE_NZ} and {@link #PLANE_PZ}
     */
    public int intersectAab(Vector3f min, Vector3f max, int mask, int startPlane) {
        return intersectAab(min.x, min.y, min.z, max.x, max.y, max.z, mask, startPlane);
    }

    /**
     * Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler
     * and, if the box is not inside this frustum, return the index of the plane that culled it.
     * The box is specified via its min and max corner coordinates.
     *

     * This method differs from {@link #intersectAab(float, float, float, float, float, float)} in that
     * it allows to mask-off planes that should not be calculated. For example, in order to only test a box against the
     * left frustum plane, use a mask of {@link #PLANE_MASK_NX}. Or in order to test all planes except the left plane, use
     * a mask of <tt>(~0 ^ PLANE_MASK_NX)</tt>.
     *

     * In addition, the startPlane denotes the first frustum plane to test the box against. To use this effectively means to store the
     * plane that previously culled an axis-aligned box (as returned by <tt>intersectAab()</tt>) and in the next frame use the return value
     * as the argument to the startPlane parameter of this method. The assumption is that the plane that culled the object previously will also
     * cull it now (temporal coherency) and the culling computation is likely reduced in that case.
     *

     * The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive
     * can occur, when the method returns <tt>-1</tt> for boxes that are actually not visible/do not intersect the frustum.
     * See iquilezles.org for an examination of this problem.
     *

     * Reference: Efficient View Frustum Culling
     *
     * @param minX
     *          the x-coordinate of the minimum corner
     * @param minY
     *          the y-coordinate of the minimum corner
     * @param minZ
     *          the z-coordinate of the minimum corner
     * @param maxX
     *          the x-coordinate of the maximum corner
     * @param maxY
     *          the y-coordinate of the maximum corner
     * @param maxZ
     *          the z-coordinate of the maximum corner
     * @param mask
     *          contains as bitset all the planes that should be tested.
     *          This value can be any combination of
     *          {@link #PLANE_MASK_NX}, {@link #PLANE_MASK_PY},
     *          {@link #PLANE_MASK_NY}, {@link #PLANE_MASK_PY},
     *          {@link #PLANE_MASK_NZ} and {@link #PLANE_MASK_PZ}
     * @param startPlane
     *          the first frustum plane to test the axis-aligned box against. It is one of
     *          {@link #PLANE_NX}, {@link #PLANE_PX}, {@link #PLANE_NY}, {@link #PLANE_PY}, {@link #PLANE_NZ} and {@link #PLANE_PZ}
     * @return the index of the first plane that culled the box, if the box does not intersect the frustum,
     *         or {@link #INTERSECT} if the box intersects the frustum, or {@link #INSIDE} if the box is fully inside of the frustum.
     *         The plane index is one of {@link #PLANE_NX}, {@link #PLANE_PX}, {@link #PLANE_NY}, {@link #PLANE_PY}, {@link #PLANE_NZ} and {@link #PLANE_PZ}
     */
    public int intersectAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ, int mask, int startPlane) {
        /*
         * This is an implementation of the second algorithm in "2.5 Plane masking and coherency" of the mentioned site.
         *
         * In addition to the algorithm in the paper, this method also returns the index of the first plane that culled the box.
         */
        int plane = startPlane;
        boolean inside = true;
        Vector4f p = planes[startPlane];
        if ((mask & 1<<startPlane) != 0 && p.x * (p.x < 0 ? minX : maxX) + p.y * (p.y < 0 ? minY : maxY) + p.z * (p.z < 0 ? minZ : maxZ) < -p.w) {
            return plane;
        }
        if ((mask & PLANE_MASK_NX) == 0 || nxX * (nxX < 0 ? minX : maxX) + nxY * (nxY < 0 ? minY : maxY) + nxZ * (nxZ < 0 ? minZ : maxZ) >= -nxW) {
            plane = PLANE_PX;
            inside &= nxX * (nxX < 0 ? maxX : minX) + nxY * (nxY < 0 ? maxY : minY) + nxZ * (nxZ < 0 ? maxZ : minZ) >= -nxW;
            if ((mask & PLANE_MASK_PX) == 0 || pxX * (pxX < 0 ? minX : maxX) + pxY * (pxY < 0 ? minY : maxY) + pxZ * (pxZ < 0 ? minZ : maxZ) >= -pxW) {
                plane = PLANE_NY;
                inside &= pxX * (pxX < 0 ? maxX : minX) + pxY * (pxY < 0 ? maxY : minY) + pxZ * (pxZ < 0 ? maxZ : minZ) >= -pxW;
                if ((mask & PLANE_MASK_NY) == 0 || nyX * (nyX < 0 ? minX : maxX) + nyY * (nyY < 0 ? minY : maxY) + nyZ * (nyZ < 0 ? minZ : maxZ) >= -nyW) {
                    plane = PLANE_PY;
                    inside &= nyX * (nyX < 0 ? maxX : minX) + nyY * (nyY < 0 ? maxY : minY) + nyZ * (nyZ < 0 ? maxZ : minZ) >= -nyW;
                    if ((mask & PLANE_MASK_PY) == 0 || pyX * (pyX < 0 ? minX : maxX) + pyY * (pyY < 0 ? minY : maxY) + pyZ * (pyZ < 0 ? minZ : maxZ) >= -pyW) {
                        plane = PLANE_NZ;
                        inside &= pyX * (pyX < 0 ? maxX : minX) + pyY * (pyY < 0 ? maxY : minY) + pyZ * (pyZ < 0 ? maxZ : minZ) >= -pyW;
                        if ((mask & PLANE_MASK_NZ) == 0 || nzX * (nzX < 0 ? minX : maxX) + nzY * (nzY < 0 ? minY : maxY) + nzZ * (nzZ < 0 ? minZ : maxZ) >= -nzW) {
                            plane = PLANE_PZ;
                            inside &= nzX * (nzX < 0 ? maxX : minX) + nzY * (nzY < 0 ? maxY : minY) + nzZ * (nzZ < 0 ? maxZ : minZ) >= -nzW;
                            if ((mask & PLANE_MASK_PZ) == 0 || pzX * (pzX < 0 ? minX : maxX) + pzY * (pzY < 0 ? minY : maxY) + pzZ * (pzZ < 0 ? minZ : maxZ) >= -pzW) {
                                inside &= pzX * (pzX < 0 ? maxX : minX) + pzY * (pzY < 0 ? maxY : minY) + pzZ * (pzZ < 0 ? maxZ : minZ) >= -pzW;
                                return inside ? INSIDE : INTERSECT;
                            }
                        }
                    }
                }
            }
        }
        return plane;
    }

}


text:
<?php

namespace JMBTechnologyLimited\GeoLibDoesMaths\LatLngConvert;

abstract class Datum {

	/** @var  Ellipsoid */
	protected $ellipsoid;

	/** @var Transform */
	protected $transform;

	/**
	 * @return Ellipsoid
	 */
	public function getEllipsoid()
	{
		return $this->ellipsoid;
	}

	/**
	 * @return Transform
	 */
	public function getTransform()
	{
		return $this->transform;
	}

}


text:
package cli

import (
	"os/exec"
	"path/filepath"
	"syscall"

	"github.com/codegangsta/cli"
)

func (s SpreadCli) Git() *cli.Command {
	return &cli.Command{
		Name:  "git",
		Usage: "Allows access to git commands while Spread is build out",
		Action: func(c *cli.Context) {
			cli.ShowSubcommandHelp(c)
		},
	}
}

func (s SpreadCli) ExecGitCmd(args ...string) {
	git, err := exec.LookPath("git")
	if err != nil {
		s.fatalf("Could not locate git: %v", err)
	}

	proj := s.projectOrDie()
	gitDir := filepath.Join(proj.Path, "git")

	gitArgs := []string{git, "--git-dir=" + gitDir}
	gitArgs = append(gitArgs, args...)

	err = syscall.Exec(git, gitArgs, []string{})
	if err != nil {
		s.fatalf("could not run git: %v", err)
	}
}


text:
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'

$modulePath = "$here\..\.."
$moduleName = Split-Path -Path $modulePath -Leaf

Describe 'General module control' -Tags 'FunctionalQuality'  {

    It 'imports without errors' {
        { Import-Module -Name $modulePath -Force -ErrorAction Stop } | Should Not Throw
        Get-Module $moduleName | Should Not BeNullOrEmpty
    }

    It 'Removes without error' {
        { Remove-Module -Name $moduleName -ErrorAction Stop} | Should not Throw
        Get-Module $moduleName | Should beNullOrEmpty
    }
}

#$PrivateFunctions = Get-ChildItem -Path "$modulePath\Private\*.ps1"
#$PublicFunctions =  Get-ChildItem -Path "$modulePath\Public\*.ps1"
$allModuleFunctions = @()
$allModuleFunctions += Get-ChildItem -Path "$modulePath\Private\*.ps1"
$allModuleFunctions += Get-ChildItem -Path "$modulePath\Public\*.ps1"

if (Get-Command Invoke-ScriptAnalyzer -ErrorAction SilentlyContinue) {
    $scriptAnalyzerRules = Get-ScriptAnalyzerRule
}
else {
    if($ErrorActionPreference -ne 'Stop') {
        Write-Warning "ScriptAnalyzer not found!"
    }
    else {
        Throw "ScriptAnalyzer not found!"
    }
}

foreach ($function in $allModuleFunctions) {
    Describe "Quality for $($function.BaseName)" -Tags 'TestQuality' {
        It "$($function.BaseName) has a unit test" {
            Get-ChildItem "$modulePath\tests\Unit\" -recurse -include "$($function.BaseName).tests.ps1" | Should Not BeNullOrEmpty
        }

        if ($scriptAnalyzerRules) {
            It "Script Analyzer for $($function.BaseName)" {
                forEach ($scriptAnalyzerRule in $scriptAnalyzerRules) {
                    $PSSAResult = (Invoke-ScriptAnalyzer -Path $function.FullName -IncludeRule $scriptAnalyzerRule)
                    ($PSSAResult | Select-Object Message,Line | Out-String) | Should -BeNullOrEmpty
                }
            }
        }
    }

    Describe "Help for $($function.BaseName)" -Tags 'helpQuality' {
            $AbstractSyntaxTree = [System.Management.Automation.Language.Parser]::
                ParseInput((Get-Content -raw $function.FullName), [ref]$null, [ref]$null)
                $AstSearchDelegate = { $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] }
                $ParsedFunction = $AbstractSyntaxTree.FindAll( $AstSearchDelegate,$true )   |
                                    ? Name -eq $function.BaseName
            $FunctionHelp = $ParsedFunction.GetHelpContent()

            It 'Has a SYNOPSIS' {
                $FunctionHelp.Synopsis | should not BeNullOrEmpty
            }

            It 'Has a Description, with length > 40' {
                $FunctionHelp.Description.Length | Should beGreaterThan 40
            }

            It 'Has at least 1 example' {
                $FunctionHelp.Examples.Count | Should beGreaterThan 0
                $FunctionHelp.Examples[0] | Should match ([regex]::Escape($function.BaseName))
                $FunctionHelp.Examples[0].Length | Should BeGreaterThan ($function.BaseName.Length + 10)
            }

            $parameters = $ParsedFunction.Body.ParamBlock.Parameters.name.VariablePath.Foreach{$_.ToString() }
            foreach ($parameter in $parameters) {
                It "Has help for Parameter: $parameter" {
                    $FunctionHelp.Parameters.($parameter.ToUpper())        | Should Not BeNullOrEmpty
                    $FunctionHelp.Parameters.($parameter.ToUpper()).Length | Should BeGreaterThan 25
                }
            }
    }
}


text:
package nl.Steffion.PLUGINNAME;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import net.minecraft.server.v1_7_R1.ChatSerializer;
import net.minecraft.server.v1_7_R1.PacketPlayOutChat;

import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;

public class StefsAPI {
	/**
	 * StefsAPI - Made by Steffion.
	 *
	 * You're allowed to use this engine for own usage, you're not allowed to
	 * republish the engine. Using this for your own plugin is allowed when a
	 * credit is placed somewhere in the plugin.
	 *
	 * Thanks for your cooperate!
	 *
	 * @author Steffion
	 */

	public static String engineVersion = "5.0.8";
	public static String engineAuthors = "Steffion";

	public static ArrayList<String> newConfigs = new ArrayList<String>();
	public static ArrayList<Command> commands = new ArrayList<Command>();

	public static void enableAPI() {
		StefsAPI.MessageHandler
				.buildMessage()
				.addSender("$")
				.setMessage(
						"%TAGPlugin is being enabled and using %AStefsAPI%N %version. Made by %A%authors%N.")
				.changeVariable("version", "v" + engineVersion)
				.changeVariable("authors", engineAuthors).build();
	}

	public static class ConfigHandler {
		private static StefsAPI api = new StefsAPI();

		public static Config createConfig(String name) {
			return api.new Config(name);
		}

		public static Config createConfig(String name, String location) {
			return api.new Config(name, location);
		}

		public static boolean deleteConfig(Config config) {
			if (config.file.exists()) {
				config.file.delete();
				return true;
			} else {
				return false;
			}
		}

		public static void addDefault(Config config, String location,
				Object value) {
			config.load();
			if (config.getFile().get(location) == null) {
				config.getFile().set(location, value);
				config.save();
			}
		}

		public static void displayNewFiles() {
			for (String file : newConfigs) {
				MessageHandler
						.buildMessage()
						.addSender("$")
						.setMessage(
								"%TAG%WUnable to find config file '%A" + file
										+ ".yml%W', creating new one!").build();
			}

			newConfigs = new ArrayList<String>();
		}
	}

	public class Config {
		public String name;
		public String location;
		public File file;
		public FileConfiguration fileC;
		public ConfigurationSection fileCS;

		public Config (String name) {
			this.name = name;
			this.file = new File("plugins/" + PLUGINNAME.pdfFile.getName(),
					name + ".yml");
			this.fileC = new YamlConfiguration();
			this.checkFile(name, "");
			this.fileCS = fileC.getConfigurationSection("");
			this.load();
		}

		public Config (String name, String location) {
			this.name = name;
			this.location = location;
			this.file = new File("plugins/" + PLUGINNAME.pdfFile.getName()
					+ "/" + location, name + ".yml");
			this.fileC = new YamlConfiguration();
			this.checkFile(name, location + "/");
			this.fileCS = fileC.getConfigurationSection("");
			this.load();
		}

		public void checkFile(String name, String location) {
			if (!this.file.exists()) {
				try {
					this.file.getParentFile().mkdirs();
					this.file.createNewFile();
					newConfigs.add(location + name);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}

		public void save() {
			try {
				this.fileC.save(this.file);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		public void load() {
			this.checkFile(file.getName(), this.location);
			if (this.file.exists()) {
				try {
					this.fileC.load(this.file);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}

		public FileConfiguration getFile() {
			return this.fileC;
		}
	}

	public static class MessageHandler {
		private static StefsAPI api = new StefsAPI();

		public static MessageBuilder buildMessage() {
			return api.new MessageBuilder();
		}

		public static String replaceColours(String message) {
			return message.replaceAll("(&([a-fk-or0-9]))", "\u00A7$2")
					.replaceAll("&u", "\n");
		}

		public static String replacePrefixes(String message) {
			return message.replaceAll("%N", NORMAL())
					.replaceAll("%W", WARNING()).replaceAll("%E", ERROR())
					.replaceAll("%A", ARGUMENT()).replaceAll("%H", HEADER())
					.replaceAll("%TAG", TAG());
		}

		public static String NORMAL() {
			return PLUGINNAME.config.getFile().getString("chat.normal");
		}

		public static String WARNING() {
			return PLUGINNAME.config.getFile().getString("chat.warning");
		}

		public static String ERROR() {
			return PLUGINNAME.config.getFile().getString("chat.error");
		}

		public static String ARGUMENT() {
			return PLUGINNAME.config.getFile().getString("chat.argument");
		}

		public static String HEADER() {
			return PLUGINNAME.config.getFile().getString("chat.header");
		}

		public static String TAG() {
			return PLUGINNAME.config.getFile().getString("chat.header")
					+ PLUGINNAME.config.getFile().getString("chat.tag")
					+ PLUGINNAME.config.getFile().getString("chat.normal");
		}
	}

	public class MessageBuilder {
		ArrayList<String> senders = new ArrayList<String>();
		String message;
		Config message_config;
		Map<String, String> replacements = new HashMap<String, String>();

		public MessageBuilder () {
		}

		public MessageBuilder addSender(String sender) {
			this.senders.add(sender);
			return this;
		}

		public MessageBuilder setMessage(String message) {
			this.message = message;
			this.message_config = null;
			return this;
		}

		public MessageBuilder setMessage(String message, Config config) {
			this.message = message;
			this.message_config = config;
			return this;
		}

		public MessageBuilder changeVariable(String variable, String replacement) {
			this.replacements.put(variable, replacement);
			return this;
		}

		public MessageBuilder build() {
			for (String sender : this.senders) {
				String message = this.message;
				Config messages_config = this.message_config;
				String finalmessage;

				if (messages_config != null) {
					if (messages_config.getFile().get(message) != null) {
						finalmessage = (String) messages_config.getFile().get(
								message);
					} else {
						finalmessage = "&9[" + PLUGINNAME.pdfFile.getName()
								+ "] &cERROR: Message string &e" + message
								+ "&c has not been found in the &e"
								+ messages_config.name + ".yml&c config.";
					}
				} else {
					finalmessage = message;
				}

				for (Map.Entry<String, String> replacement_pairs : this.replacements
						.entrySet()) {
					finalmessage = finalmessage.replaceAll("%"
							+ replacement_pairs.getKey(),
							replacement_pairs.getValue());
				}

				finalmessage = MessageHandler.replacePrefixes(finalmessage);
				finalmessage = MessageHandler.replaceColours(finalmessage);

				if (!finalmessage.startsWith("-")) {
					if (sender == "*") {
						for (Player player : Bukkit.getOnlinePlayers()) {
							player.sendMessage(finalmessage);
						}
					} else if (sender == "$") {
						Bukkit.getConsoleSender().sendMessage(finalmessage);
					} else {
						Player player = Bukkit.getPlayer(sender);
						if (player != null) {
							player.sendMessage(finalmessage);
						}
					}
				}
			}

			this.replacements = new HashMap<String, String>();
			return this;
		}

		public MessageBuilder buildAsJSON() {
			for (String sender : this.senders) {
				String message = this.message;
				Config messages_config = this.message_config;
				String finalmessage;

				if (messages_config != null) {
					if (messages_config.getFile().get(message) != null) {
						finalmessage = (String) messages_config.getFile().get(
								message);
					} else {
						finalmessage = "&9[" + PLUGINNAME.pdfFile.getName()
								+ "] &cERROR: Message string &e" + message
								+ "&c has not been found in the &e"
								+ messages_config.name + ".yml&c config.";
					}
				} else {
					finalmessage = message;
				}

				for (Map.Entry<String, String> replacement_pairs : this.replacements
						.entrySet()) {
					finalmessage = finalmessage.replaceAll("%"
							+ replacement_pairs.getKey(),
							replacement_pairs.getValue());
				}

				finalmessage = MessageHandler.replacePrefixes(finalmessage);

				String[] texts = finalmessage.split(";");
				String json = "{'text':'','extra':[";

				for (int i = 0; i < texts.length; i++) {
					String text = texts[i];
					json += "{";

					if (text.contains("**")) {
						String runcommand = text
								.substring(text.indexOf("**") + 2);
						runcommand = runcommand.substring(0,
								runcommand.indexOf("**"));

						text = text.replaceAll(
								"\\*\\*" + runcommand + "\\*\\*", "");

						json += "'clickEvent': {'action':'run_command','value':'"
								+ runcommand + "'},";
					}

					if (text.contains("__")) {
						String hovermessage = text
								.substring(text.indexOf("__") + 2);
						hovermessage = hovermessage.substring(0,
								hovermessage.indexOf("__"));

						text = text.replaceAll("__" + hovermessage + "__", "");

						json += "'hoverEvent': {";

						hovermessage = StefsAPI.MessageHandler
								.replaceColours(StefsAPI.MessageHandler
										.replacePrefixes(hovermessage));

						json += "'action':'show_text','value':'" + hovermessage
								+ "'},";
					}

					if (text.contains("&a")) {
						text = text.replaceAll("&a", "");
						json += "'color':'green',";
					}

					if (text.contains("&b")) {
						text = text.replaceAll("&b", "");
						json += "'color':'aqua',";
					}

					if (text.contains("&c")) {
						text = text.replaceAll("&c", "");
						json += "'color':'red',";
					}

					if (text.contains("&d")) {
						text = text.replaceAll("&d", "");
						json += "'color':'light_purple',";
					}

					if (text.contains("&e")) {
						text = text.replaceAll("&e", "");
						json += "'color':'yellow',";
					}

					if (text.contains("&f")) {
						text = text.replaceAll("&f", "");
						json += "'color':'white',";
					}

					if (text.contains("&0")) {
						text = text.replaceAll("&0", "");
						json += "'color':'black',";
					}

					if (text.contains("&1")) {
						text = text.replaceAll("&1", "");
						json += "'color':'dark_blue',";
					}

					if (text.contains("&2")) {
						text = text.replaceAll("&2", "");
						json += "'color':'dark_green',";
					}

					if (text.contains("&3")) {
						text = text.replaceAll("&3", "");
						json += "'color':'dark_aqua',";
					}

					if (text.contains("&4")) {
						text = text.replaceAll("&4", "");
						json += "'color':'dark_red',";
					}

					if (text.contains("&5")) {
						text = text.replaceAll("&5", "");
						json += "'color':'dark_purple',";
					}

					if (text.contains("&6")) {
						text = text.replaceAll("&6", "");
						json += "'color':'gold',";
					}

					if (text.contains("&7")) {
						text = text.replaceAll("&7", "");
						json += "'color':'gray',";
					}

					if (text.contains("&8")) {
						text = text.replaceAll("&8", "");
						json += "'color':'dark_gray',";
					}

					if (text.contains("&9")) {
						text = text.replaceAll("&9", "");
						json += "'color':'blue',";
					}

					if (text.contains("&k")) {
						text = text.replaceAll("&k", "");
						json += "'obfuscated':'true',";
					}

					if (text.contains("&l")) {
						text = text.replaceAll("&l", "");
						json += "'bold':'true',";
					}

					if (text.contains("&m")) {
						text = text.replaceAll("&m", "");
						json += "'strikethrough':'true',";
					}

					if (text.contains("&n")) {
						text = text.replaceAll("&n", "");
						json += "'underlined':'true',";
					}

					if (text.contains("&o")) {
						text = text.replaceAll("&o", "");
						json += "'italic':'true',";
					}

					if (texts.length - 1 == i) {
						json += "'text':'" + text + "'}]}";
					} else {
						json += "'text':'" + text + "'},";
					}
				}

				if (sender == "*") {
					for (Player player : Bukkit.getOnlinePlayers()) {
						try {
							((CraftPlayer) player).getHandle().playerConnection
									.sendPacket(new PacketPlayOutChat(
											ChatSerializer.a(json), true));
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				} else if (sender == "$") {
					Bukkit.getConsoleSender().sendMessage(json);
				} else {
					Player player = Bukkit.getPlayer(sender);
					if (player != null) {
						try {
							((CraftPlayer) player).getHandle().playerConnection
									.sendPacket(new PacketPlayOutChat(
											ChatSerializer.a(json), true));
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				}
			}

			this.replacements = new HashMap<String, String>();
			return this;
		}
	}

	public static class CommandHandler {
		private static StefsAPI api = new StefsAPI();

		public static Command registerCommand(String label, String[] arguments,
				String[] aliases, String name, String help,
				PermissionType typePermission, ExecutedCommand command,
				String usage) {
			return api.new Command(label, arguments, aliases, name, help,
					typePermission, command, usage);
		}
	}

	public class Command {
		String label;
		String[] arguments;
		String[] aliases;
		String name;
		String help;
		PermissionType typePermission;
		ExecutedCommand command;
		String usage;

		public Command (String label, String[] arguments, String[] aliases,
				String name, String help, PermissionType typePermission,
				ExecutedCommand command, String usage) {
			this.label = label;
			this.arguments = arguments;
			this.aliases = aliases;
			this.name = name;
			this.help = help;
			this.typePermission = typePermission;
			this.command = command;
			this.usage = usage;

			ConfigHandler.addDefault(PLUGINNAME.config, "commandEnabled."
					+ name, true);
			ConfigHandler.addDefault(PLUGINNAME.messages, "help." + name, help);
			commands.add(this);
		}
	}

	public static class ExecutedCommand {
		public boolean execute(Player player, String playerName,
				org.bukkit.command.Command cmd, String label, String[] args) {
			return true;
		}
	}

	public static class PermissionHandler {
		public static boolean hasPermission(Player player, String permission,
				PermissionType typePermission, Boolean message) {
			if (player == null) {
				return true;
			}

			if (typePermission == PermissionType.ALL) {
				return true;
			} else if (typePermission == PermissionType.OP) {
				if (player.isOp()) {
					return true;
				}
			} else if (typePermission == PermissionType.ADMIN) {
				if (player.hasPermission(PLUGINNAME.mainPermission + "admin")) {
					return true;
				}
			} else if (typePermission == PermissionType.MODERATOR) {
				if (player.hasPermission(PLUGINNAME.mainPermission
						+ "moderator")) {
					return true;
				}
			} else if (typePermission == PermissionType.PLAYER) {
				if (player.hasPermission(PLUGINNAME.mainPermission + "player")) {
					return true;
				}
			}

			if (player.hasPermission("*")) {
				return true;
			} else if (player.hasPermission(PLUGINNAME.mainPermission + "*")) {
				return true;
			} else if (player.hasPermission(PLUGINNAME.mainPermission
					+ permission)) {
				return true;
			} else if (player.hasPermission(PLUGINNAME.mainPermission
					+ permission + ".*")) {
				return true;
			} else {
				if (message) {
					MessageHandler
							.buildMessage()
							.addSender(player.getName())
							.setMessage("error.noPermission",
									PLUGINNAME.messages).build();
				}
			}

			return false;
		}
	}

	public enum PermissionType {
		ALL, PLAYER, MODERATOR, ADMIN, OP;
	}
}


text:
.audio-sample {
	padding: 15px;
}

.audio-sample-divider {
	color: #F49200;
	text-transform: uppercase;
	font-family: Segoe UI, Prelude Medium, Helvetica, Verdana, sans-serif;
	font-size: 14px;
	font-weight: bold;
	margin-bottom: 8px;
}