key0-96/
key0-96/doc/key/
key0-96/doc/key/credits/
key0-96/doc/key/developers/
key0-96/doc/key/developers/resources/
key0-96/setup/caves/
key0-96/setup/help/
key0-96/setup/ruins/
key0-96/src/
key0-96/src/commands/
key0-96/src/events/
key0-96/src/hack/
key0-96/src/sql/
key0-96/src/swing/
key0-96/src/talker/forest/
key0-96/src/talker/objects/
key0-96/src/terminals/
/*
**               j###t  ########## ####   ####
**              j###t   ########## ####   ####
**             j###T               "###L J###"
**          ######P'    ##########  #########
**          ######k,    ##########   T######T
**          ####~###L   ####
**          #### q###L  ##########   .#####
**          ####  \###L ##########   #####"
**
**  Class History
**  
**  Date        Name         Description
**  ---------|------------|-----------------------------------------------
**  17Jul97     merlin       created this command
**
*/

package key.commands;

import key.*;
import key.primitive.DateTime;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Enumeration;
import java.lang.String;

/**
  *  This command is to display all the sites in detail, more detail 
  *  than sitesbanned. Shows if a site had been banned, or unbanned  
 */
public class SiteDisplay extends Command
{
	public SiteDisplay()
	{
		setKey( "sitedisplay" );
		usage = "";
	}

	public void run( Player p, StringTokenizer args, String fullLine, CategoryCommand caller, InteractiveConnection ic, Flags flags ) throws IOException
	{
		Object o = p.getContext();

		if( !( p.getContext() instanceof Site ) )
		{
			ic.sendFeedback( "This command can not be run unless a site is being referenced" );
		return;
		}

		Site s = (Site) o;

		StringBuffer str = new StringBuffer();
		Player pl = (Player) s.bannedBy.get();

		boolean banned = ( !s.connectionsAllowed() || !s.newbiesAllowed() );
		//DateTime bannedAt = (DateTime) s.getProperty( "bannedAt" );
		//DateTime bannedUntil = (DateTime) s.getProperty( "bannedUntil" );
		//String reasonBanned = (String) s.getProperty( "reasonBanned" );
		//TextParagraph notes = (TextParagraph) s.getProperty( "notes" );
		
		ic.sendLine();
		str.append( s + " " );
		
			//check to see if the site has ever been banned
		if( s.bannedAt == null )
		{
			str.append( "has never been banned\n" );
		}
		else
		{
			if( !banned )
				str.append( "unbanned" );
			else
			{
				str.append( ( s.newbiesAllowed()?"newbie":"site" ) );
				str.append( " banned" );
			}

			if ( pl != null )
				str.append( " by " + pl.getName() );

			if ( banned )
				str.append( "\n" );
			else
				str.append( " " );

			str.append( "on " + s.bannedAt + "\n" );

			if ( banned )
			{
				str.append( "The site is banned until " + s.bannedUntil + "\n" );
			}

			str.append( "This site was " );
			str.append( ( (banned)?"banned":"unbanned" ) );
			str.append( " for '" + s.reasonBanned + "'\n" );
		}

		ic.sendFeedback( str.toString() );
		ic.sendLine();
		ic.send( s.notes );
		ic.sendLine();
	}
}