import com.dmgame.net.script.*;
import com.dmgame.net.server.ServerConnectionHandler;

return new Port();

class Port extends ServerCommand{

	String getName(){return "port"};

	public boolean perform(Scanner s){
		String input = s.next()
		int portNum = 0
		try{
			portNum = Integer.parseInt(input)
		}
		catch(NumberFormatException ex){
			println("The port must be an integer between 1 65535")
			return false
		}
		if(portNum < 1 || portNum > 65535){
			println("Valid port numbers are 1 through 65535.")
			return false
		}
		ServerConnectionHandler.port = portNum
		println("Set port# to "+portNum)
		com.dmgame.net.server.ServerUtility.output("The server will need to restart in order for the change to take effect.");
		return true
	}
}